@bessemer/cornerstone 0.5.113 → 0.5.115
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/dist/array.d.ts.map +1 -1
- package/dist/array.js +28 -28
- package/dist/array.js.map +1 -1
- package/dist/aspect-ratio.d.ts +3 -3
- package/dist/aspect-ratio.d.ts.map +1 -1
- package/dist/aspect-ratio.js +13 -12
- package/dist/aspect-ratio.js.map +1 -1
- package/dist/assertion.d.ts.map +1 -1
- package/dist/assertion.js +5 -5
- package/dist/assertion.js.map +1 -1
- package/dist/async-value.js +2 -2
- package/dist/async-value.js.map +1 -1
- package/dist/async.d.ts.map +1 -1
- package/dist/async.js +2 -2
- package/dist/async.js.map +1 -1
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +11 -12
- package/dist/cache.js.map +1 -1
- package/dist/combinable.js +5 -5
- package/dist/combinable.js.map +1 -1
- package/dist/comparator.js +8 -8
- package/dist/comparator.js.map +1 -1
- package/dist/data-size.d.ts +2 -1
- package/dist/data-size.d.ts.map +1 -1
- package/dist/data-size.js +3 -3
- package/dist/data-size.js.map +1 -1
- package/dist/either.js +5 -5
- package/dist/either.js.map +1 -1
- package/dist/equalitor.d.ts.map +1 -1
- package/dist/equalitor.js +2 -2
- package/dist/equalitor.js.map +1 -1
- package/dist/error/error-cause.d.ts.map +1 -1
- package/dist/error/error-cause.js +14 -14
- package/dist/error/error-cause.js.map +1 -1
- package/dist/error/error-code.js +2 -2
- package/dist/error/error-code.js.map +1 -1
- package/dist/error/error-event.d.ts +3 -2
- package/dist/error/error-event.d.ts.map +1 -1
- package/dist/error/error-event.js +28 -28
- package/dist/error/error-event.js.map +1 -1
- package/dist/error/error-type.d.ts +2 -1
- package/dist/error/error-type.d.ts.map +1 -1
- package/dist/error/error-type.js +2 -2
- package/dist/error/error-type.js.map +1 -1
- package/dist/error/error.js +5 -5
- package/dist/error/error.js.map +1 -1
- package/dist/expression/array-expression.js +3 -3
- package/dist/expression/array-expression.js.map +1 -1
- package/dist/expression/core-expression.d.ts.map +1 -1
- package/dist/expression/core-expression.js +19 -19
- package/dist/expression/core-expression.js.map +1 -1
- package/dist/expression/expression-evaluator.js +2 -2
- package/dist/expression/expression-evaluator.js.map +1 -1
- package/dist/expression/expression-mapper.js +4 -4
- package/dist/expression/expression-mapper.js.map +1 -1
- package/dist/expression/internal.js +3 -3
- package/dist/expression/internal.js.map +1 -1
- package/dist/expression/numeric-expression.js +13 -13
- package/dist/expression/numeric-expression.js.map +1 -1
- package/dist/expression/string-expression.js +4 -4
- package/dist/expression/string-expression.js.map +1 -1
- package/dist/expression.d.ts +17 -1
- package/dist/expression.d.ts.map +1 -1
- package/dist/expression.js.map +1 -1
- package/dist/glob.d.ts +3 -3
- package/dist/glob.d.ts.map +1 -1
- package/dist/glob.js +11 -12
- package/dist/glob.js.map +1 -1
- package/dist/global-variable.d.ts.map +1 -1
- package/dist/global-variable.js +5 -5
- package/dist/global-variable.js.map +1 -1
- package/dist/hex-code.d.ts +3 -3
- package/dist/hex-code.d.ts.map +1 -1
- package/dist/hex-code.js +11 -10
- package/dist/hex-code.js.map +1 -1
- package/dist/index.d.ts +311 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/intl/country-code.d.ts +3 -3
- package/dist/intl/country-code.d.ts.map +1 -1
- package/dist/intl/country-code.js +9 -10
- package/dist/intl/country-code.js.map +1 -1
- package/dist/intl/country-subdivision-code.d.ts +3 -3
- package/dist/intl/country-subdivision-code.d.ts.map +1 -1
- package/dist/intl/country-subdivision-code.js +13 -11
- package/dist/intl/country-subdivision-code.js.map +1 -1
- package/dist/intl/currency-code.d.ts +3 -3
- package/dist/intl/currency-code.d.ts.map +1 -1
- package/dist/intl/currency-code.js +9 -10
- package/dist/intl/currency-code.js.map +1 -1
- package/dist/intl/language-code.d.ts +3 -3
- package/dist/intl/language-code.d.ts.map +1 -1
- package/dist/intl/language-code.js +9 -10
- package/dist/intl/language-code.js.map +1 -1
- package/dist/intl/locale.d.ts +3 -3
- package/dist/intl/locale.d.ts.map +1 -1
- package/dist/intl/locale.js +18 -19
- package/dist/intl/locale.js.map +1 -1
- package/dist/json.d.ts.map +1 -1
- package/dist/json.js +2 -2
- package/dist/json.js.map +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +12 -12
- package/dist/logger.js.map +1 -1
- package/dist/map.d.ts +306 -0
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +8 -8
- package/dist/map.js.map +1 -1
- package/dist/mime-type.d.ts +3 -3
- package/dist/mime-type.d.ts.map +1 -1
- package/dist/mime-type.js +9 -10
- package/dist/mime-type.js.map +1 -1
- package/dist/misc.js +4 -4
- package/dist/misc.js.map +1 -1
- package/dist/monetary-amount.d.ts +3 -2
- package/dist/monetary-amount.d.ts.map +1 -1
- package/dist/monetary-amount.js +16 -16
- package/dist/monetary-amount.js.map +1 -1
- package/dist/net/content-type.d.ts +2 -1
- package/dist/net/content-type.d.ts.map +1 -1
- package/dist/net/content-type.js +2 -2
- package/dist/net/content-type.js.map +1 -1
- package/dist/net/domain-name.d.ts +3 -3
- package/dist/net/domain-name.d.ts.map +1 -1
- package/dist/net/domain-name.js +10 -11
- package/dist/net/domain-name.js.map +1 -1
- package/dist/net/http-method.d.ts.map +1 -1
- package/dist/net/http-method.js +9 -9
- package/dist/net/http-method.js.map +1 -1
- package/dist/net/ipv4-address.d.ts +3 -3
- package/dist/net/ipv4-address.d.ts.map +1 -1
- package/dist/net/ipv4-address.js +10 -11
- package/dist/net/ipv4-address.js.map +1 -1
- package/dist/net/ipv6-address.d.ts +3 -3
- package/dist/net/ipv6-address.d.ts.map +1 -1
- package/dist/net/ipv6-address.js +10 -11
- package/dist/net/ipv6-address.js.map +1 -1
- package/dist/net/uri-host-name.d.ts +3 -3
- package/dist/net/uri-host-name.d.ts.map +1 -1
- package/dist/net/uri-host-name.js +15 -16
- package/dist/net/uri-host-name.js.map +1 -1
- package/dist/net/uri.d.ts +1 -2
- package/dist/net/uri.d.ts.map +1 -1
- package/dist/net/uri.js +5 -3
- package/dist/net/uri.js.map +1 -1
- package/dist/net/url.d.ts.map +1 -1
- package/dist/net/url.js +6 -7
- package/dist/net/url.js.map +1 -1
- package/dist/object/object-path.d.ts.map +1 -1
- package/dist/object/object-path.js +23 -28
- package/dist/object/object-path.js.map +1 -1
- package/dist/object/type-path.js +19 -19
- package/dist/object/type-path.js.map +1 -1
- package/dist/patch.js +4 -4
- package/dist/patch.js.map +1 -1
- package/dist/promise.js +2 -2
- package/dist/promise.js.map +1 -1
- package/dist/property.d.ts.map +1 -1
- package/dist/property.js +7 -7
- package/dist/property.js.map +1 -1
- package/dist/proxy.js +2 -2
- package/dist/proxy.js.map +1 -1
- package/dist/range.js +2 -2
- package/dist/range.js.map +1 -1
- package/dist/reference.d.ts +2 -1
- package/dist/reference.d.ts.map +1 -1
- package/dist/reference.js +13 -13
- package/dist/reference.js.map +1 -1
- package/dist/resource-key.js +2 -2
- package/dist/resource-key.js.map +1 -1
- package/dist/result.js +5 -5
- package/dist/result.js.map +1 -1
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +12 -12
- package/dist/retry.js.map +1 -1
- package/dist/rich-text.js +2 -2
- package/dist/rich-text.js.map +1 -1
- package/dist/signature.d.ts.map +1 -1
- package/dist/signature.js +9 -9
- package/dist/signature.js.map +1 -1
- package/dist/sql/sql-expression-parser.js +2 -2
- package/dist/sql/sql-expression-parser.js.map +1 -1
- package/dist/sql.d.ts +5 -1
- package/dist/sql.d.ts.map +1 -1
- package/dist/sql.js.map +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +9 -9
- package/dist/store.js.map +1 -1
- package/dist/string.js +4 -4
- package/dist/string.js.map +1 -1
- package/dist/tag.d.ts.map +1 -1
- package/dist/tag.js +10 -10
- package/dist/tag.js.map +1 -1
- package/dist/temporal/clock.d.ts +13 -13
- package/dist/temporal/clock.d.ts.map +1 -1
- package/dist/temporal/clock.js +10 -10
- package/dist/temporal/clock.js.map +1 -1
- package/dist/temporal/duration.d.ts +15 -9
- package/dist/temporal/duration.d.ts.map +1 -1
- package/dist/temporal/duration.js +30 -31
- package/dist/temporal/duration.js.map +1 -1
- package/dist/temporal/instant.d.ts +18 -15
- package/dist/temporal/instant.d.ts.map +1 -1
- package/dist/temporal/instant.js +42 -43
- package/dist/temporal/instant.js.map +1 -1
- package/dist/temporal/plain-date-time.d.ts +16 -13
- package/dist/temporal/plain-date-time.d.ts.map +1 -1
- package/dist/temporal/plain-date-time.js +36 -38
- package/dist/temporal/plain-date-time.js.map +1 -1
- package/dist/temporal/plain-date.d.ts +16 -13
- package/dist/temporal/plain-date.d.ts.map +1 -1
- package/dist/temporal/plain-date.js +35 -37
- package/dist/temporal/plain-date.js.map +1 -1
- package/dist/temporal/plain-month-day.d.ts +37 -0
- package/dist/temporal/plain-month-day.d.ts.map +1 -0
- package/dist/temporal/plain-month-day.js +84 -0
- package/dist/temporal/plain-month-day.js.map +1 -0
- package/dist/temporal/plain-time.d.ts +19 -17
- package/dist/temporal/plain-time.d.ts.map +1 -1
- package/dist/temporal/plain-time.js +43 -42
- package/dist/temporal/plain-time.js.map +1 -1
- package/dist/temporal/plain-year-month.d.ts +57 -0
- package/dist/temporal/plain-year-month.d.ts.map +1 -0
- package/dist/temporal/plain-year-month.js +109 -0
- package/dist/temporal/plain-year-month.js.map +1 -0
- package/dist/temporal/time-zone-id.d.ts +5 -4
- package/dist/temporal/time-zone-id.d.ts.map +1 -1
- package/dist/temporal/time-zone-id.js +11 -11
- package/dist/temporal/time-zone-id.js.map +1 -1
- package/dist/temporal/time-zone-offset.d.ts +12 -11
- package/dist/temporal/time-zone-offset.d.ts.map +1 -1
- package/dist/temporal/time-zone-offset.js +42 -50
- package/dist/temporal/time-zone-offset.js.map +1 -1
- package/dist/temporal/zoned-date-time.d.ts +16 -13
- package/dist/temporal/zoned-date-time.d.ts.map +1 -1
- package/dist/temporal/zoned-date-time.js +35 -36
- package/dist/temporal/zoned-date-time.js.map +1 -1
- package/dist/uuid/ulid.d.ts +3 -3
- package/dist/uuid/ulid.d.ts.map +1 -1
- package/dist/uuid/ulid.js +9 -10
- package/dist/uuid/ulid.js.map +1 -1
- package/dist/uuid/uuid-v4.d.ts +3 -3
- package/dist/uuid/uuid-v4.d.ts.map +1 -1
- package/dist/uuid/uuid-v4.js +13 -14
- package/dist/uuid/uuid-v4.js.map +1 -1
- package/dist/uuid/uuid-v7.d.ts +1 -2
- package/dist/uuid/uuid-v7.d.ts.map +1 -1
- package/dist/uuid/uuid-v7.js +1 -2
- package/dist/uuid/uuid-v7.js.map +1 -1
- package/dist/zod-util.d.ts +4 -3
- package/dist/zod-util.d.ts.map +1 -1
- package/dist/zod-util.js +21 -11
- package/dist/zod-util.js.map +1 -1
- package/package.json +6 -4
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
// src/temporal/time-zone-id.ts
|
|
2
|
-
import
|
|
2
|
+
import * as Results from "@bessemer/cornerstone/result";
|
|
3
3
|
import Zod from "zod";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
var Namespace = createNamespace("time-zone-id");
|
|
4
|
+
import * as ResourceKeys from "@bessemer/cornerstone/resource-key";
|
|
5
|
+
import * as ErrorEvents from "@bessemer/cornerstone/error/error-event";
|
|
6
|
+
import * as Errors from "@bessemer/cornerstone/error/error";
|
|
7
|
+
import * as ZodUtil from "@bessemer/cornerstone/zod-util";
|
|
8
|
+
var Namespace = ResourceKeys.createNamespace("time-zone-id");
|
|
9
9
|
var parseString = (value) => {
|
|
10
10
|
try {
|
|
11
11
|
const fmt = new Intl.DateTimeFormat(void 0, { timeZone: value });
|
|
12
|
-
return success(fmt.resolvedOptions().timeZone);
|
|
12
|
+
return Results.success(fmt.resolvedOptions().timeZone);
|
|
13
13
|
} catch (e) {
|
|
14
|
-
if (isError(e)) {
|
|
15
|
-
return failure(invalidValue(value, { namespace: Namespace, message: e.message }));
|
|
14
|
+
if (Errors.isError(e)) {
|
|
15
|
+
return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: e.message }));
|
|
16
16
|
} else {
|
|
17
17
|
throw e;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
var from = (value) => {
|
|
22
|
-
return unpackResult(parseString(value));
|
|
22
|
+
return ErrorEvents.unpackResult(parseString(value));
|
|
23
23
|
};
|
|
24
|
-
var Schema = structuredTransform(Zod.string(), parseString);
|
|
24
|
+
var Schema = ZodUtil.structuredTransform(Zod.string(), parseString);
|
|
25
25
|
var Utc = "UTC";
|
|
26
26
|
var getSystemDefault = () => {
|
|
27
27
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/temporal/time-zone-id.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../src/temporal/time-zone-id.ts"],"sourcesContent":["import * as Results from '@bessemer/cornerstone/result'\nimport Zod from 'zod'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport * as ResourceKeys from '@bessemer/cornerstone/resource-key'\nimport * as ErrorEvents from '@bessemer/cornerstone/error/error-event'\nimport * as Errors from '@bessemer/cornerstone/error/error'\nimport * as ZodUtil from '@bessemer/cornerstone/zod-util'\n\nexport const Namespace = ResourceKeys.createNamespace('time-zone-id')\nexport type TimeZoneId = NominalType<string, typeof Namespace>\n\nexport const parseString = (value: string): Results.Result<TimeZoneId, ErrorEvents.ErrorEvent> => {\n try {\n const fmt = new Intl.DateTimeFormat(undefined, { timeZone: value })\n return Results.success(fmt.resolvedOptions().timeZone as TimeZoneId)\n } catch (e) {\n if (Errors.isError(e)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: e.message }))\n } else {\n throw e\n }\n }\n}\n\nexport const from = (value: string): TimeZoneId => {\n return ErrorEvents.unpackResult(parseString(value))\n}\n\nexport const Schema = ZodUtil.structuredTransform(Zod.string(), parseString)\n\nexport const Utc = 'UTC' as TimeZoneId\nexport const getSystemDefault = (): TimeZoneId => {\n return Intl.DateTimeFormat().resolvedOptions().timeZone as TimeZoneId\n}\n"],"mappings":";AAAA,YAAY,aAAa;AACzB,OAAO,SAAS;AAEhB,YAAY,kBAAkB;AAC9B,YAAY,iBAAiB;AAC7B,YAAY,YAAY;AACxB,YAAY,aAAa;AAElB,IAAM,YAAyB,6BAAgB,cAAc;AAG7D,IAAM,cAAc,CAAC,UAAsE;AAChG,MAAI;AACF,UAAM,MAAM,IAAI,KAAK,eAAe,QAAW,EAAE,UAAU,MAAM,CAAC;AAClE,WAAe,gBAAQ,IAAI,gBAAgB,EAAE,QAAsB;AAAA,EACrE,SAAS,GAAG;AACV,QAAW,eAAQ,CAAC,GAAG;AACrB,aAAe,gBAAoB,yBAAa,OAAO,EAAE,WAAW,WAAW,SAAS,EAAE,QAAQ,CAAC,CAAC;AAAA,IACtG,OAAO;AACL,YAAM;AAAA,IACR;AAAA,EACF;AACF;AAEO,IAAM,OAAO,CAAC,UAA8B;AACjD,SAAmB,yBAAa,YAAY,KAAK,CAAC;AACpD;AAEO,IAAM,SAAiB,4BAAoB,IAAI,OAAO,GAAG,WAAW;AAEpE,IAAM,MAAM;AACZ,IAAM,mBAAmB,MAAkB;AAChD,SAAO,KAAK,eAAe,EAAE,gBAAgB,EAAE;AACjD;","names":[]}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { NominalType } from '@bessemer/cornerstone/types';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import * as Durations from '@bessemer/cornerstone/temporal/duration';
|
|
3
|
+
import * as Results from '@bessemer/cornerstone/result';
|
|
4
4
|
import Zod from 'zod';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import * as ErrorEvents from '@bessemer/cornerstone/error/error-event';
|
|
6
|
+
import * as ResourceKeys from '@bessemer/cornerstone/resource-key';
|
|
7
7
|
import { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id';
|
|
8
|
-
|
|
8
|
+
import * as Instants from '@bessemer/cornerstone/temporal/instant';
|
|
9
|
+
export declare const Namespace: ResourceKeys.ResourceNamespace<"time-zone-offset">;
|
|
9
10
|
export type TimeZoneOffset = NominalType<number, typeof Namespace>;
|
|
10
|
-
export declare const parseMinutes: (value: number) => Result<TimeZoneOffset, ErrorEvent>;
|
|
11
|
-
export declare const parseDuration: (value: Duration) => Result<TimeZoneOffset, ErrorEvent>;
|
|
11
|
+
export declare const parseMinutes: (value: number) => Results.Result<TimeZoneOffset, ErrorEvents.ErrorEvent>;
|
|
12
|
+
export declare const parseDuration: (value: Durations.Duration) => Results.Result<TimeZoneOffset, ErrorEvents.ErrorEvent>;
|
|
12
13
|
export declare const fromMinutes: (value: number) => TimeZoneOffset;
|
|
13
|
-
export declare const fromDuration: (value: DurationLike) => TimeZoneOffset;
|
|
14
|
-
export declare const fromTimeZone: (timeZone: TimeZoneId, instant: Instant) => TimeZoneOffset;
|
|
15
|
-
export declare const parseString: (value: string) => Result<TimeZoneOffset, ErrorEvent>;
|
|
14
|
+
export declare const fromDuration: (value: Durations.DurationLike) => TimeZoneOffset;
|
|
15
|
+
export declare const fromTimeZone: (timeZone: TimeZoneId, instant: Instants.Instant) => TimeZoneOffset;
|
|
16
|
+
export declare const parseString: (value: string) => Results.Result<TimeZoneOffset, ErrorEvents.ErrorEvent>;
|
|
16
17
|
export declare const from: (value: string) => TimeZoneOffset;
|
|
17
18
|
export declare const Schema: Zod.ZodUnion<readonly [Zod.ZodPipe<Zod.ZodNumber, Zod.ZodTransform<TimeZoneOffset, number>>, Zod.ZodPipe<Zod.ZodString, Zod.ZodTransform<TimeZoneOffset, string>>]>;
|
|
18
|
-
export declare const toDuration: (offset: TimeZoneOffset) => Duration;
|
|
19
|
+
export declare const toDuration: (offset: TimeZoneOffset) => Durations.Duration;
|
|
19
20
|
export declare const toMilliseconds: (offset: TimeZoneOffset) => number;
|
|
20
21
|
export declare const toString: (offset: TimeZoneOffset) => string;
|
|
21
22
|
export declare const Utc: TimeZoneOffset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-zone-offset.d.ts","sourceRoot":"","sources":["../../src/temporal/time-zone-offset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"time-zone-offset.d.ts","sourceRoot":"","sources":["../../src/temporal/time-zone-offset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,SAAS,MAAM,yCAAyC,CAAA;AAEpE,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAA;AACvD,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,KAAK,WAAW,MAAM,yCAAyC,CAAA;AACtE,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAA;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAA;AACxE,OAAO,KAAK,QAAQ,MAAM,wCAAwC,CAAA;AAElE,eAAO,MAAM,SAAS,oDAAmD,CAAA;AACzE,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,EAAE,OAAO,SAAS,CAAC,CAAA;AAIlE,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,UAAU,CAUjG,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,OAAO,SAAS,CAAC,QAAQ,KAAG,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,UAAU,CAE9G,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,cAE3C,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,OAAO,SAAS,CAAC,YAAY,KAAG,cAE5D,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,UAAU,UAAU,EAAE,SAAS,QAAQ,CAAC,OAAO,KAAG,cAsB9E,CAAA;AAGD,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,UAAU,CAyEhG,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,OAAO,MAAM,KAAG,cAEpC,CAAA;AAED,eAAO,MAAM,MAAM,qKAA+H,CAAA;AAElJ,eAAO,MAAM,UAAU,GAAI,QAAQ,cAAc,KAAG,SAAS,CAAC,QAE7D,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,QAAQ,cAAc,KAAG,MAEvD,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,QAAQ,cAAc,KAAG,MASjD,CAAA;AAED,eAAO,MAAM,GAAG,EAAQ,cAAc,CAAA"}
|
|
@@ -1,38 +1,30 @@
|
|
|
1
1
|
// src/temporal/time-zone-offset.ts
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
fromMilliseconds,
|
|
6
|
-
fromMinutes as durationFromMinutes,
|
|
7
|
-
isGreater,
|
|
8
|
-
isLess,
|
|
9
|
-
toMinutes
|
|
10
|
-
} from "@bessemer/cornerstone/temporal/duration";
|
|
11
|
-
import { fromDuration as plainTimeFromDuration, toLiteral as plainTimeToLiteral } from "@bessemer/cornerstone/temporal/plain-time";
|
|
12
|
-
import { failure, success } from "@bessemer/cornerstone/result";
|
|
2
|
+
import * as Durations from "@bessemer/cornerstone/temporal/duration";
|
|
3
|
+
import * as PlainTimes from "@bessemer/cornerstone/temporal/plain-time";
|
|
4
|
+
import * as Results from "@bessemer/cornerstone/result";
|
|
13
5
|
import Zod from "zod";
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
var Namespace = createNamespace("time-zone-offset");
|
|
18
|
-
var EighteenHours = fromHours(18);
|
|
6
|
+
import * as ErrorEvents from "@bessemer/cornerstone/error/error-event";
|
|
7
|
+
import * as ResourceKeys from "@bessemer/cornerstone/resource-key";
|
|
8
|
+
import * as ZodUtil from "@bessemer/cornerstone/zod-util";
|
|
9
|
+
var Namespace = ResourceKeys.createNamespace("time-zone-offset");
|
|
10
|
+
var EighteenHours = Durations.fromHours(18);
|
|
19
11
|
var parseMinutes = (value) => {
|
|
20
12
|
if (!Number.isInteger(value)) {
|
|
21
|
-
return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be a round number of minutes.` }));
|
|
13
|
+
return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be a round number of minutes.` }));
|
|
22
14
|
}
|
|
23
|
-
if (value < toMinutes(EighteenHours.negated()) || value > toMinutes(EighteenHours)) {
|
|
24
|
-
return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }));
|
|
15
|
+
if (value < Durations.toMinutes(EighteenHours.negated()) || value > Durations.toMinutes(EighteenHours)) {
|
|
16
|
+
return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }));
|
|
25
17
|
}
|
|
26
|
-
return success(value);
|
|
18
|
+
return Results.success(value);
|
|
27
19
|
};
|
|
28
20
|
var parseDuration = (value) => {
|
|
29
|
-
return parseMinutes(toMinutes(value));
|
|
21
|
+
return parseMinutes(Durations.toMinutes(value));
|
|
30
22
|
};
|
|
31
|
-
var
|
|
32
|
-
return unpackResult(parseMinutes(value));
|
|
23
|
+
var fromMinutes2 = (value) => {
|
|
24
|
+
return ErrorEvents.unpackResult(parseMinutes(value));
|
|
33
25
|
};
|
|
34
|
-
var
|
|
35
|
-
return unpackResult(parseDuration(
|
|
26
|
+
var fromDuration2 = (value) => {
|
|
27
|
+
return ErrorEvents.unpackResult(parseDuration(Durations.from(value)));
|
|
36
28
|
};
|
|
37
29
|
var fromTimeZone = (timeZone, instant) => {
|
|
38
30
|
const instantWithoutMs = new Date(Math.floor(instant.epochMilliseconds / 1e3) * 1e3);
|
|
@@ -49,14 +41,14 @@ var fromTimeZone = (timeZone, instant) => {
|
|
|
49
41
|
const formatted = formatter.format(instantWithoutMs);
|
|
50
42
|
const localTime = (/* @__PURE__ */ new Date(formatted + "Z")).getTime();
|
|
51
43
|
const offsetMs = localTime - instantWithoutMs.getTime();
|
|
52
|
-
return
|
|
44
|
+
return fromDuration2({ milliseconds: offsetMs });
|
|
53
45
|
};
|
|
54
46
|
var parseString = (value) => {
|
|
55
47
|
if (value === "Z") {
|
|
56
|
-
return success(0);
|
|
48
|
+
return Results.success(0);
|
|
57
49
|
}
|
|
58
50
|
if (!value.startsWith("+") && !value.startsWith("-")) {
|
|
59
|
-
return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must start with +, -, or be Z.` }));
|
|
51
|
+
return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must start with +, -, or be Z.` }));
|
|
60
52
|
}
|
|
61
53
|
const sign = value[0] === "+" ? 1 : -1;
|
|
62
54
|
const offsetStr = value.slice(1);
|
|
@@ -65,55 +57,55 @@ var parseString = (value) => {
|
|
|
65
57
|
if (offsetStr.length === 1) {
|
|
66
58
|
hours = parseInt(offsetStr, 10);
|
|
67
59
|
if (isNaN(hours)) {
|
|
68
|
-
return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }));
|
|
60
|
+
return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }));
|
|
69
61
|
}
|
|
70
62
|
} else if (offsetStr.length === 2) {
|
|
71
63
|
hours = parseInt(offsetStr, 10);
|
|
72
64
|
if (isNaN(hours)) {
|
|
73
|
-
return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }));
|
|
65
|
+
return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }));
|
|
74
66
|
}
|
|
75
67
|
} else if (offsetStr.includes(":")) {
|
|
76
68
|
const parts = offsetStr.split(":");
|
|
77
69
|
if (parts.length < 2 || parts.length > 3) {
|
|
78
|
-
return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }));
|
|
70
|
+
return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }));
|
|
79
71
|
}
|
|
80
72
|
hours = parseInt(parts[0], 10);
|
|
81
73
|
minutes = parseInt(parts[1], 10);
|
|
82
74
|
if (parts.length === 3) {
|
|
83
|
-
return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }));
|
|
75
|
+
return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }));
|
|
84
76
|
}
|
|
85
77
|
if (isNaN(hours) || isNaN(minutes)) {
|
|
86
|
-
return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }));
|
|
78
|
+
return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }));
|
|
87
79
|
}
|
|
88
80
|
} else if (offsetStr.length === 4) {
|
|
89
81
|
hours = parseInt(offsetStr.slice(0, 2), 10);
|
|
90
82
|
minutes = parseInt(offsetStr.slice(2, 4), 10);
|
|
91
83
|
if (isNaN(hours) || isNaN(minutes)) {
|
|
92
|
-
return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }));
|
|
84
|
+
return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }));
|
|
93
85
|
}
|
|
94
86
|
} else {
|
|
95
|
-
return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }));
|
|
87
|
+
return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }));
|
|
96
88
|
}
|
|
97
89
|
if (minutes >= 60) {
|
|
98
|
-
return failure(
|
|
99
|
-
invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid minutes in time zone offset: must be less than 60.` })
|
|
90
|
+
return Results.failure(
|
|
91
|
+
ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid minutes in time zone offset: must be less than 60.` })
|
|
100
92
|
);
|
|
101
93
|
}
|
|
102
|
-
let duration =
|
|
94
|
+
let duration = Durations.from({ hours, minutes });
|
|
103
95
|
if (sign === -1) {
|
|
104
96
|
duration = duration.negated();
|
|
105
97
|
}
|
|
106
|
-
if (isLess(duration, EighteenHours.negated()) || isGreater(duration, EighteenHours)) {
|
|
107
|
-
return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }));
|
|
98
|
+
if (Durations.isLess(duration, EighteenHours.negated()) || Durations.isGreater(duration, EighteenHours)) {
|
|
99
|
+
return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }));
|
|
108
100
|
}
|
|
109
|
-
return success(toMinutes(duration));
|
|
101
|
+
return Results.success(Durations.toMinutes(duration));
|
|
110
102
|
};
|
|
111
|
-
var
|
|
112
|
-
return unpackResult(parseString(value));
|
|
103
|
+
var from2 = (value) => {
|
|
104
|
+
return ErrorEvents.unpackResult(parseString(value));
|
|
113
105
|
};
|
|
114
|
-
var Schema = Zod.union([structuredTransform(Zod.number(), parseMinutes), structuredTransform(Zod.string(), parseString)]);
|
|
106
|
+
var Schema = Zod.union([ZodUtil.structuredTransform(Zod.number(), parseMinutes), ZodUtil.structuredTransform(Zod.string(), parseString)]);
|
|
115
107
|
var toDuration = (offset) => {
|
|
116
|
-
return fromMilliseconds(offset);
|
|
108
|
+
return Durations.fromMilliseconds(offset);
|
|
117
109
|
};
|
|
118
110
|
var toMilliseconds = (offset) => {
|
|
119
111
|
return offset;
|
|
@@ -123,17 +115,17 @@ var toString = (offset) => {
|
|
|
123
115
|
return "Z";
|
|
124
116
|
}
|
|
125
117
|
const sign = offset > 0 ? "+" : "-";
|
|
126
|
-
const time =
|
|
127
|
-
return `${sign}${
|
|
118
|
+
const time = PlainTimes.fromDuration(Durations.fromMinutes(Math.abs(offset)));
|
|
119
|
+
return `${sign}${PlainTimes.toLiteral(time)}`;
|
|
128
120
|
};
|
|
129
121
|
var Utc = 0;
|
|
130
122
|
export {
|
|
131
123
|
Namespace,
|
|
132
124
|
Schema,
|
|
133
125
|
Utc,
|
|
134
|
-
from,
|
|
135
|
-
fromDuration,
|
|
136
|
-
fromMinutes,
|
|
126
|
+
from2 as from,
|
|
127
|
+
fromDuration2 as fromDuration,
|
|
128
|
+
fromMinutes2 as fromMinutes,
|
|
137
129
|
fromTimeZone,
|
|
138
130
|
parseDuration,
|
|
139
131
|
parseMinutes,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/temporal/time-zone-offset.ts"],"sourcesContent":["import { NominalType } from '@bessemer/cornerstone/types'\nimport {\n Duration,\n DurationLike,\n from as _fromDuration,\n fromHours,\n fromMilliseconds,\n fromMinutes as durationFromMinutes,\n isGreater,\n isLess,\n toMinutes,\n} from '@bessemer/cornerstone/temporal/duration'\nimport { fromDuration as plainTimeFromDuration, toLiteral as plainTimeToLiteral } from '@bessemer/cornerstone/temporal/plain-time'\nimport { failure, Result, success } from '@bessemer/cornerstone/result'\nimport Zod from 'zod'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { createNamespace } from '@bessemer/cornerstone/resource-key'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport { Instant } from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\n\nexport const Namespace = createNamespace('time-zone-offset')\nexport type TimeZoneOffset = NominalType<number, typeof Namespace>\n\nconst EighteenHours = fromHours(18)\n\nexport const parseMinutes = (value: number): Result<TimeZoneOffset, ErrorEvent> => {\n if (!Number.isInteger(value)) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be a round number of minutes.` }))\n }\n\n if (value < toMinutes(EighteenHours.negated()) || value > toMinutes(EighteenHours)) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }))\n }\n\n return success(value as TimeZoneOffset)\n}\n\nexport const parseDuration = (value: Duration): Result<TimeZoneOffset, ErrorEvent> => {\n return parseMinutes(toMinutes(value))\n}\n\nexport const fromMinutes = (value: number): TimeZoneOffset => {\n return unpackResult(parseMinutes(value))\n}\n\nexport const fromDuration = (value: DurationLike): TimeZoneOffset => {\n return unpackResult(parseDuration(_fromDuration(value)))\n}\n\nexport const fromTimeZone = (timeZone: TimeZoneId, instant: Instant): TimeZoneOffset => {\n const instantWithoutMs = new Date(Math.floor(instant.epochMilliseconds / 1000) * 1000)\n\n // Note: We use 'en-CA' locale because it produces ISO 8601 format (YYYY-MM-DD, HH:MM:SS)\n // which is predictable and easily parseable. The locale only affects the output format,\n // not the timezone conversion - that's handled by the timeZone parameter.\n const formatter = new Intl.DateTimeFormat('en-CA', {\n timeZone: timeZone,\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: false,\n })\n\n const formatted = formatter.format(instantWithoutMs)\n const localTime = new Date(formatted + 'Z').getTime()\n\n const offsetMs = localTime - instantWithoutMs.getTime()\n return fromDuration({ milliseconds: offsetMs })\n}\n\n// JOHN maybe this parsing could be consolidated with LocalTime?\nexport const parseString = (value: string): Result<TimeZoneOffset, ErrorEvent> => {\n if (value === 'Z') {\n return success(0 as TimeZoneOffset)\n }\n\n if (!value.startsWith('+') && !value.startsWith('-')) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must start with +, -, or be Z.` }))\n }\n\n const sign = value[0] === '+' ? 1 : -1\n const offsetStr = value.slice(1)\n\n let hours = 0\n let minutes = 0\n\n // Parse different formats\n if (offsetStr.length === 1) {\n // +h format\n hours = parseInt(offsetStr, 10)\n if (isNaN(hours)) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }))\n }\n } else if (offsetStr.length === 2) {\n // +hh format\n hours = parseInt(offsetStr, 10)\n if (isNaN(hours)) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }))\n }\n } else if (offsetStr.includes(':')) {\n // Formats with colons: +hh:mm or +hh:mm:ss\n const parts = offsetStr.split(':')\n if (parts.length < 2 || parts.length > 3) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }))\n }\n\n hours = parseInt(parts[0]!, 10)\n minutes = parseInt(parts[1]!, 10)\n\n if (parts.length === 3) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }))\n }\n\n if (isNaN(hours) || isNaN(minutes)) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }))\n }\n } else if (offsetStr.length === 4) {\n // +hhmm format\n hours = parseInt(offsetStr.slice(0, 2), 10)\n minutes = parseInt(offsetStr.slice(2, 4), 10)\n\n if (isNaN(hours) || isNaN(minutes)) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }))\n }\n } else {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }))\n }\n\n if (minutes >= 60) {\n return failure(\n invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid minutes in time zone offset: must be less than 60.` })\n )\n }\n\n let duration = _fromDuration({ hours, minutes })\n if (sign === -1) {\n duration = duration.negated()\n }\n\n if (isLess(duration, EighteenHours.negated()) || isGreater(duration, EighteenHours)) {\n return failure(invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }))\n }\n\n return success(toMinutes(duration) as TimeZoneOffset)\n}\n\nexport const from = (value: string): TimeZoneOffset => {\n return unpackResult(parseString(value))\n}\n\nexport const Schema = Zod.union([structuredTransform(Zod.number(), parseMinutes), structuredTransform(Zod.string(), parseString)])\n\nexport const toDuration = (offset: TimeZoneOffset): Duration => {\n return fromMilliseconds(offset)\n}\n\nexport const toMilliseconds = (offset: TimeZoneOffset): number => {\n return offset\n}\n\nexport const toString = (offset: TimeZoneOffset): string => {\n if (offset === 0) {\n return 'Z'\n }\n\n const sign = offset > 0 ? '+' : '-'\n\n const time = plainTimeFromDuration(durationFromMinutes(Math.abs(offset)))\n return `${sign}${plainTimeToLiteral(time)}`\n}\n\nexport const Utc = 0 as TimeZoneOffset\n"],"mappings":";AACA;AAAA,EAGE,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB,uBAAuB,aAAa,0BAA0B;AACvF,SAAS,SAAiB,eAAe;AACzC,OAAO,SAAS;AAChB,SAAqB,cAAc,oBAAoB;AACvD,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AAI7B,IAAM,YAAY,gBAAgB,kBAAkB;AAG3D,IAAM,gBAAgB,UAAU,EAAE;AAE3B,IAAM,eAAe,CAAC,UAAsD;AACjF,MAAI,CAAC,OAAO,UAAU,KAAK,GAAG;AAC5B,WAAO,QAAQ,aAAa,OAAO,EAAE,WAAW,WAAW,SAAS,oDAAoD,CAAC,CAAC;AAAA,EAC5H;AAEA,MAAI,QAAQ,UAAU,cAAc,QAAQ,CAAC,KAAK,QAAQ,UAAU,aAAa,GAAG;AAClF,WAAO,QAAQ,aAAa,OAAO,EAAE,WAAW,WAAW,SAAS,8DAA8D,CAAC,CAAC;AAAA,EACtI;AAEA,SAAO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;AACjB,WAAO;AAAA,MACL,aAAa,OAAO,EAAE,WAAW,WAAW,SAAS,8EAA8E,CAAC;AAAA,IACtI;AAAA,EACF;AAEA,MAAI,WAAW,cAAc,EAAE,OAAO,QAAQ,CAAC;AAC/C,MAAI,SAAS,IAAI;AACf,eAAW,SAAS,QAAQ;AAAA,EAC9B;AAEA,MAAI,OAAO,UAAU,cAAc,QAAQ,CAAC,KAAK,UAAU,UAAU,aAAa,GAAG;AACnF,WAAO,QAAQ,aAAa,OAAO,EAAE,WAAW,WAAW,SAAS,8DAA8D,CAAC,CAAC;AAAA,EACtI;AAEA,SAAO,QAAQ,UAAU,QAAQ,CAAmB;AACtD;AAEO,IAAM,OAAO,CAAC,UAAkC;AACrD,SAAO,aAAa,YAAY,KAAK,CAAC;AACxC;AAEO,IAAM,SAAS,IAAI,MAAM,CAAC,oBAAoB,IAAI,OAAO,GAAG,YAAY,GAAG,oBAAoB,IAAI,OAAO,GAAG,WAAW,CAAC,CAAC;AAE1H,IAAM,aAAa,CAAC,WAAqC;AAC9D,SAAO,iBAAiB,MAAM;AAChC;AAEO,IAAM,iBAAiB,CAAC,WAAmC;AAChE,SAAO;AACT;AAEO,IAAM,WAAW,CAAC,WAAmC;AAC1D,MAAI,WAAW,GAAG;AAChB,WAAO;AAAA,EACT;AAEA,QAAM,OAAO,SAAS,IAAI,MAAM;AAEhC,QAAM,OAAO,sBAAsB,oBAAoB,KAAK,IAAI,MAAM,CAAC,CAAC;AACxE,SAAO,GAAG,IAAI,GAAG,mBAAmB,IAAI,CAAC;AAC3C;AAEO,IAAM,MAAM;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/temporal/time-zone-offset.ts"],"sourcesContent":["import { NominalType } from '@bessemer/cornerstone/types'\nimport * as Durations from '@bessemer/cornerstone/temporal/duration'\nimport * as PlainTimes from '@bessemer/cornerstone/temporal/plain-time'\nimport * as Results from '@bessemer/cornerstone/result'\nimport Zod from 'zod'\nimport * as ErrorEvents from '@bessemer/cornerstone/error/error-event'\nimport * as ResourceKeys from '@bessemer/cornerstone/resource-key'\nimport * as ZodUtil from '@bessemer/cornerstone/zod-util'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport * as Instants from '@bessemer/cornerstone/temporal/instant'\n\nexport const Namespace = ResourceKeys.createNamespace('time-zone-offset')\nexport type TimeZoneOffset = NominalType<number, typeof Namespace>\n\nconst EighteenHours = Durations.fromHours(18)\n\nexport const parseMinutes = (value: number): Results.Result<TimeZoneOffset, ErrorEvents.ErrorEvent> => {\n if (!Number.isInteger(value)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be a round number of minutes.` }))\n }\n\n if (value < Durations.toMinutes(EighteenHours.negated()) || value > Durations.toMinutes(EighteenHours)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }))\n }\n\n return Results.success(value as TimeZoneOffset)\n}\n\nexport const parseDuration = (value: Durations.Duration): Results.Result<TimeZoneOffset, ErrorEvents.ErrorEvent> => {\n return parseMinutes(Durations.toMinutes(value))\n}\n\nexport const fromMinutes = (value: number): TimeZoneOffset => {\n return ErrorEvents.unpackResult(parseMinutes(value))\n}\n\nexport const fromDuration = (value: Durations.DurationLike): TimeZoneOffset => {\n return ErrorEvents.unpackResult(parseDuration(Durations.from(value)))\n}\n\nexport const fromTimeZone = (timeZone: TimeZoneId, instant: Instants.Instant): TimeZoneOffset => {\n const instantWithoutMs = new Date(Math.floor(instant.epochMilliseconds / 1000) * 1000)\n\n // Note: We use 'en-CA' locale because it produces ISO 8601 format (YYYY-MM-DD, HH:MM:SS)\n // which is predictable and easily parseable. The locale only affects the output format,\n // not the timezone conversion - that's handled by the timeZone parameter.\n const formatter = new Intl.DateTimeFormat('en-CA', {\n timeZone: timeZone,\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: false,\n })\n\n const formatted = formatter.format(instantWithoutMs)\n const localTime = new Date(formatted + 'Z').getTime()\n\n const offsetMs = localTime - instantWithoutMs.getTime()\n return fromDuration({ milliseconds: offsetMs })\n}\n\n// JOHN maybe this parsing could be consolidated with LocalTime?\nexport const parseString = (value: string): Results.Result<TimeZoneOffset, ErrorEvents.ErrorEvent> => {\n if (value === 'Z') {\n return Results.success(0 as TimeZoneOffset)\n }\n\n if (!value.startsWith('+') && !value.startsWith('-')) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must start with +, -, or be Z.` }))\n }\n\n const sign = value[0] === '+' ? 1 : -1\n const offsetStr = value.slice(1)\n\n let hours = 0\n let minutes = 0\n\n // Parse different formats\n if (offsetStr.length === 1) {\n // +h format\n hours = parseInt(offsetStr, 10)\n if (isNaN(hours)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }))\n }\n } else if (offsetStr.length === 2) {\n // +hh format\n hours = parseInt(offsetStr, 10)\n if (isNaN(hours)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid hour value in time zone offset.` }))\n }\n } else if (offsetStr.includes(':')) {\n // Formats with colons: +hh:mm or +hh:mm:ss\n const parts = offsetStr.split(':')\n if (parts.length < 2 || parts.length > 3) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }))\n }\n\n hours = parseInt(parts[0]!, 10)\n minutes = parseInt(parts[1]!, 10)\n\n if (parts.length === 3) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }))\n }\n\n if (isNaN(hours) || isNaN(minutes)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }))\n }\n } else if (offsetStr.length === 4) {\n // +hhmm format\n hours = parseInt(offsetStr.slice(0, 2), 10)\n minutes = parseInt(offsetStr.slice(2, 4), 10)\n\n if (isNaN(hours) || isNaN(minutes)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time values in time zone offset.` }))\n }\n } else {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid time zone offset format.` }))\n }\n\n if (minutes >= 60) {\n return Results.failure(\n ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset - Invalid minutes in time zone offset: must be less than 60.` })\n )\n }\n\n let duration = Durations.from({ hours, minutes })\n if (sign === -1) {\n duration = duration.negated()\n }\n\n if (Durations.isLess(duration, EighteenHours.negated()) || Durations.isGreater(duration, EighteenHours)) {\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: `TimeZoneOffset must be between -18:00 and +18:00 inclusive.` }))\n }\n\n return Results.success(Durations.toMinutes(duration) as TimeZoneOffset)\n}\n\nexport const from = (value: string): TimeZoneOffset => {\n return ErrorEvents.unpackResult(parseString(value))\n}\n\nexport const Schema = Zod.union([ZodUtil.structuredTransform(Zod.number(), parseMinutes), ZodUtil.structuredTransform(Zod.string(), parseString)])\n\nexport const toDuration = (offset: TimeZoneOffset): Durations.Duration => {\n return Durations.fromMilliseconds(offset)\n}\n\nexport const toMilliseconds = (offset: TimeZoneOffset): number => {\n return offset\n}\n\nexport const toString = (offset: TimeZoneOffset): string => {\n if (offset === 0) {\n return 'Z'\n }\n\n const sign = offset > 0 ? '+' : '-'\n\n const time = PlainTimes.fromDuration(Durations.fromMinutes(Math.abs(offset)))\n return `${sign}${PlainTimes.toLiteral(time)}`\n}\n\nexport const Utc = 0 as TimeZoneOffset\n"],"mappings":";AACA,YAAY,eAAe;AAC3B,YAAY,gBAAgB;AAC5B,YAAY,aAAa;AACzB,OAAO,SAAS;AAChB,YAAY,iBAAiB;AAC7B,YAAY,kBAAkB;AAC9B,YAAY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AAC,WAAmC;AAC1D,MAAI,WAAW,GAAG;AAChB,WAAO;AAAA,EACT;AAEA,QAAM,OAAO,SAAS,IAAI,MAAM;AAEhC,QAAM,OAAkB,wBAAuB,sBAAY,KAAK,IAAI,MAAM,CAAC,CAAC;AAC5E,SAAO,GAAG,IAAI,GAAc,qBAAU,IAAI,CAAC;AAC7C;AAEO,IAAM,MAAM;","names":["fromMinutes","fromDuration","from"]}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
import * as ResourceKeys from '@bessemer/cornerstone/resource-key';
|
|
2
3
|
import { NominalType } from '@bessemer/cornerstone/types';
|
|
3
4
|
import { Comparator } from '@bessemer/cornerstone/comparator';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
5
|
+
import * as Equalitors from '@bessemer/cornerstone/equalitor';
|
|
6
|
+
import * as Results from '@bessemer/cornerstone/result';
|
|
7
|
+
import * as ErrorEvents from '@bessemer/cornerstone/error/error-event';
|
|
6
8
|
import Zod from 'zod';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
+
import * as Clocks from '@bessemer/cornerstone/temporal/clock';
|
|
10
|
+
import * as Durations from '@bessemer/cornerstone/temporal/duration';
|
|
11
|
+
import * as Instants from '@bessemer/cornerstone/temporal/instant';
|
|
9
12
|
import { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id';
|
|
10
13
|
import { TimeUnit } from '@bessemer/cornerstone/temporal/chrono';
|
|
11
14
|
import { PlainTimeBuilder, TimeFormatOptions } from '@bessemer/cornerstone/temporal/plain-time';
|
|
12
15
|
import { DateFormatOptions, PlainDateBuilder } from '@bessemer/cornerstone/temporal/plain-date';
|
|
13
16
|
export type ZonedDateTime = Temporal.ZonedDateTime;
|
|
14
|
-
export declare const Namespace:
|
|
17
|
+
export declare const Namespace: ResourceKeys.ResourceNamespace<"zoned-date-time">;
|
|
15
18
|
export type ZonedDateTimeLiteral = NominalType<string, typeof Namespace>;
|
|
16
19
|
export type ZonedDateTimeBuilder = PlainDateBuilder & PlainTimeBuilder & {
|
|
17
20
|
timeZone: TimeZoneId;
|
|
@@ -22,9 +25,9 @@ export declare function from(value: ZonedDateTimeLike | string | null): ZonedDat
|
|
|
22
25
|
export declare function from(value: ZonedDateTimeLike | string | undefined): ZonedDateTime | undefined;
|
|
23
26
|
export declare function from(value: ZonedDateTimeLike | string | null | undefined): ZonedDateTime | null | undefined;
|
|
24
27
|
export declare const CompareBy: Comparator<ZonedDateTime>;
|
|
25
|
-
export declare const EqualBy:
|
|
26
|
-
export declare const parseString: (value: string) => Result<ZonedDateTime, ErrorEvent>;
|
|
27
|
-
export declare const fromInstant: (instant: InstantLike, zone: TimeZoneId) => ZonedDateTime;
|
|
28
|
+
export declare const EqualBy: Equalitors.Equalitor<Temporal.ZonedDateTime>;
|
|
29
|
+
export declare const parseString: (value: string) => Results.Result<ZonedDateTime, ErrorEvents.ErrorEvent>;
|
|
30
|
+
export declare const fromInstant: (instant: Instants.InstantLike, zone: TimeZoneId) => ZonedDateTime;
|
|
28
31
|
export declare function toLiteral(likeValue: ZonedDateTimeLike): ZonedDateTimeLiteral;
|
|
29
32
|
export declare function toLiteral(likeValue: ZonedDateTimeLike | null): ZonedDateTimeLiteral | null;
|
|
30
33
|
export declare function toLiteral(likeValue: ZonedDateTimeLike | undefined): ZonedDateTimeLiteral | undefined;
|
|
@@ -34,13 +37,13 @@ export declare const SchemaInstance: Zod.ZodPipe<Zod.ZodString, Zod.ZodTransform
|
|
|
34
37
|
export declare const isPlainDateTime: (value: unknown) => value is ZonedDateTime;
|
|
35
38
|
export declare const now: (zone: TimeZoneId, clock?: {
|
|
36
39
|
readonly zone: TimeZoneId;
|
|
37
|
-
instant():
|
|
38
|
-
withZone(zone: TimeZoneId):
|
|
40
|
+
instant(): Instants.Instant;
|
|
41
|
+
withZone(zone: TimeZoneId): Clocks.Clock;
|
|
39
42
|
}) => ZonedDateTime;
|
|
40
43
|
export declare const merge: (element: ZonedDateTimeLike, builder: Partial<ZonedDateTimeBuilder>) => ZonedDateTime;
|
|
41
|
-
export declare const add: (element: ZonedDateTimeLike, duration: DurationLike) => ZonedDateTime;
|
|
42
|
-
export declare const subtract: (element: ZonedDateTimeLike, duration: DurationLike) => ZonedDateTime;
|
|
43
|
-
export declare const until: (element: ZonedDateTimeLike, other: ZonedDateTimeLike) => Duration;
|
|
44
|
+
export declare const add: (element: ZonedDateTimeLike, duration: Durations.DurationLike) => ZonedDateTime;
|
|
45
|
+
export declare const subtract: (element: ZonedDateTimeLike, duration: Durations.DurationLike) => ZonedDateTime;
|
|
46
|
+
export declare const until: (element: ZonedDateTimeLike, other: ZonedDateTimeLike) => Durations.Duration;
|
|
44
47
|
export declare const round: (element: ZonedDateTimeLike, unit: TimeUnit) => ZonedDateTime;
|
|
45
48
|
export declare function isEqual(element: ZonedDateTimeLike, other: ZonedDateTimeLike): boolean;
|
|
46
49
|
export declare function isEqual(element: ZonedDateTimeLike | null, other: ZonedDateTimeLike | null): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zoned-date-time.d.ts","sourceRoot":"","sources":["../../src/temporal/zoned-date-time.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"zoned-date-time.d.ts","sourceRoot":"","sources":["../../src/temporal/zoned-date-time.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAC7D,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAA;AAC7D,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAA;AACvD,OAAO,KAAK,WAAW,MAAM,yCAAyC,CAAA;AAGtE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O,MAAM,KAAK,GAAI,SAAS,iBAAiB,EAAE,MAAM,QAAQ,KAAG,aAElE,CAAA;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAA;AACtF,wBAAgB,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,EAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI,GAAG,OAAO,CAAA;AACpG,wBAAgB,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,SAAS,EAAE,KAAK,EAAE,iBAAiB,GAAG,SAAS,GAAG,OAAO,CAAA;AAS9G,eAAO,MAAM,QAAQ,GAAI,SAAS,iBAAiB,EAAE,OAAO,iBAAiB,KAAG,OAE/E,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,SAAS,iBAAiB,EAAE,OAAO,iBAAiB,KAAG,OAE9E,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG,iBAAiB,CAAA"}
|
|
@@ -1,87 +1,86 @@
|
|
|
1
1
|
// src/temporal/zoned-date-time.ts
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import * as ResourceKeys from "@bessemer/cornerstone/resource-key";
|
|
4
|
+
import * as Equalitors from "@bessemer/cornerstone/equalitor";
|
|
5
5
|
import * as Results from "@bessemer/cornerstone/result";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { structuredTransform } from "@bessemer/cornerstone/zod-util";
|
|
6
|
+
import * as ErrorEvents from "@bessemer/cornerstone/error/error-event";
|
|
7
|
+
import * as Errors from "@bessemer/cornerstone/error/error";
|
|
8
|
+
import * as ZodUtil from "@bessemer/cornerstone/zod-util";
|
|
10
9
|
import Zod from "zod";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
var Namespace = createNamespace("zoned-date-time");
|
|
17
|
-
function
|
|
18
|
-
if (isNil(value)) {
|
|
10
|
+
import * as Clocks from "@bessemer/cornerstone/temporal/clock";
|
|
11
|
+
import * as Durations from "@bessemer/cornerstone/temporal/duration";
|
|
12
|
+
import * as Instants from "@bessemer/cornerstone/temporal/instant";
|
|
13
|
+
import * as Strings from "@bessemer/cornerstone/string";
|
|
14
|
+
import * as Objects from "@bessemer/cornerstone/object";
|
|
15
|
+
var Namespace = ResourceKeys.createNamespace("zoned-date-time");
|
|
16
|
+
function from3(value) {
|
|
17
|
+
if (Objects.isNil(value)) {
|
|
19
18
|
return value;
|
|
20
19
|
}
|
|
21
20
|
if (value instanceof Temporal.ZonedDateTime) {
|
|
22
21
|
return value;
|
|
23
22
|
}
|
|
24
|
-
if (isString(value)) {
|
|
25
|
-
return unpackResult(parseString(value));
|
|
23
|
+
if (Strings.isString(value)) {
|
|
24
|
+
return ErrorEvents.unpackResult(parseString(value));
|
|
26
25
|
}
|
|
27
26
|
return Temporal.ZonedDateTime.from(value);
|
|
28
27
|
}
|
|
29
28
|
var CompareBy = (first, second) => Temporal.PlainDateTime.compare(first, second);
|
|
30
|
-
var EqualBy = fromComparator(CompareBy);
|
|
29
|
+
var EqualBy = Equalitors.fromComparator(CompareBy);
|
|
31
30
|
var parseString = (value) => {
|
|
32
31
|
try {
|
|
33
|
-
return success(Temporal.ZonedDateTime.from(value));
|
|
32
|
+
return Results.success(Temporal.ZonedDateTime.from(value));
|
|
34
33
|
} catch (e) {
|
|
35
|
-
if (!isError(e)) {
|
|
34
|
+
if (!Errors.isError(e)) {
|
|
36
35
|
throw e;
|
|
37
36
|
}
|
|
38
|
-
return failure(invalidValue(value, { namespace: Namespace, message: e.message }));
|
|
37
|
+
return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: e.message }));
|
|
39
38
|
}
|
|
40
39
|
};
|
|
41
40
|
var fromInstant = (instant, zone) => {
|
|
42
|
-
return
|
|
41
|
+
return Instants.from(instant).toZonedDateTimeISO(zone);
|
|
43
42
|
};
|
|
44
43
|
function toLiteral(likeValue) {
|
|
45
|
-
if (isNil(likeValue)) {
|
|
44
|
+
if (Objects.isNil(likeValue)) {
|
|
46
45
|
return likeValue;
|
|
47
46
|
}
|
|
48
|
-
const value =
|
|
47
|
+
const value = from3(likeValue);
|
|
49
48
|
return value.toString();
|
|
50
49
|
}
|
|
51
|
-
var SchemaLiteral = structuredTransform(Zod.string(), (it) => Results.map(parseString(it), (it2) => toLiteral(it2)));
|
|
52
|
-
var SchemaInstance = structuredTransform(Zod.string(), parseString);
|
|
50
|
+
var SchemaLiteral = ZodUtil.structuredTransform(Zod.string(), (it) => Results.map(parseString(it), (it2) => toLiteral(it2)));
|
|
51
|
+
var SchemaInstance = ZodUtil.structuredTransform(Zod.string(), parseString);
|
|
53
52
|
var isPlainDateTime = (value) => {
|
|
54
53
|
return value instanceof Temporal.PlainDateTime;
|
|
55
54
|
};
|
|
56
|
-
var now = (zone, clock =
|
|
55
|
+
var now = (zone, clock = Clocks.Default) => {
|
|
57
56
|
return fromInstant(clock.instant(), zone);
|
|
58
57
|
};
|
|
59
58
|
var merge = (element, builder) => {
|
|
60
|
-
return
|
|
59
|
+
return from3(element).with(builder);
|
|
61
60
|
};
|
|
62
61
|
var add = (element, duration) => {
|
|
63
|
-
return
|
|
62
|
+
return from3(element).add(Durations.from(duration));
|
|
64
63
|
};
|
|
65
64
|
var subtract = (element, duration) => {
|
|
66
|
-
return
|
|
65
|
+
return from3(element).subtract(Durations.from(duration));
|
|
67
66
|
};
|
|
68
67
|
var until = (element, other) => {
|
|
69
|
-
return
|
|
68
|
+
return from3(element).until(from3(other));
|
|
70
69
|
};
|
|
71
70
|
var round = (element, unit) => {
|
|
72
|
-
return
|
|
71
|
+
return from3(element).round({ smallestUnit: unit });
|
|
73
72
|
};
|
|
74
73
|
function isEqual(element, other) {
|
|
75
|
-
if (isNil(element) || isNil(other)) {
|
|
74
|
+
if (Objects.isNil(element) || Objects.isNil(other)) {
|
|
76
75
|
return element === other;
|
|
77
76
|
}
|
|
78
|
-
return EqualBy(
|
|
77
|
+
return EqualBy(from3(element), from3(other));
|
|
79
78
|
}
|
|
80
79
|
var isBefore = (element, other) => {
|
|
81
|
-
return CompareBy(
|
|
80
|
+
return CompareBy(from3(element), from3(other)) < 0;
|
|
82
81
|
};
|
|
83
82
|
var isAfter = (element, other) => {
|
|
84
|
-
return CompareBy(
|
|
83
|
+
return CompareBy(from3(element), from3(other)) > 0;
|
|
85
84
|
};
|
|
86
85
|
export {
|
|
87
86
|
CompareBy,
|
|
@@ -90,7 +89,7 @@ export {
|
|
|
90
89
|
SchemaInstance,
|
|
91
90
|
SchemaLiteral,
|
|
92
91
|
add,
|
|
93
|
-
from,
|
|
92
|
+
from3 as from,
|
|
94
93
|
fromInstant,
|
|
95
94
|
isAfter,
|
|
96
95
|
isBefore,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/temporal/zoned-date-time.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/temporal/zoned-date-time.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport * as ResourceKeys from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport * as Equalitors from '@bessemer/cornerstone/equalitor'\nimport * as Results from '@bessemer/cornerstone/result'\nimport * as ErrorEvents from '@bessemer/cornerstone/error/error-event'\nimport * as Errors from '@bessemer/cornerstone/error/error'\nimport * as ZodUtil from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport * as Clocks from '@bessemer/cornerstone/temporal/clock'\nimport * as Durations from '@bessemer/cornerstone/temporal/duration'\nimport * as Instants from '@bessemer/cornerstone/temporal/instant'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport { TimeUnit } from '@bessemer/cornerstone/temporal/chrono'\nimport * as Strings from '@bessemer/cornerstone/string'\nimport * as Objects from '@bessemer/cornerstone/object'\nimport { PlainTimeBuilder, TimeFormatOptions } from '@bessemer/cornerstone/temporal/plain-time'\nimport { DateFormatOptions, PlainDateBuilder } from '@bessemer/cornerstone/temporal/plain-date'\n\nexport type ZonedDateTime = Temporal.ZonedDateTime\nexport const Namespace = ResourceKeys.createNamespace('zoned-date-time')\nexport type ZonedDateTimeLiteral = NominalType<string, typeof Namespace>\nexport type ZonedDateTimeBuilder = PlainDateBuilder &\n PlainTimeBuilder & {\n timeZone: TimeZoneId\n }\n\nexport type ZonedDateTimeLike = ZonedDateTime | ZonedDateTimeLiteral | ZonedDateTimeBuilder\n\nexport function from(value: ZonedDateTimeLike | string): ZonedDateTime\nexport function from(value: ZonedDateTimeLike | string | null): ZonedDateTime | null\nexport function from(value: ZonedDateTimeLike | string | undefined): ZonedDateTime | undefined\nexport function from(value: ZonedDateTimeLike | string | null | undefined): ZonedDateTime | null | undefined\nexport function from(value: ZonedDateTimeLike | string | null | undefined): ZonedDateTime | null | undefined {\n if (Objects.isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.ZonedDateTime) {\n return value\n }\n\n if (Strings.isString(value)) {\n return ErrorEvents.unpackResult(parseString(value))\n }\n\n return Temporal.ZonedDateTime.from(value)\n}\n\nexport const CompareBy: Comparator<ZonedDateTime> = (first: ZonedDateTime, second: ZonedDateTime): number =>\n Temporal.PlainDateTime.compare(first, second)\nexport const EqualBy = Equalitors.fromComparator(CompareBy)\n\nexport const parseString = (value: string): Results.Result<ZonedDateTime, ErrorEvents.ErrorEvent> => {\n try {\n return Results.success(Temporal.ZonedDateTime.from(value))\n } catch (e) {\n if (!Errors.isError(e)) {\n throw e\n }\n\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport const fromInstant = (instant: Instants.InstantLike, zone: TimeZoneId): ZonedDateTime => {\n return Instants.from(instant).toZonedDateTimeISO(zone)\n}\n\nexport function toLiteral(likeValue: ZonedDateTimeLike): ZonedDateTimeLiteral\nexport function toLiteral(likeValue: ZonedDateTimeLike | null): ZonedDateTimeLiteral | null\nexport function toLiteral(likeValue: ZonedDateTimeLike | undefined): ZonedDateTimeLiteral | undefined\nexport function toLiteral(likeValue: ZonedDateTimeLike | null | undefined): ZonedDateTimeLiteral | null | undefined\nexport function toLiteral(likeValue: ZonedDateTimeLike | null | undefined): ZonedDateTimeLiteral | null | undefined {\n if (Objects.isNil(likeValue)) {\n return likeValue\n }\n\n const value = from(likeValue)\n return value.toString() as ZonedDateTimeLiteral\n}\n\nexport const SchemaLiteral = ZodUtil.structuredTransform(Zod.string(), (it: string) => Results.map(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = ZodUtil.structuredTransform(Zod.string(), parseString)\n\nexport const isPlainDateTime = (value: unknown): value is ZonedDateTime => {\n return value instanceof Temporal.PlainDateTime\n}\n\nexport const now = (zone: TimeZoneId, clock = Clocks.Default): ZonedDateTime => {\n return fromInstant(clock.instant(), zone)\n}\n\nexport const merge = (element: ZonedDateTimeLike, builder: Partial<ZonedDateTimeBuilder>): ZonedDateTime => {\n return from(element).with(builder)\n}\n\nexport const add = (element: ZonedDateTimeLike, duration: Durations.DurationLike): ZonedDateTime => {\n return from(element).add(Durations.from(duration))\n}\n\nexport const subtract = (element: ZonedDateTimeLike, duration: Durations.DurationLike): ZonedDateTime => {\n return from(element).subtract(Durations.from(duration))\n}\n\nexport const until = (element: ZonedDateTimeLike, other: ZonedDateTimeLike): Durations.Duration => {\n return from(element).until(from(other))\n}\n\nexport const round = (element: ZonedDateTimeLike, unit: TimeUnit): ZonedDateTime => {\n return from(element).round({ smallestUnit: unit })\n}\n\nexport function isEqual(element: ZonedDateTimeLike, other: ZonedDateTimeLike): boolean\nexport function isEqual(element: ZonedDateTimeLike | null, other: ZonedDateTimeLike | null): boolean\nexport function isEqual(element: ZonedDateTimeLike | undefined, other: ZonedDateTimeLike | undefined): boolean\nexport function isEqual(element: ZonedDateTimeLike | null | undefined, other: ZonedDateTimeLike | null | undefined): boolean {\n if (Objects.isNil(element) || Objects.isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isBefore = (element: ZonedDateTimeLike, other: ZonedDateTimeLike): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isAfter = (element: ZonedDateTimeLike, other: ZonedDateTimeLike): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport type DateTimeFormatOptions = DateFormatOptions & TimeFormatOptions\n\n// JOHN need to consider what to do about time zone offset vs. time zone id discrepancy\n// export const format = (element: ZonedDateTimeLike, locale: Locale, options: DateTimeFormatOptions): string => {\n// const zonedDateTime = from(element)\n//\n// // Convert PlainDateTime to Date\n// const date = new Date(\n// zonedDateTime.year,\n// zonedDateTime.month - 1, // Date months are 0-based\n// zonedDateTime.day,\n// zonedDateTime.hour,\n// zonedDateTime.minute,\n// zonedDateTime.second,\n// zonedDateTime.millisecond\n// )\n//\n// const formatter = new Intl.DateTimeFormat(locale, { ...options, timeZone: zonedDateTime.timeZoneId })\n// return formatter.format(date)\n// }\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,YAAY,kBAAkB;AAG9B,YAAY,gBAAgB;AAC5B,YAAY,aAAa;AACzB,YAAY,iBAAiB;AAC7B,YAAY,YAAY;AACxB,YAAY,aAAa;AACzB,OAAO,SAAS;AAChB,YAAY,YAAY;AACxB,YAAY,eAAe;AAC3B,YAAY,cAAc;AAG1B,YAAY,aAAa;AACzB,YAAY,aAAa;AAKlB,IAAM,YAAyB,6BAAgB,iBAAiB;AAahE,SAASA,MAAK,OAAwF;AAC3G,MAAY,cAAM,KAAK,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,SAAS,eAAe;AAC3C,WAAO;AAAA,EACT;AAEA,MAAY,iBAAS,KAAK,GAAG;AAC3B,WAAmB,yBAAa,YAAY,KAAK,CAAC;AAAA,EACpD;AAEA,SAA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AAK,OAAO,EAAE,SAAmB,eAAK,QAAQ,CAAC;AACxD;AAEO,IAAM,QAAQ,CAAC,SAA4B,UAAiD;AACjG,SAAOA,MAAK,OAAO,EAAE,MAAMA,MAAK,KAAK,CAAC;AACxC;AAEO,IAAM,QAAQ,CAAC,SAA4B,SAAkC;AAClF,SAAOA,MAAK,OAAO,EAAE,MAAM,EAAE,cAAc,KAAK,CAAC;AACnD;AAKO,SAAS,QAAQ,SAA+C,OAAsD;AAC3H,MAAY,cAAM,OAAO,KAAa,cAAM,KAAK,GAAG;AAClD,WAAO,YAAY;AAAA,EACrB;AAEA,SAAO,QAAQA,MAAK,OAAO,GAAGA,MAAK,KAAK,CAAC;AAC3C;AAEO,IAAM,WAAW,CAAC,SAA4B,UAAsC;AACzF,SAAO,UAAUA,MAAK,OAAO,GAAGA,MAAK,KAAK,CAAC,IAAI;AACjD;AAEO,IAAM,UAAU,CAAC,SAA4B,UAAsC;AACxF,SAAO,UAAUA,MAAK,OAAO,GAAGA,MAAK,KAAK,CAAC,IAAI;AACjD;","names":["from","it"]}
|
package/dist/uuid/ulid.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { NominalType } from '@bessemer/cornerstone/types';
|
|
2
|
-
import Zod from 'zod';
|
|
3
2
|
import { Result } from '@bessemer/cornerstone/result';
|
|
3
|
+
import * as ResourceKeys from '@bessemer/cornerstone/resource-key';
|
|
4
4
|
import { ErrorEvent } from '@bessemer/cornerstone/error/error-event';
|
|
5
|
-
export declare const Namespace:
|
|
5
|
+
export declare const Namespace: ResourceKeys.ResourceNamespace<"ulid">;
|
|
6
6
|
export type Ulid = NominalType<string, typeof Namespace>;
|
|
7
7
|
export declare const parse: (value: string) => Result<Ulid, ErrorEvent>;
|
|
8
8
|
export declare const from: (value: string) => Ulid;
|
|
9
|
-
export declare const Schema:
|
|
9
|
+
export declare const Schema: import("zod").ZodPipe<import("zod").ZodType<Ulid, Ulid, import("zod/v4/core").$ZodTypeInternals<Ulid, Ulid>>, import("zod").ZodTransform<Ulid, Ulid>>;
|
|
10
10
|
export declare const generate: () => Ulid;
|
|
11
11
|
//# sourceMappingURL=ulid.d.ts.map
|
package/dist/uuid/ulid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ulid.d.ts","sourceRoot":"","sources":["../../src/uuid/ulid.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"ulid.d.ts","sourceRoot":"","sources":["../../src/uuid/ulid.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AACrD,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAA;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAA;AAGpE,eAAO,MAAM,SAAS,wCAAuC,CAAA;AAC7D,MAAM,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,EAAE,OAAO,SAAS,CAAC,CAAA;AAExD,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,KAAG,MAAM,CAAC,IAAI,EAAE,UAAU,CAM5D,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,OAAO,MAAM,KAAG,IAEpC,CAAA;AAED,eAAO,MAAM,MAAM,uJAIjB,CAAA;AAEF,eAAO,MAAM,QAAQ,QAAO,IAE3B,CAAA"}
|