Maybe slightly more clear
This commit is contained in:
parent
e925b257bb
commit
e1b1ba2e48
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue