diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index d1f0760..f784f06 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -11,11 +11,11 @@ jobs:
permissions:
contents: write
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: 0
- - uses: actions/setup-node@v3
+ - uses: actions/setup-node@v4
with:
node-version: lts/*
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 49f24f9..42c22c5 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -4,9 +4,7 @@ jobs:
vitest-run:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
- - uses: pnpm/action-setup@v2
- with:
- version: 8
+ - uses: actions/checkout@v4
+ - run: corepack enable
- run: pnpm install
- run: pnpm test
diff --git a/.size-limit.cjs b/.size-limit.cjs
index d87b432..7b53e82 100644
--- a/.size-limit.cjs
+++ b/.size-limit.cjs
@@ -14,6 +14,6 @@ module.exports = [
{ path, limit: "2.9 kb", import: "{ format }", name: "format" },
{ path, limit: "4.3 kb", import: "{ parse }", name: "parse" },
- { path, limit: "5.1 kb", import: "*", name: "all esm" },
- { path: "./dist/index.cjs", limit: "5.4 kb", import: "*", name: "all cjs" },
+ { path, limit: "5.2 kb", import: "*", name: "all esm" },
+ { path: "./dist/index.cjs", limit: "5.5 kb", import: "*", name: "all cjs" },
]
diff --git a/README.md b/README.md
index c5abc74..b4712b4 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ Tempo is a new library in a proud tradition of JavaScript date and time librarie
Tempo is best thought of as a collection of utilities for working with `Date` objects — an important distinction from other libraries that provide custom date primitives. Under the hood, Tempo mines JavaScript's `Intl.DateTimeFormat` to extract complex data like timezones offsets and locale aware date formats giving you a simple API to format, parse, and manipulates dates.
-Tempo is tiny tree-shakable framework, you can only take what you need. All functionality is available in **5.1 kB for esm** and **5.4 kB for cjs** modules (minified and brotlied). [Size Limit](https://github.com/ai/size-limit) controls the size.
+Tempo is tiny tree-shakable framework, you can only take what you need. All functionality is available in **5.2 kB for esm** and **5.5 kB for cjs** modules (minified and brotlied). [Size Limit](https://github.com/ai/size-limit) controls the size.
diff --git a/docs/assets/func-sizes.json b/docs/assets/func-sizes.json
new file mode 100644
index 0000000..3931bb7
--- /dev/null
+++ b/docs/assets/func-sizes.json
@@ -0,0 +1,454 @@
+{
+ "addDay": {
+ "esm": {
+ "size": 326,
+ "formattedSize": "326 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "addHour": {
+ "esm": {
+ "size": 331,
+ "formattedSize": "331 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "addMinute": {
+ "esm": {
+ "size": 330,
+ "formattedSize": "330 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "addMonth": {
+ "esm": {
+ "size": 394,
+ "formattedSize": "394 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "addSecond": {
+ "esm": {
+ "size": 329,
+ "formattedSize": "329 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "addYear": {
+ "esm": {
+ "size": 407,
+ "formattedSize": "407 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "ap": {
+ "esm": {
+ "size": 279,
+ "formattedSize": "279 B"
+ },
+ "cjs": {
+ "size": 5452,
+ "formattedSize": "5.45 kB"
+ }
+ },
+ "applyOffset": {
+ "esm": {
+ "size": 428,
+ "formattedSize": "428 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "date": {
+ "esm": {
+ "size": 304,
+ "formattedSize": "304 B"
+ },
+ "cjs": {
+ "size": 5451,
+ "formattedSize": "5.45 kB"
+ }
+ },
+ "dayEnd": {
+ "esm": {
+ "size": 324,
+ "formattedSize": "324 B"
+ },
+ "cjs": {
+ "size": 5457,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "dayOfYear": {
+ "esm": {
+ "size": 354,
+ "formattedSize": "354 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "dayStart": {
+ "esm": {
+ "size": 319,
+ "formattedSize": "319 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "format": {
+ "esm": {
+ "size": 2864,
+ "formattedSize": "2.86 kB"
+ },
+ "cjs": {
+ "size": 5452,
+ "formattedSize": "5.45 kB"
+ }
+ },
+ "formatStr": {
+ "esm": {
+ "size": 1609,
+ "formattedSize": "1.61 kB"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "fourDigitYear": {
+ "esm": {
+ "size": 79,
+ "formattedSize": "79 B"
+ },
+ "cjs": {
+ "size": 5457,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "hourEnd": {
+ "esm": {
+ "size": 323,
+ "formattedSize": "323 B"
+ },
+ "cjs": {
+ "size": 5457,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "hourStart": {
+ "esm": {
+ "size": 318,
+ "formattedSize": "318 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "isAfter": {
+ "esm": {
+ "size": 323,
+ "formattedSize": "323 B"
+ },
+ "cjs": {
+ "size": 5457,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "isBefore": {
+ "esm": {
+ "size": 323,
+ "formattedSize": "323 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "isEqual": {
+ "esm": {
+ "size": 324,
+ "formattedSize": "324 B"
+ },
+ "cjs": {
+ "size": 5457,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "iso8601": {
+ "esm": {
+ "size": 168,
+ "formattedSize": "168 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "minuteEnd": {
+ "esm": {
+ "size": 321,
+ "formattedSize": "321 B"
+ },
+ "cjs": {
+ "size": 5457,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "minuteStart": {
+ "esm": {
+ "size": 316,
+ "formattedSize": "316 B"
+ },
+ "cjs": {
+ "size": 5457,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "monthDays": {
+ "esm": {
+ "size": 345,
+ "formattedSize": "345 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "monthEnd": {
+ "esm": {
+ "size": 330,
+ "formattedSize": "330 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "monthStart": {
+ "esm": {
+ "size": 326,
+ "formattedSize": "326 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "nearestDay": {
+ "esm": {
+ "size": 566,
+ "formattedSize": "566 B"
+ },
+ "cjs": {
+ "size": 5457,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "offset": {
+ "esm": {
+ "size": 666,
+ "formattedSize": "666 B"
+ },
+ "cjs": {
+ "size": 5453,
+ "formattedSize": "5.45 kB"
+ }
+ },
+ "parse": {
+ "esm": {
+ "size": 4308,
+ "formattedSize": "4.31 kB"
+ },
+ "cjs": {
+ "size": 5455,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "parseParts": {
+ "esm": {
+ "size": 370,
+ "formattedSize": "370 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "parts": {
+ "esm": {
+ "size": 1503,
+ "formattedSize": "1.5 kB"
+ },
+ "cjs": {
+ "size": 5452,
+ "formattedSize": "5.45 kB"
+ }
+ },
+ "range": {
+ "esm": {
+ "size": 3175,
+ "formattedSize": "3.17 kB"
+ },
+ "cjs": {
+ "size": 5453,
+ "formattedSize": "5.45 kB"
+ }
+ },
+ "removeOffset": {
+ "esm": {
+ "size": 460,
+ "formattedSize": "460 B"
+ },
+ "cjs": {
+ "size": 5458,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "sameDay": {
+ "esm": {
+ "size": 348,
+ "formattedSize": "348 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "sameHour": {
+ "esm": {
+ "size": 332,
+ "formattedSize": "332 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "sameMinute": {
+ "esm": {
+ "size": 333,
+ "formattedSize": "333 B"
+ },
+ "cjs": {
+ "size": 5457,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "sameSecond": {
+ "esm": {
+ "size": 332,
+ "formattedSize": "332 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "sameYear": {
+ "esm": {
+ "size": 336,
+ "formattedSize": "336 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "tzDate": {
+ "esm": {
+ "size": 806,
+ "formattedSize": "806 B"
+ },
+ "cjs": {
+ "size": 5457,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "weekEnd": {
+ "esm": {
+ "size": 379,
+ "formattedSize": "379 B"
+ },
+ "cjs": {
+ "size": 5457,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "weekStart": {
+ "esm": {
+ "size": 359,
+ "formattedSize": "359 B"
+ },
+ "cjs": {
+ "size": 5457,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "yearDays": {
+ "esm": {
+ "size": 342,
+ "formattedSize": "342 B"
+ },
+ "cjs": {
+ "size": 5456,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "yearEnd": {
+ "esm": {
+ "size": 337,
+ "formattedSize": "337 B"
+ },
+ "cjs": {
+ "size": 5457,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "yearStart": {
+ "esm": {
+ "size": 332,
+ "formattedSize": "332 B"
+ },
+ "cjs": {
+ "size": 5457,
+ "formattedSize": "5.46 kB"
+ }
+ },
+ "all esm": {
+ "esm": {
+ "size": 5153,
+ "formattedSize": "5.15 kB"
+ }
+ },
+ "all cjs": {
+ "cjs": {
+ "size": 5451,
+ "formattedSize": "5.45 kB"
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/components/GithubLinkAndSize.vue b/docs/components/GithubLinkAndSize.vue
new file mode 100644
index 0000000..0c91a03
--- /dev/null
+++ b/docs/components/GithubLinkAndSize.vue
@@ -0,0 +1,24 @@
+
+
+
+ Tempo’s format()
function outputs dates in two ways:
en
-
+
de
-
+
zh
-
+
@@ -88,11 +104,14 @@ import { format } from "@formkit/tempo"
en
-
+
de
-
+
zh
-
+
@@ -101,11 +120,14 @@ import { format } from "@formkit/tempo"
en
-
+
de
-
+
zh
-
+
@@ -114,11 +136,14 @@ import { format } from "@formkit/tempo"
@@ -147,15 +172,18 @@ import { format } from "@formkit/tempo"
en
-
+
de
-
+
zh
-
+
en
+ }}
de
+ }}
zh
+ }}
@@ -166,15 +194,18 @@ import { format } from "@formkit/tempo"
en
+ }}
de
+ }}
zh
+ }}
@@ -185,15 +216,18 @@ import { format } from "@formkit/tempo"
en
+ }}
de
+ }}
zh
+ }}
@@ -204,15 +238,18 @@ import { format } from "@formkit/tempo"
@@ -343,8 +380,13 @@ import { format } from "@formkit/tempo"
en
+ }}
de
+ }}
zh
+ }}
+
+ Z
+08:00, +05:30, -13:45
+ The timezone offset from GMT (
+ [+-]HH:mm
)
+
@@ -354,50 +396,53 @@ import { format } from "@formkit/tempo"
The ZZ
+0800, +0530, -1345
- The timezone offset from GMT
+ The timezone offset from GMT (
[+-]HHmm
)format()
function can accept an object of options as its
argument to provide more control over the output.
The tz
option allows you to format the provided date from the
@@ -407,7 +452,10 @@ import { format } from "@formkit/tempo"
The partFilter
option allows you to filter out
- parts
+ parts
of the formatted date. The function is called with each "part" of the
formatted date and should return a boolean indicating whether or not to
include that part in final formatted string.
diff --git a/docs/components/content/Helpers.vue b/docs/components/content/Helpers.vue
index 0253501..9814fbb 100644
--- a/docs/components/content/Helpers.vue
+++ b/docs/components/content/Helpers.vue
@@ -1,5 +1,7 @@
@@ -141,12 +292,25 @@ const fns: Record<
Tempo includes a number of (tree-shakable) helper functions to assist you - in your date workarounds. These functions all accept either an ISO - 8601 string or a Date object and return a boolean. + in your date workarounds. These functions all accept either an ISO 8601 + string or a Date object and return a boolean.
Tempo is a new library in a proud tradition of JavaScript date and time libraries. Inspired by the likes of moment.js, day.js, and date-fns, Tempo - is built from the ground up to be as small and easy to use as possible — - including first-class support for timezone operations. + is built from the ground up to be as small and easy to use as possible + (all features ~5kB compressed) — including first-class support for + timezone operations.
Tempo is best thought of as a collection of utilities for working with the diff --git a/docs/components/content/Modify.vue b/docs/components/content/Modify.vue index 0f63939..f88b205 100644 --- a/docs/components/content/Modify.vue +++ b/docs/components/content/Modify.vue @@ -1,5 +1,7 @@