diff --git a/server/lib/set-headers-for-date-temporal-context.js b/server/lib/set-headers-for-date-temporal-context.js index 4150356..a72f63f 100644 --- a/server/lib/set-headers-for-date-temporal-context.js +++ b/server/lib/set-headers-for-date-temporal-context.js @@ -5,17 +5,19 @@ const assert = require('assert'); const { getUtcStartOfDayTs } = require('matrix-public-archive-shared/lib/timestamp-utilities'); // `X-Date-Temporal-Context` indicates the temporal context of the content, whether it -// is related to past, present, or future *day*. This is useful for caching purposes so -// you can heavily cache past content, but not present/future. +// is related to past, present, or future *day*. +// +// This is useful for caching purposes so you can heavily cache past content, but not +// present/future. function setHeadersForDateTemporalContext({ res, nowTs, comparedToUrlDate: { yyyy, mm, dd } }) { assert(res); - assert(nowTs); - assert(yyyy); - assert(mm); - assert(dd); + assert(Number.isInteger(nowTs)); + assert(Number.isInteger(yyyy)); + assert(Number.isInteger(mm)); + assert(Number.isInteger(dd)); - // We use the start of the UTC day so we can compare apples to apples and see whether - // yyyy-mm-dd is the past/present/future day. + // We use the start of the UTC day so we can compare apples to apples with a new date + // constructed with yyyy-mm-dd (no time occured since the start of the day) const startOfTodayTs = getUtcStartOfDayTs(nowTs); const compareTs = Date.UTC(yyyy, mm, dd);