Skip to content

Tree-shakeable API

Unlike normal API where you can pass string/obj loosely, func api is strict. Must always be proper object. No interchangeable arg types

Talk about code transform, Talk about manual conversions.

No input validation checks (unlike standard API)

ground rules:

  • no Calendar/TimeZone protocols

bare-metal

Extra utilities too Add non-standard utils too

PlainDate

Standard APITree-shakeable API
new Temporal.PlainDate(...args)PlainDateFns.create(...args)
Temporal.PlainDate.from(fields, opts)PlainDateFns.fromFields(fields, opts)
Temporal.PlainDate.from(str)PlainDateFns.fromString(str)
Temporal.PlainDate.compare(a, b)PlainDateFns.compare(a, b)
a instanceof Temporal.PlainDatePlainDateFns.isInstance(a)
pd.eraPlainDateFns.getFields(pd).era
pd.eraYearPlainDateFns.getFields(pd).eraYear
pd.yearPlainDateFns.getFields(pd).year
pd.monthPlainDateFns.getFields(pd).month
pd.monthCodePlainDateFns.getFields(pd).monthCode
pd.dayPlainDateFns.getFields(pd).day
pd.calendarIdPlainDateFns.calendarId(pd)
pd.dayOfWeekPlainDateFns.dayOfWeek(pd)
pd.dayOfYearPlainDateFns.dayOfYear(pd)
pd.weekOfYearPlainDateFns.weekOfYear(pd)
pd.yearOfWeekPlainDateFns.yearOfWeek(pd)
pd.daysInWeekPlainDateFns.daysInWeek(pd)
pd.daysInMonthPlainDateFns.daysInMonth(pd)
pd.daysInYearPlainDateFns.daysInYear(pd)
pd.monthsInYearPlainDateFns.monthsInYear(pd)
pd.inLeapYearPlainDateFns.inLeapYear(pd)
pd.with(fields, opts)PlainDateFns.withFields(pd, fields, opts)
pd.withCalendar(cId)PlainDateFns.withCalendar(pd, cId)
pd.add(dur)PlainDateFns.add(pd, dur)
pd.subtract(dur)PlainDateFns.subtract(pd, dur)
pd.until(other)PlainDateFns.until(pd, other)
pd.since(other)PlainDateFns.since(pd, other)
pd.equals(other)PlainDateFns.equals(pd, others)
pd.toZonedDateTime(opts)PlainDateFns.toZonedDateTime(pd, opts)
pd.toPlainDateTime(pt)PlainDateFns.toPlainDateTime(pd, pt)
pd.toPlainYearMonth()PlainDateFns.toPlainYearMonth(pd)
pd.toPlainMonthDay()PlainDateFns.toPlainMonthDay(pd)
pd.toLocaleString(locale, opts)PlainDateFns.toLocaleString(pd, locale, opts)
pd.toString(opts)PlainDateFns.toString(pd, opts)
pd.toJSON()PlainDateFns.toString(pd)
pd.getISOFields()PlainDateFns.getISOFields(pd)
pd.getCalendar()
pd.valueOf()

PlainDateTime

Standard APITree-shakeable API
new Temporal.PlainDateTime(...args)PlainDateTimeFns.create(...args)
Temporal.PlainDateTime.from(fields, opts)PlainDateTimeFns.fromFields(fields, opts)
Temporal.PlainDateTime.from(str)PlainDateTimeFns.fromString(str)
Temporal.PlainDateTime.compare(a, b)PlainDateTimeFns.compare(a, b)
a instanceof Temporal.PlainDateTimePlainDateTimeFns.isInstance(a)
pdt.eraPlainDateTimeFns.getFields(pdt).era
pdt.eraYearPlainDateTimeFns.getFields(pdt).eraYear
pdt.yearPlainDateTimeFns.getFields(pdt).year
pdt.monthPlainDateTimeFns.getFields(pdt).month
pdt.monthCodePlainDateTimeFns.getFields(pdt).monthCode
pdt.dayPlainDateTimeFns.getFields(pdt).day
pdt.hourPlainDateTimeFns.getFields(pdt).hour
pdt.minutePlainDateTimeFns.getFields(pdt).minute
pdt.secondPlainDateTimeFns.getFields(pdt).second
pdt.millisecondPlainDateTimeFns.getFields(pdt).millisecond
pdt.microsecondPlainDateTimeFns.getFields(pdt).microsecond
pdt.nanosecondPlainDateTimeFns.getFields(pdt).nanosecond
pdt.calendarIdPlainDateTimeFns.getFields(pdt).calendarId
pdt.dayOfWeekPlainDateTimeFns.dayOfWeek(pdt)
pdt.dayOfYearPlainDateTimeFns.dayOfYear(pdt)
pdt.weekOfYearPlainDateTimeFns.weekOfYear(pdt)
pdt.yearOfWeekPlainDateTimeFns.yearOfWeek(pdt)
pdt.daysInWeekPlainDateTimeFns.daysInWeek(pdt)
pdt.daysInMonthPlainDateTimeFns.daysInMonth(pdt)
pdt.daysInYearPlainDateTimeFns.daysInYear(pdt)
pdt.monthsInYearPlainDateTimeFns.monthsInYear(pdt)
pdt.inLeapYearPlainDateTimeFns.inLeapYear(pdt)
pdt.with(fields, opts)PlainDateTimeFns.withFields(pdt, fields, opts)
pdt.withPlainTime(pt)PlainDateTimeFns.withPlainTime(pdt, pt)
pdt.withPlainDate(pd)PlainDateTimeFns.withPlainDate(pdt, pd)
pdt.withCalendar(cId)PlainDateTimeFns.withCalendar(pdt, cId)
pdt.add(dur, opts)PlainDateTimeFns.add(pdt, dur, opts)
pdt.subtract(dur, opts)PlainDateTimeFns.subtract(pdt, dur, opts)
pdt.until(other, opts)PlainDateTimeFns.until(pdt, other, opts)
pdt.since(other, opts)PlainDateTimeFns.since(pdt, other, opts)
pdt.round(opts)PlainDateTimeFns.round(pdt, opts)
pdt.equals(other)PlainDateTimeFns.equals(pdt, other)
pdt.toZonedDateTime(tzId, opts)PlainDateTimeFns.toZonedDateTime(pdt, tzId, opts)
pdt.toPlainDate()PlainDateTimeFns.toPlainDate(pdt)
pdt.toPlainYearMonth()PlainDateTimeFns.toPlainYearMonth(pdt)
pdt.toPlainMonthDay()PlainDateTimeFns.toPlainMonthDay(pdt)
pdt.toPlainTime()PlainDateTimeFns.toPlainTime(pdt)
pdt.toLocaleString(locale, opts)PlainDateTimeFns.toLocaleString(pdt, locale, opts)
pdt.toString(opts)PlainDateTimeFns.toString(pdt, opts)
pdt.toJSON()PlainDateTimeFns.toString(pdt)
pdt.getISOFields()PlainDateTimeFns.getISOFields(pdt)
pdt.getCalendar()
pdt.valueOf()

ZonedDateTime

Standard APITree-shakeable API
new Temporal.ZonedDateTime(...args)ZonedDateTimeFns.create(...args)
Temporal.ZonedDateTime.from(fields, opts)ZonedDateTimeFns.fromFields(fields, opts)
Temporal.ZonedDateTime.from(str, opts)ZonedDateTimeFns.fromString(str, opts)
Temporal.ZonedDateTime.compare(a, b)ZonedDateTimeFns.compare(a, b)
a instanceof Temporal.ZonedDateTimeZonedDateTimeFns.isInstance(a)
zdt.eraZonedDateTimeFns.getFields(zdt).era
zdt.eraYearZonedDateTimeFns.getFields(zdt).eraYear
zdt.yearZonedDateTimeFns.getFields(zdt).year
zdt.monthZonedDateTimeFns.getFields(zdt).month
zdt.monthCodeZonedDateTimeFns.getFields(zdt).monthCode
zdt.dayZonedDateTimeFns.getFields(zdt).day
zdt.hourZonedDateTimeFns.getFields(zdt).hour
zdt.minuteZonedDateTimeFns.getFields(zdt).minute
zdt.secondZonedDateTimeFns.getFields(zdt).second
zdt.millisecondZonedDateTimeFns.getFields(zdt).millisecond
zdt.microsecondZonedDateTimeFns.getFields(zdt).microsecond
zdt.nanosecondZonedDateTimeFns.getFields(zdt).nanosecond
zdt.epochSecondsZonedDateTimeFns.epochSeconds(zdt)
zdt.epochMillisecondsZonedDateTimeFns.epochMilliseconds(zdt)
zdt.epochMicrosecondsZonedDateTimeFns.epochMicroseconds(zdt)
zdt.epochNanosecondsZonedDateTimeFns.epochNanoseconds(zdt)
zdt.calendarIdZonedDateTimeFns.calendarId(zdt)
zdt.timeZoneIdZonedDateTimeFns.timeZoneId(zdt)
zdt.dayOfWeekZonedDateTimeFns.dayOfWeek(zdt)
zdt.dayOfYearZonedDateTimeFns.dayOfYear(zdt)
zdt.weekOfYearZonedDateTimeFns.weekOfYear(zdt)
zdt.yearOfWeekZonedDateTimeFns.yearOfWeek(zdt)
zdt.daysInWeekZonedDateTimeFns.daysInWeek(zdt)
zdt.daysInMonthZonedDateTimeFns.daysInMonth(zdt)
zdt.daysInYearZonedDateTimeFns.daysInYear(zdt)
zdt.monthsInYearZonedDateTimeFns.monthsInYear(zdt)
zdt.inLeapYearZonedDateTimeFns.inLeapYear(zdt)
zdt.hoursInDayZonedDateTimeFns.hoursInDay(zdt)
zdt.offsetNanosecondsZonedDateTimeFns.offsetNanoseconds(zdt)
zdt.offsetZonedDateTimeFns.offset(zdt)
zdt.with(fields, opts)ZonedDateTimeFns.withFields(zdt, fields, opts)
zdt.withPlainTime(pt)ZonedDateTimeFns.withPlainTime(zdt, pt)
zdt.withPlainDate(pd)ZonedDateTimeFns.withPlainDate(zdt, pd)
zdt.withCalendar(cId)ZonedDateTimeFns.withCalendar(zdt, cId)
zdt.withTimeZone(tzId)ZonedDateTimeFns.withTimeZone(zdt, tzId)
zdt.add(dur, opts)ZoneDateTimeFns.add(zdt, dur, opts)
zdt.subtract(dur, opts)ZoneDateTimeFns.subtract(zdt, dur, opts)
zdt.until(other, opts)ZoneDateTimeFns.until(zdt, other, opts)
zdt.since(other, opts)ZoneDateTimeFns.since(zdt, other, opts)
zdt.round(opts)ZoneDateTimeFns.round(zdt, opts)
zdt.startOfDay()ZoneDateTimeFns.startOfDay(zdt)
zdt.equals(other)ZoneDateTimeFns.equals(zdt, other)
zdt.toInstant()ZonedDateTimeFns.toInstant(zdt)
zdt.toPlainDate()ZonedDateTimeFns.toPlainDate(zdt)
zdt.toPlainTime()ZonedDateTimeFns.toPlainTime(zdt)
zdt.toPlainDateTime()ZonedDateTimeFns.toPlainDateTime(zdt)
zdt.toPlainYearMonth()ZonedDateTimeFns.toPlainYearMonth(zdt)
zdt.toPlainMonthDay()ZonedDateTimeFns.toPlainMonthDay(zdt)
zdt.toLocaleString(locale, opts)ZonedDateTimeFns.toLocaleString(zdt, locale, opts)
zdt.toString(opts)ZonedDateTimeFns.toString(zdt, opts)
zdt.toJSON()ZonedDateTimeFns.toString(zdt)
zdt.getISOFields()ZonedDateTimeFns.getISOFields(zdt)
zdt.getCalendar()
zdt.getTimeZone()
zdt.valueOf()

Instant

Standard APITree-shakeable API
new Temporal.Instant(ns)InstantFns.create(ns)
Temporal.Instant.from(str)InstantFns.fromString(str)
Temporal.Instant.fromEpochSeconds(sec)InstantFns.fromEpochSeconds(sec)
Temporal.Instant.fromEpochMilliseconds(ms)InstantFns.fromEpochMilliseconds(ms)
Temporal.Instant.fromEpochMicroseconds(μs)InstantFns.fromEpochMicroseconds(μs)
Temporal.Instant.fromEpochNanoseconds(ns)InstantFns.fromEpochNanoseconds(ns)
Temporal.Instant.compare(a, b)InstantFns.compare(a, b)
a instanceof Temporal.InstantInstantFns.isInstance(a)
inst.epochSecondsInstantFns.epochSeconds(inst)
inst.epochMillisecondsInstantFns.epochMilliseconds(inst)
inst.epochMicrosecondsInstantFns.epochMicroseconds(inst)
inst.epochNanosecondsInstantFns.epochNanoseconds(inst)
inst.add(dur)InstantFns.add(inst, dur)
inst.subtract(dur)InstantFns.subtract(inst, dur)
inst.until(other, opts)InstantFns.until(inst, other, opts)
inst.since(other, opts)InstantFns.since(inst, other, opts)
inst.round(opts)InstantFns.round(inst, opts)
inst.equals(other)InstantFns.equals(inst, other)
inst.toZonedDateTimeISO(tzId)InstantFns.toZonedDateTimeISO(inst, tzId)
inst.toZonedDateTime(opts)InstantFns.toZonedDateTime(inst, opts)
inst.toLocaleString(locale, opts)InstantFns.toLocaleString(inst, locale, opts)
inst.toString(opts)InstantFns.toString(inst, opts)
inst.toJSON()InstantFns.toString(inst)
inst.valueOf()

Duration

Standard APITree-shakeable API
new Temporal.Duration(...args)DurationFns.create(...args)
Temporal.Duration.from(fields)DurationFns.fromFields(fields)
Temporal.Duration.from(str)DurationFns.fromString(str)
Temporal.Duration.compare(a, b, opts)DurationFns.compare(a, b, opts)
a instanceof Temporal.DurationDurationFns.isInstance(a)
dur.yearsdur.years (same)
dur.monthsdur.months (same)
dur.weeksdur.weeks (same)
dur.daysdur.days (same)
dur.hoursdur.hours (same)
dur.minutesdur.minutes (same)
dur.secondsdur.seconds (same)
dur.millisecondsdur.milliseconds (same)
dur.microsecondsdur.microseconds (same)
dur.nanosecondsdur.nanoseconds (same)
dur.signdur.sign (same)
dur.blankDurationFns.blank(dur)
dur.with(fields)DurationFns.withFields(dur, fields)
dur.add(other, opts)DurationFns.add(dur, other, opts)
dur.subtract(other, opts)DurationFns.subtract(dur, other, opts)
dur.negated()DurationFns.negated(dur)
dur.abs()DurationFns.abs(dur)
dur.round(opts)DurationFns.round(dur, opts)
dur.total(opts)DurationFns.total(dur, opts)
dur.toLocaleString(locale, opts)DurationFns.toLocaleString(dur, locale, opts)
dur.toString(opts)DurationFns.toString(dur, opts)
dur.toJSON()DurationFns.toString(dur)
dur.valueOf()

PlainTime

Standard APITree-shakeable API
new Temporal.PlainTime(...args)PlainTimeFns.create(...args)
Temporal.PlainTime.from(fields, opts)PlainTimeFns.fromFields(fields, opts)
Temporal.PlainTime.from(str)PlainTimeFns.fromString(str)
Temporal.PlainTime.compare(a, b)PlainTimeFns.compare(a, b)
a instanceof Temporal.PlainTimePlainTimeFns.isInstance(a)
pt.hourPlainTimeFns.getFields(pt).hour
pt.minutePlainTimeFns.getFields(pt).minute
pt.secondPlainTimeFns.getFields(pt).second
pt.millisecondPlainTimeFns.getFields(pt).millisecond
pt.microsecondPlainTimeFns.getFields(pt).microsecond
pt.nanosecondPlainTimeFns.getFields(pt).nanosecond
pt.with(fields, opts)PlainTimeFns.withFields(pt, fields, opts)
pt.add(dur)PlainTimeFns.add(pt, dur)
pt.subtract(dur)PlainTimeFns.subtract(pt, dur)
pt.until(other, opts)PlainTimeFns.until(pt, other, opts)
pt.since(other, opts)PlainTimeFns.since(pt, other, opts)
pt.round(opts)PlainTimeFns.round(pt, opts)
pt.equals(other)PlainTimeFns.equals(pt, other)
pt.toZonedDateTime(opts)PlainTimeFns.toZonedDateTime(pt, opts)
pt.toPlainDateTime(pd)PlainTimeFns.toPlainDateTime(pt, pd)
pt.toLocaleString(locale, opts)PlainTimeFns.toLocaleString(pt, locale, opts)
pt.toString(opts)PlainTimeFns.toString(pt, opts)
pt.toJSON()PlainTimeFns.toString(pt)
pt.getISOFields()PlainTimeFns.getISOFields(pt)
pt.valueOf()

PlainYearMonth

Standard APITree-shakeable API
new Temporal.PlainYearMonth(...args)PlainYearMonthFns.create(...args)
Temporal.PlainYearMonth.from(fields, opts)PlainYearMonthFns.fromFields(fields, opts)
Temporal.PlainYearMonth.from(str)PlainYearMonthFns.fromString(str)
a instanceof Temporal.PlainYearMonthPlainYearMonthFns.isInstance(a)
pym.eraPlainYearMonthFns.getFields(pym).era
pym.eraYearPlainYearMonthFns.getFields(pym).eraYear
pym.yearPlainYearMonthFns.getFields(pym).year
pym.monthPlainYearMonthFns.getFields(pym).month
pym.monthCodePlainYearMonthFns.getFields(pym).monthCode
pym.calendarIdPlainYearMonthFns.calendarId(pym)
pym.daysInMonthPlainYearMonthFns.daysInMonth(pym)
pym.daysInYearPlainYearMonthFns.daysInYear(pym)
pym.monthsInYearPlainYearMonthFns.monthsInYear(pym)
pym.inLeapYearPlainYearMonthFns.inLeapYear(pym)
pym.with(fields, opts)PlainYearMonthFns.with(pym, fields, opts)
pym.add(dur, opts)PlainYearMonthFns.add(pym, dur, opts)
pym.subtract(dur, opts)PlainYearMonthFns.subtract(pym, dur, opts)
pym.until(dur, opts)PlainYearMonthFns.until(pym, dur, opts)
pym.since(dur, opts)PlainYearMonthFns.since(pym, dur, opts)
pym.equals(other)PlainYearMonthFns.equals(pym, other)
pym.toPlainDate(opts)PlainYearMonthFns.toPlainDate(pym, opts)
pym.toLocaleString(locale, opts)PlainYearMonthFns.toLocaleString(pym, locale, opts)
pym.toString(opts)PlainYearMonthFns.toString(pym, opts)
pym.toJSON()PlainYearMonthFns.toString(pym)
pym.getISOFields()PlainYearMonthFns.getISOFields(pym)
pym.getCalendar()
pym.valueOf()

PlainMonthDay

Standard APITree-shakeable API
new Temporal.PlainMonthDay(...args)PlainMonthDayFns.create(...args)
Temporal.PlainMonthDay.from(fields, opts)PlainMonthDayFns.fromFields(fields, opts)
Temporal.PlainMonthDay.from(str)PlainMonthDayFns.fromString(str)
a instanceof Temporal.PlainMonthDayPlainMonthDayFns.isInstance(a)
pmd.monthCodePlainMonthDayFns.getFields(pmd).monthCode
pmd.dayPlainMonthDayFns.getFields(pmd).day
pmd.calendarIdPlainMonthDayFns.calendarId(pmd)
pmd.with(fields, opts)PlainMonthDayFns.withFields(pmd, fields, opts)
pmd.equals(other)PlainMonthDayFns.equals(pmd, other)
pmd.toString(opts)PlainMonthDayFns.toString(pmd, opts)
pmd.toLocaleString(locale, opts)PlainMonthDayFns.toLocaleString(pmd, locale, opts)
pmd.toJSON()PlainMonthDayFns.toString(pmd)
pmd.toPlainDate(opts)PlainMonthDayFns.toPlainDate(pmd, opts)
pmd.getCalendar()PlainMonthDayFns.getCalendar(pmd)
pmd.getISOFields()PlainMonthDayFns.getISOFields(pmd)
pmd.valueOf()