Skip to content

Commit

Permalink
Normative: Remove getISOFields methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomato committed May 28, 2024
1 parent a490169 commit f276d71
Show file tree
Hide file tree
Showing 19 changed files with 0 additions and 370 deletions.
26 changes: 0 additions & 26 deletions docs/plaindate.md
Original file line number Diff line number Diff line change
Expand Up @@ -745,29 +745,3 @@ date = Temporal.PlainDate.from('2006-08-24');
date.toPlainYearMonth(); // => 2006-08
date.toPlainMonthDay(); // => 08-24
```

### date.**getISOFields**(): { isoYear: number, isoMonth: number, isoDay: number, calendar: string | object }

**Returns:** a plain object with properties expressing `date` in the ISO 8601 calendar, as well as the calendar (usually a string, but may be an object) in which `date` is reckoned.

This method is mainly useful if you are implementing a custom calendar.
Most code will not need to use it.

Usage example:

```javascript
date = Temporal.PlainDate.from('2006-08-24');
f = date.getISOFields();
f.isoDay; // => 24
// Fields correspond exactly to constructor arguments:
date2 = new Temporal.PlainDate(f.isoYear, f.isoMonth, f.isoDay, f.calendar);
date.equals(date2); // => true

// Date in other calendar
date = date.withCalendar('hebrew');
date.day; // => 30
date.getISOFields().isoDay; // => 24

// Most likely what you need is this:
date.withCalendar('iso8601').day; // => 24
```
29 changes: 0 additions & 29 deletions docs/plaindatetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -939,32 +939,3 @@ dt.toPlainTime(); // => 03:24:30.0000035
dt.toPlainDate().toPlainYearMonth(); // => 1995-12
dt.toPlainDate().toPlainMonthDay(); // => 12-07
```

### datetime.**getISOFields**(): { isoYear: number, isoMonth: number, isoDay: number, isoHour: number, isoMinute: number, isoSecond: number, isoMillisecond: number, isoMicrosecond: number, isoNanosecond: number, calendar: string | object }

**Returns:** a plain object with properties expressing `datetime` in the ISO 8601 calendar, as well as the calendar (usually a string, but may be an object) in which `datetime` is reckoned.

This method is mainly useful if you are implementing a custom calendar.
Most code will not need to use it.

Usage example:

<!-- prettier-ignore-start -->
```javascript
dt = Temporal.PlainDateTime.from('1995-12-07T03:24:30.000003500');
f = dt.getISOFields();
f.isoDay; // => 7
// Fields correspond exactly to constructor arguments:
dt2 = new Temporal.PlainDateTime(f.isoYear, f.isoMonth, f.isoDay, f.isoHour, f.isoMinute,
f.isoSecond, f.isoMillisecond, f.isoMicrosecond, f.isoNanosecond, f.calendar);
dt.equals(dt2); // => true

// Date in other calendar
dt = dt.withCalendar('hebrew');
dt.day; // => 14
dt.getISOFields().isoDay; // => 7

// Most likely what you need is this:
dt.withCalendar('iso8601').day; // => 7
```
<!-- prettier-ignore-end -->
16 changes: 0 additions & 16 deletions docs/plainmonthday.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,19 +388,3 @@ md = Temporal.PlainMonthDay.from({

date = md.toPlainDate({ era: 'reiwa', eraYear: 2 }); // => 2020-01-01[u-ca=japanese]
```

### monthDay.**getISOFields**(): { isoYear: number, isoMonth: number, isoDay: number, calendar: string | object }

**Returns:** a plain object with properties expressing `monthDay` in the ISO 8601 calendar, as well as the calendar (usually a string, but may be an object) in which `monthDay` is reckoned.

This method is mainly useful if you are implementing a custom calendar.
Most code will not need to use it.

The value of the `isoYear` property will be equal to the `referenceISOYear` constructor argument passed when `monthDay` was constructed.

Usage example:

```javascript
md = Temporal.PlainMonthDay.from('08-24');
md.getISOFields().isoDay; // => 24
```
14 changes: 0 additions & 14 deletions docs/plaintime.md
Original file line number Diff line number Diff line change
Expand Up @@ -517,17 +517,3 @@ JSON.parse(str, reviver);
This method overrides `Object.prototype.valueOf()` and always throws an exception.
This is because it's not possible to compare `Temporal.PlainTime` objects with the relational operators `<`, `<=`, `>`, or `>=`.
Use `Temporal.PlainTime.compare()` for this, or `time.equals()` for equality.

### time.**getISOFields**(): { isoHour: number, isoMinute: number, isoSecond: number, isoMillisecond: number, isoMicrosecond: number, isoNanosecond: number }

**Returns:** a plain object with properties expressing `time` in the ISO 8601 calendar.

This method is present for forward compatibility with custom calendars.

Usage example:

```javascript
time = Temporal.PlainTime.from('03:20:00');
f = time.getISOFields();
f.isoHour; // => 3
```
16 changes: 0 additions & 16 deletions docs/plainyearmonth.md
Original file line number Diff line number Diff line change
Expand Up @@ -576,19 +576,3 @@ Usage example:
ym = Temporal.PlainYearMonth.from('2019-06');
ym.toPlainDate({ day: 24 }); // => 2019-06-24
```

### yearMonth.**getISOFields**(): { isoYear: number, isoMonth: number, isoDay: number, calendar: string | object }

**Returns:** a plain object with properties expressing `yearMonth` in the ISO 8601 calendar, as well as the calendar (usually a string, but may be an object) that `yearMonth` is reckoned in.

This method is mainly useful if you are implementing a custom calendar.
Most code will not need to use it.

The value of the `isoDay` property will be equal to the `referenceISODay` constructor argument passed when `yearMonth` was constructed.

Usage example:

```javascript
ym = Temporal.PlainYearMonth.from('2019-06');
ym.getISOFields().isoYear; // => 2019
```
21 changes: 0 additions & 21 deletions docs/zoneddatetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -1446,24 +1446,3 @@ zdt.toPlainTime(); // => 03:24:30
zdt.toPlainDate().toPlainYearMonth(); // => 1995-12
zdt.toPlainDate().toPlainMonthDay(); // => 12-07
```

### zonedDateTime.**getISOFields**(): { isoYear: number, isoMonth: number, isoDay: number, hour: number, minute: number, second: number, millisecond: number, microsecond: number, nanosecond: number, offset: string, timeZone: string | object, calendar: string | object }

**Returns:** a plain object with properties expressing `zonedDateTime` in the ISO 8601 calendar, including all date/time fields as well as the `offset` property, and the calendar and time zone (which are usually strings, but may be objects) in which `zonedDateTime` is reckoned.

This is an advanced method that's mainly useful if you are implementing a custom calendar.
Most developers will not need to use it.

Usage example:

```javascript
// get a Temporal.ZonedDateTime in `hebrew` calendar system
zdt = Temporal.ZonedDateTime.from('2019-02-23T03:24:30.000003500[Europe/Rome]').withCalendar('hebrew');

// Month in Hebrew calendar is month 6 of leap year 5779
zdt.month; // => 6
zdt.getISOFields().isoMonth; // => 2

// Instead of calling getISOFields, the pattern below is recommended for most use cases
zdt.withCalendar('iso8601').month; // => 2
```
50 changes: 0 additions & 50 deletions polyfill/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,13 +608,6 @@ export namespace Temporal {
calendar?: CalendarLike;
};

type PlainDateISOFields = {
isoYear: number;
isoMonth: number;
isoDay: number;
calendar: string;
};

/**
* A `Temporal.PlainDate` represents a calendar date. "Calendar date" refers to the
* concept of a date as expressed in everyday usage, independent of any time
Expand Down Expand Up @@ -666,7 +659,6 @@ export namespace Temporal {
): Temporal.ZonedDateTime;
toPlainYearMonth(): Temporal.PlainYearMonth;
toPlainMonthDay(): Temporal.PlainMonthDay;
getISOFields(): PlainDateISOFields;
toLocaleString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
toJSON(): string;
toString(options?: ShowCalendarOption): string;
Expand All @@ -690,19 +682,6 @@ export namespace Temporal {
calendar?: CalendarLike;
};

type PlainDateTimeISOFields = {
isoYear: number;
isoMonth: number;
isoDay: number;
isoHour: number;
isoMinute: number;
isoSecond: number;
isoMillisecond: number;
isoMicrosecond: number;
isoNanosecond: number;
calendar: string;
};

/**
* A `Temporal.PlainDateTime` represents a calendar date and wall-clock time, with
* a precision in nanoseconds, and without any time zone. Of the Temporal
Expand Down Expand Up @@ -773,7 +752,6 @@ export namespace Temporal {
toZonedDateTime(tzLike: TimeZoneLike, options?: ToInstantOptions): Temporal.ZonedDateTime;
toPlainDate(): Temporal.PlainDate;
toPlainTime(): Temporal.PlainTime;
getISOFields(): PlainDateTimeISOFields;
toLocaleString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
toJSON(): string;
toString(options?: CalendarTypeToStringOptions): string;
Expand Down Expand Up @@ -810,7 +788,6 @@ export namespace Temporal {
equals(other: Temporal.PlainMonthDay | PlainMonthDayLike | string): boolean;
with(monthDayLike: PlainMonthDayLike, options?: AssignmentOptions): Temporal.PlainMonthDay;
toPlainDate(year: { year: number }): Temporal.PlainDate;
getISOFields(): PlainDateISOFields;
toLocaleString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
toJSON(): string;
toString(options?: ShowCalendarOption): string;
Expand All @@ -827,15 +804,6 @@ export namespace Temporal {
nanosecond?: number;
};

type PlainTimeISOFields = {
isoHour: number;
isoMinute: number;
isoSecond: number;
isoMillisecond: number;
isoMicrosecond: number;
isoNanosecond: number;
};

/**
* A `Temporal.PlainTime` represents a wall-clock time, with a precision in
* nanoseconds, and without any time zone. "Wall-clock time" refers to the
Expand Down Expand Up @@ -881,7 +849,6 @@ export namespace Temporal {
round(
roundTo: RoundTo<'hour' | 'minute' | 'second' | 'millisecond' | 'microsecond' | 'nanosecond'>
): Temporal.PlainTime;
getISOFields(): PlainTimeISOFields;
toLocaleString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
toJSON(): string;
toString(options?: ToStringPrecisionOptions): string;
Expand Down Expand Up @@ -938,7 +905,6 @@ export namespace Temporal {
options?: DifferenceOptions<'year' | 'month'>
): Temporal.Duration;
toPlainDate(day: { day: number }): Temporal.PlainDate;
getISOFields(): PlainDateISOFields;
toLocaleString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
toJSON(): string;
toString(options?: ShowCalendarOption): string;
Expand All @@ -964,21 +930,6 @@ export namespace Temporal {
calendar?: CalendarLike;
};

type ZonedDateTimeISOFields = {
isoYear: number;
isoMonth: number;
isoDay: number;
isoHour: number;
isoMinute: number;
isoSecond: number;
isoMillisecond: number;
isoMicrosecond: number;
isoNanosecond: number;
offset: string;
timeZone: string;
calendar: string;
};

export class ZonedDateTime {
static from(
item: Temporal.ZonedDateTime | ZonedDateTimeLike | string,
Expand Down Expand Up @@ -1039,7 +990,6 @@ export namespace Temporal {
toPlainDateTime(): Temporal.PlainDateTime;
toPlainDate(): Temporal.PlainDate;
toPlainTime(): Temporal.PlainTime;
getISOFields(): ZonedDateTimeISOFields;
toLocaleString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
toJSON(): string;
toString(options?: ZonedDateTimeToStringOptions): string;
Expand Down
9 changes: 0 additions & 9 deletions polyfill/lib/plaindate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,6 @@ export class PlainDate {
const fields = ES.PrepareCalendarFields(calendar, this, ['day', 'monthCode'], [], []);
return ES.CalendarMonthDayFromFields(calendar, fields);
}
getISOFields() {
if (!ES.IsTemporalDate(this)) throw new TypeError('invalid receiver');
return {
calendar: GetSlot(this, CALENDAR),
isoDay: GetSlot(this, ISO_DAY),
isoMonth: GetSlot(this, ISO_MONTH),
isoYear: GetSlot(this, ISO_YEAR)
};
}

static from(item, options = undefined) {
options = ES.GetOptionsObject(options);
Expand Down
15 changes: 0 additions & 15 deletions polyfill/lib/plaindatetime.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -367,21 +367,6 @@ export class PlainDateTime {
if (!ES.IsTemporalDateTime(this)) throw new TypeError('invalid receiver');
return ES.TemporalDateTimeToTime(this);
}
getISOFields() {
if (!ES.IsTemporalDateTime(this)) throw new TypeError('invalid receiver');
return {
calendar: GetSlot(this, CALENDAR),
isoDay: GetSlot(this, ISO_DAY),
isoHour: GetSlot(this, ISO_HOUR),
isoMicrosecond: GetSlot(this, ISO_MICROSECOND),
isoMillisecond: GetSlot(this, ISO_MILLISECOND),
isoMinute: GetSlot(this, ISO_MINUTE),
isoMonth: GetSlot(this, ISO_MONTH),
isoNanosecond: GetSlot(this, ISO_NANOSECOND),
isoSecond: GetSlot(this, ISO_SECOND),
isoYear: GetSlot(this, ISO_YEAR)
};
}

static from(item, options = undefined) {
options = ES.GetOptionsObject(options);
Expand Down
9 changes: 0 additions & 9 deletions polyfill/lib/plainmonthday.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,6 @@ export class PlainMonthDay {
mergedFields = ES.PrepareTemporalFields(mergedFields, concatenatedFieldNames, [], [], 'ignore');
return ES.CalendarDateFromFields(calendar, mergedFields, 'constrain');
}
getISOFields() {
if (!ES.IsTemporalMonthDay(this)) throw new TypeError('invalid receiver');
return {
calendar: GetSlot(this, CALENDAR),
isoDay: GetSlot(this, ISO_DAY),
isoMonth: GetSlot(this, ISO_MONTH),
isoYear: GetSlot(this, ISO_YEAR)
};
}

static from(item, options = undefined) {
options = ES.GetOptionsObject(options);
Expand Down
12 changes: 0 additions & 12 deletions polyfill/lib/plaintime.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,6 @@ export class PlainTime {
return new DateTimeFormat(locales, options).format(this);
}

getISOFields() {
if (!ES.IsTemporalTime(this)) throw new TypeError('invalid receiver');
return {
isoHour: GetSlot(this, ISO_HOUR),
isoMicrosecond: GetSlot(this, ISO_MICROSECOND),
isoMillisecond: GetSlot(this, ISO_MILLISECOND),
isoMinute: GetSlot(this, ISO_MINUTE),
isoNanosecond: GetSlot(this, ISO_NANOSECOND),
isoSecond: GetSlot(this, ISO_SECOND)
};
}

static from(item, options = undefined) {
options = ES.GetOptionsObject(options);
const overflow = ES.GetTemporalOverflowOption(options);
Expand Down
9 changes: 0 additions & 9 deletions polyfill/lib/plainyearmonth.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,6 @@ export class PlainYearMonth {
mergedFields = ES.PrepareTemporalFields(mergedFields, concatenatedFieldNames, [], [], 'ignore');
return ES.CalendarDateFromFields(calendar, mergedFields, 'constrain');
}
getISOFields() {
if (!ES.IsTemporalYearMonth(this)) throw new TypeError('invalid receiver');
return {
calendar: GetSlot(this, CALENDAR),
isoDay: GetSlot(this, ISO_DAY),
isoMonth: GetSlot(this, ISO_MONTH),
isoYear: GetSlot(this, ISO_YEAR)
};
}

static from(item, options = undefined) {
options = ES.GetOptionsObject(options);
Expand Down
20 changes: 0 additions & 20 deletions polyfill/lib/zoneddatetime.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -557,26 +557,6 @@ export class ZonedDateTime {
if (!ES.IsTemporalZonedDateTime(this)) throw new TypeError('invalid receiver');
return dateTime(this);
}
getISOFields() {
if (!ES.IsTemporalZonedDateTime(this)) throw new TypeError('invalid receiver');
const timeZone = GetSlot(this, TIME_ZONE);
const offsetNanoseconds = ES.GetOffsetNanosecondsFor(timeZone, GetSlot(this, INSTANT));
const dt = ES.GetPlainDateTimeFor(timeZone, GetSlot(this, INSTANT), GetSlot(this, CALENDAR), offsetNanoseconds);
return {
calendar: GetSlot(this, CALENDAR),
isoDay: GetSlot(dt, ISO_DAY),
isoHour: GetSlot(dt, ISO_HOUR),
isoMicrosecond: GetSlot(dt, ISO_MICROSECOND),
isoMillisecond: GetSlot(dt, ISO_MILLISECOND),
isoMinute: GetSlot(dt, ISO_MINUTE),
isoMonth: GetSlot(dt, ISO_MONTH),
isoNanosecond: GetSlot(dt, ISO_NANOSECOND),
isoSecond: GetSlot(dt, ISO_SECOND),
isoYear: GetSlot(dt, ISO_YEAR),
offset: ES.FormatUTCOffsetNanoseconds(offsetNanoseconds),
timeZone: timeZone
};
}

static from(item, options = undefined) {
options = ES.GetOptionsObject(options);
Expand Down
Loading

0 comments on commit f276d71

Please sign in to comment.