True-Time-Format
Smart parsing date and time format for true time.
Support:
- The default hundred years value
- Daylight Saving Time
- Nanoseconds
- Leap second
Install
$ yarn add true-time-format
Usage
let time = ; // for normal datetime stringtime;time;time; // DST means Daylight Saving Time// LSC means expecting to consider leap second effects in time calculationstime; // customizelet parser = '20DYM+0800'; parser; parser;parser;parser;
Layout
The layout argument for un-normal datetime string only.
The layout:
20-0700
Means:
- If you match a two-digit year, it represents
20xx
years - If the data does not contain UTC offset, use
UTC-0700
The default hundred years value
The layout optional number prefix represents the default hundred years value,
such as 19
which means 19xx
if it matches a two-digit year.
Y
Represents the year.
M
Represents the month, digits or month word.
D
Represents the day.
h
Represents the hour.
m
Represents the minute.
s
Represents the second and dot nanosecond.
UTC offsets
The layout optional suffix +hhmm
or-hhmm
means
the default UTC offset, default is +0000
.
License
BSD 2-Clause License
Copyright (c) 2018, YU HengChun achun.shx@qq.com All rights reserved.