Skip to content

Repository files navigation

parser-js

One that parses

Dates

date() parses ISO-8601 strings into native Date objects:

import {date, Parser} from '@freckle/parser'

Parser.run('2016-03-12T13:00:00Z', date()) // => Date

Only ISO-8601 is accepted. Locale-dependent formats are rejected, since '03/12/2016' could mean either March 12 or December 3. Calendar-impossible dates ('2016-02-30') are rejected rather than rolled over, and date-only strings resolve to local midnight.

Migrating from v3

date() returned a Moment through v3 and returns a Date from v4 on. To keep Moment values, convert at the boundary:

import moment from 'moment-timezone'
import {date, mapStatic} from '@freckle/parser'

const momentDate = () => mapStatic(date(), d => moment(d))

Release

See RELEASE.md.

About

One that parses

Topics

Resources

Stars

0 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages