datetick 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Andreas Nicolaou
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,118 @@
1
+ <h1 align="center">DateTick</h1>
2
+
3
+ <p align="center">Tiny, <b>immutable</b>, fully <b>timezone-aware</b> date toolkit for JavaScript &amp; TypeScript — with the same ergonomic, chainable API you already know.</p>
4
+
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/package/datetick"><img src="https://img.shields.io/npm/v/datetick.svg?style=flat-square&colorB=51C838" alt="NPM Version"></a>
7
+ <a href="https://bundlephobia.com/package/datetick"><img src="https://img.shields.io/bundlephobia/minzip/datetick?style=flat-square&color=45cc11" alt="Gzip Size"></a>
8
+ </p>
9
+
10
+ ![TypeScript](https://img.shields.io/badge/TS-TypeScript-3178c6?logo=typescript&logoColor=white)
11
+ ![GitHub contributors](https://img.shields.io/github/contributors/andreasnicolaou/datetick)
12
+ ![GitHub License](https://img.shields.io/github/license/andreasnicolaou/datetick)
13
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/andreasnicolaou/datetick/build.yaml)
14
+ ![GitHub package.json version](https://img.shields.io/github/package-json/v/andreasnicolaou/datetick)
15
+ [![Known Vulnerabilities](https://snyk.io/test/github/andreasnicolaou/datetick/badge.svg)](https://snyk.io/test/github/andreasnicolaou/datetick)
16
+ ![Bundle Size](https://deno.bundlejs.com/badge?q=datetick&treeshake=[*])
17
+
18
+ ![ESLint](https://img.shields.io/badge/linter-eslint-4B32C3.svg?logo=eslint)
19
+ ![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?logo=prettier)
20
+ ![Jest](https://img.shields.io/badge/tested_with-jest-99424f.svg?logo=jest)
21
+ ![Maintenance](https://img.shields.io/maintenance/yes/2026)
22
+ [![codecov](https://codecov.io/gh/andreasnicolaou/datetick/graph/badge.svg)](https://codecov.io/gh/andreasnicolaou/datetick)
23
+ [![Socket Badge](https://badge.socket.dev/npm/package/datetick)](https://badge.socket.dev/npm/package/datetick)
24
+
25
+ ![NPM Downloads](https://img.shields.io/npm/dm/datetick)
26
+
27
+ <p align="center"><b><a href="https://andreasnicolaou.github.io/datetick/">🚀 Live demo &amp; interactive playground</a></b></p>
28
+
29
+ ---
30
+
31
+ > DateTick parses, validates, manipulates, formats and compares dates and times — with **every** calendar operation resolved through a real IANA timezone, so one absolute instant is always interpreted consistently in one zone (DST included). Zero runtime dependencies. Works the same in vanilla JS, Angular, React, Vue and Node.
32
+
33
+ ```ts
34
+ import datetick from 'datetick';
35
+
36
+ datetick('2026-06-25T19:23Z', { timezone: 'Asia/Tokyo' }).formatPattern('DD/MM/YYYY HH:mm'); // '26/06/2026 04:23'
37
+
38
+ datetick('2026-06-25').startOf('month').add(1, 'day').set('year', 2027).format('long');
39
+
40
+ datetick.duration(90, 'minute').humanize(); // '2 hours'
41
+ datetick('2026-06-25').timeAgoLive().subscribe(console.log); // live "time ago" stream
42
+ ```
43
+
44
+ - 🌐 **Fully timezone-aware** — reading components, `add`/`subtract`, `startOf`/`endOf`, weeks and formatting all resolve through the configured IANA timezone
45
+ - 💪 **Immutable & chainable** — every method returns a new instance; safe to share across Angular components, React renders and Vue computeds
46
+ - 📦 **Zero runtime dependencies** — locales come from the platform's `Intl`, so there are no locale files to import
47
+ - 🕒 **Familiar API** — Day.js-style tokens, getters/setters, comparisons and relative time
48
+ - ⏳ **Durations & live "time ago"** — ISO 8601 durations, `humanize()`, and a dependency-free live relative-time stream
49
+ - 🗓️ **Calendar-grid data** — ready-to-render month grids for building date pickers
50
+ - 🔒 **TypeScript-first** — full types shipped, ESM + UMD builds
51
+
52
+ ## Getting Started
53
+
54
+ ### Installation
55
+
56
+ ```bash
57
+ npm install datetick
58
+ ```
59
+
60
+ ### Live demo & documentation
61
+
62
+ The full API reference — getters/setters, manipulation, comparisons, formatting/parsing tokens, durations, calendar-grid data, app-wide locale defaults, and copy-paste **Angular / React / Vue** integration (including a runtime language switcher) — plus a live in-browser playground, is hosted on GitHub Pages:
63
+
64
+ **➡️ [andreasnicolaou.github.io/datetick](https://andreasnicolaou.github.io/datetick/)**
65
+
66
+ You can also open [`docs/index.html`](./docs/index.html) directly in a browser — no build step required.
67
+
68
+ ### API
69
+
70
+ It's easy to use DateTick to parse, validate, manipulate and display dates and times.
71
+
72
+ ```ts
73
+ datetick('2026-08-08'); // parse
74
+
75
+ datetick().format('YYYY-MM-DD HH:mm:ss'); // display (token pattern)
76
+ datetick().format('long'); // display (Intl preset)
77
+
78
+ datetick().set('month', 3).month(); // get & set
79
+
80
+ datetick().add(1, 'year').subtract(3, 'day'); // manipulate
81
+
82
+ datetick().isBefore(datetick()); // query
83
+ datetick('2026-06-25').isBetween('2026-06-01', '2026-07-01', '[)');
84
+ ```
85
+
86
+ ### Timezones
87
+
88
+ Every operation is resolved through the configured timezone, so the same instant is interpreted consistently — across DST transitions too.
89
+
90
+ ```ts
91
+ const t = datetick('2026-06-25T19:23Z', { timezone: 'Asia/Tokyo' });
92
+ t.hour(); // 4 (wall-clock hour in Tokyo)
93
+ t.utc().hour(); // 19 (same instant, UTC)
94
+ t.utcOffset(); // 540
95
+ ```
96
+
97
+ ### Locale-aware, without locale files
98
+
99
+ Locales resolve through the platform's `Intl`, so nothing extra needs to be imported.
100
+
101
+ ```ts
102
+ datetick('2026-06-25', { locale: 'fr' }).format('long'); // French
103
+ datetick('2026-06-25', { locale: 'fr' }).localeData().months()[0]; // 'janvier'
104
+ ```
105
+
106
+ ### App-wide defaults
107
+
108
+ Bind locale / timezone / week start once and reuse the scoped factory — no global mutation.
109
+
110
+ ```ts
111
+ const paris = datetick.withDefaults({ locale: 'fr', timezone: 'Europe/Paris' });
112
+ paris('2026-06-25').format('long'); // French, Paris
113
+ datetick('2026-06-25').format('long'); // unaffected
114
+ ```
115
+
116
+ ## License
117
+
118
+ DateTick is licensed under the [MIT License](./LICENSE) © Andreas Nicolaou.
@@ -0,0 +1,3 @@
1
+ export default {
2
+ extends: ['@commitlint/config-conventional'],
3
+ };