effect 3.5.8 → 3.6.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 (123) hide show
  1. package/DateTime/package.json +6 -0
  2. package/dist/cjs/Context.js.map +1 -1
  3. package/dist/cjs/DateTime.js +1514 -0
  4. package/dist/cjs/DateTime.js.map +1 -0
  5. package/dist/cjs/Effect.js +3 -3
  6. package/dist/cjs/Effect.js.map +1 -1
  7. package/dist/cjs/Either.js +3 -3
  8. package/dist/cjs/List.js.map +1 -1
  9. package/dist/cjs/Metric.js.map +1 -1
  10. package/dist/cjs/Micro.js +93 -41
  11. package/dist/cjs/Micro.js.map +1 -1
  12. package/dist/cjs/Option.js +3 -3
  13. package/dist/cjs/Predicate.js +8 -0
  14. package/dist/cjs/Predicate.js.map +1 -1
  15. package/dist/cjs/Random.js +16 -1
  16. package/dist/cjs/Random.js.map +1 -1
  17. package/dist/cjs/Stream.js +86 -7
  18. package/dist/cjs/Stream.js.map +1 -1
  19. package/dist/cjs/Struct.js +23 -1
  20. package/dist/cjs/Struct.js.map +1 -1
  21. package/dist/cjs/index.js +4 -2
  22. package/dist/cjs/index.js.map +1 -1
  23. package/dist/cjs/internal/configProvider.js.map +1 -1
  24. package/dist/cjs/internal/core.js +1 -1
  25. package/dist/cjs/internal/core.js.map +1 -1
  26. package/dist/cjs/internal/defaultServices.js +9 -2
  27. package/dist/cjs/internal/defaultServices.js.map +1 -1
  28. package/dist/cjs/internal/metric.js.map +1 -1
  29. package/dist/cjs/internal/stream/emit.js +73 -1
  30. package/dist/cjs/internal/stream/emit.js.map +1 -1
  31. package/dist/cjs/internal/stream.js +30 -22
  32. package/dist/cjs/internal/stream.js.map +1 -1
  33. package/dist/cjs/internal/version.js +1 -1
  34. package/dist/dts/ConfigProvider.d.ts +2 -2
  35. package/dist/dts/ConfigProvider.d.ts.map +1 -1
  36. package/dist/dts/Context.d.ts +3 -1
  37. package/dist/dts/Context.d.ts.map +1 -1
  38. package/dist/dts/DateTime.d.ts +1265 -0
  39. package/dist/dts/DateTime.d.ts.map +1 -0
  40. package/dist/dts/Effect.d.ts +18 -4
  41. package/dist/dts/Effect.d.ts.map +1 -1
  42. package/dist/dts/Either.d.ts +4 -4
  43. package/dist/dts/List.d.ts +2 -1
  44. package/dist/dts/List.d.ts.map +1 -1
  45. package/dist/dts/Metric.d.ts +1 -1
  46. package/dist/dts/Metric.d.ts.map +1 -1
  47. package/dist/dts/MetricRegistry.d.ts +1 -1
  48. package/dist/dts/MetricRegistry.d.ts.map +1 -1
  49. package/dist/dts/Micro.d.ts +60 -0
  50. package/dist/dts/Micro.d.ts.map +1 -1
  51. package/dist/dts/Option.d.ts +4 -4
  52. package/dist/dts/Predicate.d.ts +63 -2
  53. package/dist/dts/Predicate.d.ts.map +1 -1
  54. package/dist/dts/Random.d.ts +18 -0
  55. package/dist/dts/Random.d.ts.map +1 -1
  56. package/dist/dts/Stream.d.ts +95 -4
  57. package/dist/dts/Stream.d.ts.map +1 -1
  58. package/dist/dts/StreamEmit.d.ts +44 -0
  59. package/dist/dts/StreamEmit.d.ts.map +1 -1
  60. package/dist/dts/Struct.d.ts +21 -0
  61. package/dist/dts/Struct.d.ts.map +1 -1
  62. package/dist/dts/index.d.ts +4 -0
  63. package/dist/dts/index.d.ts.map +1 -1
  64. package/dist/dts/internal/core.d.ts.map +1 -1
  65. package/dist/dts/internal/defaultServices.d.ts.map +1 -1
  66. package/dist/dts/internal/stream.d.ts.map +1 -1
  67. package/dist/esm/Context.js.map +1 -1
  68. package/dist/esm/DateTime.js +1465 -0
  69. package/dist/esm/DateTime.js.map +1 -0
  70. package/dist/esm/Effect.js +4 -4
  71. package/dist/esm/Effect.js.map +1 -1
  72. package/dist/esm/Either.js +4 -4
  73. package/dist/esm/List.js.map +1 -1
  74. package/dist/esm/Metric.js.map +1 -1
  75. package/dist/esm/Micro.js +88 -38
  76. package/dist/esm/Micro.js.map +1 -1
  77. package/dist/esm/Option.js +4 -4
  78. package/dist/esm/Predicate.js +8 -0
  79. package/dist/esm/Predicate.js.map +1 -1
  80. package/dist/esm/Random.js +15 -0
  81. package/dist/esm/Random.js.map +1 -1
  82. package/dist/esm/Stream.js +84 -5
  83. package/dist/esm/Stream.js.map +1 -1
  84. package/dist/esm/Struct.js +21 -0
  85. package/dist/esm/Struct.js.map +1 -1
  86. package/dist/esm/index.js +4 -0
  87. package/dist/esm/index.js.map +1 -1
  88. package/dist/esm/internal/configProvider.js.map +1 -1
  89. package/dist/esm/internal/core.js +1 -1
  90. package/dist/esm/internal/core.js.map +1 -1
  91. package/dist/esm/internal/defaultServices.js +6 -0
  92. package/dist/esm/internal/defaultServices.js.map +1 -1
  93. package/dist/esm/internal/metric.js.map +1 -1
  94. package/dist/esm/internal/stream/emit.js +71 -0
  95. package/dist/esm/internal/stream/emit.js.map +1 -1
  96. package/dist/esm/internal/stream.js +24 -18
  97. package/dist/esm/internal/stream.js.map +1 -1
  98. package/dist/esm/internal/version.js +1 -1
  99. package/package.json +9 -1
  100. package/src/ConfigProvider.ts +2 -2
  101. package/src/Context.ts +3 -1
  102. package/src/DateTime.ts +2104 -0
  103. package/src/Effect.ts +28 -4
  104. package/src/Either.ts +4 -4
  105. package/src/List.ts +3 -2
  106. package/src/Metric.ts +1 -1
  107. package/src/MetricRegistry.ts +1 -1
  108. package/src/Micro.ts +117 -45
  109. package/src/Option.ts +4 -4
  110. package/src/Predicate.ts +68 -8
  111. package/src/Random.ts +24 -0
  112. package/src/Stream.ts +110 -5
  113. package/src/StreamEmit.ts +53 -0
  114. package/src/Struct.ts +22 -0
  115. package/src/index.ts +5 -0
  116. package/src/internal/configProvider.ts +20 -20
  117. package/src/internal/core.ts +37 -12
  118. package/src/internal/defaultServices.ts +14 -0
  119. package/src/internal/metric/registry.ts +1 -1
  120. package/src/internal/metric.ts +2 -2
  121. package/src/internal/stream/emit.ts +77 -0
  122. package/src/internal/stream.ts +86 -18
  123. package/src/internal/version.ts +1 -1
@@ -0,0 +1,1265 @@
1
+ /**
2
+ * @since 3.6.0
3
+ */
4
+ import { IllegalArgumentException } from "./Cause.js";
5
+ import * as Context from "./Context.js";
6
+ import * as Duration from "./Duration.js";
7
+ import * as Effect from "./Effect.js";
8
+ import * as Either from "./Either.js";
9
+ import * as Equivalence_ from "./Equivalence.js";
10
+ import type { LazyArg } from "./Function.js";
11
+ import * as Inspectable from "./Inspectable.js";
12
+ import * as Layer from "./Layer.js";
13
+ import * as Option from "./Option.js";
14
+ import * as order from "./Order.js";
15
+ import { type Pipeable } from "./Pipeable.js";
16
+ /**
17
+ * @since 3.6.0
18
+ * @category type ids
19
+ */
20
+ export declare const TypeId: unique symbol;
21
+ /**
22
+ * @since 3.6.0
23
+ * @category type ids
24
+ */
25
+ export type TypeId = typeof TypeId;
26
+ /**
27
+ * A `DateTime` represents a point in time. It can optionally have a time zone
28
+ * associated with it.
29
+ *
30
+ * @since 3.6.0
31
+ * @category models
32
+ */
33
+ export type DateTime = Utc | Zoned;
34
+ /**
35
+ * @since 3.6.0
36
+ * @category models
37
+ */
38
+ export interface Utc extends DateTime.Proto {
39
+ readonly _tag: "Utc";
40
+ readonly epochMillis: number;
41
+ }
42
+ /**
43
+ * @since 3.6.0
44
+ * @category models
45
+ */
46
+ export interface Zoned extends DateTime.Proto {
47
+ readonly _tag: "Zoned";
48
+ readonly epochMillis: number;
49
+ readonly zone: TimeZone;
50
+ }
51
+ /**
52
+ * @since 3.6.0
53
+ * @category models
54
+ */
55
+ export declare namespace DateTime {
56
+ /**
57
+ * @since 3.6.0
58
+ * @category models
59
+ */
60
+ type Input = DateTime | Partial<Parts> | Date | number | string;
61
+ /**
62
+ * @since 3.6.0
63
+ * @category models
64
+ */
65
+ type PreserveZone<A extends DateTime.Input> = A extends Zoned ? Zoned : Utc;
66
+ /**
67
+ * @since 3.6.0
68
+ * @category models
69
+ */
70
+ type Unit = UnitSingular | UnitPlural;
71
+ /**
72
+ * @since 3.6.0
73
+ * @category models
74
+ */
75
+ type UnitSingular = "milli" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year";
76
+ /**
77
+ * @since 3.6.0
78
+ * @category models
79
+ */
80
+ type UnitPlural = "millis" | "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | "years";
81
+ /**
82
+ * @since 3.6.0
83
+ * @category models
84
+ */
85
+ interface PartsWithWeekday {
86
+ readonly millis: number;
87
+ readonly seconds: number;
88
+ readonly minutes: number;
89
+ readonly hours: number;
90
+ readonly day: number;
91
+ readonly weekDay: number;
92
+ readonly month: number;
93
+ readonly year: number;
94
+ }
95
+ /**
96
+ * @since 3.6.0
97
+ * @category models
98
+ */
99
+ interface Parts {
100
+ readonly millis: number;
101
+ readonly seconds: number;
102
+ readonly minutes: number;
103
+ readonly hours: number;
104
+ readonly day: number;
105
+ readonly month: number;
106
+ readonly year: number;
107
+ }
108
+ /**
109
+ * @since 3.6.0
110
+ * @category models
111
+ */
112
+ interface PartsForMath {
113
+ readonly millis: number;
114
+ readonly seconds: number;
115
+ readonly minutes: number;
116
+ readonly hours: number;
117
+ readonly days: number;
118
+ readonly weeks: number;
119
+ readonly months: number;
120
+ readonly years: number;
121
+ }
122
+ /**
123
+ * @since 3.6.0
124
+ * @category models
125
+ */
126
+ interface Proto extends Pipeable, Inspectable.Inspectable {
127
+ readonly [TypeId]: TypeId;
128
+ }
129
+ }
130
+ /**
131
+ * @since 3.6.0
132
+ * @category type ids
133
+ */
134
+ export declare const TimeZoneTypeId: unique symbol;
135
+ /**
136
+ * @since 3.6.0
137
+ * @category type ids
138
+ */
139
+ export type TimeZoneTypeId = typeof TimeZoneTypeId;
140
+ /**
141
+ * @since 3.6.0
142
+ * @category models
143
+ */
144
+ export type TimeZone = TimeZone.Offset | TimeZone.Named;
145
+ /**
146
+ * @since 3.6.0
147
+ * @category models
148
+ */
149
+ export declare namespace TimeZone {
150
+ /**
151
+ * @since 3.6.0
152
+ * @category models
153
+ */
154
+ interface Proto extends Inspectable.Inspectable {
155
+ readonly [TimeZoneTypeId]: TimeZoneTypeId;
156
+ }
157
+ /**
158
+ * @since 3.6.0
159
+ * @category models
160
+ */
161
+ interface Offset extends Proto {
162
+ readonly _tag: "Offset";
163
+ readonly offset: number;
164
+ }
165
+ /**
166
+ * @since 3.6.0
167
+ * @category models
168
+ */
169
+ interface Named extends Proto {
170
+ readonly _tag: "Named";
171
+ readonly id: string;
172
+ }
173
+ }
174
+ /**
175
+ * @since 3.6.0
176
+ * @category guards
177
+ */
178
+ export declare const isDateTime: (u: unknown) => u is DateTime;
179
+ /**
180
+ * @since 3.6.0
181
+ * @category guards
182
+ */
183
+ export declare const isTimeZone: (u: unknown) => u is TimeZone;
184
+ /**
185
+ * @since 3.6.0
186
+ * @category guards
187
+ */
188
+ export declare const isTimeZoneOffset: (u: unknown) => u is TimeZone.Offset;
189
+ /**
190
+ * @since 3.6.0
191
+ * @category guards
192
+ */
193
+ export declare const isTimeZoneNamed: (u: unknown) => u is TimeZone.Named;
194
+ /**
195
+ * @since 3.6.0
196
+ * @category guards
197
+ */
198
+ export declare const isUtc: (self: DateTime) => self is Utc;
199
+ /**
200
+ * @since 3.6.0
201
+ * @category guards
202
+ */
203
+ export declare const isZoned: (self: DateTime) => self is Zoned;
204
+ /**
205
+ * @since 3.6.0
206
+ * @category instances
207
+ */
208
+ export declare const Equivalence: Equivalence_.Equivalence<DateTime>;
209
+ /**
210
+ * @since 3.6.0
211
+ * @category instances
212
+ */
213
+ export declare const Order: order.Order<DateTime>;
214
+ /**
215
+ * @since 3.6.0
216
+ */
217
+ export declare const clamp: {
218
+ (options: {
219
+ minimum: DateTime;
220
+ maximum: DateTime;
221
+ }): (self: DateTime) => DateTime;
222
+ (self: DateTime, options: {
223
+ minimum: DateTime;
224
+ maximum: DateTime;
225
+ }): DateTime;
226
+ };
227
+ /**
228
+ * Create a `DateTime` from a `Date`.
229
+ *
230
+ * If the `Date` is invalid, an `IllegalArgumentException` will be thrown.
231
+ *
232
+ * @since 3.6.0
233
+ * @category constructors
234
+ */
235
+ export declare const unsafeFromDate: (date: Date) => Utc;
236
+ /**
237
+ * Create a `DateTime` from one of the following:
238
+ *
239
+ * - A `DateTime`
240
+ * - A `Date` instance (invalid dates will throw an `IllegalArgumentException`)
241
+ * - The `number` of milliseconds since the Unix epoch
242
+ * - An object with the parts of a date
243
+ * - A `string` that can be parsed by `Date.parse`
244
+ *
245
+ * @since 3.6.0
246
+ * @category constructors
247
+ * @example
248
+ * import { DateTime } from "effect"
249
+ *
250
+ * // from Date
251
+ * DateTime.unsafeMake(new Date())
252
+ *
253
+ * // from parts
254
+ * DateTime.unsafeMake({ year: 2024 })
255
+ *
256
+ * // from string
257
+ * DateTime.unsafeMake("2024-01-01")
258
+ */
259
+ export declare const unsafeMake: <A extends DateTime.Input>(input: A) => DateTime.PreserveZone<A>;
260
+ /**
261
+ * Create a `DateTime.Zoned` using `DateTime.unsafeMake` and a time zone.
262
+ *
263
+ * The input is treated as UTC and then the time zone is attached, unless
264
+ * `adjustForTimeZone` is set to `true`. In that case, the input is treated as
265
+ * already in the time zone.
266
+ *
267
+ * @since 3.6.0
268
+ * @category constructors
269
+ * @example
270
+ * import { DateTime } from "effect"
271
+ *
272
+ * DateTime.unsafeMakeZoned(new Date(), { timeZone: "Europe/London" })
273
+ */
274
+ export declare const unsafeMakeZoned: (input: DateTime.Input, options: {
275
+ readonly timeZone: number | string | TimeZone;
276
+ readonly adjustForTimeZone?: boolean | undefined;
277
+ }) => Zoned;
278
+ /**
279
+ * Create a `DateTime.Zoned` using `DateTime.make` and a time zone.
280
+ *
281
+ * The input is treated as UTC and then the time zone is attached.
282
+ *
283
+ * If the date time input or time zone is invalid, `None` will be returned.
284
+ *
285
+ * @since 3.6.0
286
+ * @category constructors
287
+ * @example
288
+ * import { DateTime } from "effect"
289
+ *
290
+ * DateTime.makeZoned(new Date(), { timeZone: "Europe/London" })
291
+ */
292
+ export declare const makeZoned: (input: DateTime.Input, options: {
293
+ readonly timeZone: number | string | TimeZone;
294
+ readonly adjustForTimeZone?: boolean | undefined;
295
+ }) => Option.Option<Zoned>;
296
+ /**
297
+ * Create a `DateTime` from one of the following:
298
+ *
299
+ * - A `DateTime`
300
+ * - A `Date` instance (invalid dates will throw an `IllegalArgumentException`)
301
+ * - The `number` of milliseconds since the Unix epoch
302
+ * - An object with the parts of a date
303
+ * - A `string` that can be parsed by `Date.parse`
304
+ *
305
+ * If the input is invalid, `None` will be returned.
306
+ *
307
+ * @since 3.6.0
308
+ * @category constructors
309
+ * @example
310
+ * import { DateTime } from "effect"
311
+ *
312
+ * // from Date
313
+ * DateTime.make(new Date())
314
+ *
315
+ * // from parts
316
+ * DateTime.make({ year: 2024 })
317
+ *
318
+ * // from string
319
+ * DateTime.make("2024-01-01")
320
+ */
321
+ export declare const make: <A extends DateTime.Input>(input: A) => Option.Option<DateTime.PreserveZone<A>>;
322
+ /**
323
+ * Create a `DateTime.Zoned` from a string.
324
+ *
325
+ * It uses the format: `YYYY-MM-DDTHH:mm:ss.sss+HH:MM[Time/Zone]`.
326
+ *
327
+ * @since 3.6.0
328
+ * @category constructors
329
+ */
330
+ export declare const makeZonedFromString: (input: string) => Option.Option<Zoned>;
331
+ /**
332
+ * Get the current time using the `Clock` service and convert it to a `DateTime`.
333
+ *
334
+ * @since 3.6.0
335
+ * @category constructors
336
+ * @example
337
+ * import { DateTime, Effect } from "effect"
338
+ *
339
+ * Effect.gen(function* () {
340
+ * const now = yield* DateTime.now
341
+ * })
342
+ */
343
+ export declare const now: Effect.Effect<Utc>;
344
+ /**
345
+ * Get the current time using `Date.now`.
346
+ *
347
+ * @since 3.6.0
348
+ * @category constructors
349
+ */
350
+ export declare const unsafeNow: LazyArg<Utc>;
351
+ /**
352
+ * Set the time zone of a `DateTime`, returning a new `DateTime.Zoned`.
353
+ *
354
+ * @since 3.6.0
355
+ * @category time zones
356
+ * @example
357
+ * import { DateTime, Effect } from "effect"
358
+ *
359
+ * Effect.gen(function* () {
360
+ * const now = yield* DateTime.now
361
+ * const zone = DateTime.zoneUnsafeMakeNamed("Europe/London")
362
+ *
363
+ * // set the time zone
364
+ * const zoned: DateTime.Zoned = DateTime.setZone(now, zone)
365
+ * })
366
+ */
367
+ export declare const setZone: {
368
+ (zone: TimeZone, options?: {
369
+ readonly adjustForTimeZone?: boolean | undefined;
370
+ }): (self: DateTime) => Zoned;
371
+ (self: DateTime, zone: TimeZone, options?: {
372
+ readonly adjustForTimeZone?: boolean | undefined;
373
+ }): Zoned;
374
+ };
375
+ /**
376
+ * Add a fixed offset time zone to a `DateTime`.
377
+ *
378
+ * The offset is in milliseconds.
379
+ *
380
+ * @since 3.6.0
381
+ * @category time zones
382
+ * @example
383
+ * import { DateTime, Effect } from "effect"
384
+ *
385
+ * Effect.gen(function* () {
386
+ * const now = yield* DateTime.now
387
+ *
388
+ * // set the offset time zone in milliseconds
389
+ * const zoned: DateTime.Zoned = DateTime.setZoneOffset(now, 3 * 60 * 60 * 1000)
390
+ * })
391
+ */
392
+ export declare const setZoneOffset: {
393
+ (offset: number, options?: {
394
+ readonly adjustForTimeZone?: boolean | undefined;
395
+ }): (self: DateTime) => Zoned;
396
+ (self: DateTime, offset: number, options?: {
397
+ readonly adjustForTimeZone?: boolean | undefined;
398
+ }): Zoned;
399
+ };
400
+ /**
401
+ * Attempt to create a named time zone from a IANA time zone identifier.
402
+ *
403
+ * If the time zone is invalid, an `IllegalArgumentException` will be thrown.
404
+ *
405
+ * @since 3.6.0
406
+ * @category time zones
407
+ */
408
+ export declare const zoneUnsafeMakeNamed: (zoneId: string) => TimeZone.Named;
409
+ /**
410
+ * Create a fixed offset time zone.
411
+ *
412
+ * @since 3.6.0
413
+ * @category time zones
414
+ */
415
+ export declare const zoneMakeOffset: (offset: number) => TimeZone.Offset;
416
+ /**
417
+ * Create a named time zone from a IANA time zone identifier. If the time zone
418
+ * is invalid, `None` will be returned.
419
+ *
420
+ * @since 3.6.0
421
+ * @category time zones
422
+ */
423
+ export declare const zoneMakeNamed: (zoneId: string) => Option.Option<TimeZone.Named>;
424
+ /**
425
+ * Create a named time zone from a IANA time zone identifier. If the time zone
426
+ * is invalid, it will fail with an `IllegalArgumentException`.
427
+ *
428
+ * @since 3.6.0
429
+ * @category time zones
430
+ */
431
+ export declare const zoneMakeNamedEffect: (zoneId: string) => Effect.Effect<TimeZone.Named, IllegalArgumentException>;
432
+ /**
433
+ * Create a named time zone from the system's local time zone.
434
+ *
435
+ * @since 3.6.0
436
+ * @category time zones
437
+ */
438
+ export declare const zoneMakeLocal: () => TimeZone.Named;
439
+ /**
440
+ * Try parse a TimeZone from a string
441
+ *
442
+ * @since 3.6.0
443
+ * @category time zones
444
+ */
445
+ export declare const zoneFromString: (zone: string) => Option.Option<TimeZone>;
446
+ /**
447
+ * Format a `TimeZone` as a string.
448
+ *
449
+ * @since 3.6.0
450
+ * @category time zones
451
+ * @example
452
+ * import { DateTime, Effect } from "effect"
453
+ *
454
+ * // Outputs "+03:00"
455
+ * DateTime.zoneToString(DateTime.zoneMakeOffset(3 * 60 * 60 * 1000))
456
+ *
457
+ * // Outputs "Europe/London"
458
+ * DateTime.zoneToString(DateTime.zoneUnsafeMakeNamed("Europe/London"))
459
+ */
460
+ export declare const zoneToString: (self: TimeZone) => string;
461
+ /**
462
+ * Set the time zone of a `DateTime` from an IANA time zone identifier. If the
463
+ * time zone is invalid, `None` will be returned.
464
+ *
465
+ * @since 3.6.0
466
+ * @category time zones
467
+ * @example
468
+ * import { DateTime, Effect } from "effect"
469
+ *
470
+ * Effect.gen(function* () {
471
+ * const now = yield* DateTime.now
472
+ * // set the time zone, returns an Option
473
+ * DateTime.setZoneNamed(now, "Europe/London")
474
+ * })
475
+ */
476
+ export declare const setZoneNamed: {
477
+ (zoneId: string, options?: {
478
+ readonly adjustForTimeZone?: boolean | undefined;
479
+ }): (self: DateTime) => Option.Option<Zoned>;
480
+ (self: DateTime, zoneId: string, options?: {
481
+ readonly adjustForTimeZone?: boolean | undefined;
482
+ }): Option.Option<Zoned>;
483
+ };
484
+ /**
485
+ * Set the time zone of a `DateTime` from an IANA time zone identifier. If the
486
+ * time zone is invalid, an `IllegalArgumentException` will be thrown.
487
+ *
488
+ * @since 3.6.0
489
+ * @category time zones
490
+ * @example
491
+ * import { DateTime, Effect } from "effect"
492
+ *
493
+ * Effect.gen(function* () {
494
+ * const now = yield* DateTime.now
495
+ * // set the time zone
496
+ * DateTime.unsafeSetZoneNamed(now, "Europe/London")
497
+ * })
498
+ */
499
+ export declare const unsafeSetZoneNamed: {
500
+ (zoneId: string, options?: {
501
+ readonly adjustForTimeZone?: boolean | undefined;
502
+ }): (self: DateTime) => Zoned;
503
+ (self: DateTime, zoneId: string, options?: {
504
+ readonly adjustForTimeZone?: boolean | undefined;
505
+ }): Zoned;
506
+ };
507
+ /**
508
+ * Calulate the difference between two `DateTime` values, returning the number
509
+ * of milliseconds the `other` DateTime is from `self`.
510
+ *
511
+ * If `other` is *after* `self`, the result will be a positive number.
512
+ *
513
+ * @since 3.6.0
514
+ * @category comparisons
515
+ * @example
516
+ * import { DateTime, Effect } from "effect"
517
+ *
518
+ * Effect.gen(function* () {
519
+ * const now = yield* DateTime.now
520
+ * const other = DateTime.add(now, { minutes: 1 })
521
+ *
522
+ * // returns 60000
523
+ * DateTime.distance(now, other)
524
+ * })
525
+ */
526
+ export declare const distance: {
527
+ (other: DateTime): (self: DateTime) => number;
528
+ (self: DateTime, other: DateTime): number;
529
+ };
530
+ /**
531
+ * Calulate the difference between two `DateTime` values.
532
+ *
533
+ * If the `other` DateTime is before `self`, the result will be a negative
534
+ * `Duration`, returned as a `Left`.
535
+ *
536
+ * If the `other` DateTime is after `self`, the result will be a positive
537
+ * `Duration`, returned as a `Right`.
538
+ *
539
+ * @since 3.6.0
540
+ * @category comparisons
541
+ * @example
542
+ * import { DateTime, Effect } from "effect"
543
+ *
544
+ * Effect.gen(function* () {
545
+ * const now = yield* DateTime.now
546
+ * const other = DateTime.add(now, { minutes: 1 })
547
+ *
548
+ * // returns Either.right(Duration.minutes(1))
549
+ * DateTime.distanceDurationEither(now, other)
550
+ *
551
+ * // returns Either.left(Duration.minutes(1))
552
+ * DateTime.distanceDurationEither(other, now)
553
+ * })
554
+ */
555
+ export declare const distanceDurationEither: {
556
+ (other: DateTime): (self: DateTime) => Either.Either<Duration.Duration, Duration.Duration>;
557
+ (self: DateTime, other: DateTime): Either.Either<Duration.Duration, Duration.Duration>;
558
+ };
559
+ /**
560
+ * Calulate the distance between two `DateTime` values.
561
+ *
562
+ * @since 3.6.0
563
+ * @category comparisons
564
+ * @example
565
+ * import { DateTime, Effect } from "effect"
566
+ *
567
+ * Effect.gen(function* () {
568
+ * const now = yield* DateTime.now
569
+ * const other = DateTime.add(now, { minutes: 1 })
570
+ *
571
+ * // returns Duration.minutes(1)
572
+ * DateTime.distanceDuration(now, other)
573
+ * })
574
+ */
575
+ export declare const distanceDuration: {
576
+ (other: DateTime): (self: DateTime) => Duration.Duration;
577
+ (self: DateTime, other: DateTime): Duration.Duration;
578
+ };
579
+ /**
580
+ * @since 3.6.0
581
+ * @category comparisons
582
+ */
583
+ export declare const min: {
584
+ (that: DateTime): (self: DateTime) => DateTime;
585
+ (self: DateTime, that: DateTime): DateTime;
586
+ };
587
+ /**
588
+ * @since 3.6.0
589
+ * @category comparisons
590
+ */
591
+ export declare const max: {
592
+ (that: DateTime): (self: DateTime) => DateTime;
593
+ (self: DateTime, that: DateTime): DateTime;
594
+ };
595
+ /**
596
+ * @since 3.6.0
597
+ * @category comparisons
598
+ */
599
+ export declare const greaterThan: {
600
+ (that: DateTime): (self: DateTime) => boolean;
601
+ (self: DateTime, that: DateTime): boolean;
602
+ };
603
+ /**
604
+ * @since 3.6.0
605
+ * @category comparisons
606
+ */
607
+ export declare const greaterThanOrEqualTo: {
608
+ (that: DateTime): (self: DateTime) => boolean;
609
+ (self: DateTime, that: DateTime): boolean;
610
+ };
611
+ /**
612
+ * @since 3.6.0
613
+ * @category comparisons
614
+ */
615
+ export declare const lessThan: {
616
+ (that: DateTime): (self: DateTime) => boolean;
617
+ (self: DateTime, that: DateTime): boolean;
618
+ };
619
+ /**
620
+ * @since 3.6.0
621
+ * @category comparisons
622
+ */
623
+ export declare const lessThanOrEqualTo: {
624
+ (that: DateTime): (self: DateTime) => boolean;
625
+ (self: DateTime, that: DateTime): boolean;
626
+ };
627
+ /**
628
+ * @since 3.6.0
629
+ * @category comparisons
630
+ */
631
+ export declare const between: {
632
+ (options: {
633
+ minimum: DateTime;
634
+ maximum: DateTime;
635
+ }): (self: DateTime) => boolean;
636
+ (self: DateTime, options: {
637
+ minimum: DateTime;
638
+ maximum: DateTime;
639
+ }): boolean;
640
+ };
641
+ /**
642
+ * @since 3.6.0
643
+ * @category comparisons
644
+ */
645
+ export declare const isFuture: (self: DateTime) => Effect.Effect<boolean>;
646
+ /**
647
+ * @since 3.6.0
648
+ * @category comparisons
649
+ */
650
+ export declare const unsafeIsFuture: (self: DateTime) => boolean;
651
+ /**
652
+ * @since 3.6.0
653
+ * @category comparisons
654
+ */
655
+ export declare const isPast: (self: DateTime) => Effect.Effect<boolean>;
656
+ /**
657
+ * @since 3.6.0
658
+ * @category comparisons
659
+ */
660
+ export declare const unsafeIsPast: (self: DateTime) => boolean;
661
+ /**
662
+ * Get the UTC `Date` of a `DateTime`.
663
+ *
664
+ * @since 3.6.0
665
+ * @category conversions
666
+ */
667
+ export declare const toDateUtc: (self: DateTime) => Date;
668
+ /**
669
+ * Convert a `DateTime` to a `Date`, applying the time zone first.
670
+ *
671
+ * @since 3.6.0
672
+ * @category conversions
673
+ */
674
+ export declare const toDate: (self: DateTime) => Date;
675
+ /**
676
+ * Calculate the time zone offset of a `DateTime.Zoned` in milliseconds.
677
+ *
678
+ * @since 3.6.0
679
+ * @category conversions
680
+ */
681
+ export declare const zonedOffset: (self: Zoned) => number;
682
+ /**
683
+ * Calculate the time zone offset of a `DateTime` in milliseconds.
684
+ *
685
+ * The offset is formatted as "±HH:MM".
686
+ *
687
+ * @since 3.6.0
688
+ * @category conversions
689
+ */
690
+ export declare const zonedOffsetIso: (self: Zoned) => string;
691
+ /**
692
+ * Get the milliseconds since the Unix epoch of a `DateTime`.
693
+ *
694
+ * @since 3.6.0
695
+ * @category conversions
696
+ */
697
+ export declare const toEpochMillis: (self: DateTime) => number;
698
+ /**
699
+ * Remove the time aspect of a `DateTime`, first adjusting for the time
700
+ * zone. It will return a `DateTime.Utc` only containing the date.
701
+ *
702
+ * @since 3.6.0
703
+ * @category conversions
704
+ * @example
705
+ * import { DateTime } from "effect"
706
+ *
707
+ * // returns "2024-01-01T00:00:00Z"
708
+ * DateTime.unsafeMakeZoned("2024-01-01T05:00:00Z", {
709
+ * timeZone: "Pacific/Auckland",
710
+ * adjustForTimeZone: true
711
+ * }).pipe(
712
+ * DateTime.removeTime,
713
+ * DateTime.formatIso
714
+ * )
715
+ */
716
+ export declare const removeTime: (self: DateTime) => Utc;
717
+ /**
718
+ * Get the different parts of a `DateTime` as an object.
719
+ *
720
+ * The parts will be time zone adjusted.
721
+ *
722
+ * @since 3.6.0
723
+ * @category parts
724
+ */
725
+ export declare const toParts: (self: DateTime) => DateTime.PartsWithWeekday;
726
+ /**
727
+ * Get the different parts of a `DateTime` as an object.
728
+ *
729
+ * The parts will be in UTC.
730
+ *
731
+ * @since 3.6.0
732
+ * @category parts
733
+ */
734
+ export declare const toPartsUtc: (self: DateTime) => DateTime.PartsWithWeekday;
735
+ /**
736
+ * Get a part of a `DateTime` as a number.
737
+ *
738
+ * The part will be in the UTC time zone.
739
+ *
740
+ * @since 3.6.0
741
+ * @category parts
742
+ * @example
743
+ * import { DateTime } from "effect"
744
+ *
745
+ * const now = DateTime.unsafeMake({ year: 2024 })
746
+ * const year = DateTime.getPartUtc(now, "year")
747
+ * assert.strictEqual(year, 2024)
748
+ */
749
+ export declare const getPartUtc: {
750
+ (part: keyof DateTime.PartsWithWeekday): (self: DateTime) => number;
751
+ (self: DateTime, part: keyof DateTime.PartsWithWeekday): number;
752
+ };
753
+ /**
754
+ * Get a part of a `DateTime` as a number.
755
+ *
756
+ * The part will be time zone adjusted.
757
+ *
758
+ * @since 3.6.0
759
+ * @category parts
760
+ * @example
761
+ * import { DateTime } from "effect"
762
+ *
763
+ * const now = DateTime.unsafeMakeZoned({ year: 2024 }, { timeZone: "Europe/London" })
764
+ * const year = DateTime.getPart(now, "year")
765
+ * assert.strictEqual(year, 2024)
766
+ */
767
+ export declare const getPart: {
768
+ (part: keyof DateTime.PartsWithWeekday): (self: DateTime) => number;
769
+ (self: DateTime, part: keyof DateTime.PartsWithWeekday): number;
770
+ };
771
+ /**
772
+ * Set the different parts of a `DateTime` as an object.
773
+ *
774
+ * The Date will be time zone adjusted.
775
+ *
776
+ * @since 3.6.0
777
+ * @category parts
778
+ */
779
+ export declare const setParts: {
780
+ (parts: Partial<DateTime.PartsWithWeekday>): <A extends DateTime>(self: A) => DateTime.PreserveZone<A>;
781
+ <A extends DateTime>(self: A, parts: Partial<DateTime.PartsWithWeekday>): DateTime.PreserveZone<A>;
782
+ };
783
+ /**
784
+ * Set the different parts of a `DateTime` as an object.
785
+ *
786
+ * @since 3.6.0
787
+ * @category parts
788
+ */
789
+ export declare const setPartsUtc: {
790
+ (parts: Partial<DateTime.PartsWithWeekday>): <A extends DateTime>(self: A) => DateTime.PreserveZone<A>;
791
+ <A extends DateTime>(self: A, parts: Partial<DateTime.PartsWithWeekday>): DateTime.PreserveZone<A>;
792
+ };
793
+ declare const CurrentTimeZone_base: Context.TagClass<CurrentTimeZone, "effect/DateTime/CurrentTimeZone", TimeZone>;
794
+ /**
795
+ * @since 3.6.0
796
+ * @category current time zone
797
+ */
798
+ export declare class CurrentTimeZone extends CurrentTimeZone_base {
799
+ }
800
+ /**
801
+ * Set the time zone of a `DateTime` to the current time zone, which is
802
+ * determined by the `CurrentTimeZone` service.
803
+ *
804
+ * @since 3.6.0
805
+ * @category current time zone
806
+ * @example
807
+ * import { DateTime, Effect } from "effect"
808
+ *
809
+ * Effect.gen(function* () {
810
+ * const now = yield* DateTime.now
811
+ *
812
+ * // set the time zone to "Europe/London"
813
+ * const zoned = yield* DateTime.setZoneCurrent(now)
814
+ * }).pipe(DateTime.withCurrentZoneNamed("Europe/London"))
815
+ */
816
+ export declare const setZoneCurrent: (self: DateTime) => Effect.Effect<Zoned, never, CurrentTimeZone>;
817
+ /**
818
+ * Provide the `CurrentTimeZone` to an effect.
819
+ *
820
+ * @since 3.6.0
821
+ * @category current time zone
822
+ * @example
823
+ * import { DateTime, Effect } from "effect"
824
+ *
825
+ * const zone = DateTime.zoneUnsafeMakeNamed("Europe/London")
826
+ *
827
+ * Effect.gen(function* () {
828
+ * const now = yield* DateTime.nowInCurrentZone
829
+ * }).pipe(DateTime.withCurrentZone(zone))
830
+ */
831
+ export declare const withCurrentZone: {
832
+ (zone: TimeZone): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, CurrentTimeZone>>;
833
+ <A, E, R>(effect: Effect.Effect<A, E, R>, zone: TimeZone): Effect.Effect<A, E, Exclude<R, CurrentTimeZone>>;
834
+ };
835
+ /**
836
+ * Provide the `CurrentTimeZone` to an effect, using the system's local time
837
+ * zone.
838
+ *
839
+ * @since 3.6.0
840
+ * @category current time zone
841
+ * @example
842
+ * import { DateTime, Effect } from "effect"
843
+ *
844
+ * Effect.gen(function* () {
845
+ * // will use the system's local time zone
846
+ * const now = yield* DateTime.nowInCurrentZone
847
+ * }).pipe(DateTime.withCurrentZoneLocal)
848
+ */
849
+ export declare const withCurrentZoneLocal: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, CurrentTimeZone>>;
850
+ /**
851
+ * Provide the `CurrentTimeZone` to an effect, using a offset.
852
+ *
853
+ * @since 3.6.0
854
+ * @category current time zone
855
+ * @example
856
+ * import { DateTime, Effect } from "effect"
857
+ *
858
+ * Effect.gen(function* () {
859
+ * // will use the system's local time zone
860
+ * const now = yield* DateTime.nowInCurrentZone
861
+ * }).pipe(DateTime.withCurrentZoneOffset(3 * 60 * 60 * 1000))
862
+ */
863
+ export declare const withCurrentZoneOffset: {
864
+ (offset: number): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, CurrentTimeZone>>;
865
+ <A, E, R>(effect: Effect.Effect<A, E, R>, offset: number): Effect.Effect<A, E, Exclude<R, CurrentTimeZone>>;
866
+ };
867
+ /**
868
+ * Provide the `CurrentTimeZone` to an effect using an IANA time zone
869
+ * identifier.
870
+ *
871
+ * If the time zone is invalid, it will fail with an `IllegalArgumentException`.
872
+ *
873
+ * @since 3.6.0
874
+ * @category current time zone
875
+ * @example
876
+ * import { DateTime, Effect } from "effect"
877
+ *
878
+ * Effect.gen(function* () {
879
+ * // will use the "Europe/London" time zone
880
+ * const now = yield* DateTime.nowInCurrentZone
881
+ * }).pipe(DateTime.withCurrentZoneNamed("Europe/London"))
882
+ */
883
+ export declare const withCurrentZoneNamed: {
884
+ (zone: string): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | IllegalArgumentException, Exclude<R, CurrentTimeZone>>;
885
+ <A, E, R>(effect: Effect.Effect<A, E, R>, zone: string): Effect.Effect<A, E | IllegalArgumentException, Exclude<R, CurrentTimeZone>>;
886
+ };
887
+ /**
888
+ * Get the current time as a `DateTime.Zoned`, using the `CurrentTimeZone`.
889
+ *
890
+ * @since 3.6.0
891
+ * @category current time zone
892
+ * @example
893
+ * import { DateTime, Effect } from "effect"
894
+ *
895
+ * Effect.gen(function* () {
896
+ * // will use the "Europe/London" time zone
897
+ * const now = yield* DateTime.nowInCurrentZone
898
+ * }).pipe(DateTime.withCurrentZoneNamed("Europe/London"))
899
+ */
900
+ export declare const nowInCurrentZone: Effect.Effect<Zoned, never, CurrentTimeZone>;
901
+ /**
902
+ * Create a Layer from the given time zone.
903
+ *
904
+ * @since 3.6.0
905
+ * @category current time zone
906
+ */
907
+ export declare const layerCurrentZone: (zone: TimeZone) => Layer.Layer<CurrentTimeZone>;
908
+ /**
909
+ * Create a Layer from the given time zone offset.
910
+ *
911
+ * @since 3.6.0
912
+ * @category current time zone
913
+ */
914
+ export declare const layerCurrentZoneOffset: (offset: number) => Layer.Layer<CurrentTimeZone>;
915
+ /**
916
+ * Create a Layer from the given IANA time zone identifier.
917
+ *
918
+ * @since 3.6.0
919
+ * @category current time zone
920
+ */
921
+ export declare const layerCurrentZoneNamed: (zoneId: string) => Layer.Layer<CurrentTimeZone, IllegalArgumentException>;
922
+ /**
923
+ * Create a Layer from the systems local time zone.
924
+ *
925
+ * @since 3.6.0
926
+ * @category current time zone
927
+ */
928
+ export declare const layerCurrentZoneLocal: Layer.Layer<CurrentTimeZone>;
929
+ /**
930
+ * Modify a `DateTime` by applying a function to a cloned `Date` instance.
931
+ *
932
+ * The `Date` will first have the time zone applied if possible, and then be
933
+ * converted back to a `DateTime` within the same time zone.
934
+ *
935
+ * @since 3.6.0
936
+ * @category mapping
937
+ */
938
+ export declare const mutate: {
939
+ (f: (date: Date) => void): <A extends DateTime>(self: A) => DateTime.PreserveZone<A>;
940
+ <A extends DateTime>(self: A, f: (date: Date) => void): DateTime.PreserveZone<A>;
941
+ };
942
+ /**
943
+ * Modify a `DateTime` by applying a function to a cloned UTC `Date` instance.
944
+ *
945
+ * @since 3.6.0
946
+ * @category mapping
947
+ */
948
+ export declare const mutateUtc: {
949
+ (f: (date: Date) => void): <A extends DateTime>(self: A) => DateTime.PreserveZone<A>;
950
+ <A extends DateTime>(self: A, f: (date: Date) => void): DateTime.PreserveZone<A>;
951
+ };
952
+ /**
953
+ * Transform a `DateTime` by applying a function to the number of milliseconds
954
+ * since the Unix epoch.
955
+ *
956
+ * @since 3.6.0
957
+ * @category mapping
958
+ * @example
959
+ * import { DateTime } from "effect"
960
+ *
961
+ * // add 10 milliseconds
962
+ * DateTime.unsafeMake(0).pipe(
963
+ * DateTime.mapEpochMillis((millis) => millis + 10)
964
+ * )
965
+ */
966
+ export declare const mapEpochMillis: {
967
+ (f: (millis: number) => number): <A extends DateTime>(self: A) => DateTime.PreserveZone<A>;
968
+ <A extends DateTime>(self: A, f: (millis: number) => number): DateTime.PreserveZone<A>;
969
+ };
970
+ /**
971
+ * Using the time zone adjusted `Date`, apply a function to the `Date` and
972
+ * return the result.
973
+ *
974
+ * @since 3.6.0
975
+ * @category mapping
976
+ * @example
977
+ * import { DateTime } from "effect"
978
+ *
979
+ * // get the time zone adjusted date in milliseconds
980
+ * DateTime.unsafeMakeZoned(0, { timeZone: "Europe/London" }).pipe(
981
+ * DateTime.withDate((date) => date.getTime())
982
+ * )
983
+ */
984
+ export declare const withDate: {
985
+ <A>(f: (date: Date) => A): (self: DateTime) => A;
986
+ <A>(self: DateTime, f: (date: Date) => A): A;
987
+ };
988
+ /**
989
+ * Using the time zone adjusted `Date`, apply a function to the `Date` and
990
+ * return the result.
991
+ *
992
+ * @since 3.6.0
993
+ * @category mapping
994
+ * @example
995
+ * import { DateTime } from "effect"
996
+ *
997
+ * // get the date in milliseconds
998
+ * DateTime.unsafeMake(0).pipe(
999
+ * DateTime.withDateUtc((date) => date.getTime())
1000
+ * )
1001
+ */
1002
+ export declare const withDateUtc: {
1003
+ <A>(f: (date: Date) => A): (self: DateTime) => A;
1004
+ <A>(self: DateTime, f: (date: Date) => A): A;
1005
+ };
1006
+ /**
1007
+ * @since 3.6.0
1008
+ * @category mapping
1009
+ */
1010
+ export declare const match: {
1011
+ <A, B>(options: {
1012
+ readonly onUtc: (_: Utc) => A;
1013
+ readonly onZoned: (_: Zoned) => B;
1014
+ }): (self: DateTime) => A | B;
1015
+ <A, B>(self: DateTime, options: {
1016
+ readonly onUtc: (_: Utc) => A;
1017
+ readonly onZoned: (_: Zoned) => B;
1018
+ }): A | B;
1019
+ };
1020
+ /**
1021
+ * Add the given `Duration` to a `DateTime`.
1022
+ *
1023
+ * @since 3.6.0
1024
+ * @category math
1025
+ * @example
1026
+ * import { DateTime } from "effect"
1027
+ *
1028
+ * // add 5 minutes
1029
+ * DateTime.unsafeMake(0).pipe(
1030
+ * DateTime.addDuration("5 minutes")
1031
+ * )
1032
+ */
1033
+ export declare const addDuration: {
1034
+ (duration: Duration.DurationInput): <A extends DateTime>(self: A) => DateTime.PreserveZone<A>;
1035
+ <A extends DateTime>(self: A, duration: Duration.DurationInput): DateTime.PreserveZone<A>;
1036
+ };
1037
+ /**
1038
+ * Subtract the given `Duration` from a `DateTime`.
1039
+ *
1040
+ * @since 3.6.0
1041
+ * @category math
1042
+ * @example
1043
+ * import { DateTime } from "effect"
1044
+ *
1045
+ * // subtract 5 minutes
1046
+ * DateTime.unsafeMake(0).pipe(
1047
+ * DateTime.subtractDuration("5 minutes")
1048
+ * )
1049
+ */
1050
+ export declare const subtractDuration: {
1051
+ (duration: Duration.DurationInput): <A extends DateTime>(self: A) => DateTime.PreserveZone<A>;
1052
+ <A extends DateTime>(self: A, duration: Duration.DurationInput): DateTime.PreserveZone<A>;
1053
+ };
1054
+ /**
1055
+ * Add the given `amount` of `unit`'s to a `DateTime`.
1056
+ *
1057
+ * The time zone is taken into account when adding days, weeks, months, and
1058
+ * years.
1059
+ *
1060
+ * @since 3.6.0
1061
+ * @category math
1062
+ * @example
1063
+ * import { DateTime } from "effect"
1064
+ *
1065
+ * // add 5 minutes
1066
+ * DateTime.unsafeMake(0).pipe(
1067
+ * DateTime.add({ minutes: 5 })
1068
+ * )
1069
+ */
1070
+ export declare const add: {
1071
+ (parts: Partial<DateTime.PartsForMath>): <A extends DateTime>(self: A) => DateTime.PreserveZone<A>;
1072
+ <A extends DateTime>(self: A, parts: Partial<DateTime.PartsForMath>): DateTime.PreserveZone<A>;
1073
+ };
1074
+ /**
1075
+ * Subtract the given `amount` of `unit`'s from a `DateTime`.
1076
+ *
1077
+ * @since 3.6.0
1078
+ * @category math
1079
+ * @example
1080
+ * import { DateTime } from "effect"
1081
+ *
1082
+ * // subtract 5 minutes
1083
+ * DateTime.unsafeMake(0).pipe(
1084
+ * DateTime.subtract({ minutes: 5 })
1085
+ * )
1086
+ */
1087
+ export declare const subtract: {
1088
+ (parts: Partial<DateTime.PartsForMath>): <A extends DateTime>(self: A) => DateTime.PreserveZone<A>;
1089
+ <A extends DateTime>(self: A, parts: Partial<DateTime.PartsForMath>): DateTime.PreserveZone<A>;
1090
+ };
1091
+ /**
1092
+ * Converts a `DateTime` to the start of the given `part`.
1093
+ *
1094
+ * If the part is `week`, the `weekStartsOn` option can be used to specify the
1095
+ * day of the week that the week starts on. The default is 0 (Sunday).
1096
+ *
1097
+ * @since 3.6.0
1098
+ * @category math
1099
+ * @example
1100
+ * import { DateTime } from "effect"
1101
+ *
1102
+ * // returns "2024-01-01T00:00:00Z"
1103
+ * DateTime.unsafeMake("2024-01-01T12:00:00Z").pipe(
1104
+ * DateTime.startOf("day"),
1105
+ * DateTime.formatIso
1106
+ * )
1107
+ */
1108
+ export declare const startOf: {
1109
+ (part: DateTime.UnitSingular, options?: {
1110
+ readonly weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined;
1111
+ }): <A extends DateTime>(self: A) => DateTime.PreserveZone<A>;
1112
+ <A extends DateTime>(self: A, part: DateTime.UnitSingular, options?: {
1113
+ readonly weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined;
1114
+ }): DateTime.PreserveZone<A>;
1115
+ };
1116
+ /**
1117
+ * Converts a `DateTime` to the end of the given `part`.
1118
+ *
1119
+ * If the part is `week`, the `weekStartsOn` option can be used to specify the
1120
+ * day of the week that the week starts on. The default is 0 (Sunday).
1121
+ *
1122
+ * @since 3.6.0
1123
+ * @category math
1124
+ * @example
1125
+ * import { DateTime } from "effect"
1126
+ *
1127
+ * // returns "2024-01-01T23:59:59.999Z"
1128
+ * DateTime.unsafeMake("2024-01-01T12:00:00Z").pipe(
1129
+ * DateTime.endOf("day"),
1130
+ * DateTime.formatIso
1131
+ * )
1132
+ */
1133
+ export declare const endOf: {
1134
+ (part: DateTime.UnitSingular, options?: {
1135
+ readonly weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined;
1136
+ }): <A extends DateTime>(self: A) => DateTime.PreserveZone<A>;
1137
+ <A extends DateTime>(self: A, part: DateTime.UnitSingular, options?: {
1138
+ readonly weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined;
1139
+ }): DateTime.PreserveZone<A>;
1140
+ };
1141
+ /**
1142
+ * Converts a `DateTime` to the nearest given `part`.
1143
+ *
1144
+ * If the part is `week`, the `weekStartsOn` option can be used to specify the
1145
+ * day of the week that the week starts on. The default is 0 (Sunday).
1146
+ *
1147
+ * @since 3.6.0
1148
+ * @category math
1149
+ * @example
1150
+ * import { DateTime } from "effect"
1151
+ *
1152
+ * // returns "2024-01-02T00:00:00Z"
1153
+ * DateTime.unsafeMake("2024-01-01T12:01:00Z").pipe(
1154
+ * DateTime.nearest("day"),
1155
+ * DateTime.formatIso
1156
+ * )
1157
+ */
1158
+ export declare const nearest: {
1159
+ (part: DateTime.UnitSingular, options?: {
1160
+ readonly weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined;
1161
+ }): <A extends DateTime>(self: A) => DateTime.PreserveZone<A>;
1162
+ <A extends DateTime>(self: A, part: DateTime.UnitSingular, options?: {
1163
+ readonly weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined;
1164
+ }): DateTime.PreserveZone<A>;
1165
+ };
1166
+ /**
1167
+ * Format a `DateTime` as a string using the `DateTimeFormat` API.
1168
+ *
1169
+ * The `timeZone` option is set to the offset of the time zone.
1170
+ *
1171
+ * Note: On Node versions < 22, fixed "Offset" zones will set the time zone to
1172
+ * "UTC" and use the adjusted `Date`.
1173
+ *
1174
+ * @since 3.6.0
1175
+ * @category formatting
1176
+ */
1177
+ export declare const format: {
1178
+ (options?: Intl.DateTimeFormatOptions & {
1179
+ readonly locale?: string | undefined;
1180
+ } | undefined): (self: DateTime) => string;
1181
+ (self: DateTime, options?: Intl.DateTimeFormatOptions & {
1182
+ readonly locale?: string | undefined;
1183
+ } | undefined): string;
1184
+ };
1185
+ /**
1186
+ * Format a `DateTime` as a string using the `DateTimeFormat` API.
1187
+ *
1188
+ * It will use the system's local time zone.
1189
+ *
1190
+ * @since 3.6.0
1191
+ * @category formatting
1192
+ */
1193
+ export declare const formatLocal: {
1194
+ (options?: Intl.DateTimeFormatOptions & {
1195
+ readonly locale?: string | undefined;
1196
+ } | undefined): (self: DateTime) => string;
1197
+ (self: DateTime, options?: Intl.DateTimeFormatOptions & {
1198
+ readonly locale?: string | undefined;
1199
+ } | undefined): string;
1200
+ };
1201
+ /**
1202
+ * Format a `DateTime` as a string using the `DateTimeFormat` API.
1203
+ *
1204
+ * This forces the time zone to be UTC.
1205
+ *
1206
+ * @since 3.6.0
1207
+ * @category formatting
1208
+ */
1209
+ export declare const formatUtc: {
1210
+ (options?: Intl.DateTimeFormatOptions & {
1211
+ readonly locale?: string | undefined;
1212
+ } | undefined): (self: DateTime) => string;
1213
+ (self: DateTime, options?: Intl.DateTimeFormatOptions & {
1214
+ readonly locale?: string | undefined;
1215
+ } | undefined): string;
1216
+ };
1217
+ /**
1218
+ * Format a `DateTime` as a string using the `DateTimeFormat` API.
1219
+ *
1220
+ * @since 3.6.0
1221
+ * @category formatting
1222
+ */
1223
+ export declare const formatIntl: {
1224
+ (format: Intl.DateTimeFormat): (self: DateTime) => string;
1225
+ (self: DateTime, format: Intl.DateTimeFormat): string;
1226
+ };
1227
+ /**
1228
+ * Format a `DateTime` as a UTC ISO string.
1229
+ *
1230
+ * @since 3.6.0
1231
+ * @category formatting
1232
+ */
1233
+ export declare const formatIso: (self: DateTime) => string;
1234
+ /**
1235
+ * Format a `DateTime` as a time zone adjusted ISO date string.
1236
+ *
1237
+ * @since 3.6.0
1238
+ * @category formatting
1239
+ */
1240
+ export declare const formatIsoDate: (self: DateTime) => string;
1241
+ /**
1242
+ * Format a `DateTime` as a UTC ISO date string.
1243
+ *
1244
+ * @since 3.6.0
1245
+ * @category formatting
1246
+ */
1247
+ export declare const formatIsoDateUtc: (self: DateTime) => string;
1248
+ /**
1249
+ * Format a `DateTime.Zoned` as a ISO string with an offset.
1250
+ *
1251
+ * @since 3.6.0
1252
+ * @category formatting
1253
+ */
1254
+ export declare const formatIsoOffset: (self: DateTime) => string;
1255
+ /**
1256
+ * Format a `DateTime.Zoned` as a string.
1257
+ *
1258
+ * It uses the format: `YYYY-MM-DDTHH:mm:ss.sss+HH:MM[Time/Zone]`.
1259
+ *
1260
+ * @since 3.6.0
1261
+ * @category formatting
1262
+ */
1263
+ export declare const formatIsoZoned: (self: Zoned) => string;
1264
+ export {};
1265
+ //# sourceMappingURL=DateTime.d.ts.map