JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 139764
  • Score
    100M100P100Q157333F
  • License MIT

A tiny (337B) reusable date formatter. Extremely fast!

Package Exports

  • tinydate

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tinydate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

tinydate Build Status

A tiny (337B) reusable date formatter. Extremely fast!

Inspired by tinytime, this module returns a "render" function that efficiently re-render your deconstructed template. This allows for incredibly performant results!

However, please notice that this only provides a limited subset of Date methods. If you need more, tinytime or date-fns are great alternatives!

Install

$ npm install --save tinydate

Usage

const tinydate = require('tinydate');
const fooDate = new Date('5/1/2017, 4:30:09 PM');

const stamp = tinydate('Current time: [{HH}:{mm}:{ss}]');

stamp(fooDate);
//=> Current time: [16:30:09]

stamp();
//=> Current time: [17:09:34]

API

tinydate(pattern)(date)

pattern

Type: string

The template pattern to be parsed.

date

Type: Date
Default: new Date()

The date from which to retrieve values. Defaults to current datetime.

Patterns

  • {YYYY}: full year; eg: 2017
  • {YY}: short year; eg: 17
  • {MM}: month; eg: 04
  • {DD}: day; eg: 01
  • {HH}: hours; eg: 06 (24h)
  • {mm}: minutes; eg: 59
  • {ss}: seconds; eg: 09

Benchmarks

tinydate
  --> 72,236,210 ops/sec ±0.89% (91 runs sampled)
tinytime
  --> 27,530,608 ops/sec ±0.92% (93 runs sampled)
time-stamp
  --> 569,692 ops/sec ±0.80% (90 runs sampled)

License

MIT © Luke Edwards