GitXplorerGitXplorer
t

Thyme

public
10 stars
2 forks
1 issues

Commits

List of commits on branch master.
Unverified
1a431d01cff44ffbb27e917202e6993e76c1098c

Template literals

ttrys committed 6 years ago
Unverified
061819cbb9d8d598736d638cf47477777fffdf50

Version bump

ttrys committed 6 years ago
Unverified
574f5dddd6689443f86f9c447eb7b3ba2cc7c7bc

Remove fat arrows

ttrys committed 6 years ago
Unverified
e62a25b5184b6366c02a0502cae4d8c7791bf720

Version 2.0.1

ttrys committed 6 years ago
Unverified
d76da37cc580aeec89ddc674beca1f0d73dd5649

Version two

ttrys committed 6 years ago
Unverified
9169c525b50089dfe75eae2ffb5bf077fd3c39d6

Conversion to function

ttrys committed 6 years ago

README

The README file for this repository.

Thyme

For when you need dates, but not times, and certainly not timezones.

Get started

npm i @trys/thyme
import Thyme from '@trys/thyme'

const a = new Thyme('2018-10-02')
const b = new Thyme('2018-10-05')

Comparison

a.equals(b)
// false

a.equals(a)
// true

a.equals(new Thyme('2018-10-02'))
// true

new Thyme('2018-10-02').equals('2018-10-02')
// true

Range of dates

const range = a.till(b)

range.contains(a)
// true

The contains method can be added to any array, plus it'll convert any strings into Thyme objects making it a neat way to convert multiple dates to Thyme.

const range = new Thyme().range([ '2018-02-12' ])
range.contains('2018-02-12')
// true

Date-like methods

a.getFullYear()
// 2018

/* Note, zero-based */
a.getMonth()
// 9

a.getDate()
// 2

a.getDay()
// 2

Add/Remove days

Thyme objects are mutable, so calling a.add() or a.remove() will return the new date AND mutate a.

a.add()
// 2018-10-03

a.add(2)
// 2018-10-05

a.remove()
// 2018-10-04

Basic formatting

a.format()
// 4 October 2018