(date, offsetMinutes)
| 13 | const formatDateInTimeZone = (date, timeZone) => |
| 14 | new Intl.DateTimeFormat('en-CA', { timeZone }).format(date); |
| 15 | const 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 | }; |
| 31 | const 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); |
no test coverage detected