Skip to content

chore(deps): bump @js-temporal/polyfill from 0.4.4 to 0.5.1 #5679

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/temporal-de-serializers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"readme": "ts-node ../../scripts/replace-common-readme.ts"
},
"dependencies": {
"@js-temporal/polyfill": "^0.4.4",
"@js-temporal/polyfill": "^0.5.1",
"@sap-cloud-sdk/odata-common": "^4.0.2"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,18 @@ describe('EDM to Temporal', () => {
'/Date(1556630382000)/'
) as Temporal.PlainDateTime;
expect(dateTimePlain.toString()).toBe('2019-04-30T13:19:42');
expect(() => Temporal.TimeZone.from(dateTimePlain.toString())).toThrowError(
/Invalid time zone/
expect(() => Temporal.ZonedDateTime.from(dateTimePlain)).toThrow(
/required property 'timeZone' missing or undefined/
);
});

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ export function deserializeToZonedDateTime(
parseInt(dateTimeOffsetComponents.ticks)
);
if (dateTimeOffsetComponents.sign && dateTimeOffsetComponents.offset) {
const timeZone = Temporal.TimeZone.from(
return dateTimeInstant.toZonedDateTimeISO(
dateTimeOffsetComponents.sign + dateTimeOffsetComponents.offset
);
return dateTimeInstant.toZonedDateTimeISO(timeZone);
}
return dateTimeInstant.toZonedDateTimeISO('UTC');
}
Expand Down Expand Up @@ -88,7 +87,7 @@ function isDateTimeOffsetComponents(
export function serializeFromPlainDateTime(
value: Temporal.PlainDateTime
): string {
const instant = new Temporal.TimeZone('UTC').getInstantFor(value);
const instant = value.toZonedDateTime('UTC').toInstant();
return `/Date(${instant.epochMilliseconds})/`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,20 @@ describe('edmToTs()', () => {
const dateTimePrefix = '2020-05-13T16:14';
const datePrefixUnix = 1589386440;
let actual = deserializeDateTimeOffsetToTemporal(`${dateTimePrefix}Z`);
expect(actual.epochSeconds).toBe(datePrefixUnix);
expect(actual.epochMilliseconds).toBe(datePrefixUnix * 1000);

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

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

actual = deserializeDateTimeOffsetToTemporal(
`${dateTimePrefix}:17.987+03:00`
);
expect(actual.epochSeconds).toBe(datePrefixUnix - 3600 * 3 + 17);
expect(actual.millisecond).toBe(987);
expect(actual.epochMilliseconds).toBe(
(datePrefixUnix - 3600 * 3 + 17) * 1000 + 987
);
});

it('should parse Edm.Duration to Temporal.Duration', () => {
Expand Down
11 changes: 5 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1207,13 +1207,12 @@
"@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14"

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

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

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