Skip to content

Commit d0acb66

Browse files
justingrantMs2ger
authored andcommitted
Rename Temporal.now => Temporal.Now
1 parent ef25129 commit d0acb66

File tree

88 files changed

+264
-264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+264
-264
lines changed

docs/README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,25 @@ Converting between such types and exact time types (`Temporal.Instant` and `Temp
3333

3434
Several important concepts are explained elsewhere: [exact time, wall-clock time, time zones, DST, handling ambiguity, and more](./ambiguity.md).
3535

36-
### **Temporal.now**
37-
38-
- `Temporal.now.instant()` - get the exact time since [Unix epoch](https://en.wikipedia.org/wiki/Unix_time)
39-
- `Temporal.now.timeZone()` - get the current system time zone
40-
- `Temporal.now.zonedDateTime(calendar)` - get the current date and wall-clock time in the system time zone and specified calendar
41-
- `Temporal.now.zonedDateTimeISO()` - get the current date and wall-clock time in the system time zone and ISO-8601 calendar
42-
- `Temporal.now.plainDate(calendar)` - get the current date in the system time zone and specified calendar
43-
- `Temporal.now.plainDateISO()` - get the current date in the system time zone and ISO-8601 calendar
44-
- `Temporal.now.plainTimeISO()` - get the current wall-clock time in the system time zone and ISO-8601 calendar
45-
- `Temporal.now.plainDateTime(calendar)` - get the current system date/time in the system time zone, but return an object that doesn't remember its time zone so should NOT be used to derive other values (e.g. 12 hours later) in time zones that use Daylight Saving Time (DST).
46-
- `Temporal.now.plainDateTimeISO()` - same as above, but return the DateTime in the ISO-8601 calendar
36+
### **Temporal.Now**
37+
38+
- `Temporal.Now.instant()` - get the exact time since [Unix epoch](https://en.wikipedia.org/wiki/Unix_time)
39+
- `Temporal.Now.timeZone()` - get the current system time zone
40+
- `Temporal.Now.zonedDateTime(calendar)` - get the current date and wall-clock time in the system time zone and specified calendar
41+
- `Temporal.Now.zonedDateTimeISO()` - get the current date and wall-clock time in the system time zone and ISO-8601 calendar
42+
- `Temporal.Now.plainDate(calendar)` - get the current date in the system time zone and specified calendar
43+
- `Temporal.Now.plainDateISO()` - get the current date in the system time zone and ISO-8601 calendar
44+
- `Temporal.Now.plainTimeISO()` - get the current wall-clock time in the system time zone and ISO-8601 calendar
45+
- `Temporal.Now.plainDateTime(calendar)` - get the current system date/time in the system time zone, but return an object that doesn't remember its time zone so should NOT be used to derive other values (e.g. 12 hours later) in time zones that use Daylight Saving Time (DST).
46+
- `Temporal.Now.plainDateTimeISO()` - same as above, but return the DateTime in the ISO-8601 calendar
4747

4848
```js
49-
console.log('Initialization complete', Temporal.now.instant());
49+
console.log('Initialization complete', Temporal.Now.instant());
5050
// example output:
5151
// Initialization complete 2021-01-13T20:57:01.500944804Z
5252
```
5353

54-
See [Temporal.now Documentation](./now.md) for detailed documentation.
54+
See [Temporal.Now Documentation](./now.md) for detailed documentation.
5555

5656
### **Temporal.Instant**
5757

@@ -207,8 +207,8 @@ It is also possible to implement your own time zones.
207207
const timeZone = Temporal.TimeZone.from('Africa/Cairo');
208208
timeZone.getInstantFor('2000-01-01T00:00'); // => 1999-12-31T22:00:00Z
209209
timeZone.getPlainDateTimeFor('2000-01-01T00:00Z'); // => 2000-01-01T02:00:00
210-
timeZone.getPreviousTransition(Temporal.now.instant()); // => 2014-09-25T21:00:00Z
211-
timeZone.getNextTransition(Temporal.now.instant()); // => null
210+
timeZone.getPreviousTransition(Temporal.Now.instant()); // => 2014-09-25T21:00:00Z
211+
timeZone.getNextTransition(Temporal.Now.instant()); // => null
212212
```
213213

214214
See [Temporal.TimeZone Documentation](./timezone.md) for detailed documentation.

docs/calendar-draft.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ Here is an illustrated version of this option:
299299
300300
### New Factory Methods (Option 6)
301301
302-
With this option, separate methods would indicate whether the Full ISO calendar should be used versus a potentially non-ISO calendar. For example, `Temporal.now.plainDateISO` would be added to supplement `Temporal.now.plainDate`. See the full table below.
302+
With this option, separate methods would indicate whether the Full ISO calendar should be used versus a potentially non-ISO calendar. For example, `Temporal.Now.plainDateISO` would be added to supplement `Temporal.Now.plainDate`. See the full table below.
303303
304304
### Methods of Construction
305305
@@ -312,8 +312,8 @@ The following table describes these semantics. Option 5 is not shown because the
312312
| T.Date.from(string)\* | _From String_ | Explicit | Partial ISO | Environ. | _From String_ |
313313
| T.Date.from(fields)\*\* | _From Object_ | Explicit | Partial ISO | Environ. | _From Object_ |
314314
| new T.Date() | Full ISO | Full ISO | Full ISO | Full ISO | Full ISO |
315-
| T.now.plainDate() | Full ISO | Explicit | Partial ISO | Environ. | Explicit |
316-
| T.now.plainDateISO() | N/A | N/A | N/A | N/A | Full ISO |
315+
| T.Now.plainDate() | Full ISO | Explicit | Partial ISO | Environ. | Explicit |
316+
| T.Now.plainDateISO() | N/A | N/A | N/A | N/A | Full ISO |
317317
| instant.inTimeZone() | Full ISO | Explicit | Partial ISO | Environ. | Explicit |
318318
| instant.inZoneISO() | N/A | N/A | N/A | N/A | Full ISO |
319319
| date.getMonthDay()\*\*\*\* | Inherit | Inherit | Explicit | Inherit | Inherit |
@@ -351,31 +351,31 @@ Code:
351351
352352
```javascript
353353
/// Options 1 and 4: calendar implicit
354-
const today = Temporal.now.plainDate();
354+
const today = Temporal.Now.plainDate();
355355
// OPTION 1 BUG: the ISO calendar is implicit when creating the MonthDay
356356
const monthDay = today.getMonthDay();
357357
console.log('Today is:', monthDay.toLocaleString());
358358

359359
/// Options 2 and 6: calendar in factory method
360360
const calendar = navigator.locales[0].getLikelyCalendar();
361-
const today = Temporal.now.plainDate(calendar);
361+
const today = Temporal.Now.plainDate(calendar);
362362
const monthDay = today.getMonthDay();
363363
console.log('Today is:', monthDay.toLocaleString());
364364

365365
/// Option 3 and 5: getMonthDay() requires a calendar to be given
366-
const today = Temporal.now.plainDate();
366+
const today = Temporal.Now.plainDate();
367367
const calendar = navigator.locales[0].getLikelyCalendar();
368368
const monthDay = today.withCalendar(calendar).getMonthDay();
369369
console.log('Today is:', monthDay.toLocaleString());
370370

371371
/// Option 3 and 5 alternative: add argument to getMonthDay()
372-
const today = Temporal.now.plainDate();
372+
const today = Temporal.Now.plainDate();
373373
const calendar = navigator.locales[0].getLikelyCalendar();
374374
const monthDay = today.getMonthDay(calendar);
375375
console.log('Today is:', monthDay.toLocaleString());
376376

377377
/// Alternative using Intl settings
378-
const today = Temporal.now.plainDate();
378+
const today = Temporal.Now.plainDate();
379379
console.log(
380380
'Today is:',
381381
today.toLocaleString(undefined, {
@@ -401,7 +401,7 @@ Code:
401401
402402
```javascript
403403
/// Options 1 and 4: calendar implicit
404-
const today = Temporal.now.plainDate();
404+
const today = Temporal.Now.plainDate();
405405
console.log('Today is:', today.toLocaleString());
406406
// OPTION 1 BUG:
407407
// Arithmetic in months must take place in the user calendar
@@ -410,13 +410,13 @@ console.log('Next month is: ', nextMonth.toLocaleString());
410410

411411
/// Options 2 and 6: calendar in factory method
412412
const calendar = navigator.locales[0].getLikelyCalendar();
413-
const today = Temporal.now.plainDate(calendar);
413+
const today = Temporal.Now.plainDate(calendar);
414414
console.log('Today is:', today.toLocaleString());
415415
const nextMonth = today.add({ months: 1 });
416416
console.log('Next month is: ', nextMonth.toLocaleString());
417417

418418
/// Options 3 and 5: calendar only when needed
419-
const today = Temporal.now.plainDate();
419+
const today = Temporal.Now.plainDate();
420420
console.log('Today is:', today.toLocaleString());
421421
const calendar = navigator.locales[0].getLikelyCalendar();
422422
const nextMonth = today.withCalendar(calendar).add({ months: 1 });
@@ -439,7 +439,7 @@ Code:
439439
440440
```javascript
441441
/// Options 1 and 4: calendar implicit
442-
const date = Temporal.now.plainDate();
442+
const date = Temporal.Now.plainDate();
443443
console.log('Today is:', date.toLocaleString());
444444
// OPTION 1 BUG:
445445
// The MonthDay needs to be represented in the user calendar; otherwise,
@@ -449,13 +449,13 @@ console.log(`Is ${monthDay.toLocaleString()} your birthday?`);
449449

450450
/// Options 2 and 6: calendar in factory method
451451
const calendar = navigator.locales[0].getLikelyCalendar();
452-
const date = Temporal.now.plainDate(calendar);
452+
const date = Temporal.Now.plainDate(calendar);
453453
console.log('Today is:', date.toLocaleString());
454454
const monthDay = date.getMonthDay();
455455
console.log(`Is ${monthDay.toLocaleString()} your birthday?`);
456456

457457
/// Options 3 and 5: calendar only when needed
458-
const date = Temporal.now.plainDate();
458+
const date = Temporal.Now.plainDate();
459459
console.log('Today is:', date.toLocaleString());
460460
const calendar = navigator.locales[0].getLikelyCalendar();
461461
const monthDay = date.withCalendar(calendar).getMonthDay();
@@ -478,7 +478,7 @@ Code:
478478
479479
```javascript
480480
/// Options 1 and 4: calendar implicit
481-
const date = Temporal.now.plainDate();
481+
const date = Temporal.Now.plainDate();
482482
// OPTION 1 BUG:
483483
// The YearMonth needs to be represented in the user calendar
484484
const yearMonth = date.getYearMonth();
@@ -487,13 +487,13 @@ console.log('Number of days this month:', yearMonth.daysInMonth);
487487

488488
/// Options 2 and 6: calendar in factory method
489489
const calendar = navigator.locales[0].getLikelyCalendar();
490-
const date = Temporal.now.plainDate(calendar);
490+
const date = Temporal.Now.plainDate(calendar);
491491
const yearMonth = date.getYearMonth();
492492
console.log('Today is:', date.toLocaleString());
493493
console.log('Number of days this month:', yearMonth.daysInMonth);
494494

495495
/// Options 3 and 5: calendar only when needed
496-
const date = Temporal.now.plainDate();
496+
const date = Temporal.Now.plainDate();
497497
const calendar = navigator.locales[0].getLikelyCalendar();
498498
const yearMonth = date.withCalendar(calendar).getYearMonth();
499499
console.log('Today is:', date.toLocaleString());
@@ -650,16 +650,16 @@ Temporal.Instant.prototype.inTimeZone = function(timeZone, calendar) {
650650
}
651651
```
652652
653-
### Temporal.now
653+
### Temporal.Now
654654
655655
The fourth way to get a Temporal.PlainDate is to get the current time according to the environment (or mocked for SES).
656656
657657
As above, this API depends on whether we decide to use a default calendar. If we require an explicit calendar, it would be similar to above:
658658
659659
```javascript
660-
Temporal.now.plainDate = function (calendar) {
661-
const instant = Temporal.now.instant(); // use intrinsic
662-
const timeZone = Temporal.now.timeZone(); // use intrinsic
660+
Temporal.Now.plainDate = function (calendar) {
661+
const instant = Temporal.Now.instant(); // use intrinsic
662+
const timeZone = Temporal.Now.timeZone(); // use intrinsic
663663
return instant.inTimeZone(timeZone, calendar); // use intrinsic
664664
};
665665
```

docs/calendar-review.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ For example:
192192
Userland code can completely avoid the use of calendar-specific constants (e.g. 12 months per year) by using these properties.
193193
- There is never an implicit default calendar system.
194194
Developers must explicitly decide whether they're using the ISO calendar or another calendar.
195-
For example, shortcut methods on the `Temporal.now` object are named with an ISO prefix to avoid ambiguity, such as `Temporal.now.zonedDateTimeISO()`.
195+
For example, shortcut methods on the `Temporal.Now` object are named with an ISO prefix to avoid ambiguity, such as `Temporal.Now.zonedDateTimeISO()`.
196196
- Temporal never infers a calendar from the user's environment.
197197
Introducing a calendar system into a program requires a conscious, opt-in decision on the part of the developer of the app, library, or input source.
198198

@@ -305,11 +305,11 @@ In the end, the champions decided that the subclassing approach brought a high c
305305

306306
### Alternative 4: Separate Types for Calendared Dates
307307

308-
This approach would mean introducing a new type that carries a date without a calendar system, to supplement the type with the calendar system. Most documentation would recommend the calendar-agnostic type except when calendar-aware logic is necessary. We discuss this approach in more detail as [Option 5 in calendar-draft.md](https://github.com/tc39/proposal-temporal/blob/main/docs/calendar-draft.md#new-non-calendar-types-option-5).
308+
This approach would mean introducing a new type that carries a date without a calendar system, to supplement the type with the calendar system. Most documentation would recommend the calendar-agnostic type except when calendar-aware logic is necessary. We discuss this approach in more detail as [Option 5 in calendar-draft.md](https://github.com/tc39/proposal-temporal/blob/main/docs/calendar-draft.md#new-non-calendar-types-option-5).
309309

310310
We decided against the dual classes approach because:
311311

312312
1. If the new type were truly calendar-agnostic, it could not support month and year arithmetic, because doing so would introduce an ISO bias.
313313
2. If the new type had ISO-like behavior for months and years, then it is no different from PlainDate with an ISO calendar.
314314

315-
Note that (2) is true for ECMAScript because it is dynamically typed. Statically typed languages could enforce compile-time type checking for (2) that is not possible in ECMAScript. Note also that clients such as TypeScript can treat PlainDate as having a type parameter corresponding to the calendar system in order to enforce more compile-time type checking of calendar systems. Separate data types are not necessary for that validation.
315+
Note that (2) is true for ECMAScript because it is dynamically typed. Statically typed languages could enforce compile-time type checking for (2) that is not possible in ECMAScript. Note also that clients such as TypeScript can treat PlainDate as having a type parameter corresponding to the calendar system in order to enforce more compile-time type checking of calendar systems. Separate data types are not necessary for that validation.

docs/cookbook.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ The graph always starts at midnight in the tank's location, but the graph labels
224224
<script type="text/javascript">
225225
{
226226
// Generate fictitious "data"
227-
const start = Temporal.now.instant().subtract({ hours: 24 });
227+
const start = Temporal.Now.instant().subtract({ hours: 24 });
228228
const blank = Array(24 * 12);
229229
const tankDataX = Array.from(blank, (_, ix) => start.add({ minutes: ix * 5 }));
230230
const tankDataY = Array.from(blank);
@@ -329,7 +329,7 @@ An example HTML form inspired by [Days Calculator](https://www.timeanddate.com/d
329329
// the example; see 'Calendar input element'
330330
const futureDatePicker = document.querySelector('input[name="futuredate"]');
331331
const browserCalendar = new Intl.DateTimeFormat().resolvedOptions().calendar;
332-
const today = Temporal.now.plainDate(browserCalendar);
332+
const today = Temporal.Now.plainDate(browserCalendar);
333333
futureDatePicker.min = today;
334334
futureDatePicker.value = today.add({ months: 1 });
335335

docs/cookbook/calendarInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
const datePicker = document.getElementById('calendar-input');
2-
const today = Temporal.now.plainDateISO();
2+
const today = Temporal.Now.plainDateISO();
33
datePicker.max = today;
44
datePicker.value = today;

docs/cookbook/futureDateForm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function englishPlural(n, singular, plural) {
1414
if (futuredateParam !== null) {
1515
const browserCalendar = new Intl.DateTimeFormat().resolvedOptions().calendar;
1616
const futureDate = Temporal.PlainDate.from(futuredateParam).withCalendar(browserCalendar);
17-
const today = Temporal.now.plainDate(browserCalendar);
17+
const today = Temporal.Now.plainDate(browserCalendar);
1818
const until = today.until(futureDate, { largestUnit: 'day' });
1919
const untilMonths = until.round({ largestUnit: 'month', relativeTo: today });
2020

docs/cookbook/getCurrentDate.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*
66
*/
77

8-
const date = Temporal.now.plainDateISO(); // Gets the current date
8+
const date = Temporal.Now.plainDateISO(); // Gets the current date
99
date.toString(); // returns the date in ISO 8601 date format
1010

1111
// If you additionally want the time:
12-
Temporal.now.plainDateTimeISO().toString(); // date and time in ISO 8601 format
12+
Temporal.Now.plainDateTimeISO().toString(); // date and time in ISO 8601 format

docs/cookbook/getElapsedDurationSinceInstant.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ assert.equal(`${result2}`, 'PT240M');
1010

1111
// Example of using it in a countdown:
1212

13-
const duration = Temporal.now.instant().until(Temporal.Instant.from('2020-04-01T13:00-07:00[America/Los_Angeles]'));
13+
const duration = Temporal.Now.instant().until(Temporal.Instant.from('2020-04-01T13:00-07:00[America/Los_Angeles]'));
1414
// Note that this does not work unless you have Intl.DurationFormat, which is
1515
// still an early-stage proposal.
1616
`It's ${duration.toLocaleString()} ${duration.sign < 0 ? 'until' : 'since'} the TC39 Temporal presentation`;

docs/cookbook/getTimeStamp.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
*/
77

8-
const timeStamp = Temporal.now.instant();
8+
const timeStamp = Temporal.Now.instant();
99

1010
// Timestamp in Milliseconds
1111
timeStamp.epochMilliseconds;

docs/cookbook/meetingPlanner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Display local time zone and three others
22
const browserCalendar = new Intl.DateTimeFormat().resolvedOptions().calendar;
3-
const now = Temporal.now.zonedDateTime(browserCalendar);
3+
const now = Temporal.Now.zonedDateTime(browserCalendar);
44
const timeZones = [
55
{ name: 'Here', tz: now.timeZone },
66
{ name: 'New York', tz: Temporal.TimeZone.from('America/New_York') },

0 commit comments

Comments
 (0)