-
Notifications
You must be signed in to change notification settings - Fork 0
Node22 #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Node22 #21
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ee0f90a
update with date-fns v4.1.0
le-cong 30ae720
disable ts/lint check for data-fns
le-cong b07b035
date-fns-tz compile
le-cong f60e35d
pass date-fns-tz tests, remove Temporal, prettier
le-cong bd483b9
update README for date-fns-tz v3.2.0, remove unused test file, and ad…
le-cong ca8db16
cleanup eslint config
le-cong 63510f4
minor update to README/comments
le-cong bc9036f
add migration guide for syncing with date-fns/date-fns-tz updates
le-cong 51fe773
use Date.UTC for date creation in Federal Reserve Bank holiday functions
le-cong 6788f68
isolatedDeclarations
le-cong 38d0091
type-only
le-cong 45e1ba6
comments
le-cong 764aa90
fix script
le-cong 5c644bd
update dependencies and CI configurations
le-cong 26c16a6
update comments
le-cong 8c873a7
address rama's comments
le-cong 8738333
bump node version, etc.
le-cong 40fe299
update CodeQL action versions to v3
le-cong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ################################################################################ | ||
| # As additional safeguards to reveal potential time zone related bugs, | ||
| # please comment out the below`TZ` environment (one at a time) to fake the | ||
| # local timezone in extreme edge cases. | ||
| # (Note: this is in POSIX format, so "+"/"-" means behind/ahead instead of another way around) | ||
| # | ||
| # TZ=GMT+23 | ||
| # TZ=GMT-1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,87 +1,65 @@ | ||
| # Check Digit Time Library | ||
|
|
||
| Copyright (c) 2022-2024 [Check Digit, LLC](https://checkdigit.com) | ||
| Copyright (c) 2022-2025 [Check Digit, LLC](https://checkdigit.com) | ||
|
|
||
| The Check Digit time library is the officially sanctioned method for Check Digit services to deal with time. It is a partial implementation of the new TC39 Temporal proposal | ||
| and date manipulation functions provided by date-fns. Features: | ||
| The Check Digit time library is the officially sanctioned method for Check Digit services to deal with time. It has date manipulation functions provided by date-fns. Features: | ||
|
|
||
| - Nanosecond precision date times, simulated with Node's built-in high-resolution timer | ||
| - Tests that verify compliance with latest TC39 polyfill | ||
| - Designed to be removed once Temporal is included, by default, within V8. | ||
| - Implements most of Temporal.Instant, except timezone/calendar functionality | ||
| - Implements Temporal.Now.instant() | ||
| - Stripped down `date-fns` functions | ||
| - `date-fns-tz` for timezone support | ||
| - `formatUtc` for formatting UTC dates | ||
|
|
||
| Temporal (vs the millisecond precision of standard Date built-in) is useful for webservices recording the time of events, where concurrent activity may occur and millisecond precision does not provide adequate uniqueness and ordering. | ||
|
|
||
| The [`date-fns`](https://date-fns.org) library is included. The only locale currently supported is `en-US`, but otherwise contains all | ||
| available functionality as of v3.6.0. | ||
| available functionality as of v4.1.0 except that the code in `fp` folder are excluded, which contain functional programming related stuff that is not used at the moment. | ||
|
|
||
| Additionally, the [`date-fns-tz`](https://github.com/marnusw/date-fns-tz) library is included. Contains all | ||
| available functionality as of v1.3.7 except that the code in `fp` folder is excluded, which contains functional programming related stuff that is not used at the moment. | ||
| available functionality as of v3.2.0 except that the code in `fp` folder are excluded, which contain functional programming related stuff that is not used at the moment. | ||
|
|
||
| ### `formatUtc` | ||
| ## `formatUtc` | ||
|
|
||
| The `formatUtc` function is a wrapper around `date-fns-tz`'s `format` function, but with the following differences: | ||
|
|
||
| - There is no `options` argument, `timeZone` is always UTC. | ||
|
|
||
| Generally speaking, `formatUtc` should be used in place of `format` or `tzFormat`, unless non-UTC time zones are required. | ||
|
|
||
| ### Important note about `Instant.toString()` | ||
|
|
||
| Unlike built-in `Date.toISOString()`, `Instant.toString()` will not add fractional second digits if those values are zero. | ||
|
|
||
| E.g. | ||
|
|
||
| ``` | ||
| new Date(0).toISOString() -> 1970-01-01T00:00:00.100Z | ||
|
|
||
| vs | ||
|
|
||
| Temporal.Instant(0n).toString() -> 1970-01-01T00:00:00.1Z | ||
| ``` | ||
|
|
||
| ### Why not just use the polyfill? | ||
|
|
||
| The polyfill is not production ready. The implementation is designed to be used in the browser so cannot make use of Node's high-resolution timer to more accurately simulate nanosecond precision time. Crucially, the polyfill does not guarantee always increasing nanosecond precision times on subsequent calls, which makes it a non-starter for recording the time of events in production webservices. | ||
|
|
||
| ### Installing and usage | ||
| ## Installing and usage | ||
|
|
||
| `npm install @checkdigit/time` then: | ||
|
|
||
| ``` | ||
| import { Temporal } from '@checkdigit/time'; // delete this once Temporal becomes a built-in | ||
|
|
||
| // print out nanosecond-precision ISO8601 datetime | ||
| console.log('Current time', Temporal.Now.instant().toString()); | ||
| ``` | ||
|
|
||
| For `date-fns` functionality: | ||
|
|
||
| ``` | ||
| ```typescript | ||
| import { formatUtc } from '@checkdigit/time'; | ||
|
|
||
| console.log(formatUtc(new Date(), 'yyyy-MM-dd')); | ||
| ``` | ||
|
|
||
| ### Documentation | ||
|
|
||
| The stage 3 proposal can be found here: https://github.com/tc39/proposal-temporal | ||
|
|
||
| The reference documentation is here: https://tc39.es/proposal-temporal/docs/ | ||
| ## Documentation | ||
|
|
||
| The documentation for `date-fns` is here: https://date-fns.org/ | ||
|
|
||
| The documentation for `date-fns-tz` is here: https://github.com/marnusw/date-fns-tz | ||
|
|
||
| ### Maintenance notes: | ||
| ## Migration guide | ||
|
|
||
| following are the main steps to sync up with the latest date-fns/date-fns-tz | ||
|
|
||
| - clone 3rd party repo | ||
| - remove test/fp stuff | ||
| - copy/override into @checkdigit/time repo's corresponding folder | ||
| - update CHANGELOG.md (it helps to understand the changes since the last update and to prepare accordingly) | ||
| - replace imports from '.js' to '.ts' | ||
| - Add comments in the beginning of the files to silence ts/lint errors if it forces overwhelming changes otherwise | ||
| - check things which compiles but may have other issues, e.g. import { type ZZZ } => import type { ZZZ } | ||
| - adjust tsconfig.json compilerOptions if necessary | ||
| - apply previous patch (e.g. daylight saving timezone, etc.) | ||
| - pass existing local tests | ||
| - beta-test across dependent repos to make sure it still works | ||
|
|
||
| ## Critical maintenance notes (VERY IMPORTANT!!!): | ||
|
|
||
| When updating the latest code from the original repositories, except making all the necessary changes to make them fully typescript compatible, please remember to carry over the patches to overcome the following issues: | ||
|
|
||
| - spring-forward support | ||
| - nanosecond support | ||
| - hours is incorrect when it's close to daylight saving timezone threshold | ||
|
|
||
| Please search for `[PATCH:]` in the existing codebase. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import checkdigitConfig from '@checkdigit/eslint-config'; | ||
|
|
||
| export default [ | ||
| ...checkdigitConfig, | ||
| { | ||
| files: ['src/date-fns/**', 'src/date-fns-tz/**'], | ||
| rules: { | ||
| '@checkdigit/file-path-comment': 'off', | ||
| 'markdown/no-missing-label-refs': 'off', | ||
| 'markdown/fenced-code-language': 'off', | ||
| 'unicorn/filename-case': 'off', | ||
| }, | ||
| }, | ||
| ]; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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-fnsanddate-fns-tzdirectoriesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, will try