0.1.2 • Published 3 years ago

@twharmon/instant v0.1.2

Weekly downloads
19
License
ISC
Repository
-
Last release
3 years ago

Instant

Immutable datetime objects that wrap the native Date class. This package is a work in progress.

Usage

import Instant from '@twharmon/instant'

const x = new Instant() // x is immutable
const y = x.plus(5, 'days')
console.log(x.format('MMM, D, YYYY')) // Jan 7, 2021
console.log(y.format('MMM, D, YYYY')) // Jan 12, 2021

const z = new Instant('2021-01-07T11:17:42-00:00')
console.log(z.format('h:mm a')) // 11:17 am (if in GMT time zone)

Formatting

The following outputs are based on 2:08:06.123 am January 7, 2021 CDT (Central Daylight Time).

Year

TokenOutput
YYYY2021
YY21

Month

TokenOutput
MMMMJanuary
MMMJan
MM01
M1

Date

TokenOutput
DD07
D7

Hour

TokenOutput
HH14
H14
hh02
h2

Minute

TokenOutput
mm08
m8

Second

TokenOutput
ss06
s6

Millisecond

TokenOutput
SSS123
SS12
S1

AM / PM

TokenOutput
APM
apm

Time Zone

TokenOutput
Z-06:00

Contibuting

Make a pull request.

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago