@trackunit/date-and-time-utils 1.6.23 → 1.6.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -25,8 +25,8 @@ const getTimeZone = (timeZoneId) => {
25
25
  * @param timeZone - The time zone to use for the conversion.
26
26
  */
27
27
  const getTimeZoneOffset = (timeZone) => {
28
- const timezone = polyfill.Temporal.TimeZone.from(timeZone);
29
- return timezone.getOffsetStringFor?.(polyfill.Temporal.Now.instant()) ?? "";
28
+ const timezone = polyfill.Temporal.ZonedDateTime.from(toZonedDateTimeUtil(new Date())).withTimeZone(timeZone);
29
+ return timezone.offset;
30
30
  };
31
31
  /**
32
32
  * Returns a list of all supported time zones.
@@ -1375,10 +1375,9 @@ const toZonedDateTimeUtil = (date, timeZoneId, calendar) => {
1375
1375
  if (date instanceof Date || typeof date === "string") {
1376
1376
  date = toTemporalUtil(date);
1377
1377
  }
1378
- return date.toZonedDateTime({
1379
- calendar: polyfill.Temporal.Calendar.from(calendar ?? "iso8601"),
1380
- timeZone: polyfill.Temporal.TimeZone.from(timeZoneId || date.toString() || polyfill.Temporal.Now.timeZoneId()),
1381
- });
1378
+ return date
1379
+ .toZonedDateTimeISO(timeZoneId || date.toString() || polyfill.Temporal.Now.timeZoneId())
1380
+ .withCalendar(calendar || "iso8601");
1382
1381
  };
1383
1382
  /**
1384
1383
  * Returns the month name for the given date.
package/index.esm.js CHANGED
@@ -23,8 +23,8 @@ const getTimeZone = (timeZoneId) => {
23
23
  * @param timeZone - The time zone to use for the conversion.
24
24
  */
25
25
  const getTimeZoneOffset = (timeZone) => {
26
- const timezone = Temporal.TimeZone.from(timeZone);
27
- return timezone.getOffsetStringFor?.(Temporal.Now.instant()) ?? "";
26
+ const timezone = Temporal.ZonedDateTime.from(toZonedDateTimeUtil(new Date())).withTimeZone(timeZone);
27
+ return timezone.offset;
28
28
  };
29
29
  /**
30
30
  * Returns a list of all supported time zones.
@@ -1373,10 +1373,9 @@ const toZonedDateTimeUtil = (date, timeZoneId, calendar) => {
1373
1373
  if (date instanceof Date || typeof date === "string") {
1374
1374
  date = toTemporalUtil(date);
1375
1375
  }
1376
- return date.toZonedDateTime({
1377
- calendar: Temporal.Calendar.from(calendar ?? "iso8601"),
1378
- timeZone: Temporal.TimeZone.from(timeZoneId || date.toString() || Temporal.Now.timeZoneId()),
1379
- });
1376
+ return date
1377
+ .toZonedDateTimeISO(timeZoneId || date.toString() || Temporal.Now.timeZoneId())
1378
+ .withCalendar(calendar || "iso8601");
1380
1379
  };
1381
1380
  /**
1382
1381
  * Returns the month name for the given date.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/date-and-time-utils",
3
- "version": "1.6.23",
3
+ "version": "1.6.25",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -8,9 +8,9 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@formatjs/intl-enumerator": "^1.8.1",
11
- "@js-temporal/polyfill": "^0.4.4",
11
+ "@js-temporal/polyfill": "^0.5.1",
12
12
  "@formatjs/intl-durationformat": "^0.6.1",
13
- "@trackunit/react-test-setup": "1.3.23"
13
+ "@trackunit/react-test-setup": "1.3.25"
14
14
  },
15
15
  "module": "./index.esm.js",
16
16
  "main": "./index.cjs.js",