MCPcopy Create free account
hub / github.com/tinyplex/tinybase / addTime

Function addTime

src/ui-react-dom-charts/common/wilkinson.ts:335–344  ·  view source on GitHub ↗
(timestamp: number, [unit, step]: TimeInterval)

Source from the content-addressed store, hash-verified

333};
334
335const addTime = (timestamp: number, [unit, step]: TimeInterval): number => {
336 const date = dateNew(timestamp);
337 return unit == YEAR_UNIT
338 ? dateUtc(dateGetUTCFullYear(date) + step, 0, 1)
339 : unit == QUARTER_UNIT
340 ? dateUtc(dateGetUTCFullYear(date), dateGetUTCMonth(date) + step * 3, 1)
341 : unit == MONTH_UNIT
342 ? dateUtc(dateGetUTCFullYear(date), dateGetUTCMonth(date) + step, 1)
343 : timestamp + getFixedInterval(unit, step);
344};
345
346const getFixedInterval = (unit: TimeUnit, step: number): number =>
347 unit == WEEK_UNIT

Callers 1

getTimeTicksFunction · 0.70

Calls 4

dateNewFunction · 0.90
dateGetUTCFullYearFunction · 0.90
dateGetUTCMonthFunction · 0.90
getFixedIntervalFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…