Detalhes do pacote

spacetime

spencermountain570.7kApache-2.07.10.0

figure-out dates across timezones

readme (leia-me)

Isn't it weird how we can do math in our head, but not date math?

- how many days until the end of the year?
-what time was it, 11 hours ago?
-is it lunchtime in france?

and worse - there is no real date calculator.

people end up asking google, and going to weird websites.

that's bad.

spacetime is a date-calculator,

It's very small, and very handy.
let s = spacetime.now()

s.diff(s.endOf('year'), 'days')
// 292

s.substract(11, 'hours').time()
// 6:50am

s = s.goto('Europe/Paris')
s.isAfter(s.time('11:00am'))
// true 🥐

- calculate time in remote timezones - support daylight savings, leap years, and hemispheres - Moment-like API (but immutable) - Orient time by quarter, season, month, week.. - Zero Dependencies - (no _Intl API) - weighs about 40kb. - has a cool plugin thing_. - frequent updates for approaching DST changes - support for upcoming Temporal standards html <script src="https://unpkg.com/spacetime"></script> <script> var d = spacetime('March 1 2012', 'America/New_York') //set the time d = d.time('4:20pm') d = d.goto('America/Los_Angeles') d.time() //'1:20pm' </script> npm install spacetime js const spacetime = require('spacetime') let d = spacetime.now('Europe/Paris') d.dayName() //'Wednesday' d.isAsleep() //true typescript / babel / deno: ts import spacetime from 'spacetime' let d = spacetime.now() d.format('nice') //'Apr 1st, 4:32pm'

Demo     •     Full API

plugins:

Date Inputs:

we can parse all the normal stuff, and some fancy stuff:

//epoch
s = spacetime(1489520157124)

//array [yyyy, m, d] (zero-based months, 1-based days)
s = spacetime([2017, 5, 2])

//iso
s = spacetime('July 2, 2017 5:01:00')

// All inputs accept a timezone, as 2nd param:
s = spacetime(1489520157124, 'Canada/Pacific')
s = spacetime('2019/05/15', 'Canada/Pacific')

// or set the offset right in the date-string (ISO-8601)
s = spacetime('2017-04-03T08:00:00-0700')
// 'Etc/GMT-7'

// Some helpers
s = spacetime.now()
s = spacetime.today() // This morning
s = spacetime.tomorrow() // Tomorrow morning
s = spacetime.min() // the earliest-possible date (271,821 bc)
s = spacetime.max() // the furthest-possible future date (27k years from now)

// To get the native Date object back
// (this bails back to the local timezone)
jsDate = spacetimeDate.toNativeDate()

for fancier natural-language inputs, use compromise-dates.

Get & Set dates:

you can whip things around, but stay intuitive

s.date() // 14
s.year() // 2017
s.season() // Spring
s = s.hour(5) // Change to 5am
s = s.date(15) // Change to the 15th

s = s.day('monday') // Change to (this week's) monday
s = s.day('monday', true) // go forward to monday
s = s.day('monday', false) // go backward to monday

s = s.month('march') // Change to (this year's) March 1st
s = s.quarter(2) // Change to April 1st
s.era() // 'BC'/'AD'
s.decade() // 2000
s.century() // 21

// Percentage-based information
s.progress().month = 0.23 // We're a quarter way through the month
s.progress().day = 0.48 // Almost noon
s.progress().hour = 0.99 // 59 minutes and 59 seconds

// Add/subtract methods
s = s.add(1, 'week')
s = s.add(3, 'quarters')
s = s.subtract(2, 'months').add(1, 'day')

// start-of/end-of
s = s.startOf('day') // 12:00am
s = s.startOf('month') // 12:00am, April 1st
s = s.endOf('quarter') // 11:59:59pm, June 30th

s = s.nearest('hour') //round up/down to the hour
s = s.nearest('quarter-hour') //5:15, 5:30, 5:45..
s = s.next('month') //start of the next month
s = s.last('year') //start of the last year

// fill-in all dates between a range
s.every('week', 'Jan 1st 2020') // (in tz of starting-date)

//utilities:
s.clone() // Make a copy
s.isValid() // Sept 32nd → false
s.isAwake() // it's between 8am → 10pm
s.json() // get values in every unit as key-val object

if it's 9am on tuesday, and you add a week, it will still be 9am on tuesday. ... even if some crazy changes happen.

setter methods also support a handy 2nd param that controls whether it should be set forward, or backward.

s = s.time('4:00pm') // 4pm today
s = s.time('4:00pm', true) // the next 4pm in the future
s = s.time('4:00pm', false) // the most-recent 4pm

s = s.set('march 5th 2020')
s = s.set('march 4th') // 2020 (same year)
s = s.set('march 4th', true) // 2021
s = s.set('march 6th', false) // 2019

it's actually a little surprising how helpful this is.

Comparisons:

let s = spacetime([2017, 5, 2])
let start = s.subtract(1, 'milliseconds')
let end = s.add(1, 'milliseconds')

// gt/lt/equals
s.isAfter(d) // True
s.isEqual(d) // False
s.isBefore(d) // False
s.isBetween(start, end, inclusive?) // True

// Comparison by unit
s.isSame(d, 'year') // True
s.isSame(d, 'date') // False
s.diff(d, 'day') // 5
s.diff(d, 'month') // 0

//make a human-readable diff
let before = spacetime([2018, 3, 28])
let now = spacetime([2017, 3, 28]) //one year later
now.since(before)
// {diff: { months: 11, days: 30, ...},  rounded: 'in 12 months'  }

all comparisons are done with sensitivity of timezone - 8am EST is < 8am PST.

Timezones:

the best way to describe a timezone is an IANA code:

// Roll into a new timezone, at the same moment
s = s.goto('Australia/Brisbane')

if you want to support relaxed timezone names like 'EST', Eastern time, use timezone-soft

spacetime.extend(require('timezone-soft'))

s = s.goto('milwaukee') // 'America/Chicago'
s = s.goto('-7h') // UTC-7
s = s.goto('GMT+8') // -8h!
// (these should be used with some caution)

play-around with timezones, and their DST-changes:

//list timezones by their current time
spacetime.whereIts('8:30pm', '9:30pm') // ['America/Winnipeg', 'America/Yellowknife'... ]
spacetime.whereIts('9am') //(within this hour)

// Timezone metadata
s.timezone().name // 'Canada/Eastern' (either inferred or explicit)
s.hemisphere() // North
s.timezone().current.offset // -4 (in hours)
s.hasDST() // True
s.isDST() // True

//list all timezones
spacetime.timezones()

you can flip-around the world pretty quick.

spacetime will use your local timezone, by default:

.goto(null) will pluck your current tz safely from your browser or computer.

spacetime().time('4:30pm').goto('Europe/Paris').goto(null).time()
// 4:30pm

If, for some reason, you want to change the timezone without changing the date, you can do this via the .timezone(str) setter:

let s = spacetime('2023-01-01T5:30[America/Denver]')
s = s.timezone('Europe/Zagreb') // hot-swap
console.log(s.isoFull())
// '2023-01-01T05:30:00.000+01:00[Europe/Zagreb]' (same time, new tz)

Date Formatting:

it's a pretty-sensible process to create nice-looking dates:

// Date + time formatting
s.format('time') // '5:01am'
s.format('numeric-uk') // 02/03/2017
s.format('month') // 'April'
s.format('month-short') // 'Apr'
s.format('month-pad') // '03'
s.format('iso-month') // '04'

//if you want more complex formats, use {}'s
s.format('{year}-{date-pad}-{month-pad}') // '2018-02-02'
s.format("{hour} o'clock") // '2 o'clock'
s.format('{time}{ampm} sharp') // '2:30pm sharp'

//if you prefer, you can also use unix-formatting
s.unixFmt('yyyy.MM.dd h:mm a') // '2017.Nov.16 11:34 AM'

// support for the new Temporal ISO format
s.format('iso-full') // '2011-12-03T10:15:30.010+01:00[Europe/Paris]'

// support for the SQL ISO 9075 format
s.format('sql') // '2011-12-03 10:15:30'

Limitations & caveats

◆ Historical timezone info

DST changes move around all the time, and timezones pop-in and out of existence. We store and use only the latest DST information, and apply it to historical dates.

◆ International date line

.goto() never crosses the date-line. This is mostly the intuitive behaviour.

But if you're in Fiji (just west of the date line), and you go to Midway (just east of the date line), .goto() will subtract a bunch of hours, instead of just adding one.

◆ Destructive changes

if it's 2:30pm and you add a month, it should still be 2:30pm. Some changes are more destructive than others. Many of thse choices are subjective, but also sensible.

◆ 0-based vs 1-based ...

for better or worse we copy the JavaScript spec for 0-based months, and 1-based dates.

ISO-formatting is different, so keep on your toes.

see more considerations and gotchas

Daylight-savings gotchas

We've written in detail about how spacetime handles Daylight-savings changes here

Fall DST changes have an hour that is repeated twice. There are a lot of tricky situations that come from this. Add 10 minutes at 1:55am, and a spacetime diff may show -50mins. Within an hour of this change, some spacetime methods may be off-by-one hour.

Springtime DST changes are generally smoother than Fall ones.

Config:

Ambiguity warnings:

javascript dates use millisecond-epochs, instead of second-epochs, like some other languages. This is a common bug, and spacetime can warn if you set an epoch within January 1970. to enable:

let s = spacetime(123456, 'UTC', {
  silent: false
})
s.log() // "Jan 1st, 12:02am"

There is another situation where you may see a console.warn - if you give it a timezone, but then set a ISO-date string with a different offset, like 2017-04-03T08:00:00-0700 (-7hrs UTC offset). It sets the timezone to UTC-7, but also gives a warning.

let s = spacetime('2017-04-03T08:00:00-0700', 'Canada/Eastern', {
  silent: false
})
s.timezone().name // "Etc/GMT-7"

Configure 'today' context:

spacetime makes some assumptions about some string inputs:

// assumes start of month
let s = spacetime('June 1992')
s.date() // 1

// assumes current year
let s = spacetime('June 5th')
s.year() // 2020 (or whatever it is now)

// assumes Jan 1st
let s = spacetime('2030')
s.month() // 'January'

you can configure this assumed date (usually for testing) by passing it in as an option:

let today = {
  month: 3,
  date: 4,
  year: 1996
}
let s = spacetime('June 5th', null, { today: today })
s.year() // 1996

it also works for spacetime.now(tz, {today:today}) and others.

Extending/Plugins:

you can throw any methods onto the Spacetime class you want, with spacetime.extend():

spacetime.extend({
  isHappyHour: function () {
    return this.hour() === 16
  }
})

let s = spacetime.now('Australia/Adelaide')
s.isHappyHour()
//false

s = s.time('4:30pm')
s.isHappyHour()
//true

DD/MM/YYY interpretation:

by default spacetime uses the American interpretation of ambiguous date formats, like javascript does:

spacetime('12/01/2018') //dec 1st

// unless it's clear (>12):
spacetime('13/01/2018') //jan 13th

you can change this behaviour by passing in a dmy option, like this:

spacetime('12/01/2018', null, { dmy: true }) //jan 12th

this format is more common in britain, and south america.

Custom languages:

let s = spacetime.now()
s.i18n({
  days: {
    long: ['domingo', 'lunes', 'martes', 'miércoles', 'jueves', 'viernes', 'sábado'],
    short: ['dom', 'lun', 'mar', 'mié', 'jue', 'vie', 'sáb']
  },
  months: {
    long: [...],
    short: ['ene', 'feb', 'mar', 'abr', 'may', 'jun', 'jul', 'ago', 'sep', 'oct', 'nov', 'dic'],
  },
  ampm: {
    am: ' a. m.',
    pm: ' a. m.'
  },
  distance: {
    past: 'past',
    future: 'future',
    present: 'present',
    now: 'now',
    almost: 'almost',
    over: 'over',
    pastDistance: (value) => `${value} ago`,
    futureDistance: (value) => `in ${value}`
  },
  units: {
    second: 'second',
    seconds: 'seconds',
    minute: 'minute',
    minutes: 'minutes',
    hour: 'hour',
    hours: 'hours',
    day: 'day',
    days: 'seconds',
    month: 'month',
    months: 'months',
    year: 'year',
    years: 'years',
  },
  useTitleCase: true // automatically in .format()
});
s.format('day') //'Sábado'

Configure start of week:

by default, the start of the week is monday.

You can determine the week by the official country setting, with spacetime-week

let s = spacetime.now()
s = s.weekStart('sunday')

s = s.startOf('week')
s.dayName()
//sunday

s = s.endOf('week')
s.dayName()
//saturday

See also:

thank you to the amazing timeanddate.com

Apache 2.0

changelog (log de mudanças)

This project follows semVer, where:

  • [major] is an API, or result-format change
  • [minor] is a result change
  • [patch] is a bugfix

7.10.0 [Apr 2025]

  • [fix] - capitalization of "Etc/Utc" #446
  • [new] - .isoFull() method
  • [new] - spacetime.fromEpochSeconds() method #444
  • [fix] - getter form of .epochSeconds()
  • [update] - dependencies

7.9.0 [Apr 2025]

  • [new] - .format('sql') #437
  • [new] - .epochSeconds() #439
  • [fix] - duplicate type for .json() #435
  • [update] - plugin peerdepencies #440
  • [update] - dependencies

7.8.0 [Mar 2025]

  • [fix] - 2025 DST-change times for many zones #431
  • [fix] - more .week() issues from #303
  • [new] - initial support for Temporal's extended-iso RFC3339 fmt
  • [new] - adds .format('iso-full') for Temporal support
  • [new] - support hot-swap timezone via .timezone(tz) #180
  • [new] - add tz/offset info in .json() response
  • [new] - support .json(obj) setter fn
  • [fix] - proper capitalization of UTC in .timezone() response
  • [fix] - typescript fixes #432
  • [update] - dependencies

7.7.0 [Dec 2024]

  • [fix] - .week() issue #303
  • [update] - 2025 DST changes
  • [update] - greenland Nuuk DST change #420
  • [update] - alias choibalsan to ulaanbaatar

7.6.2 [Oct 2024]

  • [fix] - isEqual null on 1970-01-01 #417

7.6.1 [July 2024]

  • [new] - add stepCount paramater to .every() #411
  • [fix] - eslint update and fixes
  • [change] - readme improvements #412
  • [update] - minor DST hour changes
  • [update] - github actions script
  • [update] - dependencies

7.6.0 [Feb 2024]

  • [fix] - leap-year string parse issue
  • [change] - typescript export changes #408 #409 (thanks jecraig!)
  • [update] - DST date changes for metlakatla, kiev, ciudad_juarez
  • [update] - late DST date changes for gaza, hebron
  • [change] - update github script
  • [update] - deps

7.5.0 [Dec 2023]

  • [fix] - offset in Africa/Cairo #404
  • [update] - 2024 DST changes
  • [change] - support i18n config in .since() #403

7.4.8 [Oct 2023]

  • [fix] - fix for reversed-DST in africa/casablanca and africa/el_aaiun #400
  • [update] - deps

7.4.7 [Aug 2023]

  • [fix] - guard against non-IANA responses in Intl #397
  • [update] - deps

7.4.6 [Aug 2023]

  • [change] - add new dst for #395
  • [update] - deps

7.4.5 [Jul 2023]

  • [fix] - typescript node16 issue #393
  • [update] - moroccan and palestinian dst dates
  • [update] - africa/cairo is back on DST
  • [update] - deps

7.4.4 [May 2023]

  • [fix] - .week() results #387
  • [fix] - .dayTime() results #388

7.4.3 [April 2023]

  • [fix] - support leap-years in setting dayOfYear() #382

7.4.2 [Mar 2023]

  • [change] - Iran off of dst #379
  • [change] - mexico off of dst #378
  • [change] - allow chaining of .i18() #372
  • [change] - typescript update #373

7.4.1 [Jan 2023]

  • [update] - add etc/unknown timezone for #367

7.4.0 [Dec 2022]

  • [update] - 2023 DST changes for mexico
  • [update] - 2023 DST changes for jordan
  • [update] - 2023 DST changes for fiji
  • [update] - missing seconds, quarters methods #360 #359
  • [new] - {AMPM} uppercase fmt

7.3.0 [Dec 2022]

  • [update] - 2023 DST changes
  • [fix] - southern hemisphere december season #352
  • [fix] - Yakutsk timezone

7.2.0 [Sep 2022]

  • [update] - Kiev/Kyiv alias
  • [update] - chile DST change
  • [fix] - antarctic dst times
  • update dependencies

7.1.4 [April 2022]

  • [fix] - export .cjs format for plugins in es5
  • [fix] - typescript fix #338
  • [fix] - typescript fix #336
  • update dependencies

7.1.3 [April 2022]

  • [fix] - typescript fixes
  • [change] - update asia/gaza and asia/hebron dst times
  • update dependencies

7.1.2 [Feb 2022]

  • [fix] - for asmara issue #328

7.1.1 [Feb 2022]

  • [new] - support custom i18n strings for am/pm
  • [new] - more alias support for deprecated iana codes
  • [fix] - for silent/verbose mode
  • update deps

7.1.0 [Jan 2022]

  • [change] - rename cjs build to .cjs #319

7.0.2 [Jan 2022]

  • [fix] - another esm build path #316

7.0.1 [Jan 2022]

  • [fix] - esm build path

7.0.0 [Jan 2022]

  • [change] - update to 2022 DST dates
  • [change] - return 'Sep' instead of 'Sept' in format('month-short') and 'MMM' #304
  • [change] - convert to ES-modules, + exports fields
  • [change] - make .every() results inclusive of start
  • [change] - alias old IANA codes to contemporary ones
  • [change] - move cal plugin to repo spencermountain/scal
  • [new] - add ISO duration to .since() results (thanks Adam)
  • [fix] - iso-parsing issues #320
  • [fix] - typescript issue #305
  • [fix] - subtract months issue #312
  • [fix] - unix 'yy' format issue #302
  • [change] - return 'Etc/GMT' not 'Etc/GMT+0'
  • [change] - update deps
  • bump + republish plugins

v6.16.4 [Nov 2021]

  • [fix] - ISO fmt parsing #310
  • [update] - gaza, hebron dst date change
  • update deps

v6.16.3 [Aug 2021]

  • [new] - .daysInMonth() method (thanks m1212e!)
  • [change] - replace deprecated timezone aliases (thanks Michael!)
  • [change] - date/day naming inconsistency in add method (thanks Andy!)
  • [fix] - typescript fixes (thanks Adam!)
  • [fix] - many-year add issue #235
  • [fix] - iso format year-padding for BC years
  • update deps

v6.16.2 [June 2021]

  • [fix] - offset for asia/baku #292
  • [fix] - date-parser for #291
  • update deps

v6.16.1 [May 2021]

  • [new] - add millisecond pad #283
  • update deps

v6.16.0 [April 2021]

  • [change] - improvements to date-sting parsers
  • [change] - drop ie11 polyfills in min.js build
  • [change] - minify and stop compiling esm build

v6.15.2 [April 2021]

  • [fix] - .add(n, 'weekend')
  • update deps

v6.15.1 [April 2021]

  • [fix] - Fix pacific/chatham iana DST change time (thanks Michael!)
  • update deps

v6.15.0 [April 2021]

  • [fix] - string parsing issue for tue/tues
  • [fix] - .time('4:88') now has ceiling of 59m
  • [new] - add goFwd params to all (appropriate) setter methods

v6.14.0 [March 2021]

  • [change] - add missing timezones from indiana and argentina
  • [change] - set old timezones as aliases of newer ones
  • [new] - add min, max methods
  • [change] - comment-out tests that were failing in some timezones
  • update deps, and documentation

v6.13.0 [March 2021]

  • [change] - support more alt day formats like .day('mo')
  • [change] - allow .week() to return 53
  • [change] - support swapped-parameters for .each()
  • [change] - support swapped-parameters for .isSame()
  • update deps

v6.12.5 [Feb 2021]

  • [fix] - add/minus by quarter issue

v6.12.4 [Feb 2021]

  • [fix] - typescript issue

v6.12.3 [Feb 2021]

  • [fix] - fix .every() >= issue
  • [fix] - fix today-passthrough in some date formats
  • [change] - use updated DST changes (171 changes)
  • [change] - support explicit local-timezone (thanks Mitsunee)
  • [new] - spacetime.timezones() method
  • update deps

v6.12.2 [Dec 2020]

  • [change] - support i18n titlecase config (thanks Kayla)
  • [fix] - endOf('season') issue
  • [fix] - fix character escaping issue in unixFmt method #207 update deps

v6.12.1 [Dec 2020]

  • [new] - support for '97 year format
  • [change] - support 13h00 time format
  • [change] - support 09.13.2013 and 13.09.2013 formats
  • [fix] - .add() issue sometimes effecting quarter/season

v6.12.0 [Dec 2020]

  • [new] - support period-seperated short-iso format
  • [new] - support fortnight in add/remove methods
  • [new] - support 'tues' 'thurs' in day() method
  • [new] - support '2002-06' truncated iso input

v6.11.0 [Nov 2020]

  • [change] - support 6-digit millisecond, and lowercase iso
  • [change] - first week of year must start > dec 29th
  • [fix] - typescript fixes
  • update deps

v6.10.1 [Nov 2020]

  • [fix] - keep yukon dst changes (for now!) #243
  • [fix] - support new-zealand time in '13h' format #242
  • update deps

v6.10.0 [Nov 2020]

  • [fix] - support whitespace between time and am/pm (thanks Andy!)
  • [change] - make empty array + obj equal to null inputs #240
  • [change] - update timezones
  • [change] - remove Yukon DST pre-emtively

v6.9.0 [Nov 2020]

  • [fix] - dst-change issues like #236
  • [fix] - inc/dec year issue on exact nye millisecond
  • [change] support parsing quarter-names as input - 'q2 2001'
  • [change] support parsing season-names as input - 'fall 2001'

v6.8.0 [Oct 2020]

  • [fix] major DST issue #182 (thanks Boris!)

v6.7.0 [Oct 2020]

  • [fix] add missing timezones America/Fort_Nelson, Asia/Qostanay, and America/Nuuk
  • [fix] comparison issue #231 effecting .isSame() and .since() accross different timezones

v6.6.4

  • [fix] 45m offset formatting issue
  • update deps

v6.6.3

  • [change] support for 'today' param with null inputs
  • [change] support for 'today' param with 'today/tonight' inputs
  • [change] interpret empty-string input like null input (as 'now')
  • [fix] typescript fixes (#220 #222) -

v6.6.2

  • [fix] for formatting when the output is 0 😓
  • [fix] for leap-day in .date() method
  • update deps
  • add github release/publish script

v6.6.1

  • [fix] typescript fix

v6.6.0 [June 2020]

  • [change] support undefined as input (like null)
  • [fix] for missing defaults in object input
  • [fix] major DST add/subtract bug #193

v6.5.0

  • support options.today
  • update deps, minor zonefile update

v6.4.1

  • run mjs build through babel (#175)

v6.4.0 [Jan 2020]

  • add .toLocalDate()
  • update zonefile to 2020
  • add Famagusta and Yangon iana zones

v6.3.0 [Nov 2019]

  • add .decade()
  • add .century()
  • add .millenium()
  • add .json() method
  • remove dst for Brazil
  • fix .week() counting logic
  • change overflow error-amount for #166

v6.2.1

  • fix typescript types

v6.2.0

  • add config for dmy british date parsing
  • support 18-feb-2019 format

v6.1.0

  • support for +14 timezones.

v6.0.0 [Aug 2019]

  • remove 'informal' timezone parsing (like .goto('south africa'))
  • remove 'display' info from .timezone() like 'EST' (move to spacetime-informal)
  • throw error on an invalid timezone #150
  • optimize .week() method

5.9.0

  • add support for changing start/end of the week
  • allow more flexible .i18n() inputs

5.8.0

  • faster diff for large-number of months
  • more support for esoteric iso formats
  • add format('iso-month')
  • change fallback behaviour for set failure edge-cases

5.7.0

  • avoid setting dates/months/hours past maximums and minimums
  • .hour(24) now changes date to tomorrow
  • faster diffs for large (decade-long) ranges
  • [big] fix awkward diff/since issues ('dec 25->jan 5' should be 0 years)

5.6.0

  • support typescript types by Jacob Craig
  • use given timezone when given a spacetime object as an input
  • adds .every(unit, to) method
  • set UTC as default fallback timezone

5.4.0

  • support more time input formats
  • fixes offset input issue #103

5.3.0

  • added more iana timezones
  • fixed zero-padding in iso offsets
  • support half hour offsets in iso formats

5.2.0

  • next() and last() methods
  • support for century and decades
  • full-api tests and docs

5.1.0

  • titlecase short-forms of months, days in .format()
  • support implicit date in nov 2019
  • support tues March 5th 2018 inputs
  • pretty-dramatic speed optimizations (~50%)

v5.0.0 🚨 -breaking

  • 🚨 all methods now immutable by default.🚨 -- existing code will now need to be s = s.add(1,'day') --- (instead of s.add(1,'day'))
  • move unix-formating out of .format() into .unixFmt()
  • support new {hour} oclock-style format templates
  • change default .format() response to yyyy-mm-dd
  • uppercase month and day names in .dayName()
  • support city-names, EST, PDT, etc as input
  • set default silent: true to avoid unwanted logging

v4.5.0

  • update a few TZ offsets in mostly eastern-Russia
  • updates to 2019 Palestinian dst dates
  • fixes for missing immutable setter methods

v4.4.0

  • big - swap interpretation of ISO date offsets -0500 → +5 offset #61

v4.3.0

  • assume current year with input spacetime('July 5th')
  • do larger .diff() operations (gt 1yr) in fast-mode
  • support BC formatting of input and in s.format('year')
  • bug fix for iso-format hour-offsets (#58)

v4.2.2

  • adds .extend() method for authoring plugins

v4.2.0

  • fix dayOfYear regression on 31st days
  • support space in ISO-186 format
  • update deps, use babel-env

v4.1.0

  • fix 'February 30th' regression
  • remove denormalized .valid boolean on Spacetime class

v4.0.1

  • support .from() and .fromNow() methods

v4.0.0

  • format(iso) now uses . for millisecond separator: 2016-11-04T09:00:59.122Z
  • adds .since() method to calculate a human-readable diff
  • support string/number input to .diff()
  • support ordinal inputs, like June 5th 2018
  • isAwake() method
  • alias for .plus() .minus() methods
  • .diff() without a unit does a couple units together
  • update zonefile to proper dst-flip time

v3.2.0

  • update zonefile to 2018 dst dates

v3.1.0

  • dramatic speedup by optimizing walkTo method

v3.0.1

  • fallback to UTC, instead of PST if no Intl is present
  • support passing-in offsets as ISO_8601 date-strings
  • add epoch-seconds warning msg
  • allow getting/setting new timezones

v2.1.0

  • support unix/unicode time-formating basic-level
  • add .era() get/set method
  • found 6 or 7 wrong offsets

v2.0.0


v1.3.2

  • fix for inf-loop regression on DST-switch

v1.3.1

  • adds spacetime.i18n() method
  • adds spacetime.nearest() method
  • support for "quarterHour" units - '4:15, 4:30, 4:45, 5:00' etc

v1.3.0

  • adds spacetime.whereIts() method
  • actually implement 😓 season by hemisphere

v1.2.0

  • adds isBetween() method

v1.0.0 :rocket: