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

aurelia-time

v1.1.1

Published

A set of value converters and custom elements for date and time based on existing libraries.

Downloads

28

Readme

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

  1. install the package
npm install aurelia-time --save

yarn add aurelia-time
  1. 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 )
export class Home {

    languages: Array<any>;

    options: any;

    myDate: string = "1985/01/23";
    myFormat: string = "YYYY/MM/DD MMMM";

    constructor() {
        this.options = {
            locale: "fa" // This line will force value converters to use jalali-moment,locales/languages other than Farsi/Persian such as 'en', 'it', 'fr' etc. will use moment library.
        };
    }
}

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.

<label>
    Date: 
    <input type="datetime" value.bind="myDate" />
</label>
<label>
    Format:
    <input type="text" value.bind="myFormat" />
</label>
<h1 style="direction:ltr">
    <span>
        ${myDate|date:myFormat:options.locale}
    </span>

    <span>
        ${myDate|time:false:options.locale}
    </span>

</h1>

2. Moment Timezone

export class Home {

    private selectedTimezone;
    private timezones:Array<string>;

    constructor(){
        this.timezones = [
                    "Asia/Tehran",
                    "Asia/Tokyo",
                    "Europe/London",
                    'America/Los_Angeles'
                ];
    }
}
 <label>
    Timezone:
    <select value.bind="selectedTimezone">
        <option repeat.for="tz of timezones" value.bind="tz">
            ${tz}
        </option>
    </select>
</label>

<br />

<label textcontent.bind="myDate|timezone:selectedTimezone">
</label>

3. Humanize Duration

<span>
    ${361000 |humanize:{language:options.locale}}
</span>

Custom Elements

1. Clock

Inspired by Codepen

 <au-clock font-size="40" be24-hours="false" date-format="YYYY MMMM DD" locale="fa"
     style="left: 300px; top:200px; position: absolute">
</au-clock>

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

Any contribution will be welcome