Skip to content

Commit

Permalink
Add support for Temporal objects
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer committed Aug 14, 2024
1 parent 6b8dc64 commit 23d1405
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-ties-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sumup/intl': major
---

Added support for Temporal objects to the date and time formatting functions. The [`temporal-polyfill`](https://www.npmjs.com/package/temporal-polyfill) package is now a required peer dependency.
34 changes: 34 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@
"eslint-plugin-prettier": "^5.1.3",
"jest-extended": "^4.0.2",
"license-checker": "^25.0.1",
"temporal-polyfill": "^0.2.5",
"typedoc": "^0.26.3",
"typedoc-github-wiki-theme": "^2.0.0",
"typedoc-plugin-markdown": "^4.0.3",
"typescript": "^5.4.5",
"vitest": "^2.0.5"
},
"peerDependencies": {
"temporal-polyfill": "0.2.x"
}
}
5 changes: 3 additions & 2 deletions src/lib/date-time-format/intl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* limitations under the License.
*/

import { Intl as IntlWithTemporal } from 'temporal-polyfill';
import memoizeFormatConstructor from 'intl-format-cache';

import { Locale } from '../../types';
Expand Down Expand Up @@ -61,8 +62,8 @@ export const isDateTimeStyleSupported = (() => {
})();

export const getDateTimeFormat = memoizeFormatConstructor(
Intl.DateTimeFormat,
IntlWithTemporal.DateTimeFormat,
) as (
locales?: Locale | Locale[],
options?: Intl.DateTimeFormatOptions,
) => Intl.DateTimeFormat;
) => IntlWithTemporal.DateTimeFormat;

0 comments on commit 23d1405

Please sign in to comment.