Maybe slightly more clear

This commit is contained in:
Eric Eastwood 2023-05-04 12:55:32 -05:00
parent e925b257bb
commit e1b1ba2e48
1 changed files with 10 additions and 8 deletions

View File

@ -5,17 +5,19 @@ const assert = require('assert');
const { getUtcStartOfDayTs } = require('matrix-public-archive-shared/lib/timestamp-utilities'); const { getUtcStartOfDayTs } = require('matrix-public-archive-shared/lib/timestamp-utilities');
// `X-Date-Temporal-Context` indicates the temporal context of the content, whether it // `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 // is related to past, present, or future *day*.
// you can heavily cache past content, but not present/future. //
// 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 } }) { function setHeadersForDateTemporalContext({ res, nowTs, comparedToUrlDate: { yyyy, mm, dd } }) {
assert(res); assert(res);
assert(nowTs); assert(Number.isInteger(nowTs));
assert(yyyy); assert(Number.isInteger(yyyy));
assert(mm); assert(Number.isInteger(mm));
assert(dd); assert(Number.isInteger(dd));
// We use the start of the UTC day so we can compare apples to apples and see whether // We use the start of the UTC day so we can compare apples to apples with a new date
// yyyy-mm-dd is the past/present/future day. // constructed with yyyy-mm-dd (no time occured since the start of the day)
const startOfTodayTs = getUtcStartOfDayTs(nowTs); const startOfTodayTs = getUtcStartOfDayTs(nowTs);
const compareTs = Date.UTC(yyyy, mm, dd); const compareTs = Date.UTC(yyyy, mm, dd);