Published
Edited
Oct 17, 2019
1 fork
Insert cell
Insert cell
Insert cell
timezonesWhereDayIsJustStarted = _.filter(
_.map(
moment.tz.names(),
(tz) => [tz, moment.tz(tz).format('HH'), moment().tz(tz).format('DD')]),
([_, hour]) => hour == "00"
)
Insert cell
Insert cell
referenceTimezone = timezonesWhereDayIsJustStarted[0][0]
Insert cell
Insert cell
dateA = moment().tz(referenceTimezone)
.startOf('day')
.subtract(1, 'day')
.format("YYYY-MM-DD")
Insert cell
Insert cell
dateB = moment().tz(referenceTimezone)
.startOf('day')
.subtract(1, 'day')
.toISOString(true)
.slice(0, 10)
Insert cell
Insert cell
dateA == dateB
Insert cell
Insert cell
viewof from = show(moment.tz(dateA, referenceTimezone).startOf('day'))
Insert cell
viewof to = show(moment.tz(dateA, referenceTimezone).endOf('day'))
Insert cell
Insert cell
interval = `${from.toISOString()}/${to.toISOString()}`
Insert cell
md`The same ISO intercal, with explicit timezones:`
Insert cell
`${from.toISOString(true)}/${to.toISOString(true)}`
Insert cell
Insert cell
moment = require('https://momentjs.com/downloads/moment-timezone-with-data.js')
Insert cell
_ = require('lodash')
Insert cell
show = (m) => {
const element = md`${m.format()}`;
element.value = m;
return element;
}
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