1.2.6 • Published 2 years ago

datetime-next v1.2.6

Weekly downloads
-
License
LGPL-3.0
Repository
gitlab
Last release
2 years ago

DateTime Next


Next gen Date and Time manipulation library designed with performance in mind, it is extremely lightweight. It is about 3.5Kb minified and gzipped.

Does not use any static data such as localization files, everything comes from built in Intl object. However, this can be overridden if you provide your own Month names.

DateTime is designed to only operate on UTC date and time. It has however support for formatting date and time in user specified locale and timezone.

DateTime is specifically built as Mutable object, if you wish to use immutable object use DateTimeImmutable instead. Read more about this choice here

Zero dependencies.

npm

WARNING: API is not yet final

Requirements

Technically it should have no requirements, For node recommended version 8+. For browser, it's the existence of Intl object.


Docs

Read the docs here


Installation

For yarn:

yarn add datetime-next

For npm:

npm i datetime-next

For browser just include the script or import it via ES6 import statement.

Some examples


Imports:

// ES6 JS/Typescript style
import { DateTime } from 'datetime-next';
// OR
import { DateTime } from 'datetime-next/DateTime';

// require

const { DateTime } = require('datetime-next');

Basic usage:

const dt = new DateTime(); // Current datetime in UTC
dt.addHour(1); // Add one hour
dt.getString('YYYY-MM-DD'); // format date ex `2021-06-21`
dt.getString('HH:mm:ss'); // format time `15:25:41`

Format properties:

SymbolDescriptionExample
YYYear in 2 digit format21
YYYYYear in full format2021
MMonth digit not padded with zeros4
MMMonth padded to 2 digits04
MMMShort locale aware month nameDec
MMMMLong locale aware month nameDecember
dWeekday number5
ddWeekday locale aware narrow nameF
dddWeekday locale aware short nameFri
ddddWeekday locale aware short nameFriday
DDay of month not padded9
DDDay of month padded to 2 digits09
HHour in 24h format not padded7
HHHour in 24h format padded to 2 digits07
hHour in 12h format not padded7
hhHour in 12h format padded to 2 digits07
aMeridian locale aware in lowercaseam
AMeridian locale aware in uppercaseAM
mMinute not padded5
mmMinute padded to 2 digits05
sSecond not padded3
ssSecond padded to 2 digits03
SSSMilliseconds padded to 3 digits245
ZTimezone offset from UTC with colon+02:00
ZZTimezone offset from UTC without colon+02:00
1.2.6

2 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago