MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / formatDateTimeWithOffset

Function formatDateTimeWithOffset

scripts/commit-summary.js:15–30  ·  view source on GitHub ↗
(date, offsetMinutes)

Source from the content-addressed store, hash-verified

13const formatDateInTimeZone = (date, timeZone) =>
14 new Intl.DateTimeFormat('en-CA', { timeZone }).format(date);
15const formatDateTimeWithOffset = (date, offsetMinutes) => {
16 const pad = (value) => String(value).padStart(2, '0');
17 const adjusted = new Date(date.getTime() + offsetMinutes * 60 * 1000);
18 const yyyy = adjusted.getUTCFullYear();
19 const MM = pad(adjusted.getUTCMonth() + 1);
20 const dd = pad(adjusted.getUTCDate());
21 const hh = pad(adjusted.getUTCHours());
22 const mm = pad(adjusted.getUTCMinutes());
23 const ss = pad(adjusted.getUTCSeconds());
24 const sign = offsetMinutes >= 0 ? '+' : '-';
25 const abs = Math.abs(offsetMinutes);
26 const offH = pad(Math.floor(abs / 60));
27 const offM = pad(abs % 60);
28
29 return `${yyyy}-${MM}-${dd}T${hh}:${mm}:${ss}${sign}${offH}:${offM}`;
30};
31const getCommitWindow = (date) => {
32 const end = new Date(`${date}T23:00:00${LOCAL_TZ_OFFSET}`);
33 const start = new Date(end.getTime() - 24 * 60 * 60 * 1000);

Callers 1

getCommitWindowFunction · 0.85

Calls 1

padFunction · 0.70

Tested by

no test coverage detected