Skip to content

Commit 3b1bf3f

Browse files
authored
Update docs for zero-padded monthCode format (#1364)
1 parent 2143855 commit 3b1bf3f

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

docs/calendar.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ For example:
234234
const date = Temporal.PlainDate.from('2019-02-06').withCalendar('hebrew');
235235
date.year; // => 5779
236236
date.calendar.year(date); // same result, but calling the method directly
237-
date.monthCode; // => "M5L"
237+
date.monthCode; // => "M05L"
238238
date.calendar.monthCode(date); // same result, but calling the method directly
239239
date.daysInYear; // => 385
240240
date.calendar.daysInYear(date); // same result, but calling the method directly
@@ -271,10 +271,10 @@ A custom implementation of these methods would convert the calendar-space argume
271271
For example:
272272

273273
```javascript
274-
date = Temporal.PlainDate.from({ year: 5779, monthCode: 'M5L', day: 18, calendar: 'hebrew' });
274+
date = Temporal.PlainDate.from({ year: 5779, monthCode: 'M05L', day: 18, calendar: 'hebrew' });
275275
date.year; // => 5779
276276
date.month; // => 6
277-
date.monthCode; // => "M5L"
277+
date.monthCode; // => "M05L"
278278
date.day; // => 18
279279
date.toString(); // => 2019-02-23[u-ca-hebrew]
280280
date.toLocaleString('en-US', { calendar: 'hebrew' }); // => "18 Adar I 5779"
@@ -433,9 +433,9 @@ Usage example:
433433
// and `monthCode` into account
434434
Temporal.Calendar.from('iso8601').mergeFields(
435435
{ year: 2006, month: 7, day: 31 },
436-
{ monthCode: 'M8' }
436+
{ monthCode: 'M08' }
437437
);
438-
// => { year: 2006, monthCode: 'M8', day: 31 }
438+
// => { year: 2006, monthCode: 'M08', day: 31 }
439439
```
440440
<!-- prettier-ignore-end -->
441441

docs/plaindate.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ The above read-only properties allow accessing each component of a date individu
165165
The last month of every year has `month` equal to the `monthsInYear` property.
166166
`month` values start at 1, which is different from legacy `Date` where months are represented by zero-based indices (0 to 11).
167167
- `monthCode` is a calendar-specific string that identifies the month in a year-independent way.
168-
For common (non-leap) months, `monthCode` should be `` `M${month}` ``.
168+
For common (non-leap) months, `monthCode` should be `` `M${month}` ``, where `month` is zero padded up to two digits.
169169
For uncommon (leap) months in lunisolar calendars like Hebrew or Chinese, the month code is the previous month's code with with an "L" suffix appended.
170-
Examples: `'M2'` => February; `'M8L'` => repeated 8th month in the Chinese calendar; `'M5L'` => Adar I in the Hebrew calendar.
170+
Examples: `'M02'` => February; `'M08L'` => repeated 8th month in the Chinese calendar; `'M05L'` => Adar I in the Hebrew calendar.
171171
- `day` is a positive integer representing the day of the month.
172172

173173
Either `month` or `monthCode` can be used in `from` or `with` to refer to the month.
@@ -180,13 +180,13 @@ Usage examples:
180180
date = Temporal.PlainDate.from('2006-08-24');
181181
date.year; // => 2006
182182
date.month; // => 8
183-
date.monthCode; // => "M8"
183+
date.monthCode; // => "M08"
184184
date.day; // => 24
185185

186186
date = Temporal.PlainDate.from('2019-02-23[u-ca-hebrew]');
187187
date.year; // => 5779
188188
date.month; // => 6
189-
date.monthCode; // => "M5L"
189+
date.monthCode; // => "M05L"
190190
date.day; // => 18
191191
```
192192
<!-- prettier-ignore-end -->

docs/plaindatetime.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ Date unit details:
241241
The last month of every year has `month` equal to the `monthsInYear` property.
242242
`month` values start at 1, which is different from legacy `Date` where months are represented by zero-based indices (0 to 11).
243243
- `monthCode` is a calendar-specific string that identifies the month in a year-independent way.
244-
For common (non-leap) months, `monthCode` should be `` `M${month}` ``.
244+
For common (non-leap) months, `monthCode` should be `` `M${month}` ``, where `month` is zero padded up to two digits.
245245
For uncommon (leap) months in lunisolar calendars like Hebrew or Chinese, the month code is the previous month's code with with an "L" suffix appended.
246-
Examples: `'M2'` => February; `'M8L'` => repeated 8th month in the Chinese calendar; `'M5L'` => Adar I in the Hebrew calendar.
246+
Examples: `'M02'` => February; `'M08L'` => repeated 8th month in the Chinese calendar; `'M05L'` => Adar I in the Hebrew calendar.
247247
- `day` is a positive integer representing the day of the month.
248248

249249
Either `month` or `monthCode` can be used in `from` or `with` to refer to the month.
@@ -278,7 +278,7 @@ dt.nanosecond; // => 500
278278
dt = Temporal.PlainDate.from('2019-02-23T03:24:30.000003500[u-ca-hebrew]');
279279
dt.year; // => 5779
280280
dt.month; // => 6
281-
dt.monthCode; // => "M5L"
281+
dt.monthCode; // => "M05L"
282282
dt.day; // => 18
283283
dt.hour; // => 3
284284
dt.minute; // => 24

docs/plainmonthday.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ md = Temporal.PlainMonthDay.from('2006-08-24T15:43:27+01:00[Europe/Brussels]');
9595
// => 08-24
9696
md === Temporal.PlainMonthDay.from(md); // => true
9797

98-
md = Temporal.PlainMonthDay.from({ monthCode: 'M8', day: 24 }); // => 08-24
98+
md = Temporal.PlainMonthDay.from({ monthCode: 'M08', day: 24 }); // => 08-24
9999
md = Temporal.PlainMonthDay.from(Temporal.PlainDate.from('2006-08-24'));
100100
// => same as above; Temporal.PlainDate has month and day properties
101101

@@ -112,14 +112,14 @@ md = Temporal.PlainMonthDay.from({ month: 2, day: 29, year: 2001 }, { overflow:
112112
// throws (this year is not a leap year in the ISO calendar)
113113

114114
// non-ISO calendars
115-
md = Temporal.PlainMonthDay.from({ monthCode: 'M5L', day: 15, calendar: 'hebrew' });
115+
md = Temporal.PlainMonthDay.from({ monthCode: 'M05L', day: 15, calendar: 'hebrew' });
116116
// => 2019-02-20[u-ca-hebrew]
117117
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: 'hebrew' });
118118
// => 2019-02-20[u-ca-hebrew]
119119
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: 'hebrew' });
120120
// => throws (either year or monthCode is required)
121121
md = Temporal.PlainMonthDay.from('2019-02-20[u-ca-hebrew]');
122-
md.monthCode; // => "M5L"
122+
md.monthCode; // => "M05L"
123123
md.day; // => 15
124124
md.month; // undefined (month property is not present in this type; use monthCode instead)
125125
```
@@ -133,9 +133,9 @@ md.month; // undefined (month property is not present in this type; use monthCod
133133
The above read-only properties allow accessing each component of the date individually.
134134

135135
- `monthCode` is a calendar-specific string that identifies the month in a year-independent way.
136-
For common (non-leap) months, `monthCode` should be ` ` `M${month}` ` `.
136+
For common (non-leap) months, `monthCode` should be ` ` `M${month}` ` `, where `month` is zero padded up to two digits.
137137
For uncommon (leap) months in lunisolar calendars like Hebrew or Chinese, the month code is the previous month's code with with an "L" suffix appended.
138-
Examples: `'M2'` => February; `'M8L'` => repeated 8th month in the Chinese calendar; `'M5L'` => Adar I in the Hebrew calendar.
138+
Examples: `'M02'` => February; `'M08L'` => repeated 8th month in the Chinese calendar; `'M05L'` => Adar I in the Hebrew calendar.
139139
- `day` is a positive integer representing the day of the month.
140140

141141
Note that this type has no `month` property, because `month` is ambiguous for some calendars without knowing the year.
@@ -145,12 +145,12 @@ Usage examples:
145145

146146
```javascript
147147
md = Temporal.PlainMonthDay.from('08-24');
148-
md.monthCode; // => "M8"
148+
md.monthCode; // => "M08"
149149
md.day; // => 24
150150
md.month; // undefined (no `month` property; use `monthCode` instead)
151151

152152
md = Temporal.PlainMonthDay.from('2019-02-20[u-ca-hebrew]');
153-
md.monthCode; // => "M5L"
153+
md.monthCode; // => "M05L"
154154
md.day; // => 15
155155
md.month; // undefined (no `month` property; use `monthCode` instead)
156156
```
@@ -285,7 +285,7 @@ Example usage:
285285

286286
```js
287287
({ calendar } = new Intl.DateTimeFormat().resolvedOptions());
288-
md = Temporal.PlainMonthDay.from({ monthCode: 'M8', day: 24, calendar });
288+
md = Temporal.PlainMonthDay.from({ monthCode: 'M08', day: 24, calendar });
289289
md.toLocaleString(); // => example output: 08-24
290290
// Same as above, but explicitly specifying the calendar:
291291
md.toLocaleString(undefined, { calendar });
@@ -311,7 +311,7 @@ Example usage:
311311
```js
312312
const holiday = {
313313
name: 'Canada Day',
314-
holidayMonthDay: Temporal.PlainMonthDay.from({ monthCode: 'M7', day: 1 })
314+
holidayMonthDay: Temporal.PlainMonthDay.from({ monthCode: 'M07', day: 1 })
315315
};
316316
const str = JSON.stringify(holiday, null, 2);
317317
console.log(str);
@@ -364,7 +364,7 @@ Example:
364364
```javascript
365365
md = Temporal.PlainMonthDay.from({
366366
calendar: 'japanese',
367-
monthCode: 'M1',
367+
monthCode: 'M01',
368368
day: 1
369369
});
370370

docs/plainyearmonth.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ The above read-only properties allow accessing the year or month individually.
164164
The last month of every year has `month` equal to the `monthsInYear` property.
165165
`month` values start at 1, which is different from legacy `Date` where months are represented by zero-based indices (0 to 11).
166166
- `monthCode` is a calendar-specific string that identifies the month in a year-independent way.
167-
For common (non-leap) months, `monthCode` should be `` `M${month}` ``.
167+
For common (non-leap) months, `monthCode` should be `` `M${month}` ``, where `month` is zero padded up to two digits.
168168
For uncommon (leap) months in lunisolar calendars like Hebrew or Chinese, the month code is the previous month's code with with an "L" suffix appended.
169-
Examples: `'M2'` => February; `'M8L'` => repeated 8th month in the Chinese calendar; `'M5L'` => Adar I in the Hebrew calendar.
169+
Examples: `'M02'` => February; `'M08L'` => repeated 8th month in the Chinese calendar; `'M05L'` => Adar I in the Hebrew calendar.
170170

171171
Either `month` or `monthCode` can be used in `from` or `with` to refer to the month.
172172
Similarly, in calendars that user eras an `era`/`eraYear` pair can be used in place of `year` when calling `from` or `with`.
@@ -177,12 +177,12 @@ Usage examples:
177177
ym = Temporal.PlainYearMonth.from('2019-06');
178178
ym.year; // => 2019
179179
ym.month; // => 6
180-
ym.monthCode; // => "M6"
180+
ym.monthCode; // => "M06"
181181

182182
ym = Temporal.PlainYearMonth.from('2019-02-23[u-ca-hebrew]');
183183
ym.year; // => 5779
184184
ym.month; // => 6
185-
ym.monthCode; // => "M5L"
185+
ym.monthCode; // => "M05L"
186186
ym.day; // => 18
187187
```
188188

docs/zoneddatetime.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,9 @@ Date unit details:
301301
The last month of every year has `month` equal to the `monthsInYear` property.
302302
`month` values start at 1, which is different from legacy `Date` where months are represented by zero-based indices (0 to 11).
303303
- `monthCode` is a calendar-specific string that identifies the month in a year-independent way.
304-
For common (non-leap) months, `monthCode` should be `` `M${month}` ``.
304+
For common (non-leap) months, `monthCode` should be `` `M${month}` ``, where `month` is zero padded up to two digits.
305305
For uncommon (leap) months in lunisolar calendars like Hebrew or Chinese, the month code is the previous month's code with with an "L" suffix appended.
306-
Examples: `'M2'` => February; `'M8L'` => repeated 8th month in the Chinese calendar; `'M5L'` => Adar I in the Hebrew calendar.
306+
Examples: `'M02'` => February; `'M08L'` => repeated 8th month in the Chinese calendar; `'M05L'` => Adar I in the Hebrew calendar.
307307
- `day` is a positive integer representing the day of the month.
308308

309309
Either `month` or `monthCode` can be used in `from` or `with` to refer to the month.
@@ -338,7 +338,7 @@ dt.nanosecond; // => 500
338338
dt = Temporal.ZonedDateTime.from('2019-02-23T03:24:30.000003500[Europe/Rome][u-ca-hebrew]');
339339
dt.year; // => 5779
340340
dt.month; // => 6
341-
dt.monthCode; // => "M5L"
341+
dt.monthCode; // => "M05L"
342342
dt.day; // => 18
343343
dt.hour; // => 3
344344
dt.minute; // => 24

0 commit comments

Comments
 (0)