fast-date-parse

1.0.0 • Public • Published

fast-date-parse

Build Status Coverage Status NPM version JavaScript Style Guide

Performant date parsing.

Installation

npm i fast-date-parse

Example

const DateParser = require('fast-date-parse')
 
const parser = new DateParser('YYYY-MM-DD')
 
parser.parse('2018-09-02')

Tokens

Supported tokens:

Token Example Description
YYYY 2018 Year
MM 01..12 Month
HH 00..23 Hours (24 hour time)
DD 01..31 Day of month
mm 00..59 Minutes
ss 00..59 Seconds
SSS 000..999 Milliseconds

API

DateParser(datePattern)

Creates a new parser.

The parser ignores all non-token characters.

DateParser#parse(dateString)

Parses the dateString and returns a date object.

Benchmark

$ node benchmark/benchmark.js
moment x 73,592 ops/sec ±1.75% (90 runs sampled)
fast-date-parse x 1,727,745 ops/sec ±1.09% (87 runs sampled)
fecha x 98,347 ops/sec ±1.74% (84 runs sampled)
Fastest is fast-date-parse

License

MIT

/fast-date-parse/

    Package Sidebar

    Install

    npm i fast-date-parse

    Weekly Downloads

    57

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    18.8 kB

    Total Files

    10

    Last publish

    Collaborators

    • serayaeryn