@magmacomputing/tempo 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.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +61 -0
  3. package/dist/array.library.d.ts +25 -0
  4. package/dist/array.library.js +78 -0
  5. package/dist/buffer.library.d.ts +6 -0
  6. package/dist/buffer.library.js +192 -0
  7. package/dist/cipher.class.d.ts +18 -0
  8. package/dist/cipher.class.js +65 -0
  9. package/dist/class.library.d.ts +10 -0
  10. package/dist/class.library.js +57 -0
  11. package/dist/coercion.library.d.ts +14 -0
  12. package/dist/coercion.library.js +71 -0
  13. package/dist/enumerate.library.d.ts +64 -0
  14. package/dist/enumerate.library.js +54 -0
  15. package/dist/function.library.d.ts +9 -0
  16. package/dist/function.library.js +49 -0
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.js +3 -0
  19. package/dist/logify.class.d.ts +33 -0
  20. package/dist/logify.class.js +53 -0
  21. package/dist/number.library.d.ts +16 -0
  22. package/dist/number.library.js +36 -0
  23. package/dist/object.library.d.ts +37 -0
  24. package/dist/object.library.js +94 -0
  25. package/dist/pledge.class.d.ts +54 -0
  26. package/dist/pledge.class.js +131 -0
  27. package/dist/prototype.library.d.ts +33 -0
  28. package/dist/prototype.library.js +51 -0
  29. package/dist/reflection.library.d.ts +74 -0
  30. package/dist/reflection.library.js +97 -0
  31. package/dist/serialize.library.d.ts +25 -0
  32. package/dist/serialize.library.js +266 -0
  33. package/dist/storage.library.d.ts +8 -0
  34. package/dist/storage.library.js +57 -0
  35. package/dist/string.library.d.ts +37 -0
  36. package/dist/string.library.js +93 -0
  37. package/dist/tempo.class.d.ts +556 -0
  38. package/dist/tempo.class.js +1412 -0
  39. package/dist/tempo.config/plugins/term.import.d.ts +42 -0
  40. package/dist/tempo.config/plugins/term.import.js +44 -0
  41. package/dist/tempo.config/plugins/term.quarter.d.ts +7 -0
  42. package/dist/tempo.config/plugins/term.quarter.js +28 -0
  43. package/dist/tempo.config/plugins/term.season.d.ts +7 -0
  44. package/dist/tempo.config/plugins/term.season.js +36 -0
  45. package/dist/tempo.config/plugins/term.timeline.d.ts +7 -0
  46. package/dist/tempo.config/plugins/term.timeline.js +19 -0
  47. package/dist/tempo.config/plugins/term.utils.d.ts +17 -0
  48. package/dist/tempo.config/plugins/term.utils.js +38 -0
  49. package/dist/tempo.config/plugins/term.zodiac.d.ts +7 -0
  50. package/dist/tempo.config/plugins/term.zodiac.js +62 -0
  51. package/dist/tempo.config/tempo.default.d.ts +169 -0
  52. package/dist/tempo.config/tempo.default.js +158 -0
  53. package/dist/tempo.config/tempo.enum.d.ts +99 -0
  54. package/dist/tempo.config/tempo.enum.js +78 -0
  55. package/dist/temporal.polyfill.d.ts +9 -0
  56. package/dist/temporal.polyfill.js +18 -0
  57. package/dist/type.library.d.ts +296 -0
  58. package/dist/type.library.js +80 -0
  59. package/dist/utility.library.d.ts +32 -0
  60. package/dist/utility.library.js +54 -0
  61. package/package.json +54 -0
@@ -0,0 +1,158 @@
1
+ import { looseIndex } from '../object.library.js';
2
+ import { secure } from '../utility.library.js';
3
+ /** common RegExp patterns */
4
+ export const Match = {
5
+ /** match all {} pairs, if they start with a word char */ braces: /{([\w]+(?:\.[\w]+)*)}/g,
6
+ /** named capture-group, if it starts with a letter */ captures: /\(\?<([a-zA-Z][\w]*)>(.*?)(?<!\\)\)/g,
7
+ /** event */ event: /^(g|l)evt[0-9]+$/,
8
+ /** period */ period: /^(g|l)per[0-9]+$/,
9
+ /** two digit year */ twoDigit: /^[0-9]{2}$/,
10
+ /** hour-minute-second with no separator */ hhmiss: /(hh)(m[i|m])(ss)?/i,
11
+ /** separator characters (/ - . ,) */ separator: /[\/\-\.\s,]/,
12
+ /** modifier characters (+-<>=) */ modifier: /[\+\-\<\>][\=]?|this|next|prev|last/,
13
+ /** offset post keywords (ago|hence) */ affix: /ago|hence/,
14
+ /** strip out these characters from a string */ strips: /\(|\)/g,
15
+ };
16
+ /** Tempo Symbol registry */
17
+ export const Token = looseIndex()({
18
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Snippet Symbols
19
+ /** year */ yy: Symbol('yy'),
20
+ /** month */ mm: Symbol('mm'),
21
+ /** day */ dd: Symbol('dd'),
22
+ /** hour */ hh: Symbol('hh'),
23
+ /** minute */ mi: Symbol('mi'),
24
+ /** second */ ss: Symbol('ss'),
25
+ /** fraction */ ff: Symbol('ff'),
26
+ /** meridiem */ mer: Symbol('mer'),
27
+ /** short weekday name */ www: Symbol('www'),
28
+ /** relative-suffix */ afx: Symbol('afx'),
29
+ /** time-suffix */ sfx: Symbol('sfx'),
30
+ /** time unit */ unt: Symbol('unt'),
31
+ /** separator */ sep: Symbol('sep'),
32
+ /** modifier */ mod: Symbol('mod'),
33
+ /** generic number */ nbr: Symbol('nbr'),
34
+ /** Tempo event */ evt: Symbol('evt'),
35
+ /** Tempo period */ per: Symbol('per'),
36
+ /** time zone offset */ tzd: Symbol('tzd'),
37
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Layout Symbols
38
+ /** date */ dt: Symbol('date'),
39
+ /** time */ tm: Symbol('time'),
40
+ /** date and time */ dtm: Symbol('dateTime'),
41
+ /** day-month-year */ dmy: Symbol('dayMonthYear'),
42
+ /** month-day-year */ mdy: Symbol('monthDayYear'),
43
+ /** year-month-day */ ymd: Symbol('yearMonthDay'),
44
+ /** day of month offset */ off: Symbol('offset'),
45
+ /** weekDay */ wkd: Symbol('weekDay'),
46
+ /** relative offset (years, days, hours, etc) */ rel: Symbol('relativeOffset'),
47
+ });
48
+ /**
49
+ * user will need to know these in order to configure their own patterns
50
+ * Tempo.Snippet is a simple regex pattern object , e.g. { Symbol('yy'): /(([0-9]{2})?[0-9]{2})/ }
51
+ * Tempo.Layout is a string-combination of Snippet names , e.g. '{yy}{sep}{mm}({sep}{dd})?{sfx}?'
52
+ * Tempo.Pattern is a translation of a Layout/Snippets into an anchored regex.
53
+ * The {pattern} is used to parse a string | number in the Tempo constructor {DateTime} argument
54
+ */
55
+ /**
56
+ * a {snippet} is a simple, reusable regex pattern for a component of a date-time string (e.g. 'hh' or 'yy')
57
+ */
58
+ // Note: computed Components ('evt', 'per') are added during 'Tempo.init()' (for static) and/or 'new Tempo()' (per instance)
59
+ export const Snippet = looseIndex()({
60
+ [Token.yy]: /(?<yy>([0-9]{2})?[0-9]{2})/, // arbitrary upper-limit of yy=9999
61
+ [Token.mm]: /(?<mm>[0\s]?[1-9]|1[0-2]|Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)/, // month-name (abbrev or full) or month-number 01-12
62
+ [Token.dd]: /(?<dd>[0\s]?[1-9]|[12][0-9]|3[01])/, // day-number 01-31
63
+ [Token.hh]: /(?<hh>2[0-4]|[01]?[0-9])/, // hour-number 00-24
64
+ [Token.mi]: /(\:(?<mi>[0-5][0-9]))/, // minute-number 00-59
65
+ [Token.ss]: /(\:(?<ss>[0-5][0-9]))/, // seconds-number 00-59
66
+ [Token.ff]: /(\.(?<ff>[0-9]{1,9}))/, // fractional-seconds up-to 9-digits
67
+ [Token.mer]: /(\s*(?<mer>am|pm))/, // meridiem suffix (am,pm)
68
+ [Token.sfx]: /((?:{sep}+|T)({tm}){tzd}?)/, // time-pattern suffix 'T {tm} Z'
69
+ [Token.wkd]: /(?<wkd>Mon(?:day)?|Tue(?:sday)?|Wed(?:nesday)?|Thu(?:rsday)?|Fri(?:day)?|Sat(?:urday)?|Sun(?:day)?)/, // day-name (abbrev or full)
70
+ [Token.tzd]: /(?<tzd>Z|(?:\+(?:(?:0[0-9]|1[0-3]):?[0-5][0-9]|14:00)|-(?:(?:0[0-9]|1[0-1]):?[0-5][0-9]|12:00)))/, // time-zone offset +14:00 to -12:00
71
+ [Token.nbr]: /(?<nbr>[0-9]*)/, // modifier count
72
+ [Token.afx]: new RegExp(`((s)? (?<afx>${Match.affix.source}))?{sep}?`), // affix optional plural 's' and (ago|hence)
73
+ [Token.mod]: new RegExp(`((?<mod>${Match.modifier.source})?{nbr} *)`), // modifier (+,-,<,<=,>,>=) plus optional offset-count
74
+ [Token.sep]: new RegExp(`(?:${Match.separator.source})`), // date-input separator character "/\\-., " (non-capture group)
75
+ [Token.unt]: /(?<unt>year|month|week|day|hour|minute|second|millisecond)(?:s)?/, // useful for '2 days ago' etc
76
+ });
77
+ /**
78
+ * a {layout} is a Record of snippet-combinations describing an input DateTime argument
79
+ * the Layout's keys are in the order that they will be checked against an input value
80
+ */
81
+ export const Layout = looseIndex()({
82
+ [Token.dt]: '{dd}{sep}?{mm}({sep}?{yy})?|{mod}?({evt})', // calendar or event
83
+ [Token.tm]: '({hh}{mi}?{ss}?{ff}?{mer}?|{per})', // clock or period
84
+ [Token.dtm]: '({dt}){sfx}?', // calendar/event and clock/period
85
+ [Token.dmy]: '({wkd}{sep}+)?{dd}{sep}?{mm}({sep}?{yy})?{sfx}?', // day-month(-year)
86
+ [Token.mdy]: '({wkd}{sep}+)?{mm}{sep}?{dd}({sep}?{yy})?{sfx}?', // month-day(-year)
87
+ [Token.ymd]: '({wkd}{sep}+)?{yy}{sep}?{mm}({sep}?{dd})?{sfx}?', // year-month(-day)
88
+ [Token.wkd]: '{mod}?{wkd}{afx}?{sfx}?', // special layout (no {dt}!) used for weekday calcs (only one that requires {wkd} pattern)
89
+ [Token.off]: '{mod}?{dd}{afx}?', // day of month, with optional offset
90
+ [Token.rel]: '{nbr}{sep}?{unt}{sep}?{afx}', // relative duration (e.g. 2 days ago)
91
+ });
92
+ /**
93
+ * an {event} is a Record of regex-pattern-like-string keys that describe Date strings.
94
+ * values can be a string or a function.
95
+ * if assigning a function, use standard 'function()' syntax to allow for 'this' binding.
96
+ * also, a function should always have a .toString() method which returns a parse-able Date string
97
+ */
98
+ export const Event = looseIndex()({
99
+ 'new.?years? ?eve': '31 Dec',
100
+ 'nye': '31 Dec',
101
+ 'new.?years?( ?day)?': '01 Jan',
102
+ 'ny': '01 Jan',
103
+ 'christmas ?eve': '24 Dec',
104
+ 'christmas': '25 Dec',
105
+ 'xmas ?eve': '24 Dec',
106
+ 'xmas': '25 Dec',
107
+ 'now': function () { return Temporal.Now.instant(); },
108
+ 'today': function () { return Temporal.Now.plainDateISO(); },
109
+ 'tomorrow': function () { return Temporal.Now.plainDateISO().add({ days: 1 }); },
110
+ 'yesterday': function () { return Temporal.Now.plainDateISO().add({ days: -1 }); },
111
+ });
112
+ /**
113
+ * a {period} is a Record of regex-pattern-like keys that describe pre-defined Time strings.
114
+ * values can be a string or a function.
115
+ * if using a function, use regular 'function()' syntax to allow for 'this' binding.
116
+ */
117
+ export const Period = looseIndex()({
118
+ 'mid[ -]?night': '24:00',
119
+ 'morning': '8:00',
120
+ 'mid[ -]?morning': '10:00',
121
+ 'mid[ -]?day': '12:00',
122
+ 'noon': '12:00',
123
+ 'after[ -]?noon': '3:00pm',
124
+ 'evening': '18:00',
125
+ 'night': '20:00',
126
+ });
127
+ /**
128
+ * a {timeZone} alias dictionary mapping common abbreviations to IANA strings.
129
+ * Tempo will check this registry to convert abbreviations before passing them to Temporal.
130
+ */
131
+ export const TimeZone = looseIndex()({
132
+ 'utc': 'UTC',
133
+ 'gmt': 'Europe/London',
134
+ 'est': 'America/New_York',
135
+ 'cst': 'America/Chicago',
136
+ 'mst': 'America/Denver',
137
+ 'pst': 'America/Los_Angeles',
138
+ 'aest': 'Australia/Sydney',
139
+ 'acst': 'Australia/Adelaide',
140
+ 'awst': 'Australia/Perth',
141
+ 'nzt': 'Pacific/Auckland',
142
+ 'cet': 'Europe/Paris',
143
+ 'eet': 'Europe/Helsinki',
144
+ 'ist': 'Asia/Kolkata',
145
+ 'npt': 'Asia/Kathmandu',
146
+ 'jst': 'Asia/Tokyo',
147
+ });
148
+ /** Reasonable default options for initial Tempo config */
149
+ export const Options = ['value', 'mdyLocales', 'mdyLayouts', 'store', 'debug', 'catch', 'timeZone', 'calendar', 'locale', 'pivot', 'sphere', 'timeStamp', 'snippet', 'layout', 'event', 'period'];
150
+ export const Default = secure({
151
+ /** log to console */ debug: false,
152
+ /** catch or throw Errors */ catch: false,
153
+ /** used to parse two-digit years*/ pivot: 75, /** @link https://en.wikipedia.org/wiki/Date_windowing */
154
+ /** precision to measure timestamps (ms | us) */ timeStamp: 'ms',
155
+ /** calendaring system */ calendar: 'iso8601',
156
+ /** locales that prefer month-day order */ mdyLocales: ['en-US', 'en-AS'], /** @link https://en.wikipedia.org/wiki/Date_format_by_country */
157
+ /** layouts that need to swap parse-order */ mdyLayouts: [['dayMonthYear', 'monthDayYear']],
158
+ });
@@ -0,0 +1,99 @@
1
+ import type { KeyOf, LooseUnion, ValueOf } from '../type.library.js';
2
+ /**
3
+ * Various enumerations used throughout Tempo library.
4
+ * These are exported and added as static getters of the Tempo class.
5
+ * Usage example:
6
+ ```javascript
7
+ const dayNames = Tempo.WEEKDAY.keys(); // ['All', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
8
+ */
9
+ /** */
10
+ export declare const WEEKDAY: import("../enumerate.library.js").Enum.wrap<import("../type.library.js").Index<readonly ["All", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]>>;
11
+ export declare const WEEKDAYS: import("../enumerate.library.js").Enum.wrap<import("../type.library.js").Index<readonly ["Everyday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]>>;
12
+ export type WEEKDAY = KeyOf<typeof WEEKDAY>;
13
+ export type WEEKDAYS = KeyOf<typeof WEEKDAYS>;
14
+ export type Weekday = ValueOf<typeof WEEKDAY>;
15
+ export declare const MONTH: import("../enumerate.library.js").Enum.wrap<import("../type.library.js").Index<readonly ["All", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]>>;
16
+ export declare const MONTHS: import("../enumerate.library.js").Enum.wrap<import("../type.library.js").Index<readonly ["Every", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]>>;
17
+ export type MONTH = KeyOf<typeof MONTH>;
18
+ export type MONTHS = KeyOf<typeof MONTHS>;
19
+ export type Month = ValueOf<typeof MONTH>;
20
+ /** DURATION is now an alias for TIME */
21
+ export declare const SEASON: import("../enumerate.library.js").Enum.wrap<{
22
+ readonly Summer: "summer";
23
+ readonly Autumn: "autumn";
24
+ readonly Winter: "winter";
25
+ readonly Spring: "spring";
26
+ }>;
27
+ export declare const COMPASS: import("../enumerate.library.js").Enum.wrap<{
28
+ readonly North: "north";
29
+ readonly East: "east";
30
+ readonly South: "south";
31
+ readonly West: "west";
32
+ }>;
33
+ export type SEASON = ValueOf<typeof SEASON>;
34
+ export type COMPASS = ValueOf<typeof COMPASS>;
35
+ /** number of seconds in a time unit */
36
+ export declare const DURATION: import("../enumerate.library.js").Enum.wrap<{
37
+ /** approx number of seconds in a year */ readonly year: 31536000;
38
+ /** approx number of seconds in a month */ readonly month: 2628000;
39
+ /** number of seconds in a week */ readonly week: 604800;
40
+ /** number of seconds in a day */ readonly day: 86400;
41
+ /** number of seconds in an hour */ readonly hour: 3600;
42
+ /** number of seconds in a minute */ readonly minute: 60;
43
+ /** one second */ readonly second: 1;
44
+ /** number of seconds in a millisecond */ readonly millisecond: 0.001;
45
+ /** number of seconds in a microsecond */ readonly microsecond: 0.000001;
46
+ /** number of seconds in a nanosecond */ readonly nanosecond: 1e-9;
47
+ }>;
48
+ /** number of milliseconds in a time unit */
49
+ export declare const DURATIONS: import("../enumerate.library.js").Enum.wrap<{
50
+ /** approx number of milliseconds in a year */ readonly years: number;
51
+ /** approx number of milliseconds in a month */ readonly months: number;
52
+ /** number of milliseconds in a week */ readonly weeks: number;
53
+ /** number of milliseconds in a day */ readonly days: number;
54
+ /** number of milliseconds in an hour */ readonly hours: number;
55
+ /** number of milliseconds in a minute */ readonly minutes: number;
56
+ /** number of milliseconds in a second */ readonly seconds: number;
57
+ /** one millisecond */ readonly milliseconds: number;
58
+ /** number of milliseconds in a microsecond */ readonly microseconds: number;
59
+ /** number of milliseconds in a nanosecond */ readonly nanoseconds: number;
60
+ }>;
61
+ export type DURATION = KeyOf<typeof DURATION>;
62
+ export type DURATIONS = KeyOf<typeof DURATIONS>;
63
+ /** pre-defined Format code short-cuts */
64
+ export declare const FORMAT: import("../enumerate.library.js").Enum.wrap<{
65
+ /** useful for standard date display */ readonly display: "{www}, {dd} {mmm} {yyyy}";
66
+ /** useful for standard datestamps */ readonly weekDate: "{www}, {yyyy}-{mmm}-{dd}";
67
+ /** useful for standard timestamps */ readonly weekTime: "{www}, {yyyy}-{mmm}-{dd} {hh}:{mi}:{ss}";
68
+ /** useful for standard full timestamps */ readonly weekStamp: "{www}, {yyyy}-{mmm}-{dd} {hh}:{mi}:{ss}.{ff}";
69
+ /** useful for readable month and day */ readonly dayMonth: "{dd}-{mmm}";
70
+ /** useful for Date */ readonly dayDate: "{dd}-{mmm}-{yyyy}";
71
+ /** display with Time */ readonly dayTime: "{dd}-{mmm}-{yyyy} {hh}:{mi}:{ss}";
72
+ /** useful for stamping logs */ readonly logStamp: "{yyyy}{mm}{dd}T{hhmiss}.{ff}";
73
+ /** useful for sorting display-strings */ readonly sortTime: "{yyyy}-{mm}-{dd} {hh}:{mi}:{ss}";
74
+ /** useful for sorting week order */ readonly yearWeek: "{yyyy}{ww}";
75
+ /** useful for sorting month order */ readonly yearMonth: "{yyyy}{mm}";
76
+ /** useful for sorting date order */ readonly yearMonthDay: "{yyyy}{mm}{dd}";
77
+ /** just Date portion */ readonly date: "{yyyy}-{mm}-{dd}";
78
+ /** just Time portion */ readonly time: "{hh}:{mi}:{ss}";
79
+ }>;
80
+ export type FORMAT = ValueOf<typeof FORMAT>;
81
+ export type Format = LooseUnion<KeyOf<typeof FORMAT>>;
82
+ export declare const LIMIT: import("../type.library.js").SecureObject<{
83
+ /** Tempo(31-Dec-9999.23:59:59).ns */ readonly maxTempo: bigint;
84
+ /** Tempo(01-Jan-1000.00:00:00).ns */ readonly minTempo: bigint;
85
+ }>;
86
+ export declare const ELEMENT: import("../enumerate.library.js").Enum.wrap<{
87
+ readonly yy: "year";
88
+ readonly mm: "month";
89
+ readonly ww: "week";
90
+ readonly dd: "day";
91
+ readonly hh: "hour";
92
+ readonly mi: "minute";
93
+ readonly ss: "second";
94
+ readonly ms: "millisecond";
95
+ readonly us: "microsecond";
96
+ readonly ns: "nanosecond";
97
+ }>;
98
+ export type ELEMENT = ValueOf<typeof ELEMENT>;
99
+ export type Element = KeyOf<typeof ELEMENT>;
@@ -0,0 +1,78 @@
1
+ import { enumify } from '../enumerate.library.js';
2
+ import { secure } from '../utility.library.js';
3
+ /**
4
+ * Various enumerations used throughout Tempo library.
5
+ * These are exported and added as static getters of the Tempo class.
6
+ * Usage example:
7
+ ```javascript
8
+ const dayNames = Tempo.WEEKDAY.keys(); // ['All', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
9
+ */
10
+ /** */
11
+ export const WEEKDAY = enumify(['All', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']);
12
+ export const WEEKDAYS = enumify(['Everyday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']);
13
+ export const MONTH = enumify(['All', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
14
+ export const MONTHS = enumify(['Every', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']);
15
+ /** DURATION is now an alias for TIME */
16
+ // export const DURATION = enumify(['year', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond', 'microsecond', 'nanosecond']);
17
+ // export const DURATIONS = enumify(['years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds', 'milliseconds', 'microseconds', 'nanoseconds']);
18
+ export const SEASON = enumify({ Summer: 'summer', Autumn: 'autumn', Winter: 'winter', Spring: 'spring' });
19
+ export const COMPASS = enumify({ North: 'north', East: 'east', South: 'south', West: 'west' });
20
+ /** number of seconds in a time unit */
21
+ export const DURATION = enumify({
22
+ /** approx number of seconds in a year */ year: 31_536_000,
23
+ /** approx number of seconds in a month */ month: 2_628_000,
24
+ /** number of seconds in a week */ week: 604_800,
25
+ /** number of seconds in a day */ day: 86_400,
26
+ /** number of seconds in an hour */ hour: 3_600,
27
+ /** number of seconds in a minute */ minute: 60,
28
+ /** one second */ second: 1,
29
+ /** number of seconds in a millisecond */ millisecond: .001,
30
+ /** number of seconds in a microsecond */ microsecond: .000_001,
31
+ /** number of seconds in a nanosecond */ nanosecond: .000_000_001,
32
+ });
33
+ /** number of milliseconds in a time unit */
34
+ export const DURATIONS = enumify({
35
+ /** approx number of milliseconds in a year */ years: DURATION.year * 1_000,
36
+ /** approx number of milliseconds in a month */ months: DURATION.month * 1_000,
37
+ /** number of milliseconds in a week */ weeks: DURATION.week * 1_000,
38
+ /** number of milliseconds in a day */ days: DURATION.day * 1_000,
39
+ /** number of milliseconds in an hour */ hours: DURATION.hour * 1_000,
40
+ /** number of milliseconds in a minute */ minutes: DURATION.minute * 1_000,
41
+ /** number of milliseconds in a second */ seconds: DURATION.second * 1_000,
42
+ /** one millisecond */ milliseconds: DURATION.millisecond * 1_000,
43
+ /** number of milliseconds in a microsecond */ microseconds: DURATION.microsecond * 1_000,
44
+ /** number of milliseconds in a nanosecond */ nanoseconds: Number((DURATION.nanosecond * 1_000).toPrecision(6)),
45
+ });
46
+ /** pre-defined Format code short-cuts */
47
+ export const FORMAT = enumify({
48
+ /** useful for standard date display */ display: '{www}, {dd} {mmm} {yyyy}',
49
+ /** useful for standard datestamps */ weekDate: '{www}, {yyyy}-{mmm}-{dd}',
50
+ /** useful for standard timestamps */ weekTime: '{www}, {yyyy}-{mmm}-{dd} {hh}:{mi}:{ss}',
51
+ /** useful for standard full timestamps */ weekStamp: '{www}, {yyyy}-{mmm}-{dd} {hh}:{mi}:{ss}.{ff}',
52
+ /** useful for readable month and day */ dayMonth: '{dd}-{mmm}',
53
+ /** useful for Date */ dayDate: '{dd}-{mmm}-{yyyy}',
54
+ /** display with Time */ dayTime: '{dd}-{mmm}-{yyyy} {hh}:{mi}:{ss}',
55
+ /** useful for stamping logs */ logStamp: '{yyyy}{mm}{dd}T{hhmiss}.{ff}',
56
+ /** useful for sorting display-strings */ sortTime: '{yyyy}-{mm}-{dd} {hh}:{mi}:{ss}',
57
+ /** useful for sorting week order */ yearWeek: '{yyyy}{ww}',
58
+ /** useful for sorting month order */ yearMonth: '{yyyy}{mm}',
59
+ /** useful for sorting date order */ yearMonthDay: '{yyyy}{mm}{dd}',
60
+ /** just Date portion */ date: '{yyyy}-{mm}-{dd}',
61
+ /** just Time portion */ time: '{hh}:{mi}:{ss}',
62
+ });
63
+ export const LIMIT = secure({
64
+ /** Tempo(31-Dec-9999.23:59:59).ns */ maxTempo: Temporal.Instant.from('9999-12-31T23:59:59.999999999+00:00').epochNanoseconds,
65
+ /** Tempo(01-Jan-1000.00:00:00).ns */ minTempo: Temporal.Instant.from('1000-01-01T00:00+00:00').epochNanoseconds,
66
+ });
67
+ export const ELEMENT = enumify({
68
+ yy: 'year',
69
+ mm: 'month',
70
+ ww: 'week',
71
+ dd: 'day',
72
+ hh: 'hour',
73
+ mi: 'minute',
74
+ ss: 'second',
75
+ ms: 'millisecond',
76
+ us: 'microsecond',
77
+ ns: 'nanosecond',
78
+ });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file is used to polyfill the Temporal API for environments that do not support it.
3
+ * It is not needed in environments that support the Temporal API.
4
+ *
5
+ * The polyfill import is only needed in the 'coinSpot' and 'whiteSheet' projects.
6
+ *
7
+ * node example: npx tsx --import ./lib/temporal.polyfill.ts --env-file=.env ./src/wallet.ts
8
+ */
9
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * This file is used to polyfill the Temporal API for environments that do not support it.
3
+ * It is not needed in environments that support the Temporal API.
4
+ *
5
+ * The polyfill import is only needed in the 'coinSpot' and 'whiteSheet' projects.
6
+ *
7
+ * node example: npx tsx --import ./lib/temporal.polyfill.ts --env-file=.env ./src/wallet.ts
8
+ */
9
+ import { Temporal as _Temporal } from '@js-temporal/polyfill';
10
+ // @ts-ignore
11
+ if (!globalThis.Temporal) {
12
+ Object.defineProperty(globalThis, 'Temporal', {
13
+ value: _Temporal,
14
+ writable: false,
15
+ enumerable: true,
16
+ configurable: false,
17
+ });
18
+ }