effect 3.10.19 → 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/BigDecimal.js +125 -24
- package/dist/cjs/BigDecimal.js.map +1 -1
- package/dist/cjs/Channel.js +44 -4
- package/dist/cjs/Channel.js.map +1 -1
- package/dist/cjs/Config.js +8 -1
- package/dist/cjs/Config.js.map +1 -1
- package/dist/cjs/Context.js +26 -1
- package/dist/cjs/Context.js.map +1 -1
- package/dist/cjs/Cron.js +75 -67
- package/dist/cjs/Cron.js.map +1 -1
- package/dist/cjs/DateTime.js +114 -664
- package/dist/cjs/DateTime.js.map +1 -1
- package/dist/cjs/Effect.js +82 -4
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/Inspectable.js +8 -4
- package/dist/cjs/Inspectable.js.map +1 -1
- package/dist/cjs/JSONSchema.js.map +1 -1
- package/dist/cjs/Micro.js +1099 -1072
- package/dist/cjs/Micro.js.map +1 -1
- package/dist/cjs/STM.js.map +1 -1
- package/dist/cjs/Schema.js +57 -8
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/Sink.js +9 -1
- package/dist/cjs/Sink.js.map +1 -1
- package/dist/cjs/Stream.js +25 -7
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/Utils.js +7 -1
- package/dist/cjs/Utils.js.map +1 -1
- package/dist/cjs/internal/channel/channelExecutor.js +5 -9
- package/dist/cjs/internal/channel/channelExecutor.js.map +1 -1
- package/dist/cjs/internal/channel.js +156 -130
- package/dist/cjs/internal/channel.js.map +1 -1
- package/dist/cjs/internal/config.js +13 -4
- package/dist/cjs/internal/config.js.map +1 -1
- package/dist/cjs/internal/context.js +46 -3
- package/dist/cjs/internal/context.js.map +1 -1
- package/dist/cjs/internal/dateTime.js +747 -0
- package/dist/cjs/internal/dateTime.js.map +1 -0
- package/dist/cjs/internal/fiberRuntime.js +34 -11
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/groupBy.js +9 -3
- package/dist/cjs/internal/groupBy.js.map +1 -1
- package/dist/cjs/internal/layer.js +1 -1
- package/dist/cjs/internal/layer.js.map +1 -1
- package/dist/cjs/internal/mailbox.js +1 -1
- package/dist/cjs/internal/mailbox.js.map +1 -1
- package/dist/cjs/internal/sink.js +25 -21
- package/dist/cjs/internal/sink.js.map +1 -1
- package/dist/cjs/internal/stream.js +70 -71
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/cjs/internal/version.js.map +1 -1
- package/dist/dts/BigDecimal.d.ts +56 -1
- package/dist/dts/BigDecimal.d.ts.map +1 -1
- package/dist/dts/Channel.d.ts +66 -5
- package/dist/dts/Channel.d.ts.map +1 -1
- package/dist/dts/Config.d.ts +23 -1
- package/dist/dts/Config.d.ts.map +1 -1
- package/dist/dts/Context.d.ts +111 -0
- package/dist/dts/Context.d.ts.map +1 -1
- package/dist/dts/Cron.d.ts +15 -6
- package/dist/dts/Cron.d.ts.map +1 -1
- package/dist/dts/DateTime.d.ts +40 -49
- package/dist/dts/DateTime.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +88 -1
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Inspectable.d.ts.map +1 -1
- package/dist/dts/JSONSchema.d.ts +1 -0
- package/dist/dts/JSONSchema.d.ts.map +1 -1
- package/dist/dts/Micro.d.ts +875 -872
- package/dist/dts/Micro.d.ts.map +1 -1
- package/dist/dts/STM.d.ts +2 -0
- package/dist/dts/STM.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +32 -0
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/Sink.d.ts +8 -0
- package/dist/dts/Sink.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +50 -32
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/dts/Utils.d.ts +4 -0
- package/dist/dts/Utils.d.ts.map +1 -1
- package/dist/dts/internal/context.d.ts +1 -1
- package/dist/dts/internal/context.d.ts.map +1 -1
- package/dist/dts/internal/dateTime.d.ts +2 -0
- package/dist/dts/internal/dateTime.d.ts.map +1 -0
- package/dist/dts/internal/fiberRuntime.d.ts.map +1 -1
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/BigDecimal.js +119 -20
- package/dist/esm/BigDecimal.js.map +1 -1
- package/dist/esm/Channel.js +42 -2
- package/dist/esm/Channel.js.map +1 -1
- package/dist/esm/Config.js +7 -0
- package/dist/esm/Config.js.map +1 -1
- package/dist/esm/Context.js +25 -0
- package/dist/esm/Context.js.map +1 -1
- package/dist/esm/Cron.js +75 -67
- package/dist/esm/Cron.js.map +1 -1
- package/dist/esm/DateTime.js +112 -627
- package/dist/esm/DateTime.js.map +1 -1
- package/dist/esm/Effect.js +77 -0
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/Inspectable.js +8 -4
- package/dist/esm/Inspectable.js.map +1 -1
- package/dist/esm/JSONSchema.js.map +1 -1
- package/dist/esm/Micro.js +1077 -1047
- package/dist/esm/Micro.js.map +1 -1
- package/dist/esm/STM.js.map +1 -1
- package/dist/esm/Schema.js +54 -0
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/Sink.js +8 -0
- package/dist/esm/Sink.js.map +1 -1
- package/dist/esm/Stream.js +23 -5
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/Utils.js +5 -0
- package/dist/esm/Utils.js.map +1 -1
- package/dist/esm/internal/channel/channelExecutor.js +5 -7
- package/dist/esm/internal/channel/channelExecutor.js.map +1 -1
- package/dist/esm/internal/channel.js +152 -129
- package/dist/esm/internal/channel.js.map +1 -1
- package/dist/esm/internal/config.js +11 -3
- package/dist/esm/internal/config.js.map +1 -1
- package/dist/esm/internal/context.js +42 -2
- package/dist/esm/internal/context.js.map +1 -1
- package/dist/esm/internal/dateTime.js +704 -0
- package/dist/esm/internal/dateTime.js.map +1 -0
- package/dist/esm/internal/fiberRuntime.js +31 -9
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/groupBy.js +9 -3
- package/dist/esm/internal/groupBy.js.map +1 -1
- package/dist/esm/internal/layer.js +1 -1
- package/dist/esm/internal/layer.js.map +1 -1
- package/dist/esm/internal/mailbox.js +1 -1
- package/dist/esm/internal/mailbox.js.map +1 -1
- package/dist/esm/internal/sink.js +23 -20
- package/dist/esm/internal/sink.js.map +1 -1
- package/dist/esm/internal/stream.js +66 -69
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/dist/esm/internal/version.js.map +1 -1
- package/package.json +1 -1
- package/src/BigDecimal.ts +131 -21
- package/src/Channel.ts +81 -5
- package/src/Config.ts +24 -1
- package/src/Context.ts +119 -0
- package/src/Cron.ts +85 -68
- package/src/DateTime.ts +155 -757
- package/src/Effect.ts +340 -1
- package/src/Inspectable.ts +11 -7
- package/src/JSONSchema.ts +1 -0
- package/src/Micro.ts +2005 -1757
- package/src/STM.ts +2 -0
- package/src/Schema.ts +60 -0
- package/src/Sink.ts +11 -0
- package/src/Stream.ts +55 -44
- package/src/Utils.ts +8 -0
- package/src/internal/channel/channelExecutor.ts +37 -33
- package/src/internal/channel.ts +504 -467
- package/src/internal/config.ts +18 -6
- package/src/internal/context.ts +56 -4
- package/src/internal/dateTime.ts +1126 -0
- package/src/internal/fiberRuntime.ts +35 -16
- package/src/internal/groupBy.ts +13 -22
- package/src/internal/layer.ts +5 -8
- package/src/internal/mailbox.ts +6 -4
- package/src/internal/sink.ts +55 -35
- package/src/internal/stream.ts +299 -299
- package/src/internal/version.ts +1 -1
package/dist/esm/DateTime.js
CHANGED
|
@@ -1,124 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @since 3.6.0
|
|
3
|
-
*/
|
|
4
|
-
import { IllegalArgumentException } from "./Cause.js";
|
|
5
|
-
import * as Clock from "./Clock.js";
|
|
6
1
|
import * as Context from "./Context.js";
|
|
7
|
-
import * as Duration from "./Duration.js";
|
|
8
2
|
import * as Effect from "./Effect.js";
|
|
9
|
-
import
|
|
10
|
-
import * as
|
|
11
|
-
import * as Equivalence_ from "./Equivalence.js";
|
|
12
|
-
import { dual, pipe } from "./Function.js";
|
|
13
|
-
import { globalValue } from "./GlobalValue.js";
|
|
14
|
-
import * as Hash from "./Hash.js";
|
|
15
|
-
import * as Inspectable from "./Inspectable.js";
|
|
3
|
+
import { dual } from "./Function.js";
|
|
4
|
+
import * as Internal from "./internal/dateTime.js";
|
|
16
5
|
import * as Layer from "./Layer.js";
|
|
17
|
-
import * as Option from "./Option.js";
|
|
18
|
-
import * as order from "./Order.js";
|
|
19
|
-
import { pipeArguments } from "./Pipeable.js";
|
|
20
|
-
import * as Predicate from "./Predicate.js";
|
|
21
6
|
/**
|
|
22
7
|
* @since 3.6.0
|
|
23
8
|
* @category type ids
|
|
24
9
|
*/
|
|
25
|
-
export const TypeId =
|
|
10
|
+
export const TypeId = Internal.TypeId;
|
|
26
11
|
/**
|
|
27
12
|
* @since 3.6.0
|
|
28
13
|
* @category type ids
|
|
29
14
|
*/
|
|
30
|
-
export const TimeZoneTypeId =
|
|
31
|
-
const Proto = {
|
|
32
|
-
[TypeId]: TypeId,
|
|
33
|
-
pipe() {
|
|
34
|
-
return pipeArguments(this, arguments);
|
|
35
|
-
},
|
|
36
|
-
[Inspectable.NodeInspectSymbol]() {
|
|
37
|
-
return this.toString();
|
|
38
|
-
},
|
|
39
|
-
toJSON() {
|
|
40
|
-
return toDateUtc(this).toJSON();
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const ProtoUtc = {
|
|
44
|
-
...Proto,
|
|
45
|
-
_tag: "Utc",
|
|
46
|
-
[Hash.symbol]() {
|
|
47
|
-
return Hash.cached(this, Hash.number(this.epochMillis));
|
|
48
|
-
},
|
|
49
|
-
[Equal.symbol](that) {
|
|
50
|
-
return isDateTime(that) && that._tag === "Utc" && this.epochMillis === that.epochMillis;
|
|
51
|
-
},
|
|
52
|
-
toString() {
|
|
53
|
-
return `DateTime.Utc(${toDateUtc(this).toJSON()})`;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const ProtoZoned = {
|
|
57
|
-
...Proto,
|
|
58
|
-
_tag: "Zoned",
|
|
59
|
-
[Hash.symbol]() {
|
|
60
|
-
return pipe(Hash.number(this.epochMillis), Hash.combine(Hash.hash(this.zone)), Hash.cached(this));
|
|
61
|
-
},
|
|
62
|
-
[Equal.symbol](that) {
|
|
63
|
-
return isDateTime(that) && that._tag === "Zoned" && this.epochMillis === that.epochMillis && Equal.equals(this.zone, that.zone);
|
|
64
|
-
},
|
|
65
|
-
toString() {
|
|
66
|
-
return `DateTime.Zoned(${formatIsoZoned(this)})`;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const ProtoTimeZone = {
|
|
70
|
-
[TimeZoneTypeId]: TimeZoneTypeId,
|
|
71
|
-
[Inspectable.NodeInspectSymbol]() {
|
|
72
|
-
return this.toString();
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
const ProtoTimeZoneNamed = {
|
|
76
|
-
...ProtoTimeZone,
|
|
77
|
-
_tag: "Named",
|
|
78
|
-
[Hash.symbol]() {
|
|
79
|
-
return Hash.cached(this, Hash.string(`Named:${this.id}`));
|
|
80
|
-
},
|
|
81
|
-
[Equal.symbol](that) {
|
|
82
|
-
return isTimeZone(that) && that._tag === "Named" && this.id === that.id;
|
|
83
|
-
},
|
|
84
|
-
toString() {
|
|
85
|
-
return `TimeZone.Named(${this.id})`;
|
|
86
|
-
},
|
|
87
|
-
toJSON() {
|
|
88
|
-
return {
|
|
89
|
-
_id: "TimeZone",
|
|
90
|
-
_tag: "Named",
|
|
91
|
-
id: this.id
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
const ProtoTimeZoneOffset = {
|
|
96
|
-
...ProtoTimeZone,
|
|
97
|
-
_tag: "Offset",
|
|
98
|
-
[Hash.symbol]() {
|
|
99
|
-
return Hash.cached(this, Hash.string(`Offset:${this.offset}`));
|
|
100
|
-
},
|
|
101
|
-
[Equal.symbol](that) {
|
|
102
|
-
return isTimeZone(that) && that._tag === "Offset" && this.offset === that.offset;
|
|
103
|
-
},
|
|
104
|
-
toString() {
|
|
105
|
-
return `TimeZone.Offset(${offsetToString(this.offset)})`;
|
|
106
|
-
},
|
|
107
|
-
toJSON() {
|
|
108
|
-
return {
|
|
109
|
-
_id: "TimeZone",
|
|
110
|
-
_tag: "Offset",
|
|
111
|
-
offset: this.offset
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
const makeZonedProto = (epochMillis, zone, partsUtc) => {
|
|
116
|
-
const self = Object.create(ProtoZoned);
|
|
117
|
-
self.epochMillis = epochMillis;
|
|
118
|
-
self.zone = zone;
|
|
119
|
-
self.partsUtc = partsUtc;
|
|
120
|
-
return self;
|
|
121
|
-
};
|
|
15
|
+
export const TimeZoneTypeId = Internal.TimeZoneTypeId;
|
|
122
16
|
// =============================================================================
|
|
123
17
|
// guards
|
|
124
18
|
// =============================================================================
|
|
@@ -126,33 +20,32 @@ const makeZonedProto = (epochMillis, zone, partsUtc) => {
|
|
|
126
20
|
* @since 3.6.0
|
|
127
21
|
* @category guards
|
|
128
22
|
*/
|
|
129
|
-
export const isDateTime =
|
|
130
|
-
const isDateTimeArgs = args => isDateTime(args[0]);
|
|
23
|
+
export const isDateTime = Internal.isDateTime;
|
|
131
24
|
/**
|
|
132
25
|
* @since 3.6.0
|
|
133
26
|
* @category guards
|
|
134
27
|
*/
|
|
135
|
-
export const isTimeZone =
|
|
28
|
+
export const isTimeZone = Internal.isTimeZone;
|
|
136
29
|
/**
|
|
137
30
|
* @since 3.6.0
|
|
138
31
|
* @category guards
|
|
139
32
|
*/
|
|
140
|
-
export const isTimeZoneOffset =
|
|
33
|
+
export const isTimeZoneOffset = Internal.isTimeZoneOffset;
|
|
141
34
|
/**
|
|
142
35
|
* @since 3.6.0
|
|
143
36
|
* @category guards
|
|
144
37
|
*/
|
|
145
|
-
export const isTimeZoneNamed =
|
|
38
|
+
export const isTimeZoneNamed = Internal.isTimeZoneNamed;
|
|
146
39
|
/**
|
|
147
40
|
* @since 3.6.0
|
|
148
41
|
* @category guards
|
|
149
42
|
*/
|
|
150
|
-
export const isUtc =
|
|
43
|
+
export const isUtc = Internal.isUtc;
|
|
151
44
|
/**
|
|
152
45
|
* @since 3.6.0
|
|
153
46
|
* @category guards
|
|
154
47
|
*/
|
|
155
|
-
export const isZoned =
|
|
48
|
+
export const isZoned = Internal.isZoned;
|
|
156
49
|
// =============================================================================
|
|
157
50
|
// instances
|
|
158
51
|
// =============================================================================
|
|
@@ -160,24 +53,19 @@ export const isZoned = self => self._tag === "Zoned";
|
|
|
160
53
|
* @since 3.6.0
|
|
161
54
|
* @category instances
|
|
162
55
|
*/
|
|
163
|
-
export const Equivalence =
|
|
56
|
+
export const Equivalence = Internal.Equivalence;
|
|
164
57
|
/**
|
|
165
58
|
* @since 3.6.0
|
|
166
59
|
* @category instances
|
|
167
60
|
*/
|
|
168
|
-
export const Order =
|
|
61
|
+
export const Order = Internal.Order;
|
|
169
62
|
/**
|
|
170
63
|
* @since 3.6.0
|
|
171
64
|
*/
|
|
172
|
-
export const clamp =
|
|
65
|
+
export const clamp = Internal.clamp;
|
|
173
66
|
// =============================================================================
|
|
174
67
|
// constructors
|
|
175
68
|
// =============================================================================
|
|
176
|
-
const makeUtc = epochMillis => {
|
|
177
|
-
const self = Object.create(ProtoUtc);
|
|
178
|
-
self.epochMillis = epochMillis;
|
|
179
|
-
return self;
|
|
180
|
-
};
|
|
181
69
|
/**
|
|
182
70
|
* Create a `DateTime` from a `Date`.
|
|
183
71
|
*
|
|
@@ -186,13 +74,7 @@ const makeUtc = epochMillis => {
|
|
|
186
74
|
* @since 3.6.0
|
|
187
75
|
* @category constructors
|
|
188
76
|
*/
|
|
189
|
-
export const unsafeFromDate =
|
|
190
|
-
const epochMillis = date.getTime();
|
|
191
|
-
if (Number.isNaN(epochMillis)) {
|
|
192
|
-
throw new IllegalArgumentException("Invalid date");
|
|
193
|
-
}
|
|
194
|
-
return makeUtc(epochMillis);
|
|
195
|
-
};
|
|
77
|
+
export const unsafeFromDate = Internal.unsafeFromDate;
|
|
196
78
|
/**
|
|
197
79
|
* Create a `DateTime` from one of the following:
|
|
198
80
|
*
|
|
@@ -218,18 +100,7 @@ export const unsafeFromDate = date => {
|
|
|
218
100
|
* DateTime.unsafeMake("2024-01-01")
|
|
219
101
|
* ```
|
|
220
102
|
*/
|
|
221
|
-
export const unsafeMake =
|
|
222
|
-
if (isDateTime(input)) {
|
|
223
|
-
return input;
|
|
224
|
-
} else if (input instanceof Date) {
|
|
225
|
-
return unsafeFromDate(input);
|
|
226
|
-
} else if (typeof input === "object") {
|
|
227
|
-
const date = new Date(0);
|
|
228
|
-
setPartsDate(date, input);
|
|
229
|
-
return unsafeFromDate(date);
|
|
230
|
-
}
|
|
231
|
-
return unsafeFromDate(new Date(input));
|
|
232
|
-
};
|
|
103
|
+
export const unsafeMake = Internal.unsafeMake;
|
|
233
104
|
/**
|
|
234
105
|
* Create a `DateTime.Zoned` using `DateTime.unsafeMake` and a time zone.
|
|
235
106
|
*
|
|
@@ -246,31 +117,7 @@ export const unsafeMake = input => {
|
|
|
246
117
|
* DateTime.unsafeMakeZoned(new Date(), { timeZone: "Europe/London" })
|
|
247
118
|
* ```
|
|
248
119
|
*/
|
|
249
|
-
export const unsafeMakeZoned =
|
|
250
|
-
if (options?.timeZone === undefined && isDateTime(input) && isZoned(input)) {
|
|
251
|
-
return input;
|
|
252
|
-
}
|
|
253
|
-
const self = unsafeMake(input);
|
|
254
|
-
let zone;
|
|
255
|
-
if (options?.timeZone === undefined) {
|
|
256
|
-
const offset = new Date(self.epochMillis).getTimezoneOffset() * -60 * 1000;
|
|
257
|
-
zone = zoneMakeOffset(offset);
|
|
258
|
-
} else if (isTimeZone(options?.timeZone)) {
|
|
259
|
-
zone = options.timeZone;
|
|
260
|
-
} else if (typeof options?.timeZone === "number") {
|
|
261
|
-
zone = zoneMakeOffset(options.timeZone);
|
|
262
|
-
} else {
|
|
263
|
-
const parsedZone = zoneFromString(options.timeZone);
|
|
264
|
-
if (Option.isNone(parsedZone)) {
|
|
265
|
-
throw new IllegalArgumentException(`Invalid time zone: ${options.timeZone}`);
|
|
266
|
-
}
|
|
267
|
-
zone = parsedZone.value;
|
|
268
|
-
}
|
|
269
|
-
if (options?.adjustForTimeZone !== true) {
|
|
270
|
-
return makeZonedProto(self.epochMillis, zone, self.partsUtc);
|
|
271
|
-
}
|
|
272
|
-
return makeZonedFromAdjusted(self.epochMillis, zone);
|
|
273
|
-
};
|
|
120
|
+
export const unsafeMakeZoned = Internal.unsafeMakeZoned;
|
|
274
121
|
/**
|
|
275
122
|
* Create a `DateTime.Zoned` using `DateTime.make` and a time zone.
|
|
276
123
|
*
|
|
@@ -287,7 +134,7 @@ export const unsafeMakeZoned = (input, options) => {
|
|
|
287
134
|
* DateTime.makeZoned(new Date(), { timeZone: "Europe/London" })
|
|
288
135
|
* ```
|
|
289
136
|
*/
|
|
290
|
-
export const makeZoned =
|
|
137
|
+
export const makeZoned = Internal.makeZoned;
|
|
291
138
|
/**
|
|
292
139
|
* Create a `DateTime` from one of the following:
|
|
293
140
|
*
|
|
@@ -315,8 +162,7 @@ export const makeZoned = /*#__PURE__*/Option.liftThrowable(unsafeMakeZoned);
|
|
|
315
162
|
* DateTime.make("2024-01-01")
|
|
316
163
|
* ```
|
|
317
164
|
*/
|
|
318
|
-
export const make =
|
|
319
|
-
const zonedStringRegex = /^(.{17,35})\[(.+)\]$/;
|
|
165
|
+
export const make = Internal.make;
|
|
320
166
|
/**
|
|
321
167
|
* Create a `DateTime.Zoned` from a string.
|
|
322
168
|
*
|
|
@@ -325,19 +171,7 @@ const zonedStringRegex = /^(.{17,35})\[(.+)\]$/;
|
|
|
325
171
|
* @since 3.6.0
|
|
326
172
|
* @category constructors
|
|
327
173
|
*/
|
|
328
|
-
export const makeZonedFromString =
|
|
329
|
-
const match = zonedStringRegex.exec(input);
|
|
330
|
-
if (match === null) {
|
|
331
|
-
const offset = parseOffset(input);
|
|
332
|
-
return offset !== null ? makeZoned(input, {
|
|
333
|
-
timeZone: offset
|
|
334
|
-
}) : Option.none();
|
|
335
|
-
}
|
|
336
|
-
const [, isoString, timeZone] = match;
|
|
337
|
-
return makeZoned(isoString, {
|
|
338
|
-
timeZone
|
|
339
|
-
});
|
|
340
|
-
};
|
|
174
|
+
export const makeZonedFromString = Internal.makeZonedFromString;
|
|
341
175
|
/**
|
|
342
176
|
* Get the current time using the `Clock` service and convert it to a `DateTime`.
|
|
343
177
|
*
|
|
@@ -352,14 +186,14 @@ export const makeZonedFromString = input => {
|
|
|
352
186
|
* })
|
|
353
187
|
* ```
|
|
354
188
|
*/
|
|
355
|
-
export const now =
|
|
189
|
+
export const now = Internal.now;
|
|
356
190
|
/**
|
|
357
191
|
* Get the current time using `Date.now`.
|
|
358
192
|
*
|
|
359
193
|
* @since 3.6.0
|
|
360
194
|
* @category constructors
|
|
361
195
|
*/
|
|
362
|
-
export const unsafeNow =
|
|
196
|
+
export const unsafeNow = Internal.unsafeNow;
|
|
363
197
|
// =============================================================================
|
|
364
198
|
// time zones
|
|
365
199
|
// =============================================================================
|
|
@@ -381,7 +215,7 @@ export const unsafeNow = () => makeUtc(Date.now());
|
|
|
381
215
|
* })
|
|
382
216
|
* ```
|
|
383
217
|
*/
|
|
384
|
-
export const setZone =
|
|
218
|
+
export const setZone = Internal.setZone;
|
|
385
219
|
/**
|
|
386
220
|
* Add a fixed offset time zone to a `DateTime`.
|
|
387
221
|
*
|
|
@@ -401,30 +235,7 @@ export const setZone = /*#__PURE__*/dual(isDateTimeArgs, (self, zone, options) =
|
|
|
401
235
|
* })
|
|
402
236
|
* ```
|
|
403
237
|
*/
|
|
404
|
-
export const setZoneOffset =
|
|
405
|
-
const validZoneCache = /*#__PURE__*/globalValue("effect/DateTime/validZoneCache", () => new Map());
|
|
406
|
-
const formatOptions = {
|
|
407
|
-
day: "numeric",
|
|
408
|
-
month: "numeric",
|
|
409
|
-
year: "numeric",
|
|
410
|
-
hour: "numeric",
|
|
411
|
-
minute: "numeric",
|
|
412
|
-
second: "numeric",
|
|
413
|
-
timeZoneName: "longOffset",
|
|
414
|
-
fractionalSecondDigits: 3,
|
|
415
|
-
hourCycle: "h23"
|
|
416
|
-
};
|
|
417
|
-
const zoneMakeIntl = format => {
|
|
418
|
-
const zoneId = format.resolvedOptions().timeZone;
|
|
419
|
-
if (validZoneCache.has(zoneId)) {
|
|
420
|
-
return validZoneCache.get(zoneId);
|
|
421
|
-
}
|
|
422
|
-
const zone = Object.create(ProtoTimeZoneNamed);
|
|
423
|
-
zone.id = zoneId;
|
|
424
|
-
zone.format = format;
|
|
425
|
-
validZoneCache.set(zoneId, zone);
|
|
426
|
-
return zone;
|
|
427
|
-
};
|
|
238
|
+
export const setZoneOffset = Internal.setZoneOffset;
|
|
428
239
|
/**
|
|
429
240
|
* Attempt to create a named time zone from a IANA time zone identifier.
|
|
430
241
|
*
|
|
@@ -433,30 +244,14 @@ const zoneMakeIntl = format => {
|
|
|
433
244
|
* @since 3.6.0
|
|
434
245
|
* @category time zones
|
|
435
246
|
*/
|
|
436
|
-
export const zoneUnsafeMakeNamed =
|
|
437
|
-
if (validZoneCache.has(zoneId)) {
|
|
438
|
-
return validZoneCache.get(zoneId);
|
|
439
|
-
}
|
|
440
|
-
try {
|
|
441
|
-
return zoneMakeIntl(new Intl.DateTimeFormat("en-US", {
|
|
442
|
-
...formatOptions,
|
|
443
|
-
timeZone: zoneId
|
|
444
|
-
}));
|
|
445
|
-
} catch (_) {
|
|
446
|
-
throw new IllegalArgumentException(`Invalid time zone: ${zoneId}`);
|
|
447
|
-
}
|
|
448
|
-
};
|
|
247
|
+
export const zoneUnsafeMakeNamed = Internal.zoneUnsafeMakeNamed;
|
|
449
248
|
/**
|
|
450
249
|
* Create a fixed offset time zone.
|
|
451
250
|
*
|
|
452
251
|
* @since 3.6.0
|
|
453
252
|
* @category time zones
|
|
454
253
|
*/
|
|
455
|
-
export const zoneMakeOffset =
|
|
456
|
-
const zone = Object.create(ProtoTimeZoneOffset);
|
|
457
|
-
zone.offset = offset;
|
|
458
|
-
return zone;
|
|
459
|
-
};
|
|
254
|
+
export const zoneMakeOffset = Internal.zoneMakeOffset;
|
|
460
255
|
/**
|
|
461
256
|
* Create a named time zone from a IANA time zone identifier. If the time zone
|
|
462
257
|
* is invalid, `None` will be returned.
|
|
@@ -464,7 +259,7 @@ export const zoneMakeOffset = offset => {
|
|
|
464
259
|
* @since 3.6.0
|
|
465
260
|
* @category time zones
|
|
466
261
|
*/
|
|
467
|
-
export const zoneMakeNamed =
|
|
262
|
+
export const zoneMakeNamed = Internal.zoneMakeNamed;
|
|
468
263
|
/**
|
|
469
264
|
* Create a named time zone from a IANA time zone identifier. If the time zone
|
|
470
265
|
* is invalid, it will fail with an `IllegalArgumentException`.
|
|
@@ -472,31 +267,21 @@ export const zoneMakeNamed = /*#__PURE__*/Option.liftThrowable(zoneUnsafeMakeNam
|
|
|
472
267
|
* @since 3.6.0
|
|
473
268
|
* @category time zones
|
|
474
269
|
*/
|
|
475
|
-
export const zoneMakeNamedEffect =
|
|
476
|
-
try: () => zoneUnsafeMakeNamed(zoneId),
|
|
477
|
-
catch: e => e
|
|
478
|
-
});
|
|
270
|
+
export const zoneMakeNamedEffect = Internal.zoneMakeNamedEffect;
|
|
479
271
|
/**
|
|
480
272
|
* Create a named time zone from the system's local time zone.
|
|
481
273
|
*
|
|
482
274
|
* @since 3.6.0
|
|
483
275
|
* @category time zones
|
|
484
276
|
*/
|
|
485
|
-
export const zoneMakeLocal =
|
|
486
|
-
const offsetZoneRegex = /^(?:GMT|[+-])/;
|
|
277
|
+
export const zoneMakeLocal = Internal.zoneMakeLocal;
|
|
487
278
|
/**
|
|
488
279
|
* Try parse a TimeZone from a string
|
|
489
280
|
*
|
|
490
281
|
* @since 3.6.0
|
|
491
282
|
* @category time zones
|
|
492
283
|
*/
|
|
493
|
-
export const zoneFromString =
|
|
494
|
-
if (offsetZoneRegex.test(zone)) {
|
|
495
|
-
const offset = parseOffset(zone);
|
|
496
|
-
return offset === null ? Option.none() : Option.some(zoneMakeOffset(offset));
|
|
497
|
-
}
|
|
498
|
-
return zoneMakeNamed(zone);
|
|
499
|
-
};
|
|
284
|
+
export const zoneFromString = Internal.zoneFromString;
|
|
500
285
|
/**
|
|
501
286
|
* Format a `TimeZone` as a string.
|
|
502
287
|
*
|
|
@@ -513,12 +298,7 @@ export const zoneFromString = zone => {
|
|
|
513
298
|
* DateTime.zoneToString(DateTime.zoneUnsafeMakeNamed("Europe/London"))
|
|
514
299
|
* ```
|
|
515
300
|
*/
|
|
516
|
-
export const zoneToString =
|
|
517
|
-
if (self._tag === "Offset") {
|
|
518
|
-
return offsetToString(self.offset);
|
|
519
|
-
}
|
|
520
|
-
return self.id;
|
|
521
|
-
};
|
|
301
|
+
export const zoneToString = Internal.zoneToString;
|
|
522
302
|
/**
|
|
523
303
|
* Set the time zone of a `DateTime` from an IANA time zone identifier. If the
|
|
524
304
|
* time zone is invalid, `None` will be returned.
|
|
@@ -536,7 +316,7 @@ export const zoneToString = self => {
|
|
|
536
316
|
* })
|
|
537
317
|
* ```
|
|
538
318
|
*/
|
|
539
|
-
export const setZoneNamed =
|
|
319
|
+
export const setZoneNamed = Internal.setZoneNamed;
|
|
540
320
|
/**
|
|
541
321
|
* Set the time zone of a `DateTime` from an IANA time zone identifier. If the
|
|
542
322
|
* time zone is invalid, an `IllegalArgumentException` will be thrown.
|
|
@@ -554,7 +334,7 @@ export const setZoneNamed = /*#__PURE__*/dual(isDateTimeArgs, (self, zoneId, opt
|
|
|
554
334
|
* })
|
|
555
335
|
* ```
|
|
556
336
|
*/
|
|
557
|
-
export const unsafeSetZoneNamed =
|
|
337
|
+
export const unsafeSetZoneNamed = Internal.unsafeSetZoneNamed;
|
|
558
338
|
// =============================================================================
|
|
559
339
|
// comparisons
|
|
560
340
|
// =============================================================================
|
|
@@ -579,7 +359,7 @@ export const unsafeSetZoneNamed = /*#__PURE__*/dual(isDateTimeArgs, (self, zoneI
|
|
|
579
359
|
* })
|
|
580
360
|
* ```
|
|
581
361
|
*/
|
|
582
|
-
export const distance =
|
|
362
|
+
export const distance = Internal.distance;
|
|
583
363
|
/**
|
|
584
364
|
* Calulate the difference between two `DateTime` values.
|
|
585
365
|
*
|
|
@@ -607,10 +387,7 @@ export const distance = /*#__PURE__*/dual(2, (self, other) => toEpochMillis(othe
|
|
|
607
387
|
* })
|
|
608
388
|
* ```
|
|
609
389
|
*/
|
|
610
|
-
export const distanceDurationEither =
|
|
611
|
-
const diffMillis = distance(self, other);
|
|
612
|
-
return diffMillis > 0 ? Either.right(Duration.millis(diffMillis)) : Either.left(Duration.millis(-diffMillis));
|
|
613
|
-
});
|
|
390
|
+
export const distanceDurationEither = Internal.distanceDurationEither;
|
|
614
391
|
/**
|
|
615
392
|
* Calulate the distance between two `DateTime` values.
|
|
616
393
|
*
|
|
@@ -629,62 +406,62 @@ export const distanceDurationEither = /*#__PURE__*/dual(2, (self, other) => {
|
|
|
629
406
|
* })
|
|
630
407
|
* ```
|
|
631
408
|
*/
|
|
632
|
-
export const distanceDuration =
|
|
409
|
+
export const distanceDuration = Internal.distanceDuration;
|
|
633
410
|
/**
|
|
634
411
|
* @since 3.6.0
|
|
635
412
|
* @category comparisons
|
|
636
413
|
*/
|
|
637
|
-
export const min =
|
|
414
|
+
export const min = Internal.min;
|
|
638
415
|
/**
|
|
639
416
|
* @since 3.6.0
|
|
640
417
|
* @category comparisons
|
|
641
418
|
*/
|
|
642
|
-
export const max =
|
|
419
|
+
export const max = Internal.max;
|
|
643
420
|
/**
|
|
644
421
|
* @since 3.6.0
|
|
645
422
|
* @category comparisons
|
|
646
423
|
*/
|
|
647
|
-
export const greaterThan =
|
|
424
|
+
export const greaterThan = Internal.greaterThan;
|
|
648
425
|
/**
|
|
649
426
|
* @since 3.6.0
|
|
650
427
|
* @category comparisons
|
|
651
428
|
*/
|
|
652
|
-
export const greaterThanOrEqualTo =
|
|
429
|
+
export const greaterThanOrEqualTo = Internal.greaterThanOrEqualTo;
|
|
653
430
|
/**
|
|
654
431
|
* @since 3.6.0
|
|
655
432
|
* @category comparisons
|
|
656
433
|
*/
|
|
657
|
-
export const lessThan =
|
|
434
|
+
export const lessThan = Internal.lessThan;
|
|
658
435
|
/**
|
|
659
436
|
* @since 3.6.0
|
|
660
437
|
* @category comparisons
|
|
661
438
|
*/
|
|
662
|
-
export const lessThanOrEqualTo =
|
|
439
|
+
export const lessThanOrEqualTo = Internal.lessThanOrEqualTo;
|
|
663
440
|
/**
|
|
664
441
|
* @since 3.6.0
|
|
665
442
|
* @category comparisons
|
|
666
443
|
*/
|
|
667
|
-
export const between =
|
|
444
|
+
export const between = Internal.between;
|
|
668
445
|
/**
|
|
669
446
|
* @since 3.6.0
|
|
670
447
|
* @category comparisons
|
|
671
448
|
*/
|
|
672
|
-
export const isFuture =
|
|
449
|
+
export const isFuture = Internal.isFuture;
|
|
673
450
|
/**
|
|
674
451
|
* @since 3.6.0
|
|
675
452
|
* @category comparisons
|
|
676
453
|
*/
|
|
677
|
-
export const unsafeIsFuture =
|
|
454
|
+
export const unsafeIsFuture = Internal.unsafeIsFuture;
|
|
678
455
|
/**
|
|
679
456
|
* @since 3.6.0
|
|
680
457
|
* @category comparisons
|
|
681
458
|
*/
|
|
682
|
-
export const isPast =
|
|
459
|
+
export const isPast = Internal.isPast;
|
|
683
460
|
/**
|
|
684
461
|
* @since 3.6.0
|
|
685
462
|
* @category comparisons
|
|
686
463
|
*/
|
|
687
|
-
export const unsafeIsPast =
|
|
464
|
+
export const unsafeIsPast = Internal.unsafeIsPast;
|
|
688
465
|
// =============================================================================
|
|
689
466
|
// conversions
|
|
690
467
|
// =============================================================================
|
|
@@ -694,44 +471,21 @@ export const unsafeIsPast = self => greaterThan(unsafeNow(), self);
|
|
|
694
471
|
* @since 3.6.0
|
|
695
472
|
* @category conversions
|
|
696
473
|
*/
|
|
697
|
-
export const toDateUtc =
|
|
474
|
+
export const toDateUtc = Internal.toDateUtc;
|
|
698
475
|
/**
|
|
699
476
|
* Convert a `DateTime` to a `Date`, applying the time zone first.
|
|
700
477
|
*
|
|
701
478
|
* @since 3.6.0
|
|
702
479
|
* @category conversions
|
|
703
480
|
*/
|
|
704
|
-
export const toDate =
|
|
705
|
-
if (self._tag === "Utc") {
|
|
706
|
-
return new Date(self.epochMillis);
|
|
707
|
-
} else if (self.zone._tag === "Offset") {
|
|
708
|
-
return new Date(self.epochMillis + self.zone.offset);
|
|
709
|
-
} else if (self.adjustedEpochMillis !== undefined) {
|
|
710
|
-
return new Date(self.adjustedEpochMillis);
|
|
711
|
-
}
|
|
712
|
-
const parts = self.zone.format.formatToParts(self.epochMillis).filter(_ => _.type !== "literal");
|
|
713
|
-
const date = new Date(0);
|
|
714
|
-
date.setUTCFullYear(Number(parts[2].value), Number(parts[0].value) - 1, Number(parts[1].value));
|
|
715
|
-
date.setUTCHours(Number(parts[3].value), Number(parts[4].value), Number(parts[5].value), Number(parts[6].value));
|
|
716
|
-
self.adjustedEpochMillis = date.getTime();
|
|
717
|
-
return date;
|
|
718
|
-
};
|
|
481
|
+
export const toDate = Internal.toDate;
|
|
719
482
|
/**
|
|
720
483
|
* Calculate the time zone offset of a `DateTime.Zoned` in milliseconds.
|
|
721
484
|
*
|
|
722
485
|
* @since 3.6.0
|
|
723
486
|
* @category conversions
|
|
724
487
|
*/
|
|
725
|
-
export const zonedOffset =
|
|
726
|
-
const date = toDate(self);
|
|
727
|
-
return date.getTime() - toEpochMillis(self);
|
|
728
|
-
};
|
|
729
|
-
const offsetToString = offset => {
|
|
730
|
-
const abs = Math.abs(offset);
|
|
731
|
-
const hours = Math.floor(abs / (60 * 60 * 1000));
|
|
732
|
-
const minutes = Math.round(abs % (60 * 60 * 1000) / (60 * 1000));
|
|
733
|
-
return `${offset < 0 ? "-" : "+"}${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}`;
|
|
734
|
-
};
|
|
488
|
+
export const zonedOffset = Internal.zonedOffset;
|
|
735
489
|
/**
|
|
736
490
|
* Calculate the time zone offset of a `DateTime` in milliseconds.
|
|
737
491
|
*
|
|
@@ -740,14 +494,14 @@ const offsetToString = offset => {
|
|
|
740
494
|
* @since 3.6.0
|
|
741
495
|
* @category conversions
|
|
742
496
|
*/
|
|
743
|
-
export const zonedOffsetIso =
|
|
497
|
+
export const zonedOffsetIso = Internal.zonedOffsetIso;
|
|
744
498
|
/**
|
|
745
499
|
* Get the milliseconds since the Unix epoch of a `DateTime`.
|
|
746
500
|
*
|
|
747
501
|
* @since 3.6.0
|
|
748
502
|
* @category conversions
|
|
749
503
|
*/
|
|
750
|
-
export const toEpochMillis =
|
|
504
|
+
export const toEpochMillis = Internal.toEpochMillis;
|
|
751
505
|
/**
|
|
752
506
|
* Remove the time aspect of a `DateTime`, first adjusting for the time
|
|
753
507
|
* zone. It will return a `DateTime.Utc` only containing the date.
|
|
@@ -768,23 +522,10 @@ export const toEpochMillis = self => self.epochMillis;
|
|
|
768
522
|
* )
|
|
769
523
|
* ```
|
|
770
524
|
*/
|
|
771
|
-
export const removeTime =
|
|
772
|
-
date.setUTCHours(0, 0, 0, 0);
|
|
773
|
-
return makeUtc(date.getTime());
|
|
774
|
-
});
|
|
525
|
+
export const removeTime = Internal.removeTime;
|
|
775
526
|
// =============================================================================
|
|
776
527
|
// parts
|
|
777
528
|
// =============================================================================
|
|
778
|
-
const dateToParts = date => ({
|
|
779
|
-
millis: date.getUTCMilliseconds(),
|
|
780
|
-
seconds: date.getUTCSeconds(),
|
|
781
|
-
minutes: date.getUTCMinutes(),
|
|
782
|
-
hours: date.getUTCHours(),
|
|
783
|
-
day: date.getUTCDate(),
|
|
784
|
-
weekDay: date.getUTCDay(),
|
|
785
|
-
month: date.getUTCMonth() + 1,
|
|
786
|
-
year: date.getUTCFullYear()
|
|
787
|
-
});
|
|
788
529
|
/**
|
|
789
530
|
* Get the different parts of a `DateTime` as an object.
|
|
790
531
|
*
|
|
@@ -793,15 +534,7 @@ const dateToParts = date => ({
|
|
|
793
534
|
* @since 3.6.0
|
|
794
535
|
* @category parts
|
|
795
536
|
*/
|
|
796
|
-
export const toParts =
|
|
797
|
-
if (self._tag === "Utc") {
|
|
798
|
-
return toPartsUtc(self);
|
|
799
|
-
} else if (self.partsAdjusted !== undefined) {
|
|
800
|
-
return self.partsAdjusted;
|
|
801
|
-
}
|
|
802
|
-
self.partsAdjusted = withDate(self, dateToParts);
|
|
803
|
-
return self.partsAdjusted;
|
|
804
|
-
};
|
|
537
|
+
export const toParts = Internal.toParts;
|
|
805
538
|
/**
|
|
806
539
|
* Get the different parts of a `DateTime` as an object.
|
|
807
540
|
*
|
|
@@ -810,13 +543,7 @@ export const toParts = self => {
|
|
|
810
543
|
* @since 3.6.0
|
|
811
544
|
* @category parts
|
|
812
545
|
*/
|
|
813
|
-
export const toPartsUtc =
|
|
814
|
-
if (self.partsUtc !== undefined) {
|
|
815
|
-
return self.partsUtc;
|
|
816
|
-
}
|
|
817
|
-
self.partsUtc = withDateUtc(self, dateToParts);
|
|
818
|
-
return self.partsUtc;
|
|
819
|
-
};
|
|
546
|
+
export const toPartsUtc = Internal.toPartsUtc;
|
|
820
547
|
/**
|
|
821
548
|
* Get a part of a `DateTime` as a number.
|
|
822
549
|
*
|
|
@@ -833,7 +560,7 @@ export const toPartsUtc = self => {
|
|
|
833
560
|
* assert.strictEqual(year, 2024)
|
|
834
561
|
* ```
|
|
835
562
|
*/
|
|
836
|
-
export const getPartUtc =
|
|
563
|
+
export const getPartUtc = Internal.getPartUtc;
|
|
837
564
|
/**
|
|
838
565
|
* Get a part of a `DateTime` as a number.
|
|
839
566
|
*
|
|
@@ -850,34 +577,7 @@ export const getPartUtc = /*#__PURE__*/dual(2, (self, part) => toPartsUtc(self)[
|
|
|
850
577
|
* assert.strictEqual(year, 2024)
|
|
851
578
|
* ```
|
|
852
579
|
*/
|
|
853
|
-
export const getPart =
|
|
854
|
-
const setPartsDate = (date, parts) => {
|
|
855
|
-
if (parts.year !== undefined) {
|
|
856
|
-
date.setUTCFullYear(parts.year);
|
|
857
|
-
}
|
|
858
|
-
if (parts.month !== undefined) {
|
|
859
|
-
date.setUTCMonth(parts.month - 1);
|
|
860
|
-
}
|
|
861
|
-
if (parts.day !== undefined) {
|
|
862
|
-
date.setUTCDate(parts.day);
|
|
863
|
-
}
|
|
864
|
-
if (parts.weekDay !== undefined) {
|
|
865
|
-
const diff = parts.weekDay - date.getUTCDay();
|
|
866
|
-
date.setUTCDate(date.getUTCDate() + diff);
|
|
867
|
-
}
|
|
868
|
-
if (parts.hours !== undefined) {
|
|
869
|
-
date.setUTCHours(parts.hours);
|
|
870
|
-
}
|
|
871
|
-
if (parts.minutes !== undefined) {
|
|
872
|
-
date.setUTCMinutes(parts.minutes);
|
|
873
|
-
}
|
|
874
|
-
if (parts.seconds !== undefined) {
|
|
875
|
-
date.setUTCSeconds(parts.seconds);
|
|
876
|
-
}
|
|
877
|
-
if (parts.millis !== undefined) {
|
|
878
|
-
date.setUTCMilliseconds(parts.millis);
|
|
879
|
-
}
|
|
880
|
-
};
|
|
580
|
+
export const getPart = Internal.getPart;
|
|
881
581
|
/**
|
|
882
582
|
* Set the different parts of a `DateTime` as an object.
|
|
883
583
|
*
|
|
@@ -886,21 +586,21 @@ const setPartsDate = (date, parts) => {
|
|
|
886
586
|
* @since 3.6.0
|
|
887
587
|
* @category parts
|
|
888
588
|
*/
|
|
889
|
-
export const setParts =
|
|
589
|
+
export const setParts = Internal.setParts;
|
|
890
590
|
/**
|
|
891
591
|
* Set the different parts of a `DateTime` as an object.
|
|
892
592
|
*
|
|
893
593
|
* @since 3.6.0
|
|
894
594
|
* @category parts
|
|
895
595
|
*/
|
|
896
|
-
export const setPartsUtc =
|
|
596
|
+
export const setPartsUtc = Internal.setPartsUtc;
|
|
897
597
|
// =============================================================================
|
|
898
598
|
// current time zone
|
|
899
599
|
// =============================================================================
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
*/
|
|
600
|
+
// =============================================================================
|
|
601
|
+
// current time zone
|
|
602
|
+
// =============================================================================
|
|
603
|
+
/** @internal */
|
|
904
604
|
export class CurrentTimeZone extends /*#__PURE__*/Context.Tag("effect/DateTime/CurrentTimeZone")() {}
|
|
905
605
|
/**
|
|
906
606
|
* Set the time zone of a `DateTime` to the current time zone, which is
|
|
@@ -1006,62 +706,9 @@ export const withCurrentZoneNamed = /*#__PURE__*/dual(2, (effect, zone) => Effec
|
|
|
1006
706
|
* ```
|
|
1007
707
|
*/
|
|
1008
708
|
export const nowInCurrentZone = /*#__PURE__*/Effect.flatMap(now, setZoneCurrent);
|
|
1009
|
-
/**
|
|
1010
|
-
* Create a Layer from the given time zone.
|
|
1011
|
-
*
|
|
1012
|
-
* @since 3.6.0
|
|
1013
|
-
* @category current time zone
|
|
1014
|
-
*/
|
|
1015
|
-
export const layerCurrentZone = zone => Layer.succeed(CurrentTimeZone, zone);
|
|
1016
|
-
/**
|
|
1017
|
-
* Create a Layer from the given time zone offset.
|
|
1018
|
-
*
|
|
1019
|
-
* @since 3.6.0
|
|
1020
|
-
* @category current time zone
|
|
1021
|
-
*/
|
|
1022
|
-
export const layerCurrentZoneOffset = offset => Layer.succeed(CurrentTimeZone, zoneMakeOffset(offset));
|
|
1023
|
-
/**
|
|
1024
|
-
* Create a Layer from the given IANA time zone identifier.
|
|
1025
|
-
*
|
|
1026
|
-
* @since 3.6.0
|
|
1027
|
-
* @category current time zone
|
|
1028
|
-
*/
|
|
1029
|
-
export const layerCurrentZoneNamed = zoneId => Layer.effect(CurrentTimeZone, zoneMakeNamedEffect(zoneId));
|
|
1030
|
-
/**
|
|
1031
|
-
* Create a Layer from the systems local time zone.
|
|
1032
|
-
*
|
|
1033
|
-
* @since 3.6.0
|
|
1034
|
-
* @category current time zone
|
|
1035
|
-
*/
|
|
1036
|
-
export const layerCurrentZoneLocal = /*#__PURE__*/Layer.sync(CurrentTimeZone, zoneMakeLocal);
|
|
1037
709
|
// =============================================================================
|
|
1038
710
|
// mapping
|
|
1039
711
|
// =============================================================================
|
|
1040
|
-
const makeZonedFromAdjusted = (adjustedMillis, zone) => {
|
|
1041
|
-
const offset = zone._tag === "Offset" ? zone.offset : calculateNamedOffset(adjustedMillis, zone);
|
|
1042
|
-
return makeZonedProto(adjustedMillis - offset, zone);
|
|
1043
|
-
};
|
|
1044
|
-
const offsetRegex = /([+-])(\d{2}):(\d{2})$/;
|
|
1045
|
-
const parseOffset = offset => {
|
|
1046
|
-
const match = offsetRegex.exec(offset);
|
|
1047
|
-
if (match === null) {
|
|
1048
|
-
return null;
|
|
1049
|
-
}
|
|
1050
|
-
const [, sign, hours, minutes] = match;
|
|
1051
|
-
return (sign === "+" ? 1 : -1) * (Number(hours) * 60 + Number(minutes)) * 60 * 1000;
|
|
1052
|
-
};
|
|
1053
|
-
const calculateNamedOffset = (adjustedMillis, zone) => {
|
|
1054
|
-
const offset = zone.format.formatToParts(adjustedMillis).find(_ => _.type === "timeZoneName")?.value ?? "";
|
|
1055
|
-
if (offset === "GMT") {
|
|
1056
|
-
return 0;
|
|
1057
|
-
}
|
|
1058
|
-
const result = parseOffset(offset);
|
|
1059
|
-
if (result === null) {
|
|
1060
|
-
// fallback to using the adjusted date
|
|
1061
|
-
return zonedOffset(makeZonedProto(adjustedMillis, zone));
|
|
1062
|
-
}
|
|
1063
|
-
return result;
|
|
1064
|
-
};
|
|
1065
712
|
/**
|
|
1066
713
|
* Modify a `DateTime` by applying a function to a cloned `Date` instance.
|
|
1067
714
|
*
|
|
@@ -1071,28 +718,14 @@ const calculateNamedOffset = (adjustedMillis, zone) => {
|
|
|
1071
718
|
* @since 3.6.0
|
|
1072
719
|
* @category mapping
|
|
1073
720
|
*/
|
|
1074
|
-
export const mutate =
|
|
1075
|
-
if (self._tag === "Utc") {
|
|
1076
|
-
const date = toDateUtc(self);
|
|
1077
|
-
f(date);
|
|
1078
|
-
return makeUtc(date.getTime());
|
|
1079
|
-
}
|
|
1080
|
-
const adjustedDate = toDate(self);
|
|
1081
|
-
const newAdjustedDate = new Date(adjustedDate.getTime());
|
|
1082
|
-
f(newAdjustedDate);
|
|
1083
|
-
return makeZonedFromAdjusted(newAdjustedDate.getTime(), self.zone);
|
|
1084
|
-
});
|
|
721
|
+
export const mutate = Internal.mutate;
|
|
1085
722
|
/**
|
|
1086
723
|
* Modify a `DateTime` by applying a function to a cloned UTC `Date` instance.
|
|
1087
724
|
*
|
|
1088
725
|
* @since 3.6.0
|
|
1089
726
|
* @category mapping
|
|
1090
727
|
*/
|
|
1091
|
-
export const mutateUtc =
|
|
1092
|
-
const date = new Date(millis);
|
|
1093
|
-
f(date);
|
|
1094
|
-
return date.getTime();
|
|
1095
|
-
}));
|
|
728
|
+
export const mutateUtc = Internal.mutateUtc;
|
|
1096
729
|
/**
|
|
1097
730
|
* Transform a `DateTime` by applying a function to the number of milliseconds
|
|
1098
731
|
* since the Unix epoch.
|
|
@@ -1109,10 +742,7 @@ export const mutateUtc = /*#__PURE__*/dual(2, (self, f) => mapEpochMillis(self,
|
|
|
1109
742
|
* )
|
|
1110
743
|
* ```
|
|
1111
744
|
*/
|
|
1112
|
-
export const mapEpochMillis =
|
|
1113
|
-
const millis = f(toEpochMillis(self));
|
|
1114
|
-
return self._tag === "Utc" ? makeUtc(millis) : makeZonedProto(millis, self.zone);
|
|
1115
|
-
});
|
|
745
|
+
export const mapEpochMillis = Internal.mapEpochMillis;
|
|
1116
746
|
/**
|
|
1117
747
|
* Using the time zone adjusted `Date`, apply a function to the `Date` and
|
|
1118
748
|
* return the result.
|
|
@@ -1129,7 +759,7 @@ export const mapEpochMillis = /*#__PURE__*/dual(2, (self, f) => {
|
|
|
1129
759
|
* )
|
|
1130
760
|
* ```
|
|
1131
761
|
*/
|
|
1132
|
-
export const withDate =
|
|
762
|
+
export const withDate = Internal.withDate;
|
|
1133
763
|
/**
|
|
1134
764
|
* Using the time zone adjusted `Date`, apply a function to the `Date` and
|
|
1135
765
|
* return the result.
|
|
@@ -1146,12 +776,12 @@ export const withDate = /*#__PURE__*/dual(2, (self, f) => f(toDate(self)));
|
|
|
1146
776
|
* )
|
|
1147
777
|
* ```
|
|
1148
778
|
*/
|
|
1149
|
-
export const withDateUtc =
|
|
779
|
+
export const withDateUtc = Internal.withDateUtc;
|
|
1150
780
|
/**
|
|
1151
781
|
* @since 3.6.0
|
|
1152
782
|
* @category mapping
|
|
1153
783
|
*/
|
|
1154
|
-
export const match =
|
|
784
|
+
export const match = Internal.match;
|
|
1155
785
|
// =============================================================================
|
|
1156
786
|
// math
|
|
1157
787
|
// =============================================================================
|
|
@@ -1170,7 +800,7 @@ export const match = /*#__PURE__*/dual(2, (self, options) => self._tag === "Utc"
|
|
|
1170
800
|
* )
|
|
1171
801
|
* ```
|
|
1172
802
|
*/
|
|
1173
|
-
export const addDuration =
|
|
803
|
+
export const addDuration = Internal.addDuration;
|
|
1174
804
|
/**
|
|
1175
805
|
* Subtract the given `Duration` from a `DateTime`.
|
|
1176
806
|
*
|
|
@@ -1186,10 +816,7 @@ export const addDuration = /*#__PURE__*/dual(2, (self, duration) => mapEpochMill
|
|
|
1186
816
|
* )
|
|
1187
817
|
* ```
|
|
1188
818
|
*/
|
|
1189
|
-
export const subtractDuration =
|
|
1190
|
-
const addMillis = (date, amount) => {
|
|
1191
|
-
date.setTime(date.getTime() + amount);
|
|
1192
|
-
};
|
|
819
|
+
export const subtractDuration = Internal.subtractDuration;
|
|
1193
820
|
/**
|
|
1194
821
|
* Add the given `amount` of `unit`'s to a `DateTime`.
|
|
1195
822
|
*
|
|
@@ -1208,41 +835,7 @@ const addMillis = (date, amount) => {
|
|
|
1208
835
|
* )
|
|
1209
836
|
* ```
|
|
1210
837
|
*/
|
|
1211
|
-
export const add =
|
|
1212
|
-
if (parts.millis) {
|
|
1213
|
-
addMillis(date, parts.millis);
|
|
1214
|
-
}
|
|
1215
|
-
if (parts.seconds) {
|
|
1216
|
-
addMillis(date, parts.seconds * 1000);
|
|
1217
|
-
}
|
|
1218
|
-
if (parts.minutes) {
|
|
1219
|
-
addMillis(date, parts.minutes * 60 * 1000);
|
|
1220
|
-
}
|
|
1221
|
-
if (parts.hours) {
|
|
1222
|
-
addMillis(date, parts.hours * 60 * 60 * 1000);
|
|
1223
|
-
}
|
|
1224
|
-
if (parts.days) {
|
|
1225
|
-
date.setUTCDate(date.getUTCDate() + parts.days);
|
|
1226
|
-
}
|
|
1227
|
-
if (parts.weeks) {
|
|
1228
|
-
date.setUTCDate(date.getUTCDate() + parts.weeks * 7);
|
|
1229
|
-
}
|
|
1230
|
-
if (parts.months) {
|
|
1231
|
-
const day = date.getUTCDate();
|
|
1232
|
-
date.setUTCMonth(date.getUTCMonth() + parts.months + 1, 0);
|
|
1233
|
-
if (day < date.getUTCDate()) {
|
|
1234
|
-
date.setUTCDate(day);
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
if (parts.years) {
|
|
1238
|
-
const day = date.getUTCDate();
|
|
1239
|
-
const month = date.getUTCMonth();
|
|
1240
|
-
date.setUTCFullYear(date.getUTCFullYear() + parts.years, month + 1, 0);
|
|
1241
|
-
if (day < date.getUTCDate()) {
|
|
1242
|
-
date.setUTCDate(day);
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
}));
|
|
838
|
+
export const add = Internal.add;
|
|
1246
839
|
/**
|
|
1247
840
|
* Subtract the given `amount` of `unit`'s from a `DateTime`.
|
|
1248
841
|
*
|
|
@@ -1258,58 +851,7 @@ export const add = /*#__PURE__*/dual(2, (self, parts) => mutate(self, date => {
|
|
|
1258
851
|
* )
|
|
1259
852
|
* ```
|
|
1260
853
|
*/
|
|
1261
|
-
export const subtract =
|
|
1262
|
-
const newParts = {};
|
|
1263
|
-
for (const key in parts) {
|
|
1264
|
-
newParts[key] = -1 * parts[key];
|
|
1265
|
-
}
|
|
1266
|
-
return add(self, newParts);
|
|
1267
|
-
});
|
|
1268
|
-
function startOfDate(date, part, options) {
|
|
1269
|
-
switch (part) {
|
|
1270
|
-
case "second":
|
|
1271
|
-
{
|
|
1272
|
-
date.setUTCMilliseconds(0);
|
|
1273
|
-
break;
|
|
1274
|
-
}
|
|
1275
|
-
case "minute":
|
|
1276
|
-
{
|
|
1277
|
-
date.setUTCSeconds(0, 0);
|
|
1278
|
-
break;
|
|
1279
|
-
}
|
|
1280
|
-
case "hour":
|
|
1281
|
-
{
|
|
1282
|
-
date.setUTCMinutes(0, 0, 0);
|
|
1283
|
-
break;
|
|
1284
|
-
}
|
|
1285
|
-
case "day":
|
|
1286
|
-
{
|
|
1287
|
-
date.setUTCHours(0, 0, 0, 0);
|
|
1288
|
-
break;
|
|
1289
|
-
}
|
|
1290
|
-
case "week":
|
|
1291
|
-
{
|
|
1292
|
-
const weekStartsOn = options?.weekStartsOn ?? 0;
|
|
1293
|
-
const day = date.getUTCDay();
|
|
1294
|
-
const diff = (day - weekStartsOn + 7) % 7;
|
|
1295
|
-
date.setUTCDate(date.getUTCDate() - diff);
|
|
1296
|
-
date.setUTCHours(0, 0, 0, 0);
|
|
1297
|
-
break;
|
|
1298
|
-
}
|
|
1299
|
-
case "month":
|
|
1300
|
-
{
|
|
1301
|
-
date.setUTCDate(1);
|
|
1302
|
-
date.setUTCHours(0, 0, 0, 0);
|
|
1303
|
-
break;
|
|
1304
|
-
}
|
|
1305
|
-
case "year":
|
|
1306
|
-
{
|
|
1307
|
-
date.setUTCMonth(0, 1);
|
|
1308
|
-
date.setUTCHours(0, 0, 0, 0);
|
|
1309
|
-
break;
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
854
|
+
export const subtract = Internal.subtract;
|
|
1313
855
|
/**
|
|
1314
856
|
* Converts a `DateTime` to the start of the given `part`.
|
|
1315
857
|
*
|
|
@@ -1329,52 +871,7 @@ function startOfDate(date, part, options) {
|
|
|
1329
871
|
* )
|
|
1330
872
|
* ```
|
|
1331
873
|
*/
|
|
1332
|
-
export const startOf =
|
|
1333
|
-
function endOfDate(date, part, options) {
|
|
1334
|
-
switch (part) {
|
|
1335
|
-
case "second":
|
|
1336
|
-
{
|
|
1337
|
-
date.setUTCMilliseconds(999);
|
|
1338
|
-
break;
|
|
1339
|
-
}
|
|
1340
|
-
case "minute":
|
|
1341
|
-
{
|
|
1342
|
-
date.setUTCSeconds(59, 999);
|
|
1343
|
-
break;
|
|
1344
|
-
}
|
|
1345
|
-
case "hour":
|
|
1346
|
-
{
|
|
1347
|
-
date.setUTCMinutes(59, 59, 999);
|
|
1348
|
-
break;
|
|
1349
|
-
}
|
|
1350
|
-
case "day":
|
|
1351
|
-
{
|
|
1352
|
-
date.setUTCHours(23, 59, 59, 999);
|
|
1353
|
-
break;
|
|
1354
|
-
}
|
|
1355
|
-
case "week":
|
|
1356
|
-
{
|
|
1357
|
-
const weekStartsOn = options?.weekStartsOn ?? 0;
|
|
1358
|
-
const day = date.getUTCDay();
|
|
1359
|
-
const diff = (day - weekStartsOn + 7) % 7;
|
|
1360
|
-
date.setUTCDate(date.getUTCDate() - diff + 6);
|
|
1361
|
-
date.setUTCHours(23, 59, 59, 999);
|
|
1362
|
-
break;
|
|
1363
|
-
}
|
|
1364
|
-
case "month":
|
|
1365
|
-
{
|
|
1366
|
-
date.setUTCMonth(date.getUTCMonth() + 1, 0);
|
|
1367
|
-
date.setUTCHours(23, 59, 59, 999);
|
|
1368
|
-
break;
|
|
1369
|
-
}
|
|
1370
|
-
case "year":
|
|
1371
|
-
{
|
|
1372
|
-
date.setUTCMonth(11, 31);
|
|
1373
|
-
date.setUTCHours(23, 59, 59, 999);
|
|
1374
|
-
break;
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
}
|
|
874
|
+
export const startOf = Internal.startOf;
|
|
1378
875
|
/**
|
|
1379
876
|
* Converts a `DateTime` to the end of the given `part`.
|
|
1380
877
|
*
|
|
@@ -1394,7 +891,7 @@ function endOfDate(date, part, options) {
|
|
|
1394
891
|
* )
|
|
1395
892
|
* ```
|
|
1396
893
|
*/
|
|
1397
|
-
export const endOf =
|
|
894
|
+
export const endOf = Internal.endOf;
|
|
1398
895
|
/**
|
|
1399
896
|
* Converts a `DateTime` to the nearest given `part`.
|
|
1400
897
|
*
|
|
@@ -1414,32 +911,10 @@ export const endOf = /*#__PURE__*/dual(isDateTimeArgs, (self, part, options) =>
|
|
|
1414
911
|
* )
|
|
1415
912
|
* ```
|
|
1416
913
|
*/
|
|
1417
|
-
export const nearest =
|
|
1418
|
-
if (part === "milli") return;
|
|
1419
|
-
const millis = date.getTime();
|
|
1420
|
-
const start = new Date(millis);
|
|
1421
|
-
startOfDate(start, part, options);
|
|
1422
|
-
const startMillis = start.getTime();
|
|
1423
|
-
const end = new Date(millis);
|
|
1424
|
-
endOfDate(end, part, options);
|
|
1425
|
-
const endMillis = end.getTime() + 1;
|
|
1426
|
-
const diffStart = millis - startMillis;
|
|
1427
|
-
const diffEnd = endMillis - millis;
|
|
1428
|
-
if (diffStart < diffEnd) {
|
|
1429
|
-
date.setTime(startMillis);
|
|
1430
|
-
} else {
|
|
1431
|
-
date.setTime(endMillis);
|
|
1432
|
-
}
|
|
1433
|
-
}));
|
|
914
|
+
export const nearest = Internal.nearest;
|
|
1434
915
|
// =============================================================================
|
|
1435
916
|
// formatting
|
|
1436
917
|
// =============================================================================
|
|
1437
|
-
const intlTimeZone = self => {
|
|
1438
|
-
if (self._tag === "Named") {
|
|
1439
|
-
return self.id;
|
|
1440
|
-
}
|
|
1441
|
-
return offsetToString(self.offset);
|
|
1442
|
-
};
|
|
1443
918
|
/**
|
|
1444
919
|
* Format a `DateTime` as a string using the `DateTimeFormat` API.
|
|
1445
920
|
*
|
|
@@ -1451,19 +926,7 @@ const intlTimeZone = self => {
|
|
|
1451
926
|
* @since 3.6.0
|
|
1452
927
|
* @category formatting
|
|
1453
928
|
*/
|
|
1454
|
-
export const format =
|
|
1455
|
-
try {
|
|
1456
|
-
return new Intl.DateTimeFormat(options?.locale, {
|
|
1457
|
-
timeZone: self._tag === "Utc" ? "UTC" : intlTimeZone(self.zone),
|
|
1458
|
-
...options
|
|
1459
|
-
}).format(self.epochMillis);
|
|
1460
|
-
} catch (_) {
|
|
1461
|
-
return new Intl.DateTimeFormat(options?.locale, {
|
|
1462
|
-
timeZone: "UTC",
|
|
1463
|
-
...options
|
|
1464
|
-
}).format(toDate(self));
|
|
1465
|
-
}
|
|
1466
|
-
});
|
|
929
|
+
export const format = Internal.format;
|
|
1467
930
|
/**
|
|
1468
931
|
* Format a `DateTime` as a string using the `DateTimeFormat` API.
|
|
1469
932
|
*
|
|
@@ -1472,7 +935,7 @@ export const format = /*#__PURE__*/dual(isDateTimeArgs, (self, options) => {
|
|
|
1472
935
|
* @since 3.6.0
|
|
1473
936
|
* @category formatting
|
|
1474
937
|
*/
|
|
1475
|
-
export const formatLocal =
|
|
938
|
+
export const formatLocal = Internal.formatLocal;
|
|
1476
939
|
/**
|
|
1477
940
|
* Format a `DateTime` as a string using the `DateTimeFormat` API.
|
|
1478
941
|
*
|
|
@@ -1481,48 +944,42 @@ export const formatLocal = /*#__PURE__*/dual(isDateTimeArgs, (self, options) =>
|
|
|
1481
944
|
* @since 3.6.0
|
|
1482
945
|
* @category formatting
|
|
1483
946
|
*/
|
|
1484
|
-
export const formatUtc =
|
|
1485
|
-
...options,
|
|
1486
|
-
timeZone: "UTC"
|
|
1487
|
-
}).format(self.epochMillis));
|
|
947
|
+
export const formatUtc = Internal.formatUtc;
|
|
1488
948
|
/**
|
|
1489
949
|
* Format a `DateTime` as a string using the `DateTimeFormat` API.
|
|
1490
950
|
*
|
|
1491
951
|
* @since 3.6.0
|
|
1492
952
|
* @category formatting
|
|
1493
953
|
*/
|
|
1494
|
-
export const formatIntl =
|
|
954
|
+
export const formatIntl = Internal.formatIntl;
|
|
1495
955
|
/**
|
|
1496
956
|
* Format a `DateTime` as a UTC ISO string.
|
|
1497
957
|
*
|
|
1498
958
|
* @since 3.6.0
|
|
1499
959
|
* @category formatting
|
|
1500
960
|
*/
|
|
1501
|
-
export const formatIso =
|
|
961
|
+
export const formatIso = Internal.formatIso;
|
|
1502
962
|
/**
|
|
1503
963
|
* Format a `DateTime` as a time zone adjusted ISO date string.
|
|
1504
964
|
*
|
|
1505
965
|
* @since 3.6.0
|
|
1506
966
|
* @category formatting
|
|
1507
967
|
*/
|
|
1508
|
-
export const formatIsoDate =
|
|
968
|
+
export const formatIsoDate = Internal.formatIsoDate;
|
|
1509
969
|
/**
|
|
1510
970
|
* Format a `DateTime` as a UTC ISO date string.
|
|
1511
971
|
*
|
|
1512
972
|
* @since 3.6.0
|
|
1513
973
|
* @category formatting
|
|
1514
974
|
*/
|
|
1515
|
-
export const formatIsoDateUtc =
|
|
975
|
+
export const formatIsoDateUtc = Internal.formatIsoDateUtc;
|
|
1516
976
|
/**
|
|
1517
977
|
* Format a `DateTime.Zoned` as a ISO string with an offset.
|
|
1518
978
|
*
|
|
1519
979
|
* @since 3.6.0
|
|
1520
980
|
* @category formatting
|
|
1521
981
|
*/
|
|
1522
|
-
export const formatIsoOffset =
|
|
1523
|
-
const date = toDate(self);
|
|
1524
|
-
return self._tag === "Utc" ? date.toISOString() : `${date.toISOString().slice(0, -1)}${zonedOffsetIso(self)}`;
|
|
1525
|
-
};
|
|
982
|
+
export const formatIsoOffset = Internal.formatIsoOffset;
|
|
1526
983
|
/**
|
|
1527
984
|
* Format a `DateTime.Zoned` as a string.
|
|
1528
985
|
*
|
|
@@ -1531,5 +988,33 @@ export const formatIsoOffset = self => {
|
|
|
1531
988
|
* @since 3.6.0
|
|
1532
989
|
* @category formatting
|
|
1533
990
|
*/
|
|
1534
|
-
export const formatIsoZoned =
|
|
991
|
+
export const formatIsoZoned = Internal.formatIsoZoned;
|
|
992
|
+
/**
|
|
993
|
+
* Create a Layer from the given time zone.
|
|
994
|
+
*
|
|
995
|
+
* @since 3.6.0
|
|
996
|
+
* @category current time zone
|
|
997
|
+
*/
|
|
998
|
+
export const layerCurrentZone = zone => Layer.succeed(CurrentTimeZone, zone);
|
|
999
|
+
/**
|
|
1000
|
+
* Create a Layer from the given time zone offset.
|
|
1001
|
+
*
|
|
1002
|
+
* @since 3.6.0
|
|
1003
|
+
* @category current time zone
|
|
1004
|
+
*/
|
|
1005
|
+
export const layerCurrentZoneOffset = offset => Layer.succeed(CurrentTimeZone, Internal.zoneMakeOffset(offset));
|
|
1006
|
+
/**
|
|
1007
|
+
* Create a Layer from the given IANA time zone identifier.
|
|
1008
|
+
*
|
|
1009
|
+
* @since 3.6.0
|
|
1010
|
+
* @category current time zone
|
|
1011
|
+
*/
|
|
1012
|
+
export const layerCurrentZoneNamed = zoneId => Layer.effect(CurrentTimeZone, Internal.zoneMakeNamedEffect(zoneId));
|
|
1013
|
+
/**
|
|
1014
|
+
* Create a Layer from the systems local time zone.
|
|
1015
|
+
*
|
|
1016
|
+
* @since 3.6.0
|
|
1017
|
+
* @category current time zone
|
|
1018
|
+
*/
|
|
1019
|
+
export const layerCurrentZoneLocal = /*#__PURE__*/Layer.sync(CurrentTimeZone, zoneMakeLocal);
|
|
1535
1020
|
//# sourceMappingURL=DateTime.js.map
|