Skip to content

Commit

Permalink
Fixes for toLocalDateTime in Date and Time types
Browse files Browse the repository at this point in the history
* Use `toDateTime` instead of old `withXXX()`
* Make time arg optional in `Date.prototype.toLocalDateTime`
  • Loading branch information
justingrant committed Oct 11, 2020
1 parent d330883 commit cf9d55c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion polyfill/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ export namespace Temporal {
): Temporal.Duration;
toLocalDateTime(
tzLike: TimeZoneProtocol | string,
temporalTime: Temporal.Time,
temporalTime?: Temporal.Time,
options?: ToAbsoluteOptions
): Temporal.LocalDateTime;
toDateTime(temporalTime: Temporal.Time): Temporal.DateTime;
Expand Down
4 changes: 2 additions & 2 deletions polyfill/lib/date.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ export class Date {
}
toLocalDateTime(temporalTimeZoneLike, temporalTime, options) {
if (!ES.IsTemporalDate(this)) throw new TypeError('invalid receiver');
// TODO: switch to `toDateTime()` after that lands
const dateTime = this.withTime(temporalTime);
const TemporalTime = GetIntrinsic('%Temporal.Time%');
const dateTime = this.toDateTime(temporalTime === undefined ? TemporalTime.from('00:00') : temporalTime);
const TemporalTimeZone = GetIntrinsic('%Temporal.TimeZone%');
const timeZone = TemporalTimeZone.from(temporalTimeZoneLike);
const TemporalLocalDateTime = GetIntrinsic('%Temporal.LocalDateTime%');
Expand Down
3 changes: 1 addition & 2 deletions polyfill/lib/time.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,7 @@ export class Time {
}
toLocalDateTime(temporalTimeZoneLike, temporalDate, options) {
if (!ES.IsTemporalTime(this)) throw new TypeError('invalid receiver');
// TODO: switch to `toDateTime()`
const dateTime = this.withDate(temporalDate);
const dateTime = this.toDateTime(temporalDate);
const TemporalTimeZone = GetIntrinsic('%Temporal.TimeZone%');
const timeZone = TemporalTimeZone.from(temporalTimeZoneLike);
const TemporalLocalDateTime = GetIntrinsic('%Temporal.LocalDateTime%');
Expand Down

0 comments on commit cf9d55c

Please sign in to comment.