@clayroach/effect 3.19.14-source-capture.6 → 3.19.14-source-capture.8

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 (371) hide show
  1. package/dist/cjs/Utils.js +1 -1
  2. package/dist/cjs/Utils.js.map +1 -1
  3. package/dist/cjs/internal/clock.js +1 -1
  4. package/dist/cjs/internal/clock.js.map +1 -1
  5. package/dist/esm/Utils.js +1 -1
  6. package/dist/esm/Utils.js.map +1 -1
  7. package/dist/esm/internal/clock.js +1 -1
  8. package/dist/esm/internal/clock.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/Arbitrary.ts +0 -1101
  11. package/src/Array.ts +0 -3589
  12. package/src/BigDecimal.ts +0 -1349
  13. package/src/BigInt.ts +0 -643
  14. package/src/Boolean.ts +0 -287
  15. package/src/Brand.ts +0 -360
  16. package/src/Cache.ts +0 -281
  17. package/src/Cause.ts +0 -1555
  18. package/src/Channel.ts +0 -2355
  19. package/src/ChildExecutorDecision.ts +0 -146
  20. package/src/Chunk.ts +0 -1495
  21. package/src/Clock.ts +0 -111
  22. package/src/Config.ts +0 -542
  23. package/src/ConfigError.ts +0 -270
  24. package/src/ConfigProvider.ts +0 -333
  25. package/src/ConfigProviderPathPatch.ts +0 -100
  26. package/src/Console.ts +0 -226
  27. package/src/Context.ts +0 -585
  28. package/src/Cron.ts +0 -706
  29. package/src/Data.ts +0 -596
  30. package/src/DateTime.ts +0 -1686
  31. package/src/DefaultServices.ts +0 -34
  32. package/src/Deferred.ts +0 -301
  33. package/src/Differ.ts +0 -450
  34. package/src/Duration.ts +0 -1000
  35. package/src/Effect.ts +0 -14839
  36. package/src/Effectable.ts +0 -107
  37. package/src/Either.ts +0 -1040
  38. package/src/Encoding.ts +0 -195
  39. package/src/Equal.ts +0 -98
  40. package/src/Equivalence.ts +0 -235
  41. package/src/ExecutionPlan.ts +0 -308
  42. package/src/ExecutionStrategy.ts +0 -119
  43. package/src/Exit.ts +0 -467
  44. package/src/FastCheck.ts +0 -9
  45. package/src/Fiber.ts +0 -744
  46. package/src/FiberHandle.ts +0 -540
  47. package/src/FiberId.ts +0 -195
  48. package/src/FiberMap.ts +0 -656
  49. package/src/FiberRef.ts +0 -431
  50. package/src/FiberRefs.ts +0 -204
  51. package/src/FiberRefsPatch.ts +0 -105
  52. package/src/FiberSet.ts +0 -491
  53. package/src/FiberStatus.ts +0 -108
  54. package/src/Function.ts +0 -1222
  55. package/src/GlobalValue.ts +0 -53
  56. package/src/Graph.ts +0 -3732
  57. package/src/GroupBy.ts +0 -103
  58. package/src/HKT.ts +0 -45
  59. package/src/Hash.ts +0 -195
  60. package/src/HashMap.ts +0 -519
  61. package/src/HashRing.ts +0 -317
  62. package/src/HashSet.ts +0 -2346
  63. package/src/Inspectable.ts +0 -287
  64. package/src/Iterable.ts +0 -1119
  65. package/src/JSONSchema.ts +0 -1044
  66. package/src/KeyedPool.ts +0 -167
  67. package/src/Layer.ts +0 -1251
  68. package/src/LayerMap.ts +0 -436
  69. package/src/List.ts +0 -977
  70. package/src/LogLevel.ts +0 -285
  71. package/src/LogSpan.ts +0 -25
  72. package/src/Logger.ts +0 -702
  73. package/src/Mailbox.ts +0 -268
  74. package/src/ManagedRuntime.ts +0 -180
  75. package/src/Match.ts +0 -1477
  76. package/src/MergeDecision.ts +0 -95
  77. package/src/MergeState.ts +0 -172
  78. package/src/MergeStrategy.ts +0 -107
  79. package/src/Metric.ts +0 -780
  80. package/src/MetricBoundaries.ts +0 -69
  81. package/src/MetricHook.ts +0 -151
  82. package/src/MetricKey.ts +0 -224
  83. package/src/MetricKeyType.ts +0 -262
  84. package/src/MetricLabel.ts +0 -47
  85. package/src/MetricPair.ts +0 -71
  86. package/src/MetricPolling.ts +0 -148
  87. package/src/MetricRegistry.ts +0 -48
  88. package/src/MetricState.ts +0 -257
  89. package/src/Micro.ts +0 -4405
  90. package/src/ModuleVersion.ts +0 -18
  91. package/src/MutableHashMap.ts +0 -411
  92. package/src/MutableHashSet.ts +0 -706
  93. package/src/MutableList.ts +0 -297
  94. package/src/MutableQueue.ts +0 -227
  95. package/src/MutableRef.ts +0 -202
  96. package/src/NonEmptyIterable.ts +0 -32
  97. package/src/Number.ts +0 -1071
  98. package/src/Option.ts +0 -2170
  99. package/src/Order.ts +0 -373
  100. package/src/Ordering.ts +0 -111
  101. package/src/ParseResult.ts +0 -2031
  102. package/src/PartitionedSemaphore.ts +0 -200
  103. package/src/Pipeable.ts +0 -566
  104. package/src/Pool.ts +0 -204
  105. package/src/Predicate.ts +0 -1405
  106. package/src/Pretty.ts +0 -205
  107. package/src/PrimaryKey.ts +0 -23
  108. package/src/PubSub.ts +0 -182
  109. package/src/Queue.ts +0 -644
  110. package/src/Random.ts +0 -204
  111. package/src/RateLimiter.ts +0 -138
  112. package/src/RcMap.ts +0 -141
  113. package/src/RcRef.ts +0 -122
  114. package/src/Readable.ts +0 -93
  115. package/src/Record.ts +0 -1274
  116. package/src/RedBlackTree.ts +0 -421
  117. package/src/Redacted.ts +0 -144
  118. package/src/Ref.ts +0 -180
  119. package/src/RegExp.ts +0 -38
  120. package/src/Reloadable.ts +0 -127
  121. package/src/Request.ts +0 -347
  122. package/src/RequestBlock.ts +0 -118
  123. package/src/RequestResolver.ts +0 -366
  124. package/src/Resource.ts +0 -119
  125. package/src/Runtime.ts +0 -383
  126. package/src/RuntimeFlags.ts +0 -368
  127. package/src/RuntimeFlagsPatch.ts +0 -183
  128. package/src/STM.ts +0 -2045
  129. package/src/Schedule.ts +0 -2219
  130. package/src/ScheduleDecision.ts +0 -62
  131. package/src/ScheduleInterval.ts +0 -151
  132. package/src/ScheduleIntervals.ts +0 -122
  133. package/src/Scheduler.ts +0 -353
  134. package/src/Schema.ts +0 -10914
  135. package/src/SchemaAST.ts +0 -3043
  136. package/src/Scope.ts +0 -204
  137. package/src/ScopedCache.ts +0 -151
  138. package/src/ScopedRef.ts +0 -117
  139. package/src/Secret.ts +0 -88
  140. package/src/SingleProducerAsyncInput.ts +0 -67
  141. package/src/Sink.ts +0 -1461
  142. package/src/SortedMap.ts +0 -287
  143. package/src/SortedSet.ts +0 -390
  144. package/src/Stream.ts +0 -6468
  145. package/src/StreamEmit.ts +0 -136
  146. package/src/StreamHaltStrategy.ts +0 -123
  147. package/src/Streamable.ts +0 -45
  148. package/src/String.ts +0 -778
  149. package/src/Struct.ts +0 -243
  150. package/src/Subscribable.ts +0 -100
  151. package/src/SubscriptionRef.ts +0 -298
  152. package/src/Supervisor.ts +0 -240
  153. package/src/Symbol.ts +0 -29
  154. package/src/SynchronizedRef.ts +0 -270
  155. package/src/TArray.ts +0 -495
  156. package/src/TDeferred.ts +0 -100
  157. package/src/TMap.ts +0 -515
  158. package/src/TPriorityQueue.ts +0 -223
  159. package/src/TPubSub.ts +0 -200
  160. package/src/TQueue.ts +0 -432
  161. package/src/TRandom.ts +0 -129
  162. package/src/TReentrantLock.ts +0 -224
  163. package/src/TRef.ts +0 -178
  164. package/src/TSemaphore.ts +0 -129
  165. package/src/TSet.ts +0 -365
  166. package/src/TSubscriptionRef.ts +0 -192
  167. package/src/Take.ts +0 -258
  168. package/src/TestAnnotation.ts +0 -158
  169. package/src/TestAnnotationMap.ts +0 -119
  170. package/src/TestAnnotations.ts +0 -117
  171. package/src/TestClock.ts +0 -556
  172. package/src/TestConfig.ts +0 -47
  173. package/src/TestContext.ts +0 -36
  174. package/src/TestLive.ts +0 -53
  175. package/src/TestServices.ts +0 -390
  176. package/src/TestSized.ts +0 -55
  177. package/src/Tracer.ts +0 -198
  178. package/src/Trie.ts +0 -840
  179. package/src/Tuple.ts +0 -305
  180. package/src/Types.ts +0 -353
  181. package/src/Unify.ts +0 -113
  182. package/src/UpstreamPullRequest.ts +0 -117
  183. package/src/UpstreamPullStrategy.ts +0 -121
  184. package/src/Utils.ts +0 -809
  185. package/src/index.ts +0 -1561
  186. package/src/internal/array.ts +0 -8
  187. package/src/internal/blockedRequests.ts +0 -520
  188. package/src/internal/cache.ts +0 -733
  189. package/src/internal/cause.ts +0 -1050
  190. package/src/internal/channel/channelExecutor.ts +0 -1200
  191. package/src/internal/channel/channelState.ts +0 -134
  192. package/src/internal/channel/childExecutorDecision.ts +0 -96
  193. package/src/internal/channel/continuation.ts +0 -200
  194. package/src/internal/channel/mergeDecision.ts +0 -113
  195. package/src/internal/channel/mergeState.ts +0 -120
  196. package/src/internal/channel/mergeStrategy.ts +0 -72
  197. package/src/internal/channel/singleProducerAsyncInput.ts +0 -259
  198. package/src/internal/channel/subexecutor.ts +0 -229
  199. package/src/internal/channel/upstreamPullRequest.ts +0 -84
  200. package/src/internal/channel/upstreamPullStrategy.ts +0 -87
  201. package/src/internal/channel.ts +0 -2603
  202. package/src/internal/clock.ts +0 -95
  203. package/src/internal/completedRequestMap.ts +0 -9
  204. package/src/internal/concurrency.ts +0 -54
  205. package/src/internal/config.ts +0 -716
  206. package/src/internal/configError.ts +0 -304
  207. package/src/internal/configProvider/pathPatch.ts +0 -97
  208. package/src/internal/configProvider.ts +0 -799
  209. package/src/internal/console.ts +0 -153
  210. package/src/internal/context.ts +0 -337
  211. package/src/internal/core-effect.ts +0 -2293
  212. package/src/internal/core-stream.ts +0 -998
  213. package/src/internal/core.ts +0 -3273
  214. package/src/internal/data.ts +0 -36
  215. package/src/internal/dataSource.ts +0 -327
  216. package/src/internal/dateTime.ts +0 -1277
  217. package/src/internal/defaultServices/console.ts +0 -100
  218. package/src/internal/defaultServices.ts +0 -163
  219. package/src/internal/deferred.ts +0 -46
  220. package/src/internal/differ/chunkPatch.ts +0 -211
  221. package/src/internal/differ/contextPatch.ts +0 -232
  222. package/src/internal/differ/hashMapPatch.ts +0 -220
  223. package/src/internal/differ/hashSetPatch.ts +0 -176
  224. package/src/internal/differ/orPatch.ts +0 -311
  225. package/src/internal/differ/readonlyArrayPatch.ts +0 -210
  226. package/src/internal/differ.ts +0 -200
  227. package/src/internal/doNotation.ts +0 -80
  228. package/src/internal/effect/circular.ts +0 -905
  229. package/src/internal/effectable.ts +0 -131
  230. package/src/internal/either.ts +0 -110
  231. package/src/internal/encoding/base64.ts +0 -286
  232. package/src/internal/encoding/base64Url.ts +0 -29
  233. package/src/internal/encoding/common.ts +0 -51
  234. package/src/internal/encoding/hex.ts +0 -315
  235. package/src/internal/errors.ts +0 -7
  236. package/src/internal/executionPlan.ts +0 -114
  237. package/src/internal/executionStrategy.ts +0 -74
  238. package/src/internal/fiber.ts +0 -388
  239. package/src/internal/fiberId.ts +0 -267
  240. package/src/internal/fiberMessage.ts +0 -82
  241. package/src/internal/fiberRefs/patch.ts +0 -144
  242. package/src/internal/fiberRefs.ts +0 -297
  243. package/src/internal/fiberRuntime.ts +0 -3915
  244. package/src/internal/fiberScope.ts +0 -71
  245. package/src/internal/fiberStatus.ts +0 -119
  246. package/src/internal/groupBy.ts +0 -530
  247. package/src/internal/hashMap/array.ts +0 -49
  248. package/src/internal/hashMap/bitwise.ts +0 -32
  249. package/src/internal/hashMap/config.ts +0 -14
  250. package/src/internal/hashMap/keySet.ts +0 -8
  251. package/src/internal/hashMap/node.ts +0 -391
  252. package/src/internal/hashMap.ts +0 -586
  253. package/src/internal/hashSet.ts +0 -323
  254. package/src/internal/keyedPool.ts +0 -244
  255. package/src/internal/layer/circular.ts +0 -228
  256. package/src/internal/layer.ts +0 -1487
  257. package/src/internal/logSpan.ts +0 -20
  258. package/src/internal/logger-circular.ts +0 -24
  259. package/src/internal/logger.ts +0 -485
  260. package/src/internal/mailbox.ts +0 -561
  261. package/src/internal/managedRuntime/circular.ts +0 -6
  262. package/src/internal/managedRuntime.ts +0 -134
  263. package/src/internal/matcher.ts +0 -652
  264. package/src/internal/metric/boundaries.ts +0 -75
  265. package/src/internal/metric/hook.ts +0 -483
  266. package/src/internal/metric/key.ts +0 -167
  267. package/src/internal/metric/keyType.ts +0 -238
  268. package/src/internal/metric/label.ts +0 -41
  269. package/src/internal/metric/pair.ts +0 -48
  270. package/src/internal/metric/polling.ts +0 -149
  271. package/src/internal/metric/registry.ts +0 -187
  272. package/src/internal/metric/state.ts +0 -290
  273. package/src/internal/metric.ts +0 -577
  274. package/src/internal/opCodes/cause.ts +0 -35
  275. package/src/internal/opCodes/channel.ts +0 -83
  276. package/src/internal/opCodes/channelChildExecutorDecision.ts +0 -17
  277. package/src/internal/opCodes/channelMergeDecision.ts +0 -11
  278. package/src/internal/opCodes/channelMergeState.ts +0 -17
  279. package/src/internal/opCodes/channelMergeStrategy.ts +0 -11
  280. package/src/internal/opCodes/channelState.ts +0 -23
  281. package/src/internal/opCodes/channelUpstreamPullRequest.ts +0 -11
  282. package/src/internal/opCodes/channelUpstreamPullStrategy.ts +0 -11
  283. package/src/internal/opCodes/config.ts +0 -65
  284. package/src/internal/opCodes/configError.ts +0 -35
  285. package/src/internal/opCodes/continuation.ts +0 -11
  286. package/src/internal/opCodes/deferred.ts +0 -11
  287. package/src/internal/opCodes/effect.ts +0 -89
  288. package/src/internal/opCodes/layer.ts +0 -59
  289. package/src/internal/opCodes/streamHaltStrategy.ts +0 -23
  290. package/src/internal/option.ts +0 -80
  291. package/src/internal/pool.ts +0 -432
  292. package/src/internal/pubsub.ts +0 -1762
  293. package/src/internal/query.ts +0 -204
  294. package/src/internal/queue.ts +0 -766
  295. package/src/internal/random.ts +0 -161
  296. package/src/internal/rateLimiter.ts +0 -93
  297. package/src/internal/rcMap.ts +0 -285
  298. package/src/internal/rcRef.ts +0 -192
  299. package/src/internal/redBlackTree/iterator.ts +0 -200
  300. package/src/internal/redBlackTree/node.ts +0 -68
  301. package/src/internal/redBlackTree.ts +0 -1245
  302. package/src/internal/redacted.ts +0 -73
  303. package/src/internal/ref.ts +0 -171
  304. package/src/internal/reloadable.ts +0 -140
  305. package/src/internal/request.ts +0 -177
  306. package/src/internal/resource.ts +0 -76
  307. package/src/internal/ringBuffer.ts +0 -68
  308. package/src/internal/runtime.ts +0 -558
  309. package/src/internal/runtimeFlags.ts +0 -188
  310. package/src/internal/runtimeFlagsPatch.ts +0 -103
  311. package/src/internal/schedule/decision.ts +0 -47
  312. package/src/internal/schedule/interval.ts +0 -101
  313. package/src/internal/schedule/intervals.ts +0 -180
  314. package/src/internal/schedule.ts +0 -2199
  315. package/src/internal/schema/errors.ts +0 -191
  316. package/src/internal/schema/schemaId.ts +0 -106
  317. package/src/internal/schema/util.ts +0 -50
  318. package/src/internal/scopedCache.ts +0 -644
  319. package/src/internal/scopedRef.ts +0 -118
  320. package/src/internal/secret.ts +0 -89
  321. package/src/internal/singleShotGen.ts +0 -35
  322. package/src/internal/sink.ts +0 -2120
  323. package/src/internal/stack.ts +0 -10
  324. package/src/internal/stm/core.ts +0 -817
  325. package/src/internal/stm/entry.ts +0 -59
  326. package/src/internal/stm/journal.ts +0 -123
  327. package/src/internal/stm/opCodes/stm.ts +0 -71
  328. package/src/internal/stm/opCodes/stmState.ts +0 -17
  329. package/src/internal/stm/opCodes/strategy.ts +0 -17
  330. package/src/internal/stm/opCodes/tExit.ts +0 -29
  331. package/src/internal/stm/opCodes/tryCommit.ts +0 -11
  332. package/src/internal/stm/stm.ts +0 -1453
  333. package/src/internal/stm/stmState.ts +0 -136
  334. package/src/internal/stm/tArray.ts +0 -550
  335. package/src/internal/stm/tDeferred.ts +0 -81
  336. package/src/internal/stm/tExit.ts +0 -190
  337. package/src/internal/stm/tMap.ts +0 -824
  338. package/src/internal/stm/tPriorityQueue.ts +0 -267
  339. package/src/internal/stm/tPubSub.ts +0 -551
  340. package/src/internal/stm/tQueue.ts +0 -393
  341. package/src/internal/stm/tRandom.ts +0 -140
  342. package/src/internal/stm/tReentrantLock.ts +0 -352
  343. package/src/internal/stm/tRef.ts +0 -195
  344. package/src/internal/stm/tSemaphore.ts +0 -113
  345. package/src/internal/stm/tSet.ts +0 -259
  346. package/src/internal/stm/tSubscriptionRef.ts +0 -286
  347. package/src/internal/stm/tryCommit.ts +0 -34
  348. package/src/internal/stm/txnId.ts +0 -14
  349. package/src/internal/stm/versioned.ts +0 -4
  350. package/src/internal/stream/debounceState.ts +0 -57
  351. package/src/internal/stream/emit.ts +0 -123
  352. package/src/internal/stream/haltStrategy.ts +0 -94
  353. package/src/internal/stream/handoff.ts +0 -187
  354. package/src/internal/stream/handoffSignal.ts +0 -59
  355. package/src/internal/stream/pull.ts +0 -34
  356. package/src/internal/stream/sinkEndReason.ts +0 -30
  357. package/src/internal/stream/zipAllState.ts +0 -88
  358. package/src/internal/stream/zipChunksState.ts +0 -56
  359. package/src/internal/stream.ts +0 -8801
  360. package/src/internal/string-utils.ts +0 -107
  361. package/src/internal/subscriptionRef.ts +0 -138
  362. package/src/internal/supervisor/patch.ts +0 -190
  363. package/src/internal/supervisor.ts +0 -303
  364. package/src/internal/synchronizedRef.ts +0 -114
  365. package/src/internal/take.ts +0 -199
  366. package/src/internal/testing/sleep.ts +0 -27
  367. package/src/internal/testing/suspendedWarningData.ts +0 -85
  368. package/src/internal/testing/warningData.ts +0 -94
  369. package/src/internal/tracer.ts +0 -293
  370. package/src/internal/trie.ts +0 -722
  371. package/src/internal/version.ts +0 -7
package/src/DateTime.ts DELETED
@@ -1,1686 +0,0 @@
1
- /**
2
- * @since 3.6.0
3
- */
4
- import type { IllegalArgumentException } from "./Cause.js"
5
- import * as Context from "./Context.js"
6
- import type * as Duration from "./Duration.js"
7
- import * as Effect from "./Effect.js"
8
- import type * as Either from "./Either.js"
9
- import type * as equivalence from "./Equivalence.js"
10
- import { dual, type LazyArg } from "./Function.js"
11
- import type { Inspectable } from "./Inspectable.js"
12
- import * as Internal from "./internal/dateTime.js"
13
- import * as Layer from "./Layer.js"
14
- import type * as Option from "./Option.js"
15
- import type * as order from "./Order.js"
16
- import type { Pipeable } from "./Pipeable.js"
17
-
18
- /**
19
- * @since 3.6.0
20
- * @category type ids
21
- */
22
- export const TypeId: unique symbol = Internal.TypeId
23
-
24
- /**
25
- * @since 3.6.0
26
- * @category type ids
27
- */
28
- export type TypeId = typeof TypeId
29
-
30
- /**
31
- * A `DateTime` represents a point in time. It can optionally have a time zone
32
- * associated with it.
33
- *
34
- * @since 3.6.0
35
- * @category models
36
- */
37
- export type DateTime = Utc | Zoned
38
-
39
- /**
40
- * @since 3.6.0
41
- * @category models
42
- */
43
- export interface Utc extends DateTime.Proto {
44
- readonly _tag: "Utc"
45
- readonly epochMillis: number
46
- partsUtc: DateTime.PartsWithWeekday | undefined
47
- }
48
-
49
- /**
50
- * @since 3.6.0
51
- * @category models
52
- */
53
- export interface Zoned extends DateTime.Proto {
54
- readonly _tag: "Zoned"
55
- readonly epochMillis: number
56
- readonly zone: TimeZone
57
- adjustedEpochMillis: number | undefined
58
- partsAdjusted: DateTime.PartsWithWeekday | undefined
59
- partsUtc: DateTime.PartsWithWeekday | undefined
60
- }
61
-
62
- /**
63
- * @since 3.6.0
64
- * @category models
65
- */
66
- export declare namespace DateTime {
67
- /**
68
- * @since 3.6.0
69
- * @category models
70
- */
71
- export type Input = DateTime | Partial<Parts> | Date | number | string
72
-
73
- /**
74
- * @since 3.6.0
75
- * @category models
76
- */
77
- export type PreserveZone<A extends DateTime.Input> = A extends Zoned ? Zoned : Utc
78
-
79
- /**
80
- * @since 3.6.0
81
- * @category models
82
- */
83
- export type Unit = UnitSingular | UnitPlural
84
-
85
- /**
86
- * @since 3.6.0
87
- * @category models
88
- */
89
- export type UnitSingular =
90
- | "milli"
91
- | "second"
92
- | "minute"
93
- | "hour"
94
- | "day"
95
- | "week"
96
- | "month"
97
- | "year"
98
-
99
- /**
100
- * @since 3.6.0
101
- * @category models
102
- */
103
- export type UnitPlural =
104
- | "millis"
105
- | "seconds"
106
- | "minutes"
107
- | "hours"
108
- | "days"
109
- | "weeks"
110
- | "months"
111
- | "years"
112
-
113
- /**
114
- * @since 3.6.0
115
- * @category models
116
- */
117
- export interface PartsWithWeekday {
118
- readonly millis: number
119
- readonly seconds: number
120
- readonly minutes: number
121
- readonly hours: number
122
- readonly day: number
123
- readonly weekDay: number
124
- readonly month: number
125
- readonly year: number
126
- }
127
-
128
- /**
129
- * @since 3.6.0
130
- * @category models
131
- */
132
- export interface Parts {
133
- readonly millis: number
134
- readonly seconds: number
135
- readonly minutes: number
136
- readonly hours: number
137
- readonly day: number
138
- readonly month: number
139
- readonly year: number
140
- }
141
-
142
- /**
143
- * @since 3.6.0
144
- * @category models
145
- */
146
- export interface PartsForMath {
147
- readonly millis: number
148
- readonly seconds: number
149
- readonly minutes: number
150
- readonly hours: number
151
- readonly days: number
152
- readonly weeks: number
153
- readonly months: number
154
- readonly years: number
155
- }
156
-
157
- /**
158
- * @since 3.6.0
159
- * @category models
160
- */
161
- export interface Proto extends Pipeable, Inspectable {
162
- readonly [TypeId]: TypeId
163
- }
164
- }
165
-
166
- /**
167
- * @since 3.6.0
168
- * @category type ids
169
- */
170
- export const TimeZoneTypeId: unique symbol = Internal.TimeZoneTypeId
171
-
172
- /**
173
- * @since 3.6.0
174
- * @category type ids
175
- */
176
- export type TimeZoneTypeId = typeof TimeZoneTypeId
177
-
178
- /**
179
- * @since 3.6.0
180
- * @category models
181
- */
182
- export type TimeZone = TimeZone.Offset | TimeZone.Named
183
-
184
- /**
185
- * @since 3.6.0
186
- * @category models
187
- */
188
- export declare namespace TimeZone {
189
- /**
190
- * @since 3.6.0
191
- * @category models
192
- */
193
- export interface Proto extends Inspectable {
194
- readonly [TimeZoneTypeId]: TimeZoneTypeId
195
- }
196
-
197
- /**
198
- * @since 3.6.0
199
- * @category models
200
- */
201
- export interface Offset extends Proto {
202
- readonly _tag: "Offset"
203
- readonly offset: number
204
- }
205
-
206
- /**
207
- * @since 3.6.0
208
- * @category models
209
- */
210
- export interface Named extends Proto {
211
- readonly _tag: "Named"
212
- readonly id: string
213
- /** @internal */
214
- readonly format: Intl.DateTimeFormat
215
- }
216
- }
217
-
218
- /**
219
- * A `Disambiguation` is used to resolve ambiguities when a `DateTime` is
220
- * ambiguous, such as during a daylight saving time transition.
221
- *
222
- * For more information, see the [Temporal documentation](https://tc39.es/proposal-temporal/docs/timezone.html#ambiguity-due-to-dst-or-other-time-zone-offset-changes)
223
- *
224
- * - `"compatible"`: (default) Behavior matching Temporal API and legacy JavaScript Date and moment.js.
225
- * For repeated times, chooses the earlier occurrence. For gap times, chooses the later interpretation.
226
- *
227
- * - `"earlier"`: For repeated times, always choose the earlier occurrence.
228
- * For gap times, choose the time before the gap.
229
- *
230
- * - `"later"`: For repeated times, always choose the later occurrence.
231
- * For gap times, choose the time after the gap.
232
- *
233
- * - `"reject"`: Throw an `RangeError` when encountering ambiguous or non-existent times.
234
- *
235
- * @example
236
- * ```ts
237
- * import { DateTime } from "effect"
238
- *
239
- * // Fall-back example: 01:30 on Nov 2, 2025 in New York happens twice
240
- * const ambiguousTime = { year: 2025, month: 11, day: 2, hours: 1, minutes: 30 }
241
- * const timeZone = DateTime.zoneUnsafeMakeNamed("America/New_York")
242
- *
243
- * DateTime.makeZoned(ambiguousTime, { timeZone, adjustForTimeZone: true, disambiguation: "earlier" })
244
- * // Earlier occurrence (DST time): 2025-11-02T05:30:00.000Z
245
- *
246
- * DateTime.makeZoned(ambiguousTime, { timeZone, adjustForTimeZone: true, disambiguation: "later" })
247
- * // Later occurrence (standard time): 2025-11-02T06:30:00.000Z
248
- *
249
- * // Gap example: 02:30 on Mar 9, 2025 in New York doesn't exist
250
- * const gapTime = { year: 2025, month: 3, day: 9, hours: 2, minutes: 30 }
251
- *
252
- * DateTime.makeZoned(gapTime, { timeZone, adjustForTimeZone: true, disambiguation: "earlier" })
253
- * // Time before gap: 2025-03-09T06:30:00.000Z (01:30 EST)
254
- *
255
- * DateTime.makeZoned(gapTime, { timeZone, adjustForTimeZone: true, disambiguation: "later" })
256
- * // Time after gap: 2025-03-09T07:30:00.000Z (03:30 EDT)
257
- * ```
258
- *
259
- * @since 3.18.0
260
- * @category models
261
- */
262
- export type Disambiguation = "compatible" | "earlier" | "later" | "reject"
263
-
264
- // =============================================================================
265
- // guards
266
- // =============================================================================
267
-
268
- /**
269
- * @since 3.6.0
270
- * @category guards
271
- */
272
- export const isDateTime: (u: unknown) => u is DateTime = Internal.isDateTime
273
-
274
- /**
275
- * @since 3.6.0
276
- * @category guards
277
- */
278
- export const isTimeZone: (u: unknown) => u is TimeZone = Internal.isTimeZone
279
-
280
- /**
281
- * @since 3.6.0
282
- * @category guards
283
- */
284
- export const isTimeZoneOffset: (u: unknown) => u is TimeZone.Offset = Internal.isTimeZoneOffset
285
-
286
- /**
287
- * @since 3.6.0
288
- * @category guards
289
- */
290
- export const isTimeZoneNamed: (u: unknown) => u is TimeZone.Named = Internal.isTimeZoneNamed
291
-
292
- /**
293
- * @since 3.6.0
294
- * @category guards
295
- */
296
- export const isUtc: (self: DateTime) => self is Utc = Internal.isUtc
297
-
298
- /**
299
- * @since 3.6.0
300
- * @category guards
301
- */
302
- export const isZoned: (self: DateTime) => self is Zoned = Internal.isZoned
303
-
304
- // =============================================================================
305
- // instances
306
- // =============================================================================
307
-
308
- /**
309
- * @since 3.6.0
310
- * @category instances
311
- */
312
- export const Equivalence: equivalence.Equivalence<DateTime> = Internal.Equivalence
313
-
314
- /**
315
- * @since 3.6.0
316
- * @category instances
317
- */
318
- export const Order: order.Order<DateTime> = Internal.Order
319
-
320
- /**
321
- * @since 3.6.0
322
- */
323
- export const clamp: {
324
- <Min extends DateTime, Max extends DateTime>(
325
- options: { readonly minimum: Min; readonly maximum: Max }
326
- ): <A extends DateTime>(self: A) => A | Min | Max
327
- <A extends DateTime, Min extends DateTime, Max extends DateTime>(
328
- self: A,
329
- options: { readonly minimum: Min; readonly maximum: Max }
330
- ): A | Min | Max
331
- } = Internal.clamp
332
-
333
- // =============================================================================
334
- // constructors
335
- // =============================================================================
336
-
337
- /**
338
- * Create a `DateTime` from a `Date`.
339
- *
340
- * If the `Date` is invalid, an `IllegalArgumentException` will be thrown.
341
- *
342
- * @since 3.6.0
343
- * @category constructors
344
- */
345
- export const unsafeFromDate: (date: Date) => Utc = Internal.unsafeFromDate
346
-
347
- /**
348
- * Create a `DateTime` from one of the following:
349
- *
350
- * - A `DateTime`
351
- * - A `Date` instance (invalid dates will throw an `IllegalArgumentException`)
352
- * - The `number` of milliseconds since the Unix epoch
353
- * - An object with the parts of a date
354
- * - A `string` that can be parsed by `Date.parse`
355
- *
356
- * @since 3.6.0
357
- * @category constructors
358
- * @example
359
- * ```ts
360
- * import { DateTime } from "effect"
361
- *
362
- * // from Date
363
- * DateTime.unsafeMake(new Date())
364
- *
365
- * // from parts
366
- * DateTime.unsafeMake({ year: 2024 })
367
- *
368
- * // from string
369
- * DateTime.unsafeMake("2024-01-01")
370
- * ```
371
- */
372
- export const unsafeMake: <A extends DateTime.Input>(input: A) => DateTime.PreserveZone<A> = Internal.unsafeMake
373
-
374
- /**
375
- * Create a `DateTime.Zoned` using `DateTime.unsafeMake` and a time zone.
376
- *
377
- * The input is treated as UTC and then the time zone is attached, unless
378
- * `adjustForTimeZone` is set to `true`. In that case, the input is treated as
379
- * already in the time zone.
380
- *
381
- * When `adjustForTimeZone` is true and ambiguous times occur during DST transitions,
382
- * the `disambiguation` option controls how to resolve the ambiguity:
383
- * - `compatible` (default): Choose earlier time for repeated times, later for gaps
384
- * - `earlier`: Always choose the earlier of two possible times
385
- * - `later`: Always choose the later of two possible times
386
- * - `reject`: Throw an error when ambiguous times are encountered
387
- *
388
- * @since 3.6.0
389
- * @category constructors
390
- * @example
391
- * ```ts
392
- * import { DateTime } from "effect"
393
- *
394
- * DateTime.unsafeMakeZoned(new Date(), { timeZone: "Europe/London" })
395
- * ```
396
- */
397
- export const unsafeMakeZoned: (input: DateTime.Input, options?: {
398
- readonly timeZone?: number | string | TimeZone | undefined
399
- readonly adjustForTimeZone?: boolean | undefined
400
- readonly disambiguation?: Disambiguation | undefined
401
- }) => Zoned = Internal.unsafeMakeZoned
402
-
403
- /**
404
- * Create a `DateTime.Zoned` using `DateTime.make` and a time zone.
405
- *
406
- * The input is treated as UTC and then the time zone is attached, unless
407
- * `adjustForTimeZone` is set to `true`. In that case, the input is treated as
408
- * already in the time zone.
409
- *
410
- * When `adjustForTimeZone` is true and ambiguous times occur during DST transitions,
411
- * the `disambiguation` option controls how to resolve the ambiguity:
412
- * - `compatible` (default): Choose earlier time for repeated times, later for gaps
413
- * - `earlier`: Always choose the earlier of two possible times
414
- * - `later`: Always choose the later of two possible times
415
- * - `reject`: Throw an error when ambiguous times are encountered
416
- *
417
- * If the date time input or time zone is invalid, `None` will be returned.
418
- *
419
- * @since 3.6.0
420
- * @category constructors
421
- * @example
422
- * ```ts
423
- * import { DateTime } from "effect"
424
- *
425
- * DateTime.makeZoned(new Date(), { timeZone: "Europe/London" })
426
- * ```
427
- */
428
- export const makeZoned: (
429
- input: DateTime.Input,
430
- options?: {
431
- readonly timeZone?: number | string | TimeZone | undefined
432
- readonly adjustForTimeZone?: boolean | undefined
433
- readonly disambiguation?: Disambiguation | undefined
434
- }
435
- ) => Option.Option<Zoned> = Internal.makeZoned
436
-
437
- /**
438
- * Create a `DateTime` from one of the following:
439
- *
440
- * - A `DateTime`
441
- * - A `Date` instance (invalid dates will throw an `IllegalArgumentException`)
442
- * - The `number` of milliseconds since the Unix epoch
443
- * - An object with the parts of a date
444
- * - A `string` that can be parsed by `Date.parse`
445
- *
446
- * If the input is invalid, `None` will be returned.
447
- *
448
- * @since 3.6.0
449
- * @category constructors
450
- * @example
451
- * ```ts
452
- * import { DateTime } from "effect"
453
- *
454
- * // from Date
455
- * DateTime.make(new Date())
456
- *
457
- * // from parts
458
- * DateTime.make({ year: 2024 })
459
- *
460
- * // from string
461
- * DateTime.make("2024-01-01")
462
- * ```
463
- */
464
- export const make: <A extends DateTime.Input>(input: A) => Option.Option<DateTime.PreserveZone<A>> = Internal.make
465
-
466
- /**
467
- * Create a `DateTime.Zoned` from a string.
468
- *
469
- * It uses the format: `YYYY-MM-DDTHH:mm:ss.sss+HH:MM[Time/Zone]`.
470
- *
471
- * @since 3.6.0
472
- * @category constructors
473
- */
474
- export const makeZonedFromString: (input: string) => Option.Option<Zoned> = Internal.makeZonedFromString
475
-
476
- /**
477
- * Get the current time using the `Clock` service and convert it to a `DateTime`.
478
- *
479
- * @since 3.6.0
480
- * @category constructors
481
- * @example
482
- * ```ts
483
- * import { DateTime, Effect } from "effect"
484
- *
485
- * Effect.gen(function* () {
486
- * const now = yield* DateTime.now
487
- * })
488
- * ```
489
- */
490
- export const now: Effect.Effect<Utc> = Internal.now
491
-
492
- /**
493
- * Get the current time using the `Clock` service.
494
- *
495
- * @since 3.14.0
496
- * @category constructors
497
- * @example
498
- * ```ts
499
- * import { DateTime, Effect } from "effect"
500
- *
501
- * Effect.gen(function* () {
502
- * const now = yield* DateTime.nowAsDate
503
- * })
504
- * ```
505
- */
506
- export const nowAsDate: Effect.Effect<Date> = Internal.nowAsDate
507
-
508
- /**
509
- * Get the current time using `Date.now`.
510
- *
511
- * @since 3.6.0
512
- * @category constructors
513
- */
514
- export const unsafeNow: LazyArg<Utc> = Internal.unsafeNow
515
-
516
- // =============================================================================
517
- // time zones
518
- // =============================================================================
519
-
520
- /**
521
- * For a `DateTime` returns a new `DateTime.Utc`.
522
- *
523
- * @since 3.13.0
524
- * @category time zones
525
- * @example
526
- * ```ts
527
- * import { DateTime } from "effect"
528
- *
529
- * const now = DateTime.unsafeMakeZoned({ year: 2024 }, { timeZone: "Europe/London" })
530
- *
531
- * // set as UTC
532
- * const utc: DateTime.Utc = DateTime.toUtc(now)
533
- * ```
534
- */
535
- export const toUtc: (self: DateTime) => Utc = Internal.toUtc
536
-
537
- /**
538
- * Set the time zone of a `DateTime`, returning a new `DateTime.Zoned`.
539
- *
540
- * @since 3.6.0
541
- * @category time zones
542
- * @example
543
- * ```ts
544
- * import { DateTime, Effect } from "effect"
545
- *
546
- * Effect.gen(function* () {
547
- * const now = yield* DateTime.now
548
- * const zone = DateTime.zoneUnsafeMakeNamed("Europe/London")
549
- *
550
- * // set the time zone
551
- * const zoned: DateTime.Zoned = DateTime.setZone(now, zone)
552
- * })
553
- * ```
554
- */
555
- export const setZone: {
556
- (zone: TimeZone, options?: {
557
- readonly adjustForTimeZone?: boolean | undefined
558
- readonly disambiguation?: Disambiguation | undefined
559
- }): (self: DateTime) => Zoned
560
- (self: DateTime, zone: TimeZone, options?: {
561
- readonly adjustForTimeZone?: boolean | undefined
562
- readonly disambiguation?: Disambiguation | undefined
563
- }): Zoned
564
- } = Internal.setZone
565
-
566
- /**
567
- * Add a fixed offset time zone to a `DateTime`.
568
- *
569
- * The offset is in milliseconds.
570
- *
571
- * @since 3.6.0
572
- * @category time zones
573
- * @example
574
- * ```ts
575
- * import { DateTime, Effect } from "effect"
576
- *
577
- * Effect.gen(function* () {
578
- * const now = yield* DateTime.now
579
- *
580
- * // set the offset time zone in milliseconds
581
- * const zoned: DateTime.Zoned = DateTime.setZoneOffset(now, 3 * 60 * 60 * 1000)
582
- * })
583
- * ```
584
- */
585
- export const setZoneOffset: {
586
- (offset: number, options?: {
587
- readonly adjustForTimeZone?: boolean | undefined
588
- readonly disambiguation?: Disambiguation | undefined
589
- }): (self: DateTime) => Zoned
590
- (self: DateTime, offset: number, options?: {
591
- readonly adjustForTimeZone?: boolean | undefined
592
- readonly disambiguation?: Disambiguation | undefined
593
- }): Zoned
594
- } = Internal.setZoneOffset
595
-
596
- /**
597
- * Attempt to create a named time zone from a IANA time zone identifier.
598
- *
599
- * If the time zone is invalid, an `IllegalArgumentException` will be thrown.
600
- *
601
- * @since 3.6.0
602
- * @category time zones
603
- */
604
- export const zoneUnsafeMakeNamed: (zoneId: string) => TimeZone.Named = Internal.zoneUnsafeMakeNamed
605
-
606
- /**
607
- * Create a fixed offset time zone.
608
- *
609
- * @since 3.6.0
610
- * @category time zones
611
- */
612
- export const zoneMakeOffset: (offset: number) => TimeZone.Offset = Internal.zoneMakeOffset
613
-
614
- /**
615
- * Create a named time zone from a IANA time zone identifier. If the time zone
616
- * is invalid, `None` will be returned.
617
- *
618
- * @since 3.6.0
619
- * @category time zones
620
- */
621
- export const zoneMakeNamed: (zoneId: string) => Option.Option<TimeZone.Named> = Internal.zoneMakeNamed
622
-
623
- /**
624
- * Create a named time zone from a IANA time zone identifier. If the time zone
625
- * is invalid, it will fail with an `IllegalArgumentException`.
626
- *
627
- * @since 3.6.0
628
- * @category time zones
629
- */
630
- export const zoneMakeNamedEffect: (zoneId: string) => Effect.Effect<TimeZone.Named, IllegalArgumentException> =
631
- Internal.zoneMakeNamedEffect
632
-
633
- /**
634
- * Create a named time zone from the system's local time zone.
635
- *
636
- * @since 3.6.0
637
- * @category time zones
638
- */
639
- export const zoneMakeLocal: () => TimeZone.Named = Internal.zoneMakeLocal
640
-
641
- /**
642
- * Try parse a TimeZone from a string
643
- *
644
- * @since 3.6.0
645
- * @category time zones
646
- */
647
- export const zoneFromString: (zone: string) => Option.Option<TimeZone> = Internal.zoneFromString
648
-
649
- /**
650
- * Format a `TimeZone` as a string.
651
- *
652
- * @since 3.6.0
653
- * @category time zones
654
- * @example
655
- * ```ts
656
- * import { DateTime, Effect } from "effect"
657
- *
658
- * // Outputs "+03:00"
659
- * DateTime.zoneToString(DateTime.zoneMakeOffset(3 * 60 * 60 * 1000))
660
- *
661
- * // Outputs "Europe/London"
662
- * DateTime.zoneToString(DateTime.zoneUnsafeMakeNamed("Europe/London"))
663
- * ```
664
- */
665
- export const zoneToString: (self: TimeZone) => string = Internal.zoneToString
666
-
667
- /**
668
- * Set the time zone of a `DateTime` from an IANA time zone identifier. If the
669
- * time zone is invalid, `None` will be returned.
670
- *
671
- * @since 3.6.0
672
- * @category time zones
673
- * @example
674
- * ```ts
675
- * import { DateTime, Effect } from "effect"
676
- *
677
- * Effect.gen(function* () {
678
- * const now = yield* DateTime.now
679
- * // set the time zone, returns an Option
680
- * DateTime.setZoneNamed(now, "Europe/London")
681
- * })
682
- * ```
683
- */
684
- export const setZoneNamed: {
685
- (zoneId: string, options?: {
686
- readonly adjustForTimeZone?: boolean | undefined
687
- readonly disambiguation?: Disambiguation | undefined
688
- }): (self: DateTime) => Option.Option<Zoned>
689
- (self: DateTime, zoneId: string, options?: {
690
- readonly adjustForTimeZone?: boolean | undefined
691
- readonly disambiguation?: Disambiguation | undefined
692
- }): Option.Option<Zoned>
693
- } = Internal.setZoneNamed
694
-
695
- /**
696
- * Set the time zone of a `DateTime` from an IANA time zone identifier. If the
697
- * time zone is invalid, an `IllegalArgumentException` will be thrown.
698
- *
699
- * @since 3.6.0
700
- * @category time zones
701
- * @example
702
- * ```ts
703
- * import { DateTime, Effect } from "effect"
704
- *
705
- * Effect.gen(function* () {
706
- * const now = yield* DateTime.now
707
- * // set the time zone
708
- * DateTime.unsafeSetZoneNamed(now, "Europe/London")
709
- * })
710
- * ```
711
- */
712
- export const unsafeSetZoneNamed: {
713
- (zoneId: string, options?: {
714
- readonly adjustForTimeZone?: boolean | undefined
715
- readonly disambiguation?: Disambiguation | undefined
716
- }): (self: DateTime) => Zoned
717
- (self: DateTime, zoneId: string, options?: {
718
- readonly adjustForTimeZone?: boolean | undefined
719
- readonly disambiguation?: Disambiguation | undefined
720
- }): Zoned
721
- } = Internal.unsafeSetZoneNamed
722
-
723
- // =============================================================================
724
- // comparisons
725
- // =============================================================================
726
-
727
- /**
728
- * Calulate the difference between two `DateTime` values, returning the number
729
- * of milliseconds the `other` DateTime is from `self`.
730
- *
731
- * If `other` is *after* `self`, the result will be a positive number.
732
- *
733
- * @since 3.6.0
734
- * @category comparisons
735
- * @example
736
- * ```ts
737
- * import { DateTime, Effect } from "effect"
738
- *
739
- * Effect.gen(function* () {
740
- * const now = yield* DateTime.now
741
- * const other = DateTime.add(now, { minutes: 1 })
742
- *
743
- * // returns 60000
744
- * DateTime.distance(now, other)
745
- * })
746
- * ```
747
- */
748
- export const distance: {
749
- (other: DateTime): (self: DateTime) => number
750
- (self: DateTime, other: DateTime): number
751
- } = Internal.distance
752
-
753
- /**
754
- * Calulate the difference between two `DateTime` values.
755
- *
756
- * If the `other` DateTime is before `self`, the result will be a negative
757
- * `Duration`, returned as a `Left`.
758
- *
759
- * If the `other` DateTime is after `self`, the result will be a positive
760
- * `Duration`, returned as a `Right`.
761
- *
762
- * @since 3.6.0
763
- * @category comparisons
764
- * @example
765
- * ```ts
766
- * import { DateTime, Effect } from "effect"
767
- *
768
- * Effect.gen(function* () {
769
- * const now = yield* DateTime.now
770
- * const other = DateTime.add(now, { minutes: 1 })
771
- *
772
- * // returns Either.right(Duration.minutes(1))
773
- * DateTime.distanceDurationEither(now, other)
774
- *
775
- * // returns Either.left(Duration.minutes(1))
776
- * DateTime.distanceDurationEither(other, now)
777
- * })
778
- * ```
779
- */
780
- export const distanceDurationEither: {
781
- (other: DateTime): (self: DateTime) => Either.Either<Duration.Duration, Duration.Duration>
782
- (self: DateTime, other: DateTime): Either.Either<Duration.Duration, Duration.Duration>
783
- } = Internal.distanceDurationEither
784
-
785
- /**
786
- * Calulate the distance between two `DateTime` values.
787
- *
788
- * @since 3.6.0
789
- * @category comparisons
790
- * @example
791
- * ```ts
792
- * import { DateTime, Effect } from "effect"
793
- *
794
- * Effect.gen(function* () {
795
- * const now = yield* DateTime.now
796
- * const other = DateTime.add(now, { minutes: 1 })
797
- *
798
- * // returns Duration.minutes(1)
799
- * DateTime.distanceDuration(now, other)
800
- * })
801
- * ```
802
- */
803
- export const distanceDuration: {
804
- (other: DateTime): (self: DateTime) => Duration.Duration
805
- (self: DateTime, other: DateTime): Duration.Duration
806
- } = Internal.distanceDuration
807
-
808
- /**
809
- * @since 3.6.0
810
- * @category comparisons
811
- */
812
- export const min: {
813
- <That extends DateTime>(that: That): <Self extends DateTime>(self: Self) => Self | That
814
- <Self extends DateTime, That extends DateTime>(self: Self, that: That): Self | That
815
- } = Internal.min
816
-
817
- /**
818
- * @since 3.6.0
819
- * @category comparisons
820
- */
821
- export const max: {
822
- <That extends DateTime>(that: That): <Self extends DateTime>(self: Self) => Self | That
823
- <Self extends DateTime, That extends DateTime>(self: Self, that: That): Self | That
824
- } = Internal.max
825
-
826
- /**
827
- * @since 3.6.0
828
- * @category comparisons
829
- */
830
- export const greaterThan: {
831
- (that: DateTime): (self: DateTime) => boolean
832
- (self: DateTime, that: DateTime): boolean
833
- } = Internal.greaterThan
834
-
835
- /**
836
- * @since 3.6.0
837
- * @category comparisons
838
- */
839
- export const greaterThanOrEqualTo: {
840
- (that: DateTime): (self: DateTime) => boolean
841
- (self: DateTime, that: DateTime): boolean
842
- } = Internal.greaterThanOrEqualTo
843
-
844
- /**
845
- * @since 3.6.0
846
- * @category comparisons
847
- */
848
- export const lessThan: {
849
- (that: DateTime): (self: DateTime) => boolean
850
- (self: DateTime, that: DateTime): boolean
851
- } = Internal.lessThan
852
-
853
- /**
854
- * @since 3.6.0
855
- * @category comparisons
856
- */
857
- export const lessThanOrEqualTo: {
858
- (that: DateTime): (self: DateTime) => boolean
859
- (self: DateTime, that: DateTime): boolean
860
- } = Internal.lessThanOrEqualTo
861
-
862
- /**
863
- * @since 3.6.0
864
- * @category comparisons
865
- */
866
- export const between: {
867
- (options: { minimum: DateTime; maximum: DateTime }): (self: DateTime) => boolean
868
- (self: DateTime, options: { minimum: DateTime; maximum: DateTime }): boolean
869
- } = Internal.between
870
-
871
- /**
872
- * @since 3.6.0
873
- * @category comparisons
874
- */
875
- export const isFuture: (self: DateTime) => Effect.Effect<boolean> = Internal.isFuture
876
-
877
- /**
878
- * @since 3.6.0
879
- * @category comparisons
880
- */
881
- export const unsafeIsFuture: (self: DateTime) => boolean = Internal.unsafeIsFuture
882
-
883
- /**
884
- * @since 3.6.0
885
- * @category comparisons
886
- */
887
- export const isPast: (self: DateTime) => Effect.Effect<boolean> = Internal.isPast
888
-
889
- /**
890
- * @since 3.6.0
891
- * @category comparisons
892
- */
893
- export const unsafeIsPast: (self: DateTime) => boolean = Internal.unsafeIsPast
894
-
895
- // =============================================================================
896
- // conversions
897
- // =============================================================================
898
-
899
- /**
900
- * Get the UTC `Date` of a `DateTime`.
901
- *
902
- * @since 3.6.0
903
- * @category conversions
904
- */
905
- export const toDateUtc: (self: DateTime) => Date = Internal.toDateUtc
906
-
907
- /**
908
- * Convert a `DateTime` to a `Date`, applying the time zone first.
909
- *
910
- * @since 3.6.0
911
- * @category conversions
912
- */
913
- export const toDate: (self: DateTime) => Date = Internal.toDate
914
-
915
- /**
916
- * Calculate the time zone offset of a `DateTime.Zoned` in milliseconds.
917
- *
918
- * @since 3.6.0
919
- * @category conversions
920
- */
921
- export const zonedOffset: (self: Zoned) => number = Internal.zonedOffset
922
-
923
- /**
924
- * Calculate the time zone offset of a `DateTime` in milliseconds.
925
- *
926
- * The offset is formatted as "±HH:MM".
927
- *
928
- * @since 3.6.0
929
- * @category conversions
930
- */
931
- export const zonedOffsetIso: (self: Zoned) => string = Internal.zonedOffsetIso
932
-
933
- /**
934
- * Get the milliseconds since the Unix epoch of a `DateTime`.
935
- *
936
- * @since 3.6.0
937
- * @category conversions
938
- */
939
- export const toEpochMillis: (self: DateTime) => number = Internal.toEpochMillis
940
-
941
- /**
942
- * Remove the time aspect of a `DateTime`, first adjusting for the time
943
- * zone. It will return a `DateTime.Utc` only containing the date.
944
- *
945
- * @since 3.6.0
946
- * @category conversions
947
- * @example
948
- * ```ts
949
- * import { DateTime } from "effect"
950
- *
951
- * // returns "2024-01-01T00:00:00Z"
952
- * DateTime.unsafeMakeZoned("2024-01-01T05:00:00Z", {
953
- * timeZone: "Pacific/Auckland",
954
- * adjustForTimeZone: true
955
- * }).pipe(
956
- * DateTime.removeTime,
957
- * DateTime.formatIso
958
- * )
959
- * ```
960
- */
961
- export const removeTime: (self: DateTime) => Utc = Internal.removeTime
962
-
963
- // =============================================================================
964
- // parts
965
- // =============================================================================
966
-
967
- /**
968
- * Get the different parts of a `DateTime` as an object.
969
- *
970
- * The parts will be time zone adjusted.
971
- *
972
- * @since 3.6.0
973
- * @category parts
974
- */
975
- export const toParts: (self: DateTime) => DateTime.PartsWithWeekday = Internal.toParts
976
-
977
- /**
978
- * Get the different parts of a `DateTime` as an object.
979
- *
980
- * The parts will be in UTC.
981
- *
982
- * @since 3.6.0
983
- * @category parts
984
- */
985
- export const toPartsUtc: (self: DateTime) => DateTime.PartsWithWeekday = Internal.toPartsUtc
986
-
987
- /**
988
- * Get a part of a `DateTime` as a number.
989
- *
990
- * The part will be in the UTC time zone.
991
- *
992
- * @since 3.6.0
993
- * @category parts
994
- * @example
995
- * ```ts
996
- * import * as assert from "node:assert"
997
- * import { DateTime } from "effect"
998
- *
999
- * const now = DateTime.unsafeMake({ year: 2024 })
1000
- * const year = DateTime.getPartUtc(now, "year")
1001
- * assert.strictEqual(year, 2024)
1002
- * ```
1003
- */
1004
- export const getPartUtc: {
1005
- (part: keyof DateTime.PartsWithWeekday): (self: DateTime) => number
1006
- (self: DateTime, part: keyof DateTime.PartsWithWeekday): number
1007
- } = Internal.getPartUtc
1008
-
1009
- /**
1010
- * Get a part of a `DateTime` as a number.
1011
- *
1012
- * The part will be time zone adjusted.
1013
- *
1014
- * @since 3.6.0
1015
- * @category parts
1016
- * @example
1017
- * ```ts
1018
- * import * as assert from "node:assert"
1019
- * import { DateTime } from "effect"
1020
- *
1021
- * const now = DateTime.unsafeMakeZoned({ year: 2024 }, { timeZone: "Europe/London" })
1022
- * const year = DateTime.getPart(now, "year")
1023
- * assert.strictEqual(year, 2024)
1024
- * ```
1025
- */
1026
- export const getPart: {
1027
- (part: keyof DateTime.PartsWithWeekday): (self: DateTime) => number
1028
- (self: DateTime, part: keyof DateTime.PartsWithWeekday): number
1029
- } = Internal.getPart
1030
-
1031
- /**
1032
- * Set the different parts of a `DateTime` as an object.
1033
- *
1034
- * The Date will be time zone adjusted.
1035
- *
1036
- * @since 3.6.0
1037
- * @category parts
1038
- */
1039
- export const setParts: {
1040
- (parts: Partial<DateTime.PartsWithWeekday>): <A extends DateTime>(self: A) => A
1041
- <A extends DateTime>(self: A, parts: Partial<DateTime.PartsWithWeekday>): A
1042
- } = Internal.setParts
1043
-
1044
- /**
1045
- * Set the different parts of a `DateTime` as an object.
1046
- *
1047
- * @since 3.6.0
1048
- * @category parts
1049
- */
1050
- export const setPartsUtc: {
1051
- (parts: Partial<DateTime.PartsWithWeekday>): <A extends DateTime>(self: A) => A
1052
- <A extends DateTime>(self: A, parts: Partial<DateTime.PartsWithWeekday>): A
1053
- } = Internal.setPartsUtc
1054
-
1055
- // =============================================================================
1056
- // current time zone
1057
- // =============================================================================
1058
-
1059
- /**
1060
- * @since 3.11.0
1061
- * @category current time zone
1062
- */
1063
- export class CurrentTimeZone extends Context.Tag("effect/DateTime/CurrentTimeZone")<CurrentTimeZone, TimeZone>() {}
1064
-
1065
- /**
1066
- * Set the time zone of a `DateTime` to the current time zone, which is
1067
- * determined by the `CurrentTimeZone` service.
1068
- *
1069
- * @since 3.6.0
1070
- * @category current time zone
1071
- * @example
1072
- * ```ts
1073
- * import { DateTime, Effect } from "effect"
1074
- *
1075
- * Effect.gen(function* () {
1076
- * const now = yield* DateTime.now
1077
- *
1078
- * // set the time zone to "Europe/London"
1079
- * const zoned = yield* DateTime.setZoneCurrent(now)
1080
- * }).pipe(DateTime.withCurrentZoneNamed("Europe/London"))
1081
- * ```
1082
- */
1083
- export const setZoneCurrent = (self: DateTime): Effect.Effect<Zoned, never, CurrentTimeZone> =>
1084
- Effect.map(CurrentTimeZone, (zone) => setZone(self, zone))
1085
-
1086
- /**
1087
- * Provide the `CurrentTimeZone` to an effect.
1088
- *
1089
- * @since 3.6.0
1090
- * @category current time zone
1091
- * @example
1092
- * ```ts
1093
- * import { DateTime, Effect } from "effect"
1094
- *
1095
- * const zone = DateTime.zoneUnsafeMakeNamed("Europe/London")
1096
- *
1097
- * Effect.gen(function* () {
1098
- * const now = yield* DateTime.nowInCurrentZone
1099
- * }).pipe(DateTime.withCurrentZone(zone))
1100
- * ```
1101
- */
1102
- export const withCurrentZone: {
1103
- (
1104
- zone: TimeZone
1105
- ): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, CurrentTimeZone>>
1106
- <A, E, R>(effect: Effect.Effect<A, E, R>, zone: TimeZone): Effect.Effect<A, E, Exclude<R, CurrentTimeZone>>
1107
- } = dual(
1108
- 2,
1109
- <A, E, R>(
1110
- effect: Effect.Effect<A, E, R>,
1111
- zone: TimeZone
1112
- ): Effect.Effect<A, E, Exclude<R, CurrentTimeZone>> => Effect.provideService(effect, CurrentTimeZone, zone)
1113
- )
1114
-
1115
- /**
1116
- * Provide the `CurrentTimeZone` to an effect, using the system's local time
1117
- * zone.
1118
- *
1119
- * @since 3.6.0
1120
- * @category current time zone
1121
- * @example
1122
- * ```ts
1123
- * import { DateTime, Effect } from "effect"
1124
- *
1125
- * Effect.gen(function* () {
1126
- * // will use the system's local time zone
1127
- * const now = yield* DateTime.nowInCurrentZone
1128
- * }).pipe(DateTime.withCurrentZoneLocal)
1129
- * ```
1130
- */
1131
- export const withCurrentZoneLocal = <A, E, R>(
1132
- effect: Effect.Effect<A, E, R>
1133
- ): Effect.Effect<A, E, Exclude<R, CurrentTimeZone>> =>
1134
- Effect.provideServiceEffect(effect, CurrentTimeZone, Effect.sync(zoneMakeLocal))
1135
-
1136
- /**
1137
- * Provide the `CurrentTimeZone` to an effect, using a offset.
1138
- *
1139
- * @since 3.6.0
1140
- * @category current time zone
1141
- * @example
1142
- * ```ts
1143
- * import { DateTime, Effect } from "effect"
1144
- *
1145
- * Effect.gen(function* () {
1146
- * // will use the system's local time zone
1147
- * const now = yield* DateTime.nowInCurrentZone
1148
- * }).pipe(DateTime.withCurrentZoneOffset(3 * 60 * 60 * 1000))
1149
- * ```
1150
- */
1151
- export const withCurrentZoneOffset: {
1152
- (offset: number): <A, E, R>(
1153
- effect: Effect.Effect<A, E, R>
1154
- ) => Effect.Effect<A, E, Exclude<R, CurrentTimeZone>>
1155
- <A, E, R>(effect: Effect.Effect<A, E, R>, offset: number): Effect.Effect<A, E, Exclude<R, CurrentTimeZone>>
1156
- } = dual(
1157
- 2,
1158
- <A, E, R>(effect: Effect.Effect<A, E, R>, offset: number): Effect.Effect<A, E, Exclude<R, CurrentTimeZone>> =>
1159
- Effect.provideService(effect, CurrentTimeZone, zoneMakeOffset(offset))
1160
- )
1161
-
1162
- /**
1163
- * Provide the `CurrentTimeZone` to an effect using an IANA time zone
1164
- * identifier.
1165
- *
1166
- * If the time zone is invalid, it will fail with an `IllegalArgumentException`.
1167
- *
1168
- * @since 3.6.0
1169
- * @category current time zone
1170
- * @example
1171
- * ```ts
1172
- * import { DateTime, Effect } from "effect"
1173
- *
1174
- * Effect.gen(function* () {
1175
- * // will use the "Europe/London" time zone
1176
- * const now = yield* DateTime.nowInCurrentZone
1177
- * }).pipe(DateTime.withCurrentZoneNamed("Europe/London"))
1178
- * ```
1179
- */
1180
- export const withCurrentZoneNamed: {
1181
- (zone: string): <A, E, R>(
1182
- effect: Effect.Effect<A, E, R>
1183
- ) => Effect.Effect<A, E | IllegalArgumentException, Exclude<R, CurrentTimeZone>>
1184
- <A, E, R>(
1185
- effect: Effect.Effect<A, E, R>,
1186
- zone: string
1187
- ): Effect.Effect<A, E | IllegalArgumentException, Exclude<R, CurrentTimeZone>>
1188
- } = dual(
1189
- 2,
1190
- <A, E, R>(
1191
- effect: Effect.Effect<A, E, R>,
1192
- zone: string
1193
- ): Effect.Effect<A, E | IllegalArgumentException, Exclude<R, CurrentTimeZone>> =>
1194
- Effect.provideServiceEffect(effect, CurrentTimeZone, zoneMakeNamedEffect(zone))
1195
- )
1196
-
1197
- /**
1198
- * Get the current time as a `DateTime.Zoned`, using the `CurrentTimeZone`.
1199
- *
1200
- * @since 3.6.0
1201
- * @category current time zone
1202
- * @example
1203
- * ```ts
1204
- * import { DateTime, Effect } from "effect"
1205
- *
1206
- * Effect.gen(function* () {
1207
- * // will use the "Europe/London" time zone
1208
- * const now = yield* DateTime.nowInCurrentZone
1209
- * }).pipe(DateTime.withCurrentZoneNamed("Europe/London"))
1210
- * ```
1211
- */
1212
- export const nowInCurrentZone: Effect.Effect<Zoned, never, CurrentTimeZone> = Effect.flatMap(now, setZoneCurrent)
1213
-
1214
- // =============================================================================
1215
- // mapping
1216
- // =============================================================================
1217
-
1218
- /**
1219
- * Modify a `DateTime` by applying a function to a cloned `Date` instance.
1220
- *
1221
- * The `Date` will first have the time zone applied if possible, and then be
1222
- * converted back to a `DateTime` within the same time zone.
1223
- *
1224
- * Supports `disambiguation` when the new wall clock time is ambiguous.
1225
- *
1226
- * @since 3.6.0
1227
- * @category mapping
1228
- */
1229
- export const mutate: {
1230
- (
1231
- f: (date: Date) => void,
1232
- options?: {
1233
- readonly disambiguation?: Disambiguation | undefined
1234
- }
1235
- ): <A extends DateTime>(self: A) => A
1236
- <A extends DateTime>(
1237
- self: A,
1238
- f: (date: Date) => void,
1239
- options?: {
1240
- readonly disambiguation?: Disambiguation | undefined
1241
- }
1242
- ): A
1243
- } = Internal.mutate
1244
-
1245
- /**
1246
- * Modify a `DateTime` by applying a function to a cloned UTC `Date` instance.
1247
- *
1248
- * @since 3.6.0
1249
- * @category mapping
1250
- */
1251
- export const mutateUtc: {
1252
- (f: (date: Date) => void): <A extends DateTime>(self: A) => A
1253
- <A extends DateTime>(self: A, f: (date: Date) => void): A
1254
- } = Internal.mutateUtc
1255
-
1256
- /**
1257
- * Transform a `DateTime` by applying a function to the number of milliseconds
1258
- * since the Unix epoch.
1259
- *
1260
- * @since 3.6.0
1261
- * @category mapping
1262
- * @example
1263
- * ```ts
1264
- * import { DateTime } from "effect"
1265
- *
1266
- * // add 10 milliseconds
1267
- * DateTime.unsafeMake(0).pipe(
1268
- * DateTime.mapEpochMillis((millis) => millis + 10)
1269
- * )
1270
- * ```
1271
- */
1272
- export const mapEpochMillis: {
1273
- (f: (millis: number) => number): <A extends DateTime>(self: A) => A
1274
- <A extends DateTime>(self: A, f: (millis: number) => number): A
1275
- } = Internal.mapEpochMillis
1276
-
1277
- /**
1278
- * Using the time zone adjusted `Date`, apply a function to the `Date` and
1279
- * return the result.
1280
- *
1281
- * @since 3.6.0
1282
- * @category mapping
1283
- * @example
1284
- * ```ts
1285
- * import { DateTime } from "effect"
1286
- *
1287
- * // get the time zone adjusted date in milliseconds
1288
- * DateTime.unsafeMakeZoned(0, { timeZone: "Europe/London" }).pipe(
1289
- * DateTime.withDate((date) => date.getTime())
1290
- * )
1291
- * ```
1292
- */
1293
- export const withDate: {
1294
- <A>(f: (date: Date) => A): (self: DateTime) => A
1295
- <A>(self: DateTime, f: (date: Date) => A): A
1296
- } = Internal.withDate
1297
-
1298
- /**
1299
- * Using the time zone adjusted `Date`, apply a function to the `Date` and
1300
- * return the result.
1301
- *
1302
- * @since 3.6.0
1303
- * @category mapping
1304
- * @example
1305
- * ```ts
1306
- * import { DateTime } from "effect"
1307
- *
1308
- * // get the date in milliseconds
1309
- * DateTime.unsafeMake(0).pipe(
1310
- * DateTime.withDateUtc((date) => date.getTime())
1311
- * )
1312
- * ```
1313
- */
1314
- export const withDateUtc: {
1315
- <A>(f: (date: Date) => A): (self: DateTime) => A
1316
- <A>(self: DateTime, f: (date: Date) => A): A
1317
- } = Internal.withDateUtc
1318
-
1319
- /**
1320
- * @since 3.6.0
1321
- * @category mapping
1322
- */
1323
- export const match: {
1324
- <A, B>(options: {
1325
- readonly onUtc: (_: Utc) => A
1326
- readonly onZoned: (_: Zoned) => B
1327
- }): (self: DateTime) => A | B
1328
- <A, B>(self: DateTime, options: {
1329
- readonly onUtc: (_: Utc) => A
1330
- readonly onZoned: (_: Zoned) => B
1331
- }): A | B
1332
- } = Internal.match
1333
-
1334
- // =============================================================================
1335
- // math
1336
- // =============================================================================
1337
-
1338
- /**
1339
- * Add the given `Duration` to a `DateTime`.
1340
- *
1341
- * @since 3.6.0
1342
- * @category math
1343
- * @example
1344
- * ```ts
1345
- * import { DateTime } from "effect"
1346
- *
1347
- * // add 5 minutes
1348
- * DateTime.unsafeMake(0).pipe(
1349
- * DateTime.addDuration("5 minutes")
1350
- * )
1351
- * ```
1352
- */
1353
- export const addDuration: {
1354
- (duration: Duration.DurationInput): <A extends DateTime>(self: A) => A
1355
- <A extends DateTime>(self: A, duration: Duration.DurationInput): A
1356
- } = Internal.addDuration
1357
-
1358
- /**
1359
- * Subtract the given `Duration` from a `DateTime`.
1360
- *
1361
- * @since 3.6.0
1362
- * @category math
1363
- * @example
1364
- * ```ts
1365
- * import { DateTime } from "effect"
1366
- *
1367
- * // subtract 5 minutes
1368
- * DateTime.unsafeMake(0).pipe(
1369
- * DateTime.subtractDuration("5 minutes")
1370
- * )
1371
- * ```
1372
- */
1373
- export const subtractDuration: {
1374
- (duration: Duration.DurationInput): <A extends DateTime>(self: A) => A
1375
- <A extends DateTime>(self: A, duration: Duration.DurationInput): A
1376
- } = Internal.subtractDuration
1377
-
1378
- /**
1379
- * Add the given `amount` of `unit`'s to a `DateTime`.
1380
- *
1381
- * The time zone is taken into account when adding days, weeks, months, and
1382
- * years.
1383
- *
1384
- * @since 3.6.0
1385
- * @category math
1386
- * @example
1387
- * ```ts
1388
- * import { DateTime } from "effect"
1389
- *
1390
- * // add 5 minutes
1391
- * DateTime.unsafeMake(0).pipe(
1392
- * DateTime.add({ minutes: 5 })
1393
- * )
1394
- * ```
1395
- */
1396
- export const add: {
1397
- (parts: Partial<DateTime.PartsForMath>): <A extends DateTime>(self: A) => A
1398
- <A extends DateTime>(self: A, parts: Partial<DateTime.PartsForMath>): A
1399
- } = Internal.add
1400
-
1401
- /**
1402
- * Subtract the given `amount` of `unit`'s from a `DateTime`.
1403
- *
1404
- * @since 3.6.0
1405
- * @category math
1406
- * @example
1407
- * ```ts
1408
- * import { DateTime } from "effect"
1409
- *
1410
- * // subtract 5 minutes
1411
- * DateTime.unsafeMake(0).pipe(
1412
- * DateTime.subtract({ minutes: 5 })
1413
- * )
1414
- * ```
1415
- */
1416
- export const subtract: {
1417
- (parts: Partial<DateTime.PartsForMath>): <A extends DateTime>(self: A) => A
1418
- <A extends DateTime>(self: A, parts: Partial<DateTime.PartsForMath>): A
1419
- } = Internal.subtract
1420
-
1421
- /**
1422
- * Converts a `DateTime` to the start of the given `part`.
1423
- *
1424
- * If the part is `week`, the `weekStartsOn` option can be used to specify the
1425
- * day of the week that the week starts on. The default is 0 (Sunday).
1426
- *
1427
- * @since 3.6.0
1428
- * @category math
1429
- * @example
1430
- * ```ts
1431
- * import { DateTime } from "effect"
1432
- *
1433
- * // returns "2024-01-01T00:00:00Z"
1434
- * DateTime.unsafeMake("2024-01-01T12:00:00Z").pipe(
1435
- * DateTime.startOf("day"),
1436
- * DateTime.formatIso
1437
- * )
1438
- * ```
1439
- */
1440
- export const startOf: {
1441
- (
1442
- part: DateTime.UnitSingular,
1443
- options?: { readonly weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined }
1444
- ): <A extends DateTime>(self: A) => A
1445
- <A extends DateTime>(
1446
- self: A,
1447
- part: DateTime.UnitSingular,
1448
- options?: { readonly weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined }
1449
- ): A
1450
- } = Internal.startOf
1451
-
1452
- /**
1453
- * Converts a `DateTime` to the end of the given `part`.
1454
- *
1455
- * If the part is `week`, the `weekStartsOn` option can be used to specify the
1456
- * day of the week that the week starts on. The default is 0 (Sunday).
1457
- *
1458
- * @since 3.6.0
1459
- * @category math
1460
- * @example
1461
- * ```ts
1462
- * import { DateTime } from "effect"
1463
- *
1464
- * // returns "2024-01-01T23:59:59.999Z"
1465
- * DateTime.unsafeMake("2024-01-01T12:00:00Z").pipe(
1466
- * DateTime.endOf("day"),
1467
- * DateTime.formatIso
1468
- * )
1469
- * ```
1470
- */
1471
- export const endOf: {
1472
- (
1473
- part: DateTime.UnitSingular,
1474
- options?: { readonly weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined }
1475
- ): <A extends DateTime>(self: A) => A
1476
- <A extends DateTime>(
1477
- self: A,
1478
- part: DateTime.UnitSingular,
1479
- options?: { readonly weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined }
1480
- ): A
1481
- } = Internal.endOf
1482
-
1483
- /**
1484
- * Converts a `DateTime` to the nearest given `part`.
1485
- *
1486
- * If the part is `week`, the `weekStartsOn` option can be used to specify the
1487
- * day of the week that the week starts on. The default is 0 (Sunday).
1488
- *
1489
- * @since 3.6.0
1490
- * @category math
1491
- * @example
1492
- * ```ts
1493
- * import { DateTime } from "effect"
1494
- *
1495
- * // returns "2024-01-02T00:00:00Z"
1496
- * DateTime.unsafeMake("2024-01-01T12:01:00Z").pipe(
1497
- * DateTime.nearest("day"),
1498
- * DateTime.formatIso
1499
- * )
1500
- * ```
1501
- */
1502
- export const nearest: {
1503
- (
1504
- part: DateTime.UnitSingular,
1505
- options?: { readonly weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined }
1506
- ): <A extends DateTime>(self: A) => A
1507
- <A extends DateTime>(
1508
- self: A,
1509
- part: DateTime.UnitSingular,
1510
- options?: { readonly weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined }
1511
- ): A
1512
- } = Internal.nearest
1513
-
1514
- // =============================================================================
1515
- // formatting
1516
- // =============================================================================
1517
-
1518
- /**
1519
- * Format a `DateTime` as a string using the `DateTimeFormat` API.
1520
- *
1521
- * The `timeZone` option is set to the offset of the time zone.
1522
- *
1523
- * Note: On Node versions < 22, fixed "Offset" zones will set the time zone to
1524
- * "UTC" and use the adjusted `Date`.
1525
- *
1526
- * @since 3.6.0
1527
- * @category formatting
1528
- */
1529
- export const format: {
1530
- (
1531
- options?:
1532
- | Intl.DateTimeFormatOptions & {
1533
- readonly locale?: Intl.LocalesArgument
1534
- }
1535
- | undefined
1536
- ): (self: DateTime) => string
1537
- (
1538
- self: DateTime,
1539
- options?:
1540
- | Intl.DateTimeFormatOptions & {
1541
- readonly locale?: Intl.LocalesArgument
1542
- }
1543
- | undefined
1544
- ): string
1545
- } = Internal.format
1546
-
1547
- /**
1548
- * Format a `DateTime` as a string using the `DateTimeFormat` API.
1549
- *
1550
- * It will use the system's local time zone & locale.
1551
- *
1552
- * @since 3.6.0
1553
- * @category formatting
1554
- */
1555
- export const formatLocal: {
1556
- (
1557
- options?:
1558
- | Intl.DateTimeFormatOptions & {
1559
- readonly locale?: Intl.LocalesArgument
1560
- }
1561
- | undefined
1562
- ): (self: DateTime) => string
1563
- (
1564
- self: DateTime,
1565
- options?:
1566
- | Intl.DateTimeFormatOptions & {
1567
- readonly locale?: Intl.LocalesArgument
1568
- }
1569
- | undefined
1570
- ): string
1571
- } = Internal.formatLocal
1572
-
1573
- /**
1574
- * Format a `DateTime` as a string using the `DateTimeFormat` API.
1575
- *
1576
- * This forces the time zone to be UTC.
1577
- *
1578
- * @since 3.6.0
1579
- * @category formatting
1580
- */
1581
- export const formatUtc: {
1582
- (
1583
- options?:
1584
- | Intl.DateTimeFormatOptions & {
1585
- readonly locale?: Intl.LocalesArgument
1586
- }
1587
- | undefined
1588
- ): (self: DateTime) => string
1589
- (
1590
- self: DateTime,
1591
- options?:
1592
- | Intl.DateTimeFormatOptions & {
1593
- readonly locale?: Intl.LocalesArgument
1594
- }
1595
- | undefined
1596
- ): string
1597
- } = Internal.formatUtc
1598
-
1599
- /**
1600
- * Format a `DateTime` as a string using the `DateTimeFormat` API.
1601
- *
1602
- * @since 3.6.0
1603
- * @category formatting
1604
- */
1605
- export const formatIntl: {
1606
- (format: Intl.DateTimeFormat): (self: DateTime) => string
1607
- (self: DateTime, format: Intl.DateTimeFormat): string
1608
- } = Internal.formatIntl
1609
-
1610
- /**
1611
- * Format a `DateTime` as a UTC ISO string.
1612
- *
1613
- * @since 3.6.0
1614
- * @category formatting
1615
- */
1616
- export const formatIso: (self: DateTime) => string = Internal.formatIso
1617
-
1618
- /**
1619
- * Format a `DateTime` as a time zone adjusted ISO date string.
1620
- *
1621
- * @since 3.6.0
1622
- * @category formatting
1623
- */
1624
- export const formatIsoDate: (self: DateTime) => string = Internal.formatIsoDate
1625
-
1626
- /**
1627
- * Format a `DateTime` as a UTC ISO date string.
1628
- *
1629
- * @since 3.6.0
1630
- * @category formatting
1631
- */
1632
- export const formatIsoDateUtc: (self: DateTime) => string = Internal.formatIsoDateUtc
1633
-
1634
- /**
1635
- * Format a `DateTime.Zoned` as a ISO string with an offset.
1636
- *
1637
- * @since 3.6.0
1638
- * @category formatting
1639
- */
1640
- export const formatIsoOffset: (self: DateTime) => string = Internal.formatIsoOffset
1641
-
1642
- /**
1643
- * Format a `DateTime.Zoned` as a string.
1644
- *
1645
- * It uses the format: `YYYY-MM-DDTHH:mm:ss.sss+HH:MM[Time/Zone]`.
1646
- *
1647
- * @since 3.6.0
1648
- * @category formatting
1649
- */
1650
- export const formatIsoZoned: (self: Zoned) => string = Internal.formatIsoZoned
1651
-
1652
- /**
1653
- * Create a Layer from the given time zone.
1654
- *
1655
- * @since 3.6.0
1656
- * @category current time zone
1657
- */
1658
- export const layerCurrentZone = (zone: TimeZone): Layer.Layer<CurrentTimeZone> => Layer.succeed(CurrentTimeZone, zone)
1659
-
1660
- /**
1661
- * Create a Layer from the given time zone offset.
1662
- *
1663
- * @since 3.6.0
1664
- * @category current time zone
1665
- */
1666
- export const layerCurrentZoneOffset = (offset: number): Layer.Layer<CurrentTimeZone> =>
1667
- Layer.succeed(CurrentTimeZone, Internal.zoneMakeOffset(offset))
1668
-
1669
- /**
1670
- * Create a Layer from the given IANA time zone identifier.
1671
- *
1672
- * @since 3.6.0
1673
- * @category current time zone
1674
- */
1675
- export const layerCurrentZoneNamed = (
1676
- zoneId: string
1677
- ): Layer.Layer<CurrentTimeZone, IllegalArgumentException> =>
1678
- Layer.effect(CurrentTimeZone, Internal.zoneMakeNamedEffect(zoneId))
1679
-
1680
- /**
1681
- * Create a Layer from the systems local time zone.
1682
- *
1683
- * @since 3.6.0
1684
- * @category current time zone
1685
- */
1686
- export const layerCurrentZoneLocal: Layer.Layer<CurrentTimeZone> = Layer.sync(CurrentTimeZone, zoneMakeLocal)