@@ -13,20 +13,25 @@ import sizes from "../../assets/func-sizes.json"
13
13
/>
14
14
</div >
15
15
16
- <FunctionReference function =" format" :arguments =" [
17
- {
18
- name: 'date',
19
- type: 'Date | string',
20
- comment: 'strings must be ISO 8601',
21
- },
22
- { name: 'format', type: 'string | object' },
23
- { name: 'locale?', type: 'string' },
24
- ]" :overload =" [
25
- {
26
- name: 'options',
27
- type: 'FormatOptions',
28
- },
29
- ]" return =" string" />
16
+ <FunctionReference
17
+ function =" format"
18
+ :arguments =" [
19
+ {
20
+ name: 'date',
21
+ type: 'Date | string',
22
+ comment: 'strings must be ISO 8601',
23
+ },
24
+ { name: 'format', type: 'string | object' },
25
+ { name: 'locale?', type: 'string' },
26
+ ]"
27
+ :overload =" [
28
+ {
29
+ name: 'options',
30
+ type: 'FormatOptions',
31
+ },
32
+ ]"
33
+ return =" string"
34
+ />
30
35
<p >Tempo’s <code >format()</code > function outputs dates in two ways:</p >
31
36
<ul class =" jump-list" >
32
37
<li >
@@ -83,11 +88,14 @@ import sizes from "../../assets/func-sizes.json"
83
88
</td >
84
89
<td >
85
90
<code >en</code >
86
- <ClientOnly >{{ format(new Date(), "full", "en") }}</ClientOnly ><br />
91
+ <ClientOnly >{{ format(new Date(), "full", "en") }}</ClientOnly
92
+ ><br />
87
93
<code >de</code >
88
- <ClientOnly >{{ format(new Date(), "full", "de") }}</ClientOnly ><br />
94
+ <ClientOnly >{{ format(new Date(), "full", "de") }}</ClientOnly
95
+ ><br />
89
96
<code >zh</code >
90
- <ClientOnly >{{ format(new Date(), "full", "zh") }}</ClientOnly ><br />
97
+ <ClientOnly >{{ format(new Date(), "full", "zh") }}</ClientOnly
98
+ ><br />
91
99
</td >
92
100
</tr >
93
101
<tr >
@@ -96,11 +104,14 @@ import sizes from "../../assets/func-sizes.json"
96
104
</td >
97
105
<td >
98
106
<code >en</code >
99
- <ClientOnly >{{ format(new Date(), "long", "en") }}</ClientOnly ><br />
107
+ <ClientOnly >{{ format(new Date(), "long", "en") }}</ClientOnly
108
+ ><br />
100
109
<code >de</code >
101
- <ClientOnly >{{ format(new Date(), "long", "de") }}</ClientOnly ><br />
110
+ <ClientOnly >{{ format(new Date(), "long", "de") }}</ClientOnly
111
+ ><br />
102
112
<code >zh</code >
103
- <ClientOnly >{{ format(new Date(), "long", "zh") }}</ClientOnly ><br />
113
+ <ClientOnly >{{ format(new Date(), "long", "zh") }}</ClientOnly
114
+ ><br />
104
115
</td >
105
116
</tr >
106
117
<tr >
@@ -109,11 +120,14 @@ import sizes from "../../assets/func-sizes.json"
109
120
</td >
110
121
<td >
111
122
<code >en</code >
112
- <ClientOnly >{{ format(new Date(), "medium", "en") }}</ClientOnly ><br />
123
+ <ClientOnly >{{ format(new Date(), "medium", "en") }}</ClientOnly
124
+ ><br />
113
125
<code >de</code >
114
- <ClientOnly >{{ format(new Date(), "medium", "de") }}</ClientOnly ><br />
126
+ <ClientOnly >{{ format(new Date(), "medium", "de") }}</ClientOnly
127
+ ><br />
115
128
<code >zh</code >
116
- <ClientOnly >{{ format(new Date(), "medium", "zh") }}</ClientOnly ><br />
129
+ <ClientOnly >{{ format(new Date(), "medium", "zh") }}</ClientOnly
130
+ ><br />
117
131
</td >
118
132
</tr >
119
133
<tr >
@@ -122,11 +136,14 @@ import sizes from "../../assets/func-sizes.json"
122
136
</td >
123
137
<td >
124
138
<code >en</code >
125
- <ClientOnly >{{ format(new Date(), "short", "en") }}</ClientOnly ><br />
139
+ <ClientOnly >{{ format(new Date(), "short", "en") }}</ClientOnly
140
+ ><br />
126
141
<code >de</code >
127
- <ClientOnly >{{ format(new Date(), "short", "de") }}</ClientOnly ><br />
142
+ <ClientOnly >{{ format(new Date(), "short", "de") }}</ClientOnly
143
+ ><br />
128
144
<code >zh</code >
129
- <ClientOnly >{{ format(new Date(), "short", "zh") }}</ClientOnly ><br />
145
+ <ClientOnly >{{ format(new Date(), "short", "zh") }}</ClientOnly
146
+ ><br />
130
147
</td >
131
148
</tr >
132
149
</tbody >
@@ -155,15 +172,18 @@ import sizes from "../../assets/func-sizes.json"
155
172
<code >en</code >
156
173
<ClientOnly >{{
157
174
format(new Date(), { time: "full" }, "en")
158
- }}</ClientOnly ><br />
175
+ }}</ClientOnly
176
+ ><br />
159
177
<code >de</code >
160
178
<ClientOnly >{{
161
179
format(new Date(), { time: "full" }, "de")
162
- }}</ClientOnly ><br />
180
+ }}</ClientOnly
181
+ ><br />
163
182
<code >zh</code >
164
183
<ClientOnly >{{
165
184
format(new Date(), { time: "full" }, "zh")
166
- }}</ClientOnly ><br />
185
+ }}</ClientOnly
186
+ ><br />
167
187
</td >
168
188
</tr >
169
189
<tr >
@@ -174,15 +194,18 @@ import sizes from "../../assets/func-sizes.json"
174
194
<code >en</code >
175
195
<ClientOnly >{{
176
196
format(new Date(), { time: "long" }, "en")
177
- }}</ClientOnly ><br />
197
+ }}</ClientOnly
198
+ ><br />
178
199
<code >de</code >
179
200
<ClientOnly >{{
180
201
format(new Date(), { time: "long" }, "de")
181
- }}</ClientOnly ><br />
202
+ }}</ClientOnly
203
+ ><br />
182
204
<code >zh</code >
183
205
<ClientOnly >{{
184
206
format(new Date(), { time: "long" }, "zh")
185
- }}</ClientOnly ><br />
207
+ }}</ClientOnly
208
+ ><br />
186
209
</td >
187
210
</tr >
188
211
<tr >
@@ -193,15 +216,18 @@ import sizes from "../../assets/func-sizes.json"
193
216
<code >en</code >
194
217
<ClientOnly >{{
195
218
format(new Date(), { time: "medium" }, "en")
196
- }}</ClientOnly ><br />
219
+ }}</ClientOnly
220
+ ><br />
197
221
<code >de</code >
198
222
<ClientOnly >{{
199
223
format(new Date(), { time: "medium" }, "de")
200
- }}</ClientOnly ><br />
224
+ }}</ClientOnly
225
+ ><br />
201
226
<code >zh</code >
202
227
<ClientOnly >{{
203
228
format(new Date(), { time: "medium" }, "zh")
204
- }}</ClientOnly ><br />
229
+ }}</ClientOnly
230
+ ><br />
205
231
</td >
206
232
</tr >
207
233
<tr >
@@ -212,15 +238,18 @@ import sizes from "../../assets/func-sizes.json"
212
238
<code >en</code >
213
239
<ClientOnly >{{
214
240
format(new Date(), { time: "short" }, "en")
215
- }}</ClientOnly ><br />
241
+ }}</ClientOnly
242
+ ><br />
216
243
<code >de</code >
217
244
<ClientOnly >{{
218
245
format(new Date(), { time: "short" }, "de")
219
- }}</ClientOnly ><br />
246
+ }}</ClientOnly
247
+ ><br />
220
248
<code >zh</code >
221
249
<ClientOnly >{{
222
250
format(new Date(), { time: "short" }, "zh")
223
- }}</ClientOnly ><br />
251
+ }}</ClientOnly
252
+ ><br />
224
253
</td >
225
254
</tr >
226
255
</tbody >
@@ -351,8 +380,13 @@ import sizes from "../../assets/func-sizes.json"
351
380
</tr >
352
381
<tr >
353
382
<td ><code >Z</code ></td >
383
+ <td >+08:00, +05:30, -13:45</td >
384
+ <td >The timezone offset from GMT (<code >[+-]HH:mm</code >)</td >
385
+ </tr >
386
+ <tr >
387
+ <td ><code >ZZ</code ></td >
354
388
<td >+0800, +0530, -1345</td >
355
- <td >The timezone offset from GMT</td >
389
+ <td >The timezone offset from GMT (< code >[+-]HHmm</ code >) </td >
356
390
</tr >
357
391
</tbody >
358
392
</table >
@@ -362,50 +396,53 @@ import sizes from "../../assets/func-sizes.json"
362
396
The <code >format()</code > function can accept an object of options as its
363
397
argument to provide more control over the output.
364
398
</p >
365
- <ObjectReference type =" FormatOptions" :properties =" [
366
- {
367
- name: 'date',
368
- type: 'string | Date',
369
- jsdoc: ['An ISO 8601 date string or a Date object.'],
370
- },
371
- {
372
- name: 'format',
373
- type: 'string | { date?: string, time?: string }',
374
- jsdoc: ['The format can be either format styles or format tokens.'],
375
- },
376
- {
377
- name: 'locale?',
378
- type: 'string',
379
- jsdoc: ['The locale to use when formatting.'],
380
- },
381
- {
382
- name: 'tz?',
383
- type: 'string',
384
- jsdoc: [
385
- 'Converts the given date option to the timezone provided.',
386
- 'For example, if the provided date option is 2021-01-01T00:00:00Z',
387
- 'and the tz option is America/New_York and the format option is',
388
- 'YYYY-MM-DD HH:mm:ss, the output will be 2020-12-31 19:00:00',
389
- ],
390
- },
391
- {
392
- name: 'genitive?',
393
- type: 'boolean',
394
- jsdoc: [
395
- 'When true, the month and weekday names will be in the',
396
- 'genitive case for locales where it is applicable.',
397
- ],
398
- },
399
- {
400
- name: 'partFilter?',
401
- type: '(part: Part) => boolean',
402
- jsdoc: [
403
- 'A function that filters the parts of the formatted date.',
404
- 'The function is called with each part of the formatted date',
405
- 'and should return true to include the part in the output.',
406
- ],
407
- },
408
- ]" />
399
+ <ObjectReference
400
+ type =" FormatOptions"
401
+ :properties =" [
402
+ {
403
+ name: 'date',
404
+ type: 'string | Date',
405
+ jsdoc: ['An ISO 8601 date string or a Date object.'],
406
+ },
407
+ {
408
+ name: 'format',
409
+ type: 'string | { date?: string, time?: string }',
410
+ jsdoc: ['The format can be either format styles or format tokens.'],
411
+ },
412
+ {
413
+ name: 'locale?',
414
+ type: 'string',
415
+ jsdoc: ['The locale to use when formatting.'],
416
+ },
417
+ {
418
+ name: 'tz?',
419
+ type: 'string',
420
+ jsdoc: [
421
+ 'Converts the given date option to the timezone provided.',
422
+ 'For example, if the provided date option is 2021-01-01T00:00:00Z',
423
+ 'and the tz option is America/New_York and the format option is',
424
+ 'YYYY-MM-DD HH:mm:ss, the output will be 2020-12-31 19:00:00',
425
+ ],
426
+ },
427
+ {
428
+ name: 'genitive?',
429
+ type: 'boolean',
430
+ jsdoc: [
431
+ 'When true, the month and weekday names will be in the',
432
+ 'genitive case for locales where it is applicable.',
433
+ ],
434
+ },
435
+ {
436
+ name: 'partFilter?',
437
+ type: '(part: Part) => boolean',
438
+ jsdoc: [
439
+ 'A function that filters the parts of the formatted date.',
440
+ 'The function is called with each part of the formatted date',
441
+ 'and should return true to include the part in the output.',
442
+ ],
443
+ },
444
+ ]"
445
+ />
409
446
<h3 id =" format-timezone" >Timezone</h3 >
410
447
<p >
411
448
The <code >tz</code > option allows you to format the provided date from the
@@ -415,7 +452,10 @@ import sizes from "../../assets/func-sizes.json"
415
452
<h3 id =" format-part-filter" >Part filter</h3 >
416
453
<p >
417
454
The <code >partFilter</code > option allows you to filter out
418
- <a href =" https://tc39.es/ecma402/#table-datetimeformat-resolvedoptions-properties" >parts</a >
455
+ <a
456
+ href =" https://tc39.es/ecma402/#table-datetimeformat-resolvedoptions-properties"
457
+ >parts</a
458
+ >
419
459
of the formatted date. The function is called with each "part" of the
420
460
formatted date and should return a boolean indicating whether or not to
421
461
include that part in final formatted string.
0 commit comments