aurelia-time
This package contains a set of value converters for date and time inspired by four existing libraries which are widely used amongst developers.
The documentation is targeted for the webpack as it is the most favorite module bundler, for other module loaders follow their instructions
We used jalali moment to support Persian/Jalali calendar
Installation
- install the package
npm install aurelia-time --save
yarn add aurelia-time
- register it as a plugin in the aurelia pipeline
aurelia.use.standardConfiguration()
.plugin(PLATFORM.moduleName('aurelia-time'));
Value converters
1. Moment: consists of four value converters :
* date( value:string, format:string, locale:string )
* time( value:string, show24Hours:string|boolean )
* age( value:string )
* relative( value:string , doAsJalali: boolean )
Worth to mention than we will use jalali-moment only for Persian/Farsi locale/language, languages other than that will use moment library.
For persian users only: if you use 'fa' locale, you don't need to pass format as j-formats ( jYYYY/jMM/jDD ) to jalali-moment any more, just use like other locals.
Date:Format:${myDate|date:myFormat:options.locale}${myDate|time:false:options.locale}
2. Moment Timezone
Timezone:${tz}
3. Humanize Duration
${361000 |humanize:{language:options.locale}}
Custom Elements
1. Clock
Inspired by Codepen
This custom element consists of four one-time bindable properties:
- text: string
- color: string
- shadowColor: string
- fontSize: string | number
and six one-way bindable properties:
- locale: string
- dateFormat: string
- be24Hours: string | boolean
- showDate: string | boolean
- showTime: string | boolean
- showText: string | boolean