npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dhouse-vuetimeago

v1.0.8

Published

dhouse-vuetimeago. A vue component used to format date with time ago statement.

Downloads

31

Readme

dhouse-vuetimeago Timeago ภาษาไทย vue2

A timeago component Vue.js

ปรับปรุงมากจาก vue2-timeago กะว่าจะเพิ่มภาษาไทยให้ใน pagekage ให้แต่อัพเข้าไม่ได้เลยต้องเอาโค๊ดมาแก้ไขแล้วสร้าง pagekage มาใหม่ โดยการเพิ่มภาษาไทยเข้าไป ทั้งนี้เพื่อใช้ในการพัฒนาเว็บไซต์ ดีเฮ้าส์ แต่คิดว่าอาจจะเป็นประโยชน์สำหรับเพื่อน ๆ

ทดสอบการใช้งานจริง

ทดสอบการใช้งานแล้ว พอใช้งานได้ ตัวอย่างดูได้ที่ ดีเฮ้าส์ไทม์ไลน์

  • Localization supported
  • Show tooltip
  • Auto refresh time
  • When time refresh call a customizable function
  • Formats a date/timestamp to:
    • just now
    • 5m
    • 3h
    • 2 days ago
    • 2017-08-03
  • Rules:
    • less than 1 minute , show just now
    • 1 minute ~ 1 hour , show ** minutes ago
    • 1 hour ~ 1 day , show ** hours ago
    • 1 day ~ 1 month( 31 days ) , show ** days ago
    • more than 1 month( 31 days ) , show yyyy-mm-dd hh:mm

Navigation

Live Demo

Edit dhouse-vue_timeago_demo

Installation

Get from npm / yarn:

npm i dhouse-vuetimeago
yarn add dhouse-vuetimeago

Usage

Use this inside your app:

import TimeAgo from 'dhouse-vuetimeago'

export default {
  name: 'app',
  components: {
    TimeAgo,
  }
}
HTML
<time-ago :refresh="60" :datetime="new Date(2018, 7, 4, 0, 24, 0)" locale="th" tooltip></time-ago>

Examples

1. locale

Default locale is en, and the library supports en and th.

<time-ago locale="th"></time-ago> 
<time-ago :locale="locale"></time-ago> use v-bind
export default {
  ...
  data(){
    return{
      locale:"th",
    }
  },
  ...
2. datetime
<time-ago datetime="2018-08-03 15:47:00"></time-ago> 
<time-ago :datetime="new Date(2018, 7, 4, 0, 24, 0)"></time-ago> use v-bind
<time-ago :datetime="1533286641826"></time-ago> timestamp
  • Note. Don't bind with new Date() when you use refresh property. Because every time refresh will get a new date value.

    <time-ago :datetime="new Date(2018, 7, 4, 0, 24, 0)"></time-ago>  --> OK
    <time-ago refresh :datetime="new Date()"></time-ago> --> not OK

    If you want use new Date() , just remove datetime property.

    <time-ago refresh></time-ago>
3. refresh
<time-ago refresh></time-ago> Boolean , default refresh time 60/s
<time-ago :refresh="3600"></time-ago> bind value with a number
4. tooltip
  • Base on v-tooltip, you can use placement attribute that are allowed in v-tooltip.
<time-ago tooltip></time-ago> Show tooltip 
<time-ago tooltip="right"></time-ago> Set placement
5. long
<time-ago :datetime="datetime"></time-ago> show : 2d
<time-ago :datetime="datetime" long></time-ago> show : 2 days ago
6. todo

You can do something when time refresh every time

<time-ago :refresh="1" :locale="locale" :todo="()=> count+=1"></time-ago>
7. native event
<time-ago @click.native="todo"><time-ago/>

Props

| Property | Type | Default | Description | | ------------ | ------------ | ------------ | ------------ | | datetime | Date, String, Number | new Date() | The datetime to be formatted.| | locale | String | en | message language | | refresh | Boolean, Number | false | The period to update the component, in seconds. When true it will be 60s. Also you can bind a number.| | long | Boolean | false | Show long string with time message . ex. 3h -> 3 hours age| | tooltip | Boolean, String | false | Show tooltip.| | todo | Function | false | You can call a function when time refresh every time.|

Contributions

locale translations: The component needs more locale translations. You can Open an issue to write the locale translations, or submit a pull request. See example here.

locale support list :

  • English ( en )
  • Thai (th)