Published
Edited
Oct 9, 2018
4 stars
Insert cell
Insert cell
luxon = require("luxon@1/build/amd/luxon.js")
Insert cell
DateTime = luxon.DateTime
Insert cell
Insert cell
DateTime.local(2017, 5, 15, 8, 30)
Insert cell
Insert cell
local = DateTime.local()
Insert cell
Insert cell
DateTime.fromObject({
day: 22,
hour: 12,
zone: "America/Los_Angeles",
numberingSystem: "beng"
})
Insert cell
Insert cell
DateTime.fromISO("2017-05-15")
Insert cell
DateTime.fromISO("2017-05-15T08:30:00")
Insert cell
Insert cell
local.toString()
Insert cell
local.toISO()
Insert cell
Insert cell
local.year
Insert cell
local.month
Insert cell
local.day
Insert cell
local.second
Insert cell
local.weekday
Insert cell
local.zoneName
Insert cell
local.offset
Insert cell
local.daysInMonth
Insert cell
Insert cell
local.toLocaleString()
Insert cell
local.toLocaleString(DateTime.DATETIME_MED)
Insert cell
Insert cell
local.plus({hours: 3, minutes: 2})
Insert cell
local.minus({days: 7})
Insert cell
local.startOf("day")
Insert cell
local.endOf("hour")
Insert cell
Insert cell
local.set({hour: 3})
Insert cell
Insert cell
f = ({month: "long", day: "numeric"})
Insert cell
local.setLocale("fr").toLocaleString(f)
Insert cell
local.setLocale("en-GB").toLocaleString(f)
Insert cell
local.setLocale("en-US").toLocaleString(f)
Insert cell
Insert cell
luxon.Info.months('long', {locale: "fr"})
Insert cell
Insert cell
DateTime.fromObject({zone: "America/Los_Angeles"})
Insert cell
Insert cell
local.setZone("America/Los_Angeles")
Insert cell
Insert cell
DateTime.utc(2017, 5, 15)
Insert cell
utc = DateTime.utc()
Insert cell
local.toUTC()
Insert cell
utc.toLocal()
Insert cell
Insert cell
Duration = luxon.Duration
Insert cell
dur = Duration.fromObject({hours: 2, minutes: 7})
Insert cell
Insert cell
local.plus(dur)
Insert cell
Insert cell
dur.hours
Insert cell
dur.minutes
Insert cell
dur.seconds
Insert cell
dur.as("seconds")
Insert cell
dur.toObject()
Insert cell
dur.toISO()
Insert cell
Insert cell
Interval = luxon.Interval
Insert cell
end = DateTime.local(2020, 10, 12)
Insert cell
i = Interval.fromDateTimes(local, end)
Insert cell
i.length()
Insert cell
i.length("years", true)
Insert cell
i.contains(DateTime.local(2019))
Insert cell
i.toISO()
Insert cell
i.toString()
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more