Skip to content

Commit 2503303

Browse files
dependabot[bot]ZhongpinWangcloud-sdk-jsdeekshas8
authored
chore(deps): bump @js-temporal/polyfill from 0.4.4 to 0.5.1 (#5679)
* chore(deps): bump @js-temporal/polyfill from 0.4.4 to 0.5.0 Bumps [@js-temporal/polyfill](https://github.com/js-temporal/temporal-polyfill) from 0.4.4 to 0.5.0. - [Release notes](https://github.com/js-temporal/temporal-polyfill/releases) - [Changelog](https://github.com/js-temporal/temporal-polyfill/blob/main/CHANGELOG.md) - [Commits](js-temporal/temporal-polyfill@v0.4.4...v0.5.0) --- updated-dependencies: - dependency-name: "@js-temporal/polyfill" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * fix: replace Temperal.TimeZone * Changes from lint:fix * fix: epochSeconds * Changes from lint:fix --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Zhongpin Wang <[email protected]> Co-authored-by: cloud-sdk-js <[email protected]> Co-authored-by: Deeksha Sinha <[email protected]>
1 parent efa7c4f commit 2503303

File tree

5 files changed

+20
-25
lines changed

5 files changed

+20
-25
lines changed

packages/temporal-de-serializers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"readme": "ts-node ../../scripts/replace-common-readme.ts"
3737
},
3838
"dependencies": {
39-
"@js-temporal/polyfill": "^0.4.4",
39+
"@js-temporal/polyfill": "^0.5.1",
4040
"@sap-cloud-sdk/odata-common": "^4.0.2"
4141
},
4242
"devDependencies": {

packages/temporal-de-serializers/src/temporal-de-serializers-v2.spec.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,18 @@ describe('EDM to Temporal', () => {
1414
'/Date(1556630382000)/'
1515
) as Temporal.PlainDateTime;
1616
expect(dateTimePlain.toString()).toBe('2019-04-30T13:19:42');
17-
expect(() => Temporal.TimeZone.from(dateTimePlain.toString())).toThrowError(
18-
/Invalid time zone/
17+
expect(() => Temporal.ZonedDateTime.from(dateTimePlain)).toThrow(
18+
/required property 'timeZone' missing or undefined/
1919
);
2020
});
2121

2222
it('returns a utc date if there is an offset', () => {
2323
const dateTimeZoned = deserializeToZonedDateTime(
24-
'/Date(1556630382000+0000)/'
24+
'/Date(1556630382000+0100)/'
2525
);
26-
const zonedString = dateTimeZoned.toString({
27-
fractionalSecondDigits: 0,
28-
timeZoneName: 'never'
29-
});
30-
expect(zonedString).toBe('2019-04-30T13:19:42+00:00');
31-
expect(Temporal.TimeZone.from(dateTimeZoned.toString()).id).toEqual(
32-
'+00:00'
26+
expect(dateTimeZoned.toString()).toBe('2019-04-30T14:19:42+01:00[+01:00]');
27+
expect(Temporal.ZonedDateTime.from(dateTimeZoned).timeZoneId).toEqual(
28+
'+01:00'
3329
);
3430
});
3531

packages/temporal-de-serializers/src/temporal-de-serializers-v2.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ export function deserializeToZonedDateTime(
4848
parseInt(dateTimeOffsetComponents.ticks)
4949
);
5050
if (dateTimeOffsetComponents.sign && dateTimeOffsetComponents.offset) {
51-
const timeZone = Temporal.TimeZone.from(
51+
return dateTimeInstant.toZonedDateTimeISO(
5252
dateTimeOffsetComponents.sign + dateTimeOffsetComponents.offset
5353
);
54-
return dateTimeInstant.toZonedDateTimeISO(timeZone);
5554
}
5655
return dateTimeInstant.toZonedDateTimeISO('UTC');
5756
}
@@ -88,7 +87,7 @@ function isDateTimeOffsetComponents(
8887
export function serializeFromPlainDateTime(
8988
value: Temporal.PlainDateTime
9089
): string {
91-
const instant = new Temporal.TimeZone('UTC').getInstantFor(value);
90+
const instant = value.toZonedDateTime('UTC').toInstant();
9291
return `/Date(${instant.epochMilliseconds})/`;
9392
}
9493

packages/temporal-de-serializers/src/temporal-de-serializers-v4.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,20 @@ describe('edmToTs()', () => {
5454
const dateTimePrefix = '2020-05-13T16:14';
5555
const datePrefixUnix = 1589386440;
5656
let actual = deserializeDateTimeOffsetToTemporal(`${dateTimePrefix}Z`);
57-
expect(actual.epochSeconds).toBe(datePrefixUnix);
57+
expect(actual.epochMilliseconds).toBe(datePrefixUnix * 1000);
5858

5959
actual = deserializeDateTimeOffsetToTemporal(`${dateTimePrefix}:24Z`);
60-
expect(actual.epochSeconds).toBe(datePrefixUnix + 24);
60+
expect(actual.epochMilliseconds).toBe((datePrefixUnix + 24) * 1000);
6161

6262
actual = deserializeDateTimeOffsetToTemporal(`${dateTimePrefix}+05:00`);
63-
expect(actual.epochSeconds).toBe(datePrefixUnix - 3600 * 5);
63+
expect(actual.epochMilliseconds).toBe((datePrefixUnix - 3600 * 5) * 1000);
6464

6565
actual = deserializeDateTimeOffsetToTemporal(
6666
`${dateTimePrefix}:17.987+03:00`
6767
);
68-
expect(actual.epochSeconds).toBe(datePrefixUnix - 3600 * 3 + 17);
69-
expect(actual.millisecond).toBe(987);
68+
expect(actual.epochMilliseconds).toBe(
69+
(datePrefixUnix - 3600 * 3 + 17) * 1000 + 987
70+
);
7071
});
7172

7273
it('should parse Edm.Duration to Temporal.Duration', () => {

yarn.lock

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,13 +1207,12 @@
12071207
"@jridgewell/resolve-uri" "^3.1.0"
12081208
"@jridgewell/sourcemap-codec" "^1.4.14"
12091209

1210-
"@js-temporal/polyfill@^0.4.4":
1211-
version "0.4.4"
1212-
resolved "https://registry.npmjs.org/@js-temporal/polyfill/-/polyfill-0.4.4.tgz#4c26b4a1a68c19155808363f520204712cfc2558"
1213-
integrity sha512-2X6bvghJ/JAoZO52lbgyAPFj8uCflhTo2g7nkFzEQdXd/D8rEeD4HtmTEpmtGCva260fcd66YNXBOYdnmHqSOg==
1210+
"@js-temporal/polyfill@^0.5.1":
1211+
version "0.5.1"
1212+
resolved "https://registry.npmjs.org/@js-temporal/polyfill/-/polyfill-0.5.1.tgz#c9726fdb7fbdbc6419292ba94294b10a08852c32"
1213+
integrity sha512-hloP58zRVCRSpgDxmqCWJNlizAlUgJFqG2ypq79DCvyv9tHjRYMDOcPFjzfl/A1/YxDvRCZz8wvZvmapQnKwFQ==
12141214
dependencies:
12151215
jsbi "^4.3.0"
1216-
tslib "^2.4.1"
12171216

12181217
"@jsdevtools/ono@^7.1.3":
12191218
version "7.1.3"
@@ -9693,7 +9692,7 @@ [email protected]:
96939692
resolved "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
96949693
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==
96959694

9696-
tslib@^2.0.1, tslib@^2.4.0, tslib@^2.4.1, tslib@^2.6.2, tslib@^2.8.1:
9695+
tslib@^2.0.1, tslib@^2.4.0, tslib@^2.6.2, tslib@^2.8.1:
96979696
version "2.8.1"
96989697
resolved "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f"
96999698
integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==

0 commit comments

Comments
 (0)