@stacksjs/datetime 0.75.111 → 0.75.113

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/README.md CHANGED
@@ -85,3 +85,11 @@ Many thanks to the following core technologies & people who have contributed to
85
85
  The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information.
86
86
 
87
87
  Made with 💙
88
+
89
+ ## Site and organization clocks
90
+
91
+ `localDateTime(instant, ...timeZones)` resolves the first valid named zone, then
92
+ UTC, and returns `{ date, time, timeZone }` from one instant. Supply site and
93
+ organization zones in that order. Missing/invalid zones fall through; an
94
+ invalid instant throws. The output uses YYYY-MM-DD and HH:mm and is suitable
95
+ for comparing local schedule dates and end times, not for elapsed durations.
package/dist/index.d.ts CHANGED
@@ -15,3 +15,4 @@ export { format as dateFormat } from './format';
15
15
  // Wall-clock time in a named zone <-> the real instant (event feeds, schema.org).
16
16
  export { isoInZone, zonedTimeToUtc, zoneOffsetMinutes } from './zone';
17
17
  export { addCalendarMonths } from './calendar';
18
+ export { localDateTime } from './local';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export{DateTime,now}from"./now";export{format}from"./format";export{parse}from"./parse";export{format as dateFormat}from"./format";export{isoInZone,zonedTimeToUtc,zoneOffsetMinutes}from"./zone";export{addCalendarMonths}from"./calendar";
1
+ export{DateTime,now}from"./now";export{format}from"./format";export{parse}from"./parse";export{format as dateFormat}from"./format";export{isoInZone,zonedTimeToUtc,zoneOffsetMinutes}from"./zone";export{addCalendarMonths}from"./calendar";export{localDateTime}from"./local";
@@ -0,0 +1,2 @@
1
+ /** Resolve a site's clock, its organization's fallback, then UTC, from the same instant. */
2
+ export declare function localDateTime(instant: Date, ...timeZones: unknown[]): { date: string, time: string, timeZone: string };
package/dist/local.js ADDED
@@ -0,0 +1 @@
1
+ import{format}from"./format";export function localDateTime(instant,...timeZones){if(!Number.isFinite(instant.getTime()))throw RangeError("Invalid clock instant");for(const zone of[...timeZones,"UTC"]){if(typeof zone!=="string"||!zone.trim())continue;try{const timeZone=zone.trim(),clock=format(instant,"YYYY-MM-DD HH:mm",{tz:timeZone});return{date:clock.slice(0,10),time:clock.slice(11),timeZone}}catch(error){if(!(error instanceof RangeError))throw error}}throw RangeError("Cannot resolve a local clock")}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/datetime",
3
3
  "type": "module",
4
- "version": "0.75.111",
4
+ "version": "0.75.113",
5
5
  "description": "The Stacks datetime helpers.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "better-dx": "^0.2.24",
62
- "@stacksjs/utils": "0.75.111"
62
+ "@stacksjs/utils": "0.75.113"
63
63
  },
64
64
  "sideEffects": false
65
65
  }