0.0.2 • Published 6 years ago
vue-compose-timeago v0.0.2
vue-compose-timeago
:raised_hands: Format date with time ago statement using vue composition api
Depends on @vue/composition-api
Installation
Usage
html
<template>
<div>
Message created at : {{ time }} - {{ timeago }}
</div>
</template>
js
import { useTimeago } from "vue-compose-timeago"
setup() {
const { timer } = useTimeago({ locale: 'en', long: true, refresh: true })
const { time, timeago } = timer(new Date())
return {
time,
timeago
}
}
Props
useTimeago
Property | Type | Default | Description |
---|---|---|---|
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 |
- useTimeago will return a timer function
timer
Property | Type | Default | Description |
---|---|---|---|
datetime | Date, String, Number | new Date() | The datetime to be formatted. |
- timer will return time and timeago
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 )
- 繁體中文 ( zh_TW )
- 简体中文 ( zh_CN )
- 日本語 ( jp )
- Portugal(Brazil) ( pt_BR )
- Spain ( es )
- Arabia ( ar )
- French ( fr )
- Polish ( pl )
- Turkish ( tr )
- Russian ( ru )
Thanks for help: