@timestamp-js/core 0.1.0-alpha.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) 2026 Jeff Galbraith
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,75 @@
1
+ # Timestamp
2
+
3
+ Framework-agnostic TypeScript utilities for date-only, time-only, date-time, interval, and range workflows in browsers, Node.js, and modern JavaScript runtimes.
4
+
5
+ Timestamp focuses on immutable plain objects and small utility functions. It is intentionally independent of any UI framework, backend framework, or application platform.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @timestamp-js/core
11
+ ```
12
+
13
+ ## Basic Usage
14
+
15
+ ```ts
16
+ import { addToDate, getDateTime, parseTimestamp } from "@timestamp-js/core";
17
+
18
+ const start = parseTimestamp("2026-06-08T09:30:15.250Z");
19
+ const end = start ? addToDate(start, { day: 2, minute: 45 }) : null;
20
+
21
+ console.log(end ? getDateTime(end) : "Invalid date");
22
+ ```
23
+
24
+ ## Timestamp Values
25
+
26
+ Timestamp objects are immutable. Parsers and update helpers return frozen objects, and functions that change date/time fields return a new Timestamp instead of mutating the original.
27
+
28
+ ```ts
29
+ const start = parseTimestamp("2026-06-08 09:30")!;
30
+ const next = addToDate(start, { day: 1 });
31
+
32
+ console.log(start.date); // 2026-06-08
33
+ console.log(next.date); // 2026-06-09
34
+ ```
35
+
36
+ ## Supported Input Shape
37
+
38
+ The parser accepts compact calendar inputs and fuller ISO-style date-time inputs:
39
+
40
+ - `2026-06-08`
41
+ - `2026-06-08 09:30`
42
+ - `2026-06-08T09:30`
43
+ - `2026-06-08T09:30:15`
44
+ - `2026-06-08T09:30:15.250Z`
45
+ - `2026-06-08T09:30:15.250-07:00`
46
+
47
+ Seconds, milliseconds, and timezone suffixes are optional. Timezone suffixes are preserved on the Timestamp object, but the parser does not convert the wall-clock values into another zone.
48
+
49
+ ## SSR And Runtime Compatibility
50
+
51
+ Timestamp is designed for server-rendered and client-rendered applications. The package is ESM, side-effect free, and does not depend on browser globals such as `window`, `document`, `navigator`, or storage APIs.
52
+
53
+ The library relies on standard JavaScript runtime APIs such as `Date` and `Intl.DateTimeFormat`, so it works in modern Node.js, browser, serverless, and edge-style runtimes that provide those APIs.
54
+
55
+ For deterministic SSR output, prefer passing explicit timestamps into helpers instead of calling `today()` during render. `today()` intentionally uses the host runtime clock and timezone.
56
+
57
+ ## Current Scope
58
+
59
+ - Parse date strings and ISO-like date-time strings into Timestamp objects.
60
+ - Convert native `Date` objects into Timestamp objects.
61
+ - Compare dates, times, date-times, and timestamp ranges, including optional second and millisecond precision.
62
+ - Generate day and interval lists for calendar-style views.
63
+ - Format weekday and month names through `Intl.DateTimeFormat`.
64
+ - Keep the public surface small, typed, immutable, and runtime-agnostic while the package stabilizes.
65
+
66
+ ## Future Scope
67
+
68
+ The package is intentionally not trying to become a full general-purpose date library on day one. Planned evaluations include Temporal support, explicit timezone behavior, alternate calendar systems, duration helpers, Unix timestamp helpers, compact formatting masks, and a script-tag/browser build if CodePen-style demos need it.
69
+
70
+ ## Development
71
+
72
+ ```bash
73
+ pnpm install
74
+ pnpm verify
75
+ ```