Skip to content

Commit 2719386

Browse files
justin-schroederWilcoSpToru-Takagi
authored
chore: release 0.1.0 (#53)
* feat: diff functions * differenceInMilliseconds * created the other constant difference functions, but will need to add the option 'ignoreTime' for day/week version * created the other constant difference functions * completing tests * adding differenceInX exports in index * make sure that rounding doesn't give -0 * added difference In Months & years * shortened the all difference functions to diffX moved using monthDays at diffMonths after `if (ld < rd)` * raname type DifferenceRoundingMethod -> DiffRoundingMethod * docs: adds diffs to docs * chore: bumps tests to latest actions * feat: existing "Z" token is now "ZZ" adds "Z" token style (#52) * Support for the timezone token "ZZ" and changing the timezone format style. * Fix timezone offset parsing and applyOffset function * chore: adjusts time format < full to be ZZ --------- Co-authored-by: WilcoSp <17604138+WilcoSp@users.noreply.github.com> Co-authored-by: Kouta Motegi <toru.takagi.engineer@gmail.com>
1 parent c1fd5ab commit 2719386

39 files changed

+898
-178
lines changed

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111
permissions:
1212
contents: write
1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515
with:
1616
fetch-depth: 0
1717

18-
- uses: actions/setup-node@v3
18+
- uses: actions/setup-node@v4
1919
with:
2020
node-version: lts/*
2121

.github/workflows/tests.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ jobs:
44
vitest-run:
55
runs-on: ubuntu-latest
66
steps:
7-
- uses: actions/checkout@v3
8-
- uses: pnpm/action-setup@v2
9-
with:
10-
version: 8
7+
- uses: actions/checkout@v4
8+
- run: corepack enable
119
- run: pnpm install
1210
- run: pnpm test

docs/components/content/Format.vue

+124-84
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,25 @@ import sizes from "../../assets/func-sizes.json"
1313
/>
1414
</div>
1515

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+
/>
3035
<p>Tempo’s <code>format()</code> function outputs dates in two ways:</p>
3136
<ul class="jump-list">
3237
<li>
@@ -83,11 +88,14 @@ import sizes from "../../assets/func-sizes.json"
8388
</td>
8489
<td>
8590
<code>en</code>
86-
<ClientOnly>{{ format(new Date(), "full", "en") }}</ClientOnly><br />
91+
<ClientOnly>{{ format(new Date(), "full", "en") }}</ClientOnly
92+
><br />
8793
<code>de</code>
88-
<ClientOnly>{{ format(new Date(), "full", "de") }}</ClientOnly><br />
94+
<ClientOnly>{{ format(new Date(), "full", "de") }}</ClientOnly
95+
><br />
8996
<code>zh</code>
90-
<ClientOnly>{{ format(new Date(), "full", "zh") }}</ClientOnly><br />
97+
<ClientOnly>{{ format(new Date(), "full", "zh") }}</ClientOnly
98+
><br />
9199
</td>
92100
</tr>
93101
<tr>
@@ -96,11 +104,14 @@ import sizes from "../../assets/func-sizes.json"
96104
</td>
97105
<td>
98106
<code>en</code>
99-
<ClientOnly>{{ format(new Date(), "long", "en") }}</ClientOnly><br />
107+
<ClientOnly>{{ format(new Date(), "long", "en") }}</ClientOnly
108+
><br />
100109
<code>de</code>
101-
<ClientOnly>{{ format(new Date(), "long", "de") }}</ClientOnly><br />
110+
<ClientOnly>{{ format(new Date(), "long", "de") }}</ClientOnly
111+
><br />
102112
<code>zh</code>
103-
<ClientOnly>{{ format(new Date(), "long", "zh") }}</ClientOnly><br />
113+
<ClientOnly>{{ format(new Date(), "long", "zh") }}</ClientOnly
114+
><br />
104115
</td>
105116
</tr>
106117
<tr>
@@ -109,11 +120,14 @@ import sizes from "../../assets/func-sizes.json"
109120
</td>
110121
<td>
111122
<code>en</code>
112-
<ClientOnly>{{ format(new Date(), "medium", "en") }}</ClientOnly><br />
123+
<ClientOnly>{{ format(new Date(), "medium", "en") }}</ClientOnly
124+
><br />
113125
<code>de</code>
114-
<ClientOnly>{{ format(new Date(), "medium", "de") }}</ClientOnly><br />
126+
<ClientOnly>{{ format(new Date(), "medium", "de") }}</ClientOnly
127+
><br />
115128
<code>zh</code>
116-
<ClientOnly>{{ format(new Date(), "medium", "zh") }}</ClientOnly><br />
129+
<ClientOnly>{{ format(new Date(), "medium", "zh") }}</ClientOnly
130+
><br />
117131
</td>
118132
</tr>
119133
<tr>
@@ -122,11 +136,14 @@ import sizes from "../../assets/func-sizes.json"
122136
</td>
123137
<td>
124138
<code>en</code>
125-
<ClientOnly>{{ format(new Date(), "short", "en") }}</ClientOnly><br />
139+
<ClientOnly>{{ format(new Date(), "short", "en") }}</ClientOnly
140+
><br />
126141
<code>de</code>
127-
<ClientOnly>{{ format(new Date(), "short", "de") }}</ClientOnly><br />
142+
<ClientOnly>{{ format(new Date(), "short", "de") }}</ClientOnly
143+
><br />
128144
<code>zh</code>
129-
<ClientOnly>{{ format(new Date(), "short", "zh") }}</ClientOnly><br />
145+
<ClientOnly>{{ format(new Date(), "short", "zh") }}</ClientOnly
146+
><br />
130147
</td>
131148
</tr>
132149
</tbody>
@@ -155,15 +172,18 @@ import sizes from "../../assets/func-sizes.json"
155172
<code>en</code>
156173
<ClientOnly>{{
157174
format(new Date(), { time: "full" }, "en")
158-
}}</ClientOnly><br />
175+
}}</ClientOnly
176+
><br />
159177
<code>de</code>
160178
<ClientOnly>{{
161179
format(new Date(), { time: "full" }, "de")
162-
}}</ClientOnly><br />
180+
}}</ClientOnly
181+
><br />
163182
<code>zh</code>
164183
<ClientOnly>{{
165184
format(new Date(), { time: "full" }, "zh")
166-
}}</ClientOnly><br />
185+
}}</ClientOnly
186+
><br />
167187
</td>
168188
</tr>
169189
<tr>
@@ -174,15 +194,18 @@ import sizes from "../../assets/func-sizes.json"
174194
<code>en</code>
175195
<ClientOnly>{{
176196
format(new Date(), { time: "long" }, "en")
177-
}}</ClientOnly><br />
197+
}}</ClientOnly
198+
><br />
178199
<code>de</code>
179200
<ClientOnly>{{
180201
format(new Date(), { time: "long" }, "de")
181-
}}</ClientOnly><br />
202+
}}</ClientOnly
203+
><br />
182204
<code>zh</code>
183205
<ClientOnly>{{
184206
format(new Date(), { time: "long" }, "zh")
185-
}}</ClientOnly><br />
207+
}}</ClientOnly
208+
><br />
186209
</td>
187210
</tr>
188211
<tr>
@@ -193,15 +216,18 @@ import sizes from "../../assets/func-sizes.json"
193216
<code>en</code>
194217
<ClientOnly>{{
195218
format(new Date(), { time: "medium" }, "en")
196-
}}</ClientOnly><br />
219+
}}</ClientOnly
220+
><br />
197221
<code>de</code>
198222
<ClientOnly>{{
199223
format(new Date(), { time: "medium" }, "de")
200-
}}</ClientOnly><br />
224+
}}</ClientOnly
225+
><br />
201226
<code>zh</code>
202227
<ClientOnly>{{
203228
format(new Date(), { time: "medium" }, "zh")
204-
}}</ClientOnly><br />
229+
}}</ClientOnly
230+
><br />
205231
</td>
206232
</tr>
207233
<tr>
@@ -212,15 +238,18 @@ import sizes from "../../assets/func-sizes.json"
212238
<code>en</code>
213239
<ClientOnly>{{
214240
format(new Date(), { time: "short" }, "en")
215-
}}</ClientOnly><br />
241+
}}</ClientOnly
242+
><br />
216243
<code>de</code>
217244
<ClientOnly>{{
218245
format(new Date(), { time: "short" }, "de")
219-
}}</ClientOnly><br />
246+
}}</ClientOnly
247+
><br />
220248
<code>zh</code>
221249
<ClientOnly>{{
222250
format(new Date(), { time: "short" }, "zh")
223-
}}</ClientOnly><br />
251+
}}</ClientOnly
252+
><br />
224253
</td>
225254
</tr>
226255
</tbody>
@@ -351,8 +380,13 @@ import sizes from "../../assets/func-sizes.json"
351380
</tr>
352381
<tr>
353382
<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>
354388
<td>+0800, +0530, -1345</td>
355-
<td>The timezone offset from GMT</td>
389+
<td>The timezone offset from GMT (<code>[+-]HHmm</code>)</td>
356390
</tr>
357391
</tbody>
358392
</table>
@@ -362,50 +396,53 @@ import sizes from "../../assets/func-sizes.json"
362396
The <code>format()</code> function can accept an object of options as its
363397
argument to provide more control over the output.
364398
</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+
/>
409446
<h3 id="format-timezone">Timezone</h3>
410447
<p>
411448
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"
415452
<h3 id="format-part-filter">Part filter</h3>
416453
<p>
417454
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+
>
419459
of the formatted date. The function is called with each "part" of the
420460
formatted date and should return a boolean indicating whether or not to
421461
include that part in final formatted string.

0 commit comments

Comments
 (0)