0.0.2 • Published 6 years ago

vue-compose-timeago v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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

PropertyTypeDefaultDescription
localeStringenmessage language
refreshBoolean, NumberfalseThe period to update the component, in seconds. When true it will be 60s. Also you can bind a number.
longBooleanfalseShow long string with time message . ex. 3h -> 3 hours age
  • useTimeago will return a timer function

timer

PropertyTypeDefaultDescription
datetimeDate, String, Numbernew 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:

0.0.2

6 years ago

0.0.1

6 years ago