You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-56Lines changed: 36 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,14 +163,11 @@ When dealing with Daylight Saving Time, and days when clocks are turned backward
163
163
164
164
By default, any ambiguous time is treated as the earlier time, the first occurrence of that time during a day. You can, however, use either an explicit UTC offset, or a subscript 2 (₂), to indicate the later time.
165
165
166
-
`ttime('11/7/2021 1:25 AM America/Denver', 'MM/DD/YYYY h:m a z').toString()` →<br>
167
-
`DateTime<2021-11-07T01:25:00.000 -06:00§>`
166
+
`ttime('11/7/2021 1:25 AM America/Denver', 'MM/DD/YYYY h:m a z').toString()` →<br>`DateTime<2021-11-07T01:25:00.000 -06:00§>`
168
167
169
-
`ttime('11/7/2021 1:25₂ AM America/Denver', 'MM/DD/YYYY h:m a z').toString()` →<br>
170
-
`DateTime<2021-11-07T01:25:00.000₂-07:00>`
168
+
`ttime('11/7/2021 1:25₂ AM America/Denver', 'MM/DD/YYYY h:m a z').toString()` →<br>`DateTime<2021-11-07T01:25:00.000₂-07:00>`
@@ -182,11 +179,9 @@ You can also produce more customized, flexible formatting, specifying the order,
182
179
183
180
For example:
184
181
185
-
`ttime().format('ddd MMM D, y N [at] h:mm A z')` →<br>
186
-
`Wed Feb 3, 2021 AD at 8:59 PM EST`
182
+
`ttime().format('ddd MMM D, y N [at] h:mm A z')` →<br>`Wed Feb 3, 2021 AD at 8:59 PM EST`
187
183
188
-
`ttime().toLocale('de').format('ddd MMM D, y N [at] h:mm A z')` →<br>
189
-
`Mi 02 3, 2021 n. Chr. at 9:43 PM GMT-5`
184
+
`ttime().toLocale('de').format('ddd MMM D, y N [at] h:mm A z')` →<br>`Mi 02 3, 2021 n. Chr. at 9:43 PM GMT-5`
190
185
191
186
Please note that most unaccented Latin letters (a-z, A-Z) are interpreted as special formatting characters, as well as the tilde (`~`), so when using those characters as literal text they should be surrounded with square brackets, as with the word “at” in the example above.
192
187
@@ -196,6 +191,12 @@ A few of the formatting tokens below can have an optional trailing tilde (`~`) a
196
191
197
192
For all other languages, `~` is replaced with a space character when the following character is a letter or digit, or simply removed when followed by punctuation or the end of the format string.
@@ -206,7 +207,7 @@ For all other languages, `~` is replaced with a space character when the followi
206
207
| Year | YYYYYY | -001970 -001971 ... +001907 +001971<br><br>Always-signed years, padded to six digits. |
207
208
|| YYYY <br>YYYY~| 1970 1971 ... 2029 2030<br><br>Padded to at least four digits. With `~`, `年` or `년` is added when needed for CJK locales, otherwise replaced by a space character or empty string. |
208
209
|| YY | 70 71 ... 29 30<br><br>Padded to two digits with leading zero if necessary. |
209
-
|| Y | 1970 1971 ... 9999 +10000 +10001<br><br>Padded to at least four digits, `+` sign shown when over 9999. |
210
+
|| Y <br>Y~| 1970 1971 ... 9999 +10000 +10001<br><br>Padded to at least four digits, `+` sign shown when over 9999. With `~`, `年` or `년` is added when needed for CJK locales, otherwise `~` is replaced by a space character or empty string. |
210
211
|| y <br>y~| 1 2 ... 2020 ...<br><br>Era year, for use with BC/AD, never 0 or negative. With `~`, `年` or `년` is added when needed for CJK locales, otherwise `~` is replaced by a space character or empty string. |
211
212
| Week year (ISO) | GGGG | 1970 1971 ... 2029 2030, `+` sign shown when over 9999. |
212
213
|| GG | 70 71 ... 29 30<br><br>Padded to two digits with leading zero if necessary. |
@@ -215,9 +216,9 @@ For all other languages, `~` is replaced with a space character when the followi
215
216
| Quarter | Qo | 1st 2nd 3rd 4th |
216
217
|| Q | 1 2 3 4 |
217
218
| Month | MMMM <br>MMMM~| January February ... November December<br>1月 2月 ... 11月 12月 • 一月 二月 ... 十一月 十二月 • 1월 2월 ... 11월 12월<br><br>For CJK locales, `月` or `월` is added when using either the `MMMM` and `MMMM~` token, but using `MMMM~` allows the position of the `~` to be replaced with a blank, when appropriate, for other languages. |
218
-
|| MMM | Jan Feb ... Nov Dec |
219
-
|| MM <br>MM~| 01 02 ... 11 12<br><br>With `~`, `月` or `월` is added when needed for CJK locales, otherwise `~` is replaced by a space character or empty string. |
220
-
|| M <br>M~| 1 2 ... 11 12<br><br>With `~`, `月` or `월` is added when needed for CJK locales, otherwise `~` is replaced by a space character or empty string. |
219
+
|| MMM <br>MMM~| Jan Feb ... Nov Dec<br>1月 2月 ... 11月 12月 • 1월 2월 ... 11월 12월<br><br>With `~`, `月` or `월` is added when needed for CJK locales, otherwise `~` is replaced by a space character or empty string.|
220
+
|| MM <br>MM~| 01 02 ... 11 12<br>01月 02月 ... 11月 12月 • 01월 02월 ... 11월 12월<br><br>With `~`, `月` or `월` is added when needed for CJK locales, otherwise `~` is replaced by a space character or empty string. |
221
+
|| M <br>M~| 1 2 ... 11 12<br>1月 2月 ... 11月 12月 • 1월 2월 ... 11월 12월<br><br>With `~`, `月` or `월` is added when needed for CJK locales, otherwise `~` is replaced by a space character or empty string. |
Please note that if you pass a second argument of `true`, the timezone is changed, _but the wall time stays the same._ This same option to preserve wall time is available for the `utc()` and `local()` methods, where the optional boolean value will be the one and only argument.
`// Local zone is America/New_York`<br>`ttime('2005-10-10 16:30 America/Los_Angeles').local().toString()` →<br>`DateTime<2005-10-10T19:30:00.000 +04:00>`
362
357
363
358
## Converting locales
364
359
365
-
`ttime('7. helmikuuta 2021', 'IL', 'fi').toLocale('de').format('IL')` →<br>
366
-
`7. Februar 2021`
360
+
`ttime('7. helmikuuta 2021', 'IL', 'fi').toLocale('de').format('IL')` →<br>`7. Februar 2021`
367
361
368
362
## Defining and updating timezones
369
363
@@ -586,21 +580,18 @@ For fields `MILLI` through `HOUR`, fixed units of time, multiplied by the `amoun
Even with the default behavior, however, it is still possible for hours and minutes to change, in just the same way adding one month to January 31 does not yield February 31. When clocks are turned forward, some times of day simply do not exist, so a result might have to be adjusted to a valid hour and minute in some cases.
Here’s a skyviewcafe.com image for that extra-long day in the Marshall Islands, with two sunrises, two sunsets, and 24 hours, 6 minutes worth of daylight packed into a 47-hour day:
927
908
@@ -1047,8 +1028,7 @@ As a string, `initialTime` can also include a trailing timezone or UTC offset, u
1047
1028
1048
1029
If the `timezone` argument is itself `null` or unspecified, this embedded timezone will become the timezone for the `DateTime` instance. If the `timezone` argument is also provided, the time will be parsed according to the first timezone, then it will be transformed to the second timezone.
`new DateTime('2022-06-01 14:30 America/Chicago', 'Europe/Paris', 'fr_FR').format('IMM ZZZ')` →<br>`1 juin 2022 à 21:30:00 Europe/Paris`
1052
1032
1053
1033
The following is an example of using the `gregorianChange` parameter to apply the change from the Julian to Gregorian calendar that was used by Great Britain, including what were the American colonies at the time:
0 commit comments