Skip to content

Conversation

@le-cong
Copy link
Contributor

@le-cong le-cong commented Feb 20, 2025

Fixes #19

tested in the following repos:

  • issuer
  • cli
  • monitor
  • scanner
  • fulfillment
  • choice-nacha
  • nacha-payment-file
  • mngs-interchange-file
  • mngs-interchange-ddf

@le-cong le-cong added the MAJOR label Feb 20, 2025
@le-cong le-cong self-assigned this Feb 20, 2025
@github-actions
Copy link

Coverage after merging node22 into main will be

75.49%▴ +16.29%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   date-fns-tz.spec.ts100%100%100%100%
   date-fns.spec.ts100%100%100%100%
   format-utc.spec.ts100%100%100%100%
   format-utc.ts100%100%100%100%
   index.ts100%100%100%100%
src/date-fns
   index.ts100%100%100%100%
src/date-fns-tz
   index.ts100%100%100%100%
src/date-fns-tz/_lib/getTimezoneOffsetInMilliseconds
   index.ts55.88%100%0%56.25%17–30
src/date-fns-tz/_lib/newDateUTC
   index.ts100%100%100%100%
src/date-fns-tz/_lib/tzIntlTimeZoneName
   index.ts36.21%100%0%37.74%14–21, 23–32, 34–38, 42–51
src/date-fns-tz/_lib/tzParseTimezone
   index.ts53.53%41.18%50%55.10%103–128, 130–132, 142–144, 25–27, 31–33, 40–48, 52–62, 66–67, 71, 74–76, 79–89, 99
src/date-fns-tz/_lib/tzPattern
   index.ts100%100%100%100%
src/date-fns-tz/_lib/tzTokenizeDate
   index.ts72.27%63.64%75%73.08%11, 35–40, 43–57, 75, 90–98
src/date-fns-tz/format
   index.ts98.03%66.67%100%98.56%334–340
src/date-fns-tz/format/formatters
   index.ts23.75%100%0%24.67%100, 104–112, 114–121, 123–129, 131–137, 139–148, 17–42, 47–68, 73–85, 90–99
src/date-fns-tz/formatInTimeZone
   index.ts71.74%100%0%72.73%31–42
src/date-fns-tz/fromZonedTime
   index.ts63.79%100%0%64.29%35–54
src/date-fns-tz/getTimezoneOffset
   index.ts92.31%100%0%94.59%34–35
src/date-fns-tz/toDate
   index.ts27.25%18.18%9.09%27.93%100–101, 101, 101–103, 107–108, 112–155, 158–188, 190–220, 222–309, 311–356, 358–367, 374–376, 378–398, 400–414, 416–426, 428–442, 91–93, 95–97
src/date-fns-tz/toZonedTime
   index.ts100%100%100%100%
src/date-fns/_lib/addLeadingZeros
   index.ts93.33%66.67%100%100%6
src/date-fns/_lib/defaultLocale
   index.ts100%100%100%100%
src/date-fns/_lib/defaultOptions
   index.ts86.96%100%50%89.47%16–17
src/date-fns/_lib/format/formatters
   index.ts33.22%42.86%22.22%33.46%100–104, 110–115, 122–138, 143–146, 159–160, 165–195, 200–230, 237, 241–242, 244–248, 250–254, 256–258, 264–291, 296–302, 307–313, 318–320, 327–333, 338–367, 372–408, 413–449, 454–491, 496–524, 529–564, 569–600, 605–609, 616–618, 625–631, 636–643, 648–650, 657–659, 671–696, 701–722, 727–739, 744–756, 761–762, 767, 771–780, 782–788, 790–796, 90–99
src/date-fns/_lib/format/lightFormatters
   index.ts81.40%60%88.89%83.81%34–35, 41, 51–67, 73, 73, 81
src/date-fns/_lib/format/longFormatters
   index.ts30.77%100%0%31.08%10–20, 24–34, 38–66
src/date-fns/_lib/getRoundingMethod
   index.ts55.56%100%0%56.25%10–14, 8–9
src/date-fns/_lib/getTimezoneOffsetInMilliseconds
   index.ts57.89%100%0%58.33%20–34
src/date-fns/_lib/normalizeDates
   index.ts85.19%100%0%88%21–23
src/date-fns/_lib/normalizeInterval
   index.ts73.33%100%0%76.92%10–11, 9
src/date-fns/_lib/protectedTokens
   index.ts72.22%100%50%72.41%19–22, 24–27
src/date-fns/add
   index.ts92.21%25%100%100%54–55, 55, 58, 58, 65
src/date-fns/addBusinessDays
   index.ts51.22%100%0%51.25%40–78
src/date-fns/addDays
   index.ts94.74%40%100%100%41–42, 45
src/date-fns/addHours
   index.ts84.78%100%0%86.36%37–42
src/date-fns/addISOWeekYears
   index.ts85.11%100%0%86.67%38–43
src/date-fns/addMilliseconds
   index.ts84.44%100%0%86.05%36–41
src/date-fns/addMinutes
   index.ts81.25%100%0%82.61%37–44
src/date-fns/addMonths
   index.ts87.64%28.57%100%92.59%45–50, 61, 64–67
src/date-fns/addQuarters
   index.ts84.44%100%0%86.05%36–41
src/date-fns/addSeconds
   index.ts84.44%100%0%86.05%36–41
src/date-fns/addWeeks
   index.ts84.44%100%0%86.05%36–41
src/date-fns/addYears
   index.ts84.44%100%0%86.05%36–41
src/date-fns/areIntervalsOverlapping
   index.ts78.57%100%0%79.27%64–80
src/date-fns/clamp
   index.ts88.61%100%0%89.61%68–75
src/date-fns/closestIndexTo
   index.ts53.03%100%0%53.13%33–62
src/date-fns/closestTo
   index.ts77.78%100%0%78.48%61–77
src/date-fns/compareAsc
   index.ts82.69%100%0%84%41–48
src/date-fns/compareDesc
   index.ts82.69%100%0%84%41–48
src/date-fns/constants
   index.ts100%100%100%100%
src/date-fns/constructFrom
   index.ts84.21%40%100%87.14%47, 49–56, 65–67
src/date-fns/constructNow
   index.ts88.64%100%0%90.48%37–40
src/date-fns/daysToWeeks
   index.ts86.49%100%0%88.57%30–33
src/date-fns/differenceInBusinessDays
   index.ts73.20%100%0%73.68%69–93
src/date-fns/differenceInCalendarDays
   index.ts73.53%100%0%74.24%48–64
src/date-fns/differenceInCalendarISOWeekYears
   index.ts83.67%100%0%85.11%39–45
src/date-fns/differenceInCalendarISOWeeks
   index.ts70.49%100%0%71.19%41–57
src/date-fns/differenceInCalendarMonths
   index.ts76%100%0%77.08%36–46
src/date-fns/differenceInCalendarQuarters
   index.ts76.47%100%0%77.55%37–47
src/date-fns/differenceInCalendarWeeks
   index.ts78.26%100%0%79.10%52–65
src/date-fns/differenceInCalendarYears
   index.ts82.61%100%0%84.09%36–42
src/date-fns/differenceInDays
   index.ts66.96%100%0%67.89%100–107, 68–86, 92–99
src/date-fns/differenceInHours
   index.ts81.63%100%0%82.98%38–45
src/date-fns/differenceInISOWeekYears
   index.ts70.49%100%0%71.19%41–57
src/date-fns/differenceInMilliseconds
   index.ts91.67%100%0%94.12%31–32
src/date-fns/differenceInMinutes
   index.ts85.71%100%0%87.04%46–52
src/date-fns/differenceInMonths
   index.ts58.33%100%0%58.62%33–56
src/date-fns/differenceInQuarters
   index.ts81.82%100%0%83.33%34–40
src/date-fns/differenceInSeconds
   index.ts83.33%100%0%84.78%38–44
src/date-fns/differenceInWeeks
   index.ts87.69%100%0%88.89%55–61
src/date-fns/differenceInYears
   index.ts52.86%100%0%52.94%35–66
src/date-fns/eachDayOfInterval
   index.ts70.21%100%0%70.65%64–90
src/date-fns/eachHourOfInterval
   index.ts70.65%100%0%71.11%63–88
src/date-fns/eachMinuteOfInterval
   index.ts70.83%100%0%71.28%66–92
src/date-fns/eachMonthOfInterval
   index.ts70.53%100%0%70.97%65–91
src/date-fns/eachQuarterOfInterval
   index.ts72.34%100%0%72.83%66–90
src/date-fns/eachWeekOfInterval
   index.ts67.62%100%0%67.96%100–101, 69–99
src/date-fns/eachWeekendOfInterval
   index.ts82.05%100%0%82.89%62–74
src/date-fns/eachWeekendOfMonth
   index.ts85.71%100%0%87.04%46–52
src/date-fns/eachWeekendOfYear
   index.ts84.91%100%0%86.27%43–49
src/date-fns/eachYearOfInterval
   index.ts70.53%100%0%70.97%65–91
src/date-fns/endOfDay
   index.ts82.61%100%0%84.09%36–42
src/date-fns/endOfDecade
   index.ts72.55%100%0%73.47%35–47
src/date-fns/endOfHour
   index.ts82.61%100%0%84.09%36–42
src/date-fns/endOfISOWeek
   index.ts86.96%100%0%88.64%38–42
src/date-fns/endOfISOWeekYear
   index.ts78.18%100%0%79.25%41–51
src/date-fns/endOfMinute
   index.ts82.61%100%0%84.09%36–42
src/date-fns/endOfMonth
   index.ts79.17%100%0%80.43%36–44
src/date-fns/endOfQuarter
   index.ts77.55%100%0%78.72%36–45
src/date-fns/endOfSecond
   index.ts82.61%100%0%84.09%36–42
src/date-fns/endOfToday
   index.ts92.50%100%0%94.74%35–36
src/date-fns/endOfTomorrow
   index.ts73.47%100%0%74.47%34–45
src/date-fns/endOfWeek
   index.ts70.15%100%0%70.77%45–63
src/date-fns/endOfYear
   index.ts79.17%100%0%80.43%36–44
src/date-fns/endOfYesterday
   index.ts80%100%0%81.40%34–41
src/date-fns/format
   index.ts94.56%59.26%100%96.64%354, 356, 361, 363, 368–370, 376–379, 386–388, 399–401, 407–409, 426–428, 439–441
src/date-fns/formatDistance
   index.ts49.77%100%0%49.76%104–209
src/date-fns/formatDistanceStrict
   index.ts56.22%100%0%56.28%111–197
src/date-fns/formatDistanceToNow
   index.ts97.06%100%0%98%97–98
src/date-fns/formatDistanceToNowStrict
   index.ts93.68%100%0%94.62%87–91
src/date-fns/formatDuration
   index.ts77.98%100%0%78.50%100–105, 83–99
src/date-fns/formatISO
   index.ts46.85%100%0%46.79%100–107, 50–99
src/date-fns/formatISO9075
   index.ts56.99%100%0%57.14%51–89
src/date-fns/formatISODuration
   index.ts87.18%100%0%89.19%

@le-cong le-cong requested a review from Copilot June 9, 2025 19:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR upgrades the integrated date-fns-tz code to TypeScript v3.2.0, adds strong typing and TS/ESLint disables for compatibility, removes legacy cloneObject/assign utilities, and updates project files (package version, tests, workflows, README).

  • Added TypeScript definitions, switched to named exports, and introduced new utilities (e.g., getTimezoneOffsetInMilliseconds).
  • Refactored core timezone parsing/formatting modules, replacing default exports and improving API consistency.
  • Updated project metadata (version bump, changelog, CI workflows, test runner imports, README adjustments).

Reviewed Changes

Copilot reviewed 639 out of 639 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/date-fns-tz/format/formatters/index.ts Typed and renamed exports, removed _originalDate fallback from formatters
src/date-fns-tz/date-fns-v2-lib/{cloneObject,assign} Removed legacy cloneObject and assign files
src/date-fns-tz/_lib/tzTokenizeDate/index.ts Introduced TS types, added fallback hackyOffset path
src/date-fns-tz/_lib/tzPattern/index.ts Converted to named export with TS type
src/date-fns-tz/_lib/tzParseTimezone/index.ts Refactored parsing logic, updated patterns and typings
src/date-fns-tz/_lib/tzIntlTimeZoneName/index.ts Converted to named export, added hackyTimeZone, updated getDTF API
src/date-fns-tz/_lib/newDateUTC/index.ts Converted to named export with TS return type
src/date-fns-tz/_lib/getTimezoneOffsetInMilliseconds/index.ts Added new utility for sub-minute offsets
src/date-fns-tz/CHANGELOG.md Updated to v3.2.0 changelog
src/date-fns-tz.spec.ts Switched test runner to node:test and updated import paths
package.json Bumped to v5.0.0, reorganized scripts, devDependencies, and engines
eslint.config.mjs Added project-specific rule overrides
README.md Adjusted sections and updated feature/usage notes
.github/workflows/*.yml Updated Node.js versions in CI/CD pipelines
.env Added sample TZ environment variable configurations
Comments suppressed due to low confidence (4)

src/date-fns-tz/_lib/tzIntlTimeZoneName/index.ts:43

  • [nitpick] The original implementation validated that locale.code exists and threw an error if missing. Removing that check may lead to silent failures when an invalid locale object is passed. Consider re-adding a guard to validate locale.code.
function getDTF(

package.json:3

  • The version bump to 5.0.0 doesn’t align with the v3.2.0 tag in the changelog. Please confirm the intended versioning scheme and update the changelog or version accordingly.
"version": "5.0.0",

src/date-fns-tz/_lib/getTimezoneOffsetInMilliseconds/index.ts:16

  • [nitpick] This new function isn't referenced elsewhere; if it's public API, ensure it's documented and tested, otherwise consider removing it.
export function getTimezoneOffsetInMilliseconds(date: Date): number {

src/date-fns-tz.spec.ts:6

  • Including the .ts extension in the import path may not resolve correctly in all environments. Consider importing without the extension: from './index'.
import { tzFormat, tzUtcToZonedTime } from './index.ts';

) {
const timezoneOffset = getTimeZoneOffset(options.timeZone, options._originalDate || date);
X: function (date, token, options) {
const timezoneOffset = getTimeZoneOffset(options.timeZone, date);
Copy link

Copilot AI Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code used options._originalDate when provided; this refactor always uses date, potentially causing incorrect offsets when options._originalDate exists. Consider reintroducing an originalDate fallback (e.g., const originalDate = options._originalDate || date) when computing the timezone offset.

Suggested change
const timezoneOffset = getTimeZoneOffset(options.timeZone, date);
const originalDate = options._originalDate || date;
const timezoneOffset = getTimeZoneOffset(options.timeZone, originalDate);

Copilot uses AI. Check for mistakes.
let token: RegExpExecArray | null;
let absoluteOffset;

// Parse constious time zone offset formats to an offset in milliseconds
Copy link

Copilot AI Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo in the comment: constious should be various.

Suggested change
// Parse constious time zone offset formats to an offset in milliseconds
// Parse various time zone offset formats to an offset in milliseconds

Copilot uses AI. Check for mistakes.
@le-cong le-cong requested review from carlansley and ramaghanta June 12, 2025 21:50
@le-cong
Copy link
Contributor Author

le-cong commented Jun 12, 2025

please note that some of our home grown production codes in federal-reserve-bank folder were changed to reduce the flakiness related to timezone drifting.
this PR's beta has been tested against the following services:

  • issuer
  • cli
  • monitor
  • scanner
  • mngs-interchange-file
  • mngs-interchange-ddf
  • fulfillment
  • choice-nacha
  • nacha-payment-file

Copy link
Contributor

@ramaghanta ramaghanta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a couple of questions

export default [
...checkdigitConfig,
{
rules: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to turn these rules off only for the stuff inside date-fns and date-fns-tz directories

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, will try

package.json Outdated
"jest": {
"preset": "@checkdigit/jest-config"
"ci:style": "npm run prettier",
"ci:test": "node --env-file=.env --disable-warning ExperimentalWarning --experimental-strip-types --test-timeout 600000 --test \"src/**/*.spec.ts\"",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's different about this repo that needed --env-file=.env?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works the same way as process.loadEnvFile(), but to be consistent i agree it's better to do process.loadEnvFile explicitly in test suites.

@le-cong le-cong requested a review from ramaghanta June 23, 2025 14:10
Copy link
Contributor

@ramaghanta ramaghanta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@carlansley carlansley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a few version bumps required, otherwise lftm

uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '22.x'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

24

uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '22.x'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

24

README.md Outdated
@@ -1,87 +1,65 @@
# Check Digit Time Library

Copyright (c) 2022-2024 [Check Digit, LLC](https://checkdigit.com)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2025

package.json Outdated
},
"prettier": "@checkdigit/prettier-config"
"engines": {
"node": ">=22.14"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

22.15

@github-actions
Copy link

❌ PR review status - not all reviewers have approved - 1 approved - 1 outstanding

@le-cong le-cong requested a review from carlansley June 30, 2025 18:48
@le-cong le-cong requested a review from carlansley June 30, 2025 19:28
@github-actions
Copy link

Beta Published - Install Command: npm install @checkdigit/time@5.0.0-PR.21-e2de

@le-cong le-cong merged commit 6e45bb0 into main Jun 30, 2025
9 checks passed
@le-cong le-cong deleted the node22 branch June 30, 2025 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update to Node 22

4 participants