Public
Edited
Jun 18, 2024
Insert cell
Insert cell
function toTimestamp(year, month, day) {
return (
((year - 1970) * 365.2425 + (month - 1) * 30.436875 + (day - 1)) *
86400000 -
15 * 60 * 60 * 1000
);
}
Insert cell
dayjs(toTimestamp(2024, 6, 18)).format('YYYY-MM-DD')
Insert cell
dayDiff = dayjs().diff(dayjs(0), 'day')
Insert cell
errors = _.range(dayDiff).map((offset) => {
const d = dayjs(0).add(offset, "day");
const fuzzyD = dayjs(toTimestamp(d.year(), d.month() + 1, d.date()));
const error = d.diff(fuzzyD, "day");
return error ? { d, date: d.format("YYYY-MM-DD"), error } : null;
})
Insert cell
_.sumBy(errors, (inf) => inf?.error ?? 0)
Insert cell
_.maxBy(errors, (inf) => inf?.error ?? 0)
Insert cell
_(errors)
.compact()
.groupBy(inf => inf.d.year())
.value()
Insert cell
dayjs = require('dayjs')
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