@attocash/cli 0.1.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 (400) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +707 -0
  3. package/dist/application/app.d.ts +138 -0
  4. package/dist/application/app.js +654 -0
  5. package/dist/application/operations.d.ts +9 -0
  6. package/dist/application/operations.js +96 -0
  7. package/dist/cli/cli.d.ts +1 -0
  8. package/dist/cli/cli.js +460 -0
  9. package/dist/cli/help.d.ts +4 -0
  10. package/dist/cli/help.js +49 -0
  11. package/dist/cli/main.d.ts +2 -0
  12. package/dist/cli/main.js +13 -0
  13. package/dist/cli/onboarding.d.ts +14 -0
  14. package/dist/cli/onboarding.js +144 -0
  15. package/dist/cli/output.d.ts +2 -0
  16. package/dist/cli/output.js +231 -0
  17. package/dist/cli/terminal.d.ts +6 -0
  18. package/dist/cli/terminal.js +92 -0
  19. package/dist/cli/update-check.d.ts +1 -0
  20. package/dist/cli/update-check.js +12 -0
  21. package/dist/cli/updates.d.ts +2 -0
  22. package/dist/cli/updates.js +98 -0
  23. package/dist/core.d.ts +14 -0
  24. package/dist/core.js +14 -0
  25. package/dist/doctor/credential-probe.d.ts +7 -0
  26. package/dist/doctor/credential-probe.js +49 -0
  27. package/dist/doctor/doctor.d.ts +4 -0
  28. package/dist/doctor/doctor.js +213 -0
  29. package/dist/doctor/keyring.d.ts +7 -0
  30. package/dist/doctor/keyring.js +150 -0
  31. package/dist/doctor/profile.d.ts +19 -0
  32. package/dist/doctor/profile.js +73 -0
  33. package/dist/doctor/types.d.ts +40 -0
  34. package/dist/doctor/types.js +1 -0
  35. package/dist/domain/amount.d.ts +6 -0
  36. package/dist/domain/amount.js +27 -0
  37. package/dist/domain/errors.d.ts +10 -0
  38. package/dist/domain/errors.js +16 -0
  39. package/dist/labels/directory.d.ts +87 -0
  40. package/dist/labels/directory.js +140 -0
  41. package/dist/labels/personal.d.ts +17 -0
  42. package/dist/labels/personal.js +56 -0
  43. package/dist/labels/presentation.d.ts +154 -0
  44. package/dist/labels/presentation.js +90 -0
  45. package/dist/network/reader.d.ts +31 -0
  46. package/dist/network/reader.js +370 -0
  47. package/dist/network/retry.d.ts +7 -0
  48. package/dist/network/retry.js +53 -0
  49. package/dist/network/work.d.ts +3 -0
  50. package/dist/network/work.js +66 -0
  51. package/dist/pricing/market.d.ts +29 -0
  52. package/dist/pricing/market.js +150 -0
  53. package/dist/pricing/terms.d.ts +6 -0
  54. package/dist/pricing/terms.js +12 -0
  55. package/dist/spending/destination.d.ts +16 -0
  56. package/dist/spending/destination.js +42 -0
  57. package/dist/spending/journal.d.ts +28 -0
  58. package/dist/spending/journal.js +69 -0
  59. package/dist/spending/ledger.d.ts +118 -0
  60. package/dist/spending/ledger.js +444 -0
  61. package/dist/spending/payments.d.ts +67 -0
  62. package/dist/spending/payments.js +424 -0
  63. package/dist/spending/pool.d.ts +13 -0
  64. package/dist/spending/pool.js +38 -0
  65. package/dist/spending/reconcile.d.ts +18 -0
  66. package/dist/spending/reconcile.js +64 -0
  67. package/dist/storage/profiles.d.ts +13 -0
  68. package/dist/storage/profiles.js +86 -0
  69. package/dist/storage/secrets.d.ts +16 -0
  70. package/dist/storage/secrets.js +104 -0
  71. package/dist/storage/state.d.ts +32 -0
  72. package/dist/storage/state.js +255 -0
  73. package/dist/wallet/auto-receive.d.ts +57 -0
  74. package/dist/wallet/auto-receive.js +140 -0
  75. package/dist/wallet/defaults.d.ts +3 -0
  76. package/dist/wallet/defaults.js +26 -0
  77. package/dist/wallet/signing.d.ts +17 -0
  78. package/dist/wallet/signing.js +128 -0
  79. package/dist/wallet/types.d.ts +65 -0
  80. package/dist/wallet/types.js +1 -0
  81. package/dist/wallet/work.d.ts +29 -0
  82. package/dist/wallet/work.js +154 -0
  83. package/dist/watches/manager.d.ts +75 -0
  84. package/dist/watches/manager.js +197 -0
  85. package/node_modules/@attocash/commons-core/Kotlin-DateTime-library-kotlinx-datetime.mjs +6678 -0
  86. package/node_modules/@attocash/commons-core/Kotlin-DateTime-library-kotlinx-datetime.mjs.map +1 -0
  87. package/node_modules/@attocash/commons-core/LICENSE +28 -0
  88. package/node_modules/@attocash/commons-core/README.md +118 -0
  89. package/node_modules/@attocash/commons-core/commons-commons-core.d.mts +1036 -0
  90. package/node_modules/@attocash/commons-core/commons-commons-core.mjs +7701 -0
  91. package/node_modules/@attocash/commons-core/commons-commons-core.mjs.map +1 -0
  92. package/node_modules/@attocash/commons-core/kotlin-kotlin-stdlib.mjs +17681 -0
  93. package/node_modules/@attocash/commons-core/kotlin-kotlin-stdlib.mjs.map +1 -0
  94. package/node_modules/@attocash/commons-core/kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.mjs +4 -0
  95. package/node_modules/@attocash/commons-core/kotlin_org_jetbrains_kotlin_kotlin_dom_api_compat.mjs.map +1 -0
  96. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-bytestring.mjs +209 -0
  97. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-bytestring.mjs.map +1 -0
  98. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-core.mjs +2284 -0
  99. package/node_modules/@attocash/commons-core/kotlinx-io-kotlinx-io-core.mjs.map +1 -0
  100. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-core.mjs +6042 -0
  101. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-core.mjs.map +1 -0
  102. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  103. package/node_modules/@attocash/commons-core/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  104. package/node_modules/@attocash/commons-core/package.json +27 -0
  105. package/node_modules/@attocash/commons-node/LICENSE +28 -0
  106. package/node_modules/@attocash/commons-node/README.md +92 -0
  107. package/node_modules/@attocash/commons-node/commons-commons-node.d.mts +255 -0
  108. package/node_modules/@attocash/commons-node/commons-commons-node.mjs +2977 -0
  109. package/node_modules/@attocash/commons-node/commons-commons-node.mjs.map +1 -0
  110. package/node_modules/@attocash/commons-node/kotlin-logging.mjs +432 -0
  111. package/node_modules/@attocash/commons-node/kotlin-logging.mjs.map +1 -0
  112. package/node_modules/@attocash/commons-node/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  113. package/node_modules/@attocash/commons-node/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  114. package/node_modules/@attocash/commons-node/package.json +29 -0
  115. package/node_modules/@attocash/commons-node-remote/LICENSE +28 -0
  116. package/node_modules/@attocash/commons-node-remote/README.md +61 -0
  117. package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.d.mts +122 -0
  118. package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.mjs +1810 -0
  119. package/node_modules/@attocash/commons-node-remote/commons-commons-node-remote.mjs.map +1 -0
  120. package/node_modules/@attocash/commons-node-remote/kotlin-logging.mjs +432 -0
  121. package/node_modules/@attocash/commons-node-remote/kotlin-logging.mjs.map +1 -0
  122. package/node_modules/@attocash/commons-node-remote/kotlinx-browser.mjs +8 -0
  123. package/node_modules/@attocash/commons-node-remote/kotlinx-browser.mjs.map +1 -0
  124. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs +4 -0
  125. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -0
  126. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  127. package/node_modules/@attocash/commons-node-remote/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  128. package/node_modules/@attocash/commons-node-remote/package.json +31 -0
  129. package/node_modules/@attocash/commons-transport/LICENSE +28 -0
  130. package/node_modules/@attocash/commons-transport/README.md +5 -0
  131. package/node_modules/@attocash/commons-transport/commons-commons-transport.d.mts +64 -0
  132. package/node_modules/@attocash/commons-transport/commons-commons-transport.mjs +249 -0
  133. package/node_modules/@attocash/commons-transport/commons-commons-transport.mjs.map +1 -0
  134. package/node_modules/@attocash/commons-transport/kotlinx-atomicfu.mjs +263 -0
  135. package/node_modules/@attocash/commons-transport/kotlinx-atomicfu.mjs.map +1 -0
  136. package/node_modules/@attocash/commons-transport/kotlinx-browser.mjs +8 -0
  137. package/node_modules/@attocash/commons-transport/kotlinx-browser.mjs.map +1 -0
  138. package/node_modules/@attocash/commons-transport/kotlinx-coroutines-core.mjs +11604 -0
  139. package/node_modules/@attocash/commons-transport/kotlinx-coroutines-core.mjs.map +1 -0
  140. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json-io.mjs +4 -0
  141. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -0
  142. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  143. package/node_modules/@attocash/commons-transport/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  144. package/node_modules/@attocash/commons-transport/ktor-ktor-client-content-negotiation.mjs +499 -0
  145. package/node_modules/@attocash/commons-transport/ktor-ktor-client-content-negotiation.mjs.map +1 -0
  146. package/node_modules/@attocash/commons-transport/ktor-ktor-client-core.mjs +6456 -0
  147. package/node_modules/@attocash/commons-transport/ktor-ktor-client-core.mjs.map +1 -0
  148. package/node_modules/@attocash/commons-transport/ktor-ktor-events.mjs +83 -0
  149. package/node_modules/@attocash/commons-transport/ktor-ktor-events.mjs.map +1 -0
  150. package/node_modules/@attocash/commons-transport/ktor-ktor-http-cio.mjs +1714 -0
  151. package/node_modules/@attocash/commons-transport/ktor-ktor-http-cio.mjs.map +1 -0
  152. package/node_modules/@attocash/commons-transport/ktor-ktor-http.mjs +3197 -0
  153. package/node_modules/@attocash/commons-transport/ktor-ktor-http.mjs.map +1 -0
  154. package/node_modules/@attocash/commons-transport/ktor-ktor-io.mjs +2290 -0
  155. package/node_modules/@attocash/commons-transport/ktor-ktor-io.mjs.map +1 -0
  156. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx-json.mjs +46 -0
  157. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx-json.mjs.map +1 -0
  158. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx.mjs +482 -0
  159. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization-kotlinx.mjs.map +1 -0
  160. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization.mjs +165 -0
  161. package/node_modules/@attocash/commons-transport/ktor-ktor-serialization.mjs.map +1 -0
  162. package/node_modules/@attocash/commons-transport/ktor-ktor-sse.mjs +4 -0
  163. package/node_modules/@attocash/commons-transport/ktor-ktor-sse.mjs.map +1 -0
  164. package/node_modules/@attocash/commons-transport/ktor-ktor-utils.mjs +3222 -0
  165. package/node_modules/@attocash/commons-transport/ktor-ktor-utils.mjs.map +1 -0
  166. package/node_modules/@attocash/commons-transport/ktor-ktor-websocket-serialization.mjs +4 -0
  167. package/node_modules/@attocash/commons-transport/ktor-ktor-websocket-serialization.mjs.map +1 -0
  168. package/node_modules/@attocash/commons-transport/ktor-ktor-websockets.mjs +1485 -0
  169. package/node_modules/@attocash/commons-transport/ktor-ktor-websockets.mjs.map +1 -0
  170. package/node_modules/@attocash/commons-transport/package.json +29 -0
  171. package/node_modules/@attocash/commons-worker/LICENSE +28 -0
  172. package/node_modules/@attocash/commons-worker/README.md +48 -0
  173. package/node_modules/@attocash/commons-worker/commons-commons-worker.d.mts +73 -0
  174. package/node_modules/@attocash/commons-worker/commons-commons-worker.mjs +702 -0
  175. package/node_modules/@attocash/commons-worker/commons-commons-worker.mjs.map +1 -0
  176. package/node_modules/@attocash/commons-worker/kotlin-logging.mjs +432 -0
  177. package/node_modules/@attocash/commons-worker/kotlin-logging.mjs.map +1 -0
  178. package/node_modules/@attocash/commons-worker/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  179. package/node_modules/@attocash/commons-worker/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  180. package/node_modules/@attocash/commons-worker/package.json +29 -0
  181. package/node_modules/@attocash/commons-worker-remote/LICENSE +28 -0
  182. package/node_modules/@attocash/commons-worker-remote/README.md +60 -0
  183. package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.d.mts +93 -0
  184. package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.mjs +289 -0
  185. package/node_modules/@attocash/commons-worker-remote/commons-commons-worker-remote.mjs.map +1 -0
  186. package/node_modules/@attocash/commons-worker-remote/kotlin-logging.mjs +432 -0
  187. package/node_modules/@attocash/commons-worker-remote/kotlin-logging.mjs.map +1 -0
  188. package/node_modules/@attocash/commons-worker-remote/kotlinx-browser.mjs +8 -0
  189. package/node_modules/@attocash/commons-worker-remote/kotlinx-browser.mjs.map +1 -0
  190. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs +4 -0
  191. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json-io.mjs.map +1 -0
  192. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json.mjs +5294 -0
  193. package/node_modules/@attocash/commons-worker-remote/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -0
  194. package/node_modules/@attocash/commons-worker-remote/package.json +31 -0
  195. package/node_modules/@js-joda/core/CHANGELOG.md +363 -0
  196. package/node_modules/@js-joda/core/CheatSheet.md +947 -0
  197. package/node_modules/@js-joda/core/LICENSE +34 -0
  198. package/node_modules/@js-joda/core/README.md +155 -0
  199. package/node_modules/@js-joda/core/bower.json +21 -0
  200. package/node_modules/@js-joda/core/dist/js-joda.d.ts +2452 -0
  201. package/node_modules/@js-joda/core/dist/js-joda.esm.js +13564 -0
  202. package/node_modules/@js-joda/core/dist/js-joda.flow.js +949 -0
  203. package/node_modules/@js-joda/core/dist/js-joda.js +13630 -0
  204. package/node_modules/@js-joda/core/dist/js-joda.js.map +1 -0
  205. package/node_modules/@js-joda/core/dist/js-joda.min.js +5 -0
  206. package/node_modules/@js-joda/core/package.json +76 -0
  207. package/node_modules/@js-joda/core/src/Clock.js +330 -0
  208. package/node_modules/@js-joda/core/src/DayOfWeek.js +451 -0
  209. package/node_modules/@js-joda/core/src/Duration.js +1205 -0
  210. package/node_modules/@js-joda/core/src/Enum.js +30 -0
  211. package/node_modules/@js-joda/core/src/Instant.js +1012 -0
  212. package/node_modules/@js-joda/core/src/LocalDate.js +1703 -0
  213. package/node_modules/@js-joda/core/src/LocalDateTime.js +1686 -0
  214. package/node_modules/@js-joda/core/src/LocalTime.js +1415 -0
  215. package/node_modules/@js-joda/core/src/MathUtil.js +236 -0
  216. package/node_modules/@js-joda/core/src/Month.js +600 -0
  217. package/node_modules/@js-joda/core/src/MonthDay.js +730 -0
  218. package/node_modules/@js-joda/core/src/OffsetDateTime.js +757 -0
  219. package/node_modules/@js-joda/core/src/OffsetTime.js +621 -0
  220. package/node_modules/@js-joda/core/src/Period.js +933 -0
  221. package/node_modules/@js-joda/core/src/StringUtil.js +43 -0
  222. package/node_modules/@js-joda/core/src/Year.js +1015 -0
  223. package/node_modules/@js-joda/core/src/YearConstants.js +21 -0
  224. package/node_modules/@js-joda/core/src/YearMonth.js +1096 -0
  225. package/node_modules/@js-joda/core/src/ZoneId.js +236 -0
  226. package/node_modules/@js-joda/core/src/ZoneIdFactory.js +201 -0
  227. package/node_modules/@js-joda/core/src/ZoneOffset.js +486 -0
  228. package/node_modules/@js-joda/core/src/ZoneRegion.js +72 -0
  229. package/node_modules/@js-joda/core/src/ZonedDateTime.js +2007 -0
  230. package/node_modules/@js-joda/core/src/_init.js +68 -0
  231. package/node_modules/@js-joda/core/src/assert.js +33 -0
  232. package/node_modules/@js-joda/core/src/chrono/ChronoLocalDate.js +230 -0
  233. package/node_modules/@js-joda/core/src/chrono/ChronoLocalDateTime.js +130 -0
  234. package/node_modules/@js-joda/core/src/chrono/ChronoZonedDateTime.js +194 -0
  235. package/node_modules/@js-joda/core/src/chrono/IsoChronology.js +235 -0
  236. package/node_modules/@js-joda/core/src/convert.js +83 -0
  237. package/node_modules/@js-joda/core/src/errors.js +54 -0
  238. package/node_modules/@js-joda/core/src/format/DateTimeBuilder.js +535 -0
  239. package/node_modules/@js-joda/core/src/format/DateTimeFormatter.js +728 -0
  240. package/node_modules/@js-joda/core/src/format/DateTimeFormatterBuilder.js +1545 -0
  241. package/node_modules/@js-joda/core/src/format/DateTimeParseContext.js +297 -0
  242. package/node_modules/@js-joda/core/src/format/DateTimePrintContext.js +138 -0
  243. package/node_modules/@js-joda/core/src/format/DecimalStyle.js +113 -0
  244. package/node_modules/@js-joda/core/src/format/EnumMap.js +70 -0
  245. package/node_modules/@js-joda/core/src/format/ParsePosition.js +31 -0
  246. package/node_modules/@js-joda/core/src/format/ResolverStyle.js +93 -0
  247. package/node_modules/@js-joda/core/src/format/SignStyle.js +38 -0
  248. package/node_modules/@js-joda/core/src/format/StringBuilder.js +47 -0
  249. package/node_modules/@js-joda/core/src/format/TextStyle.js +114 -0
  250. package/node_modules/@js-joda/core/src/format/parser/CharLiteralPrinterParser.js +46 -0
  251. package/node_modules/@js-joda/core/src/format/parser/CompositePrinterParser.js +89 -0
  252. package/node_modules/@js-joda/core/src/format/parser/FractionPrinterParser.js +162 -0
  253. package/node_modules/@js-joda/core/src/format/parser/NumberPrinterParser.js +367 -0
  254. package/node_modules/@js-joda/core/src/format/parser/OffsetIdPrinterParser.js +177 -0
  255. package/node_modules/@js-joda/core/src/format/parser/PadPrinterParserDecorator.js +81 -0
  256. package/node_modules/@js-joda/core/src/format/parser/SettingsParser.js +44 -0
  257. package/node_modules/@js-joda/core/src/format/parser/StringLiteralPrinterParser.js +39 -0
  258. package/node_modules/@js-joda/core/src/format/parser/ZoneIdPrinterParser.js +218 -0
  259. package/node_modules/@js-joda/core/src/js-joda.js +210 -0
  260. package/node_modules/@js-joda/core/src/license-preamble.js +3 -0
  261. package/node_modules/@js-joda/core/src/temporal/ChronoField.js +470 -0
  262. package/node_modules/@js-joda/core/src/temporal/ChronoUnit.js +310 -0
  263. package/node_modules/@js-joda/core/src/temporal/DefaultInterfaceTemporal.js +118 -0
  264. package/node_modules/@js-joda/core/src/temporal/IsoFields.js +859 -0
  265. package/node_modules/@js-joda/core/src/temporal/NativeJsTemporal.js +105 -0
  266. package/node_modules/@js-joda/core/src/temporal/Temporal.js +346 -0
  267. package/node_modules/@js-joda/core/src/temporal/TemporalAccessor.js +125 -0
  268. package/node_modules/@js-joda/core/src/temporal/TemporalAdjuster.js +92 -0
  269. package/node_modules/@js-joda/core/src/temporal/TemporalAdjusters.js +464 -0
  270. package/node_modules/@js-joda/core/src/temporal/TemporalAmount.js +166 -0
  271. package/node_modules/@js-joda/core/src/temporal/TemporalField.js +248 -0
  272. package/node_modules/@js-joda/core/src/temporal/TemporalQueries.js +223 -0
  273. package/node_modules/@js-joda/core/src/temporal/TemporalQueriesFactory.js +77 -0
  274. package/node_modules/@js-joda/core/src/temporal/TemporalQuery.js +107 -0
  275. package/node_modules/@js-joda/core/src/temporal/TemporalUnit.js +179 -0
  276. package/node_modules/@js-joda/core/src/temporal/ValueRange.js +257 -0
  277. package/node_modules/@js-joda/core/src/use.js +20 -0
  278. package/node_modules/@js-joda/core/src/zone/SystemDefaultZoneId.js +31 -0
  279. package/node_modules/@js-joda/core/src/zone/SystemDefaultZoneRules.js +162 -0
  280. package/node_modules/@js-joda/core/src/zone/ZoneOffsetTransition.js +289 -0
  281. package/node_modules/@js-joda/core/src/zone/ZoneRules.js +464 -0
  282. package/node_modules/@js-joda/core/src/zone/ZoneRulesProvider.js +36 -0
  283. package/node_modules/@noble/hashes/LICENSE +21 -0
  284. package/node_modules/@noble/hashes/README.md +563 -0
  285. package/node_modules/@noble/hashes/_blake.d.ts +21 -0
  286. package/node_modules/@noble/hashes/_blake.d.ts.map +1 -0
  287. package/node_modules/@noble/hashes/_blake.js +52 -0
  288. package/node_modules/@noble/hashes/_blake.js.map +1 -0
  289. package/node_modules/@noble/hashes/_md.d.ts +99 -0
  290. package/node_modules/@noble/hashes/_md.d.ts.map +1 -0
  291. package/node_modules/@noble/hashes/_md.js +202 -0
  292. package/node_modules/@noble/hashes/_md.js.map +1 -0
  293. package/node_modules/@noble/hashes/_u64.d.ts +63 -0
  294. package/node_modules/@noble/hashes/_u64.d.ts.map +1 -0
  295. package/node_modules/@noble/hashes/_u64.js +84 -0
  296. package/node_modules/@noble/hashes/_u64.js.map +1 -0
  297. package/node_modules/@noble/hashes/argon2.d.ts +112 -0
  298. package/node_modules/@noble/hashes/argon2.d.ts.map +1 -0
  299. package/node_modules/@noble/hashes/argon2.js +517 -0
  300. package/node_modules/@noble/hashes/argon2.js.map +1 -0
  301. package/node_modules/@noble/hashes/blake1.d.ts +156 -0
  302. package/node_modules/@noble/hashes/blake1.d.ts.map +1 -0
  303. package/node_modules/@noble/hashes/blake1.js +560 -0
  304. package/node_modules/@noble/hashes/blake1.js.map +1 -0
  305. package/node_modules/@noble/hashes/blake2.d.ts +184 -0
  306. package/node_modules/@noble/hashes/blake2.d.ts.map +1 -0
  307. package/node_modules/@noble/hashes/blake2.js +501 -0
  308. package/node_modules/@noble/hashes/blake2.js.map +1 -0
  309. package/node_modules/@noble/hashes/blake3.d.ts +68 -0
  310. package/node_modules/@noble/hashes/blake3.d.ts.map +1 -0
  311. package/node_modules/@noble/hashes/blake3.js +284 -0
  312. package/node_modules/@noble/hashes/blake3.js.map +1 -0
  313. package/node_modules/@noble/hashes/eskdf.d.ts +92 -0
  314. package/node_modules/@noble/hashes/eskdf.d.ts.map +1 -0
  315. package/node_modules/@noble/hashes/eskdf.js +218 -0
  316. package/node_modules/@noble/hashes/eskdf.js.map +1 -0
  317. package/node_modules/@noble/hashes/hkdf.d.ts +64 -0
  318. package/node_modules/@noble/hashes/hkdf.d.ts.map +1 -0
  319. package/node_modules/@noble/hashes/hkdf.js +120 -0
  320. package/node_modules/@noble/hashes/hkdf.js.map +1 -0
  321. package/node_modules/@noble/hashes/hmac.d.ts +47 -0
  322. package/node_modules/@noble/hashes/hmac.d.ts.map +1 -0
  323. package/node_modules/@noble/hashes/hmac.js +93 -0
  324. package/node_modules/@noble/hashes/hmac.js.map +1 -0
  325. package/node_modules/@noble/hashes/index.d.ts +2 -0
  326. package/node_modules/@noble/hashes/index.d.ts.map +1 -0
  327. package/node_modules/@noble/hashes/index.js +35 -0
  328. package/node_modules/@noble/hashes/index.js.map +1 -0
  329. package/node_modules/@noble/hashes/legacy.d.ts +102 -0
  330. package/node_modules/@noble/hashes/legacy.d.ts.map +1 -0
  331. package/node_modules/@noble/hashes/legacy.js +327 -0
  332. package/node_modules/@noble/hashes/legacy.js.map +1 -0
  333. package/node_modules/@noble/hashes/package.json +97 -0
  334. package/node_modules/@noble/hashes/pbkdf2.d.ts +56 -0
  335. package/node_modules/@noble/hashes/pbkdf2.d.ts.map +1 -0
  336. package/node_modules/@noble/hashes/pbkdf2.js +135 -0
  337. package/node_modules/@noble/hashes/pbkdf2.js.map +1 -0
  338. package/node_modules/@noble/hashes/scrypt.d.ts +65 -0
  339. package/node_modules/@noble/hashes/scrypt.d.ts.map +1 -0
  340. package/node_modules/@noble/hashes/scrypt.js +257 -0
  341. package/node_modules/@noble/hashes/scrypt.js.map +1 -0
  342. package/node_modules/@noble/hashes/sha2.d.ts +249 -0
  343. package/node_modules/@noble/hashes/sha2.d.ts.map +1 -0
  344. package/node_modules/@noble/hashes/sha2.js +458 -0
  345. package/node_modules/@noble/hashes/sha2.js.map +1 -0
  346. package/node_modules/@noble/hashes/sha3-addons.d.ts +461 -0
  347. package/node_modules/@noble/hashes/sha3-addons.d.ts.map +1 -0
  348. package/node_modules/@noble/hashes/sha3-addons.js +783 -0
  349. package/node_modules/@noble/hashes/sha3-addons.js.map +1 -0
  350. package/node_modules/@noble/hashes/sha3.d.ts +199 -0
  351. package/node_modules/@noble/hashes/sha3.d.ts.map +1 -0
  352. package/node_modules/@noble/hashes/sha3.js +431 -0
  353. package/node_modules/@noble/hashes/sha3.js.map +1 -0
  354. package/node_modules/@noble/hashes/src/_blake.ts +57 -0
  355. package/node_modules/@noble/hashes/src/_md.ts +222 -0
  356. package/node_modules/@noble/hashes/src/_u64.ts +117 -0
  357. package/node_modules/@noble/hashes/src/argon2.ts +667 -0
  358. package/node_modules/@noble/hashes/src/blake1.ts +614 -0
  359. package/node_modules/@noble/hashes/src/blake2.ts +582 -0
  360. package/node_modules/@noble/hashes/src/blake3.ts +317 -0
  361. package/node_modules/@noble/hashes/src/eskdf.ts +259 -0
  362. package/node_modules/@noble/hashes/src/hkdf.ts +133 -0
  363. package/node_modules/@noble/hashes/src/hmac.ts +126 -0
  364. package/node_modules/@noble/hashes/src/index.ts +33 -0
  365. package/node_modules/@noble/hashes/src/legacy.ts +339 -0
  366. package/node_modules/@noble/hashes/src/pbkdf2.ts +175 -0
  367. package/node_modules/@noble/hashes/src/scrypt.ts +315 -0
  368. package/node_modules/@noble/hashes/src/sha2.ts +530 -0
  369. package/node_modules/@noble/hashes/src/sha3-addons.ts +983 -0
  370. package/node_modules/@noble/hashes/src/sha3.ts +485 -0
  371. package/node_modules/@noble/hashes/src/utils.ts +848 -0
  372. package/node_modules/@noble/hashes/src/webcrypto.ts +239 -0
  373. package/node_modules/@noble/hashes/utils.d.ts +519 -0
  374. package/node_modules/@noble/hashes/utils.d.ts.map +1 -0
  375. package/node_modules/@noble/hashes/utils.js +578 -0
  376. package/node_modules/@noble/hashes/utils.js.map +1 -0
  377. package/node_modules/@noble/hashes/webcrypto.d.ts +120 -0
  378. package/node_modules/@noble/hashes/webcrypto.d.ts.map +1 -0
  379. package/node_modules/@noble/hashes/webcrypto.js +165 -0
  380. package/node_modules/@noble/hashes/webcrypto.js.map +1 -0
  381. package/node_modules/ws/LICENSE +20 -0
  382. package/node_modules/ws/README.md +548 -0
  383. package/node_modules/ws/browser.js +8 -0
  384. package/node_modules/ws/index.js +22 -0
  385. package/node_modules/ws/lib/buffer-util.js +131 -0
  386. package/node_modules/ws/lib/constants.js +19 -0
  387. package/node_modules/ws/lib/event-target.js +292 -0
  388. package/node_modules/ws/lib/extension.js +203 -0
  389. package/node_modules/ws/lib/limiter.js +55 -0
  390. package/node_modules/ws/lib/permessage-deflate.js +530 -0
  391. package/node_modules/ws/lib/receiver.js +743 -0
  392. package/node_modules/ws/lib/sender.js +607 -0
  393. package/node_modules/ws/lib/stream.js +161 -0
  394. package/node_modules/ws/lib/subprotocol.js +62 -0
  395. package/node_modules/ws/lib/validation.js +152 -0
  396. package/node_modules/ws/lib/websocket-server.js +562 -0
  397. package/node_modules/ws/lib/websocket.js +1407 -0
  398. package/node_modules/ws/package.json +74 -0
  399. package/node_modules/ws/wrapper.mjs +21 -0
  400. package/package.json +53 -0
@@ -0,0 +1,2007 @@
1
+ /*
2
+ * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
3
+ * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
4
+ * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
+ */
6
+
7
+ import {requireNonNull} from './assert';
8
+ import {DateTimeException, IllegalArgumentException} from './errors';
9
+ import {MathUtil} from './MathUtil';
10
+
11
+ import {Clock} from './Clock';
12
+ import {Instant} from './Instant';
13
+ import {LocalDate} from './LocalDate';
14
+ import {LocalDateTime} from './LocalDateTime';
15
+ import {LocalTime} from './LocalTime';
16
+ import {OffsetDateTime} from './OffsetDateTime';
17
+ import {ZoneId} from './ZoneId';
18
+ import {ZoneOffset} from './ZoneOffset';
19
+
20
+ import {ChronoZonedDateTime} from './chrono/ChronoZonedDateTime';
21
+ import {DateTimeFormatter} from './format/DateTimeFormatter';
22
+ import {ChronoField} from './temporal/ChronoField';
23
+ import {ChronoUnit} from './temporal/ChronoUnit';
24
+ import {createTemporalQuery} from './temporal/TemporalQuery';
25
+ import {TemporalQueries} from './temporal/TemporalQueries';
26
+
27
+ /**
28
+ * A date-time with a time-zone in the ISO-8601 calendar system,
29
+ * such as `2007-12-03T10:15:30+01:00 Europe/Paris`.
30
+ *
31
+ * `ZonedDateTime` is an immutable representation of a date-time with a time-zone.
32
+ * This class stores all date and time fields, to a precision of nanoseconds,
33
+ * and a time-zone, with a zone offset used to handle ambiguous local date-times.
34
+ * For example, the value
35
+ * '2nd October 2007 at 13:45.30.123456789 +02:00 in the Europe/Paris time-zone'
36
+ * can be stored in a {@link ZonedDateTime}.
37
+ *
38
+ * This class handles conversion from the local time-line of {@link LocalDateTime}
39
+ * to the instant time-line of {@link Instant}.
40
+ * The difference between the two time-lines is the offset from UTC/Greenwich,
41
+ * represented by a {@link ZoneOffset}.
42
+ *
43
+ * Converting between the two time-lines involves calculating the offset using the
44
+ * {@link ZoneRules} rules accessed from the {@link ZoneId}.
45
+ * Obtaining the offset for an instant is simple, as there is exactly one valid
46
+ * offset for each instant. By contrast, obtaining the offset for a local date-time
47
+ * is not straightforward. There are three cases:
48
+ *
49
+ * * Normal, with one valid offset. For the vast majority of the year, the normal
50
+ * case applies, where there is a single valid offset for the local date-time.
51
+ * * Gap, with zero valid offsets. This is when clocks jump forward typically
52
+ * due to the spring daylight savings change from 'winter' to 'summer'.
53
+ * In a gap there are local date-time values with no valid offset.
54
+ * * Overlap, with two valid offsets. This is when clocks are set back typically
55
+ * due to the autumn daylight savings change from 'summer' to 'winter'.
56
+ * In an overlap there are local date-time values with two valid offsets.
57
+ *
58
+ * Any method that converts directly or implicitly from a local date-time to an
59
+ * instant by obtaining the offset has the potential to be complicated.
60
+ *
61
+ * For Gaps, the general strategy is that if the local date-time falls in the
62
+ * middle of a Gap, then the resulting zoned date-time will have a local date-time
63
+ * shifted forwards by the length of the Gap, resulting in a date-time in the later
64
+ * offset, typically 'summer' time.
65
+ *
66
+ * For Overlaps, the general strategy is that if the local date-time falls in the
67
+ * middle of an Overlap, then the previous offset will be retained. If there is no
68
+ * previous offset, or the previous offset is invalid, then the earlier offset is
69
+ * used, typically 'summer' time. Two additional methods,
70
+ * {@link withEarlierOffsetAtOverlap} and {@link withLaterOffsetAtOverlap},
71
+ * help manage the case of an overlap.
72
+ *
73
+ * ### Specification for implementors
74
+ *
75
+ * A {@link ZonedDateTime} holds state equivalent to three separate objects,
76
+ * a {@link LocalDateTime}, a {@link ZoneId} and the resolved {@link ZoneOffset}.
77
+ * The offset and local date-time are used to define an instant when necessary.
78
+ * The zone ID is used to obtain the rules for how and when the offset changes.
79
+ * The offset cannot be freely set, as the zone controls which offsets are valid.
80
+ */
81
+ export class ZonedDateTime extends ChronoZonedDateTime {
82
+
83
+ //-----------------------------------------------------------------------
84
+ /**
85
+ * Obtains the current date-time from the system clock in the specified time-zone or clock
86
+ * or default time zone.
87
+ *
88
+ * This will query the system clock (see {@link Clock#systemDefaultZone}) in the default
89
+ * time-zone to obtain the current date-time.
90
+ * The zone and offset will be set based on the time-zone in the clock.
91
+ *
92
+ * Using this method will prevent the ability to use an alternate clock for testing
93
+ * because the clock is hard-coded.
94
+ *
95
+ * @param {Clock|ZoneId} [clockOrZone=Clock.systemDefaultZone()]
96
+ * @return {ZonedDateTime} the current date-time using the system clock, not null
97
+ */
98
+ static now(clockOrZone) {
99
+ let clock;
100
+ if(clockOrZone instanceof ZoneId){
101
+ clock = Clock.system(clockOrZone);
102
+ } else {
103
+ clock = clockOrZone == null ? Clock.systemDefaultZone() : clockOrZone;
104
+ }
105
+ return ZonedDateTime.ofInstant(clock.instant(), clock.zone());
106
+ }
107
+
108
+ //-----------------------------------------------------------------------
109
+ /**
110
+ * function overloading for static {@link ZonedDateTime.of}
111
+ *
112
+ * if called with 2 (or less) args {@link ZonedDateTime.of2} is called,
113
+ * if called with 3 args and the first arg is an instance of LocalDate {@link ZonedDateTime.of3} is called,
114
+ * otherwise {@link ZonedDateTime.of8} is called.
115
+ */
116
+ static of(){
117
+ if(arguments.length <= 2){
118
+ return ZonedDateTime.of2.apply(this, arguments);
119
+ } else if (arguments.length === 3 && arguments[0] instanceof LocalDate){
120
+ return ZonedDateTime.of3.apply(this, arguments);
121
+ } else {
122
+ return ZonedDateTime.of8.apply(this, arguments);
123
+ }
124
+ }
125
+ /**
126
+ * Obtains an instance of {@link ZonedDateTime} from a local date and time.
127
+ *
128
+ * This creates a zoned date-time matching the input local date and time as closely as possible.
129
+ * Time-zone rules, such as daylight savings, mean that not every local date-time
130
+ * is valid for the specified zone, thus the local date-time may be adjusted.
131
+ *
132
+ * The local date time and first combined to form a local date-time.
133
+ * The local date-time is then resolved to a single instant on the time-line.
134
+ * This is achieved by finding a valid offset from UTC/Greenwich for the local
135
+ * date-time as defined by the {@link ZoneRules} of the zone ID.
136
+ *
137
+ * In most cases, there is only one valid offset for a local date-time.
138
+ * In the case of an overlap, when clocks are set back, there are two valid offsets.
139
+ * This method uses the earlier offset typically corresponding to 'summer'.
140
+ *
141
+ * In the case of a gap, when clocks jump forward, there is no valid offset.
142
+ * Instead, the local date-time is adjusted to be later by the length of the gap.
143
+ * For a typical one hour daylight savings change, the local date-time will be
144
+ * moved one hour later into the offset typically corresponding to 'summer'.
145
+ *
146
+ * @param {LocalDate} date - the local date, not null
147
+ * @param {LocalTime} time - the local time, not null
148
+ * @param {ZoneId} zone - the time-zone, not null
149
+ * @return {ZonedDateTime} the offset date-time, not null
150
+ */
151
+ static of3(date, time, zone) {
152
+ return ZonedDateTime.of2(LocalDateTime.of(date, time), zone);
153
+ }
154
+
155
+ /**
156
+ * Obtains an instance of {@link ZonedDateTime} from a local date-time.
157
+ *
158
+ * This creates a zoned date-time matching the input local date-time as closely as possible.
159
+ * Time-zone rules, such as daylight savings, mean that not every local date-time
160
+ * is valid for the specified zone, thus the local date-time may be adjusted.
161
+ *
162
+ * The local date-time is resolved to a single instant on the time-line.
163
+ * This is achieved by finding a valid offset from UTC/Greenwich for the local
164
+ * date-time as defined by the {@link ZoneRules} of the zone ID.
165
+ *
166
+ * In most cases, there is only one valid offset for a local date-time.
167
+ * In the case of an overlap, when clocks are set back, there are two valid offsets.
168
+ * This method uses the earlier offset typically corresponding to 'summer'.
169
+ *
170
+ * In the case of a gap, when clocks jump forward, there is no valid offset.
171
+ * Instead, the local date-time is adjusted to be later by the length of the gap.
172
+ * For a typical one hour daylight savings change, the local date-time will be
173
+ * moved one hour later into the offset typically corresponding to 'summer'.
174
+ *
175
+ * @param {!LocalDateTime} localDateTime - the local date-time, not null
176
+ * @param {!ZoneId} zone - the time-zone, not null
177
+ * @return {ZonedDateTime} the zoned date-time, not null
178
+ */
179
+ static of2(localDateTime, zone) {
180
+ return ZonedDateTime.ofLocal(localDateTime, zone, null);
181
+ }
182
+
183
+ /**
184
+ * Obtains an instance of {@link ZonedDateTime} from a year, month, day,
185
+ * hour, minute, second, nanosecond and time-zone.
186
+ *
187
+ * This creates a zoned date-time matching the local date-time of the seven
188
+ * specified fields as closely as possible.
189
+ * Time-zone rules, such as daylight savings, mean that not every local date-time
190
+ * is valid for the specified zone, thus the local date-time may be adjusted.
191
+ *
192
+ * The local date-time is resolved to a single instant on the time-line.
193
+ * This is achieved by finding a valid offset from UTC/Greenwich for the local
194
+ * date-time as defined by the {@link ZoneRules} of the zone ID.
195
+ *
196
+ * In most cases, there is only one valid offset for a local date-time.
197
+ * In the case of an overlap, when clocks are set back, there are two valid offsets.
198
+ * This method uses the earlier offset typically corresponding to 'summer'.
199
+ *
200
+ * In the case of a gap, when clocks jump forward, there is no valid offset.
201
+ * Instead, the local date-time is adjusted to be later by the length of the gap.
202
+ * For a typical one hour daylight savings change, the local date-time will be
203
+ * moved one hour later into the offset typically corresponding to 'summer'.
204
+ *
205
+ * This method exists primarily for writing test cases.
206
+ * Non test-code will typically use other methods to create an offset time.
207
+ * {@link LocalDateTime} has five additional convenience variants of the
208
+ * equivalent factory method taking fewer arguments.
209
+ * They are not provided here to reduce the footprint of the API.
210
+ *
211
+ * @param {number} year - the year to represent, from MIN_YEAR to MAX_YEAR
212
+ * @param {number} month - the month-of-year to represent, from 1 (January) to 12 (December)
213
+ * @param {number} dayOfMonth - the day-of-month to represent, from 1 to 31
214
+ * @param {number} hour - the hour-of-day to represent, from 0 to 23
215
+ * @param {number} minute - the minute-of-hour to represent, from 0 to 59
216
+ * @param {number} second - the second-of-minute to represent, from 0 to 59
217
+ * @param {number} nanoOfSecond - the nano-of-second to represent, from 0 to 999,999,999
218
+ * @param {ZoneId} zone - the time-zone, not null
219
+ * @return {ZonedDateTime } the offset date-time, not null
220
+ * @throws DateTimeException if the value of any field is out of range, or
221
+ * if the day-of-month is invalid for the month-year
222
+ */
223
+ static of8(
224
+ year, month, dayOfMonth,
225
+ hour, minute, second, nanoOfSecond, zone) {
226
+ const dt = LocalDateTime.of(year, month, dayOfMonth, hour, minute, second, nanoOfSecond);
227
+ return ZonedDateTime.ofLocal(dt, zone, null);
228
+ }
229
+
230
+ /**
231
+ * Obtains an instance of {@link ZonedDateTime} from a local date-time
232
+ * using the preferred offset if possible.
233
+ *
234
+ * The local date-time is resolved to a single instant on the time-line.
235
+ * This is achieved by finding a valid offset from UTC/Greenwich for the local
236
+ * date-time as defined by the {@link ZoneRules} of the zone ID.
237
+ *
238
+ * In most cases, there is only one valid offset for a local date-time.
239
+ * In the case of an overlap, where clocks are set back, there are two valid offsets.
240
+ * If the preferred offset is one of the valid offsets then it is used.
241
+ * Otherwise the earlier valid offset is used, typically corresponding to 'summer'.
242
+ *
243
+ * In the case of a gap, where clocks jump forward, there is no valid offset.
244
+ * Instead, the local date-time is adjusted to be later by the length of the gap.
245
+ * For a typical one hour daylight savings change, the local date-time will be
246
+ * moved one hour later into the offset typically corresponding to 'summer'.
247
+ *
248
+ * @param {!LocalDateTime} localDateTime - the local date-time, not null
249
+ * @param {!ZoneId} zone - the time-zone, not null
250
+ * @param {ZoneOffset} preferredOffset - the zone offset, null if no preference
251
+ * @return {ZonedDateTime} the zoned date-time, not null
252
+ */
253
+ static ofLocal(localDateTime, zone, preferredOffset) {
254
+ requireNonNull(localDateTime, 'localDateTime');
255
+ requireNonNull(zone, 'zone');
256
+ if (zone instanceof ZoneOffset) {
257
+ return new ZonedDateTime(localDateTime, zone, zone);
258
+ }
259
+ let offset = null;
260
+ const rules = zone.rules();
261
+ const validOffsets = rules.validOffsets(localDateTime);
262
+ if (validOffsets.length === 1) {
263
+ offset = validOffsets[0];
264
+ } else if (validOffsets.length === 0) {
265
+ const trans = rules.transition(localDateTime);
266
+ localDateTime = localDateTime.plusSeconds(trans.duration().seconds());
267
+ offset = trans.offsetAfter();
268
+ } else {
269
+ if (preferredOffset != null &&
270
+ validOffsets.some((validOffset) => {return validOffset.equals(preferredOffset);})) {
271
+ offset = preferredOffset;
272
+ } else {
273
+ offset = requireNonNull(validOffsets[0], 'offset'); // protect against bad ZoneRules
274
+ }
275
+ }
276
+
277
+ return new ZonedDateTime(localDateTime, offset, zone);
278
+ }
279
+
280
+ //-----------------------------------------------------------------------
281
+ /**
282
+ * function overloading for {@link ZonedDateTime.ofInstant}.
283
+ * if called with 2 args {@link ZonedDateTime.ofInstant2} is called
284
+ * otherwise {@link ZonedDateTime.ofInstant3}.
285
+ */
286
+ static ofInstant(){
287
+ if (arguments.length === 2){
288
+ return ZonedDateTime.ofInstant2.apply(this, arguments);
289
+ } else {
290
+ return ZonedDateTime.ofInstant3.apply(this, arguments);
291
+ }
292
+ }
293
+ /**
294
+ * Obtains an instance of {@link ZonedDateTime} from an {@link Instant}.
295
+ *
296
+ * This creates a zoned date-time with the same instant as that specified.
297
+ * Calling {@link toInstant} will return an instant equal to the one used here.
298
+ *
299
+ * Converting an instant to a zoned date-time is simple as there is only one valid
300
+ * offset for each instant.
301
+ *
302
+ * @param {!Instant} instant - the instant to create the date-time from, not null
303
+ * @param {!ZoneId} zone - the time-zone, not null
304
+ * @return {ZonedDateTime} the zoned date-time, not null
305
+ * @throws DateTimeException if the result exceeds the supported range
306
+ */
307
+ static ofInstant2(instant, zone) {
308
+ requireNonNull(instant, 'instant');
309
+ requireNonNull(zone, 'zone');
310
+ return ZonedDateTime._create(instant.epochSecond(), instant.nano(), zone);
311
+ }
312
+
313
+ /**
314
+ * Obtains an instance of {@link ZonedDateTime} from the instant formed by combining
315
+ * the local date-time and offset.
316
+ *
317
+ * This creates a zoned date-time by combining the {@link LocalDateTime} and {@link ZoneOffset}.
318
+ * This combination uniquely specifies an instant without ambiguity.
319
+ *
320
+ * Converting an instant to a zoned date-time is simple as there is only one valid
321
+ * offset for each instant. If the valid offset is different to the offset specified,
322
+ * the the date-time and offset of the zoned date-time will differ from those specified.
323
+ *
324
+ * If the {@link ZoneId} to be used is a {@link ZoneOffset}, this method is equivalent
325
+ * to {@link of}.
326
+ *
327
+ * @param {LocalDateTime} localDateTime - the local date-time, not null
328
+ * @param {ZoneOffset} offset - the zone offset, not null
329
+ * @param {ZoneId} zone - the time-zone, not null
330
+ * @return {ZonedDateTime} the zoned date-time, not null
331
+ */
332
+ static ofInstant3(localDateTime, offset, zone) {
333
+ requireNonNull(localDateTime, 'localDateTime');
334
+ requireNonNull(offset, 'offset');
335
+ requireNonNull(zone, 'zone');
336
+ return ZonedDateTime._create(localDateTime.toEpochSecond(offset), localDateTime.nano(), zone);
337
+ }
338
+
339
+ /**
340
+ * Obtains an instance of {@link ZonedDateTime} using seconds from the
341
+ * epoch of 1970-01-01T00:00:00Z.
342
+ *
343
+ * @param {number} epochSecond - the number of seconds from the epoch of 1970-01-01T00:00:00Z
344
+ * @param {number} nanoOfSecond - the nanosecond within the second, from 0 to 999,999,999
345
+ * @param {ZoneId} zone - the time-zone, not null
346
+ * @return {ZonedDateTime} the zoned date-time, not null
347
+ * @throws DateTimeException if the result exceeds the supported range
348
+ */
349
+ static _create(epochSecond, nanoOfSecond, zone) {
350
+ const rules = zone.rules();
351
+ const instant = Instant.ofEpochSecond(epochSecond, nanoOfSecond); // TODO: rules should be queryable by epochSeconds
352
+ const offset = rules.offset(instant);
353
+ const ldt = LocalDateTime.ofEpochSecond(epochSecond, nanoOfSecond, offset);
354
+ return new ZonedDateTime(ldt, offset, zone);
355
+ }
356
+
357
+ //-----------------------------------------------------------------------
358
+ /**
359
+ * Obtains an instance of {@link ZonedDateTime} strictly validating the
360
+ * combination of local date-time, offset and zone ID.
361
+ *
362
+ * This creates a zoned date-time ensuring that the offset is valid for the
363
+ * local date-time according to the rules of the specified zone.
364
+ * If the offset is invalid, an exception is thrown.
365
+ *
366
+ * @param {LocalDateTime} localDateTime - the local date-time, not null
367
+ * @param {ZoneOffset} offset - the zone offset, not null
368
+ * @param {ZoneId} zone - the time-zone, not null
369
+ * @return {ZonedDateTime} the zoned date-time, not null
370
+ */
371
+ static ofStrict(localDateTime, offset, zone) {
372
+ requireNonNull(localDateTime, 'localDateTime');
373
+ requireNonNull(offset, 'offset');
374
+ requireNonNull(zone, 'zone');
375
+ const rules = zone.rules();
376
+ if (rules.isValidOffset(localDateTime, offset) === false) {
377
+ const trans = rules.transition(localDateTime);
378
+ if (trans != null && trans.isGap()) {
379
+ // error message says daylight savings for simplicity
380
+ // even though there are other kinds of gaps
381
+ throw new DateTimeException('LocalDateTime ' + localDateTime +
382
+ ' does not exist in zone ' + zone +
383
+ ' due to a gap in the local time-line, typically caused by daylight savings');
384
+ }
385
+ throw new DateTimeException('ZoneOffset "' + offset + '" is not valid for LocalDateTime "' +
386
+ localDateTime + '" in zone "' + zone + '"');
387
+ }
388
+ return new ZonedDateTime(localDateTime, offset, zone);
389
+ }
390
+
391
+ /**
392
+ * Obtains an instance of {@link ZonedDateTime} leniently, for advanced use cases,
393
+ * allowing any combination of local date-time, offset and zone ID.
394
+ *
395
+ * This creates a zoned date-time with no checks other than no nulls.
396
+ * This means that the resulting zoned date-time may have an offset that is in conflict
397
+ * with the zone ID.
398
+ *
399
+ * This method is intended for advanced use cases.
400
+ * For example, consider the case where a zoned date-time with valid fields is created
401
+ * and then stored in a database or serialization-based store. At some later point,
402
+ * the object is then re-loaded. However, between those points in time, the government
403
+ * that defined the time-zone has changed the rules, such that the originally stored
404
+ * local date-time now does not occur. This method can be used to create the object
405
+ * in an 'invalid' state, despite the change in rules.
406
+ *
407
+ * @param {LocalDateTime} localDateTime - the local date-time, not null
408
+ * @param {ZoneOffset} offset - the zone offset, not null
409
+ * @param {ZoneId} zone - the time-zone, not null
410
+ * @return {ZonedDateTime} the zoned date-time, not null
411
+ */
412
+ static ofLenient(localDateTime, offset, zone) {
413
+ requireNonNull(localDateTime, 'localDateTime');
414
+ requireNonNull(offset, 'offset');
415
+ requireNonNull(zone, 'zone');
416
+ if (zone instanceof ZoneOffset && offset.equals(zone) === false) {
417
+ throw new IllegalArgumentException('ZoneId must match ZoneOffset');
418
+ }
419
+ return new ZonedDateTime(localDateTime, offset, zone);
420
+ }
421
+
422
+ //-----------------------------------------------------------------------
423
+ /**
424
+ * Obtains an instance of {@link ZonedDateTime} from a temporal object.
425
+ *
426
+ * A {@link TemporalAccessor} represents some form of date and time information.
427
+ * This factory converts the arbitrary temporal object to an instance of {@link ZonedDateTime}.
428
+ *
429
+ * The conversion will first obtain a {@link ZoneId}. It will then try to obtain an instant.
430
+ * If that fails it will try to obtain a local date-time.
431
+ * The zoned date time will either be a combination of {@link ZoneId} and instant,
432
+ * or {@link ZoneId} and local date-time.
433
+ *
434
+ * This method matches the signature of the functional interface {@link TemporalQuery}
435
+ * allowing it to be used in queries via method reference, {@link ZonedDateTime::from}.
436
+ *
437
+ * @param {!TemporalAccessor} temporal - the temporal object to convert, not null
438
+ * @return {ZonedDateTime} the zoned date-time, not null
439
+ * @throws DateTimeException if unable to convert to an {@link ZonedDateTime}
440
+ */
441
+ static from(temporal) {
442
+ requireNonNull(temporal, 'temporal');
443
+ if (temporal instanceof ZonedDateTime) {
444
+ return temporal;
445
+ }
446
+ const zone = ZoneId.from(temporal);
447
+ if (temporal.isSupported(ChronoField.INSTANT_SECONDS)) {
448
+ const zdt = ZonedDateTime._from(temporal, zone);
449
+ if(zdt != null) return zdt;
450
+ }
451
+ const ldt = LocalDateTime.from(temporal);
452
+ return ZonedDateTime.of2(ldt, zone);
453
+ }
454
+
455
+ static _from(temporal, zone){
456
+ try {
457
+ return ZonedDateTime.__from(temporal, zone);
458
+ } catch (ex) {
459
+ if(!(ex instanceof DateTimeException)) throw ex;
460
+ // ignore
461
+ }
462
+ }
463
+
464
+ static __from(temporal, zone){
465
+ const epochSecond = temporal.getLong(ChronoField.INSTANT_SECONDS);
466
+ const nanoOfSecond = temporal.get(ChronoField.NANO_OF_SECOND);
467
+ return ZonedDateTime._create(epochSecond, nanoOfSecond, zone);
468
+ }
469
+
470
+ //-----------------------------------------------------------------------
471
+ /**
472
+ * Obtains an instance of {@link ZonedDateTime} from a text string such as
473
+ * `2007-12-03T10:15:30+01:00[Europe/Paris]`.
474
+ *
475
+ * The string must represent a valid date-time and is parsed using
476
+ * {@link org.threeten.bp.format.DateTimeFormatter#ISO_ZONED_DATE_TIME}.
477
+ *
478
+ * @param {!string} text - the text to parse such as '2007-12-03T10:15:30+01:00[Europe/Paris]', not null
479
+ * @param {!DateTimeFormatter} [formatter=DateTimeFormatter.ISO_ZONED_DATE_TIME] - the formatter to use
480
+ * @return {ZonedDateTime} the parsed zoned date-time, not null
481
+ * @throws DateTimeParseException if the text cannot be parsed
482
+ */
483
+ static parse(text, formatter = DateTimeFormatter.ISO_ZONED_DATE_TIME) {
484
+ requireNonNull(formatter, 'formatter');
485
+ return formatter.parse(text, ZonedDateTime.FROM);
486
+ }
487
+
488
+ //-----------------------------------------------------------------------
489
+ /**
490
+ * Constructor.
491
+ *
492
+ * @param {LocalDateTime} dateTime - the date-time, validated as not null
493
+ * @param {ZoneOffset} offset - the zone offset, validated as not null
494
+ * @param {ZoneUd} zone - the time-zone, validated as not null
495
+ * @private
496
+ */
497
+ constructor(dateTime, offset, zone) {
498
+ requireNonNull(dateTime, 'dateTime');
499
+ requireNonNull(offset, 'offset');
500
+ requireNonNull(zone, 'zone');
501
+
502
+ super();
503
+
504
+ /**
505
+ * The local date-time.
506
+ */
507
+ this._dateTime = dateTime;
508
+ /**
509
+ * The offset from UTC/Greenwich.
510
+ */
511
+ this._offset = offset;
512
+ /**
513
+ * The time-zone.
514
+ */
515
+ this._zone = zone;
516
+ }
517
+
518
+ /**
519
+ * Resolves the new local date-time using this zone ID, retaining the offset if possible.
520
+ *
521
+ * @param {LocalDateTime} newDateTime - the new local date-time, not null
522
+ * @return {ZonedDateTime} the zoned date-time, not null
523
+ */
524
+ _resolveLocal(newDateTime) {
525
+ requireNonNull(newDateTime, 'newDateTime');
526
+ return ZonedDateTime.ofLocal(newDateTime, this._zone, this._offset);
527
+ }
528
+
529
+ /**
530
+ * Resolves the new local date-time using the offset to identify the instant.
531
+ *
532
+ * @param {LocalDateTime} newDateTime - the new local date-time, not null
533
+ * @return {ZonedDateTime} the zoned date-time, not null
534
+ */
535
+ _resolveInstant(newDateTime) {
536
+ return ZonedDateTime.ofInstant3(newDateTime, this._offset, this._zone);
537
+ }
538
+
539
+ /**
540
+ * Resolves the offset into this zoned date-time.
541
+ *
542
+ * This ignores the offset, unless it can be used in an overlap.
543
+ *
544
+ * @param {ZoneOffset} offset - the offset, not null
545
+ * @return {ZonedDateTime} the zoned date-time, not null
546
+ */
547
+ _resolveOffset(offset) {
548
+ if (offset.equals(this._offset) === false && this._zone.rules().isValidOffset(this._dateTime, offset)) {
549
+ return new ZonedDateTime(this._dateTime, offset, this._zone);
550
+ }
551
+ return this;
552
+ }
553
+
554
+ //-----------------------------------------------------------------------
555
+ /**
556
+ * Checks if the specified field is supported.
557
+ *
558
+ * This checks if this date-time can be queried for the specified field.
559
+ * If false, then calling {@link range} and {@link get} will throw an exception.
560
+ *
561
+ * If the field is a {@link ChronoField} then the query is implemented here.
562
+ * The supported fields are:
563
+ *
564
+ * * {@link NANO_OF_SECOND}
565
+ * * {@link NANO_OF_DAY}
566
+ * * {@link MICRO_OF_SECOND}
567
+ * * {@link MICRO_OF_DAY}
568
+ * * {@link MILLI_OF_SECOND}
569
+ * * {@link MILLI_OF_DAY}
570
+ * * {@link SECOND_OF_MINUTE}
571
+ * * {@link SECOND_OF_DAY}
572
+ * * {@link MINUTE_OF_HOUR}
573
+ * * {@link MINUTE_OF_DAY}
574
+ * * {@link HOUR_OF_AMPM}
575
+ * * {@link CLOCK_HOUR_OF_AMPM}
576
+ * * {@link HOUR_OF_DAY}
577
+ * * {@link CLOCK_HOUR_OF_DAY}
578
+ * * {@link AMPM_OF_DAY}
579
+ * * {@link DAY_OF_WEEK}
580
+ * * {@link ALIGNED_DAY_OF_WEEK_IN_MONTH}
581
+ * * {@link ALIGNED_DAY_OF_WEEK_IN_YEAR}
582
+ * * {@link DAY_OF_MONTH}
583
+ * * {@link DAY_OF_YEAR}
584
+ * * {@link EPOCH_DAY}
585
+ * * {@link ALIGNED_WEEK_OF_MONTH}
586
+ * * {@link ALIGNED_WEEK_OF_YEAR}
587
+ * * {@link MONTH_OF_YEAR}
588
+ * * {@link EPOCH_MONTH}
589
+ * * {@link YEAR_OF_ERA}
590
+ * * {@link YEAR}
591
+ * * {@link ERA}
592
+ * * {@link INSTANT_SECONDS}
593
+ * * {@link OFFSET_SECONDS}
594
+ *
595
+ * All other {@link ChronoField} instances will return false.
596
+ *
597
+ * If the field is not a {@link ChronoField}, then the result of this method
598
+ * is obtained by invoking {@link TemporalField.isSupportedBy}
599
+ * passing `this` as the argument.
600
+ * Whether the field is supported is determined by the field.
601
+ *
602
+ * @param {TemporalField|TemporalUnit} fieldOrUnit - the field to check, null returns false
603
+ * @return {boolean} true if the field is supported on this date-time, false if not
604
+ */
605
+ isSupported(fieldOrUnit) {
606
+ if(fieldOrUnit instanceof ChronoField){
607
+ return true;
608
+ } else if (fieldOrUnit instanceof ChronoUnit) {
609
+ return fieldOrUnit.isDateBased() || fieldOrUnit.isTimeBased();
610
+ }
611
+ return (fieldOrUnit != null && fieldOrUnit.isSupportedBy(this));
612
+ }
613
+
614
+
615
+ /**
616
+ * Gets the range of valid values for the specified field.
617
+ *
618
+ * The range object expresses the minimum and maximum valid values for a field.
619
+ * This date-time is used to enhance the accuracy of the returned range.
620
+ * If it is not possible to return the range, because the field is not supported
621
+ * or for some other reason, an exception is thrown.
622
+ *
623
+ * If the field is a {@link ChronoField} then the query is implemented here.
624
+ * The supported fields (see {@link isSupported}) will return
625
+ * appropriate range instances.
626
+ * All other {@link ChronoField} instances will throw a {@link DateTimeException}.
627
+ *
628
+ * If the field is not a {@link ChronoField}, then the result of this method
629
+ * is obtained by invoking {@link TemporalField.rangeRefinedBy}
630
+ * passing `this` as the argument.
631
+ * Whether the range can be obtained is determined by the field.
632
+ *
633
+ * @param {TemporalField} field - the field to query the range for, not null
634
+ * @return {ValueRange} the range of valid values for the field, not null
635
+ * @throws DateTimeException if the range for the field cannot be obtained
636
+ */
637
+ range(field) {
638
+ if (field instanceof ChronoField) {
639
+ if (field === ChronoField.INSTANT_SECONDS || field === ChronoField.OFFSET_SECONDS) {
640
+ return field.range();
641
+ }
642
+ return this._dateTime.range(field);
643
+ }
644
+ return field.rangeRefinedBy(this);
645
+ }
646
+
647
+ /**
648
+ * Gets the value of the specified field from this date-time as an `int`.
649
+ *
650
+ * This queries this date-time for the value for the specified field.
651
+ * The returned value will always be within the valid range of values for the field.
652
+ * If it is not possible to return the value, because the field is not supported
653
+ * or for some other reason, an exception is thrown.
654
+ *
655
+ * If the field is a {@link ChronoField} then the query is implemented here.
656
+ * The supported fields (see {@link isSupported}) will return valid
657
+ * values based on this date-time, except {@link NANO_OF_DAY}, {@link MICRO_OF_DAY},
658
+ * {@link EPOCH_DAY}, {@link EPOCH_MONTH} and {@link INSTANT_SECONDS} which are too
659
+ * large to fit in an `int` and throw a {@link DateTimeException}.
660
+ * All other {@link ChronoField} instances will throw a {@link DateTimeException}.
661
+ *
662
+ * If the field is not a {@link ChronoField}, then the result of this method
663
+ * is obtained by invoking {@link TemporalField.getFrom}
664
+ * passing `this` as the argument. Whether the value can be obtained,
665
+ * and what the value represents, is determined by the field.
666
+ *
667
+ * @param {!TemporalField} field - the field to get, not null
668
+ * @return {number} the value for the field
669
+ * @throws DateTimeException if a value for the field cannot be obtained
670
+ * @throws ArithmeticException if numeric overflow occurs
671
+ */
672
+ get(field) {
673
+ return this.getLong(field);
674
+ }
675
+
676
+ /**
677
+ * Gets the value of the specified field from this date-time as a `long`.
678
+ *
679
+ * This queries this date-time for the value for the specified field.
680
+ * If it is not possible to return the value, because the field is not supported
681
+ * or for some other reason, an exception is thrown.
682
+ *
683
+ * If the field is a {@link ChronoField} then the query is implemented here.
684
+ * The supported fields (see {@link isSupported}) will return valid
685
+ * values based on this date-time.
686
+ * All other {@link ChronoField} instances will throw a {@link DateTimeException}.
687
+ *
688
+ * If the field is not a {@link ChronoField}, then the result of this method
689
+ * is obtained by invoking {@link TemporalField.getFrom}
690
+ * passing `this` as the argument. Whether the value can be obtained,
691
+ * and what the value represents, is determined by the field.
692
+ *
693
+ * @param {!TemporalField} field the field to get, not null
694
+ * @return {number} the value for the field
695
+ * @throws DateTimeException if a value for the field cannot be obtained
696
+ * @throws ArithmeticException if numeric overflow occurs
697
+ */
698
+ getLong(field) {
699
+ if (field instanceof ChronoField) {
700
+ switch (field) {
701
+ case ChronoField.INSTANT_SECONDS: return this.toEpochSecond();
702
+ case ChronoField.OFFSET_SECONDS: return this._offset.totalSeconds();
703
+ }
704
+ return this._dateTime.getLong(field);
705
+ }
706
+ requireNonNull(field, 'field');
707
+ return field.getFrom(this);
708
+ }
709
+
710
+ //-----------------------------------------------------------------------
711
+ /**
712
+ * Gets the zone offset, such as '+01:00'.
713
+ *
714
+ * This is the offset of the local date-time from UTC/Greenwich.
715
+ *
716
+ * @return {ZoneOffset}the zone offset, not null
717
+ */
718
+ offset() {
719
+ return this._offset;
720
+ }
721
+
722
+ /**
723
+ * Returns a copy of this date-time changing the zone offset to the
724
+ * earlier of the two valid offsets at a local time-line overlap.
725
+ *
726
+ * This method only has any effect when the local time-line overlaps, such as
727
+ * at an autumn daylight savings cutover. In this scenario, there are two
728
+ * valid offsets for the local date-time. Calling this method will return
729
+ * a zoned date-time with the earlier of the two selected.
730
+ *
731
+ * If this method is called when it is not an overlap, `this`
732
+ * is returned.
733
+ *
734
+ * This instance is immutable and unaffected by this method call.
735
+ *
736
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the earlier offset, not null
737
+ */
738
+ withEarlierOffsetAtOverlap() {
739
+ const trans = this._zone.rules().transition(this._dateTime);
740
+ if (trans != null && trans.isOverlap()) {
741
+ const earlierOffset = trans.offsetBefore();
742
+ if (earlierOffset.equals(this._offset) === false) {
743
+ return new ZonedDateTime(this._dateTime, earlierOffset, this._zone);
744
+ }
745
+ }
746
+ return this;
747
+ }
748
+
749
+ /**
750
+ * Returns a copy of this date-time changing the zone offset to the
751
+ * later of the two valid offsets at a local time-line overlap.
752
+ *
753
+ * This method only has any effect when the local time-line overlaps, such as
754
+ * at an autumn daylight savings cutover. In this scenario, there are two
755
+ * valid offsets for the local date-time. Calling this method will return
756
+ * a zoned date-time with the later of the two selected.
757
+ *
758
+ * If this method is called when it is not an overlap, `this`
759
+ * is returned.
760
+ *
761
+ * This instance is immutable and unaffected by this method call.
762
+ *
763
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the later offset, not null
764
+ */
765
+ withLaterOffsetAtOverlap() {
766
+ const trans = this._zone.rules().transition(this.toLocalDateTime());
767
+ if (trans != null) {
768
+ const laterOffset = trans.offsetAfter();
769
+ if (laterOffset.equals(this._offset) === false) {
770
+ return new ZonedDateTime(this._dateTime, laterOffset, this._zone);
771
+ }
772
+ }
773
+ return this;
774
+ }
775
+
776
+ //-----------------------------------------------------------------------
777
+ /**
778
+ * Gets the time-zone, such as 'Europe/Paris'.
779
+ *
780
+ * This returns the zone ID. This identifies the time-zone {@link ZoneRules}
781
+ * that determine when and how the offset from UTC/Greenwich changes.
782
+ *
783
+ * The zone ID may be same as the offset (see {@link getOffset}).
784
+ * If this is true, then any future calculations, such as addition or subtraction,
785
+ * have no complex edge cases due to time-zone rules.
786
+ * See also {@link withFixedOffsetZone}.
787
+ *
788
+ * @return {ZoneId} the time-zone, not null
789
+ */
790
+ zone() {
791
+ return this._zone;
792
+ }
793
+
794
+ /**
795
+ * Returns a copy of this date-time with a different time-zone,
796
+ * retaining the local date-time if possible.
797
+ *
798
+ * This method changes the time-zone and retains the local date-time.
799
+ * The local date-time is only changed if it is invalid for the new zone,
800
+ * determined using the same approach as
801
+ * {@link ofLocal}.
802
+ *
803
+ * To change the zone and adjust the local date-time,
804
+ * use {@link withZoneSameInstant}.
805
+ *
806
+ * This instance is immutable and unaffected by this method call.
807
+ *
808
+ * @param {ZoneId} zone - the time-zone to change to, not null
809
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the requested zone, not null
810
+ */
811
+ withZoneSameLocal(zone) {
812
+ requireNonNull(zone, 'zone');
813
+ return this._zone.equals(zone) ? this : ZonedDateTime.ofLocal(this._dateTime, zone, this._offset);
814
+ }
815
+
816
+ /**
817
+ * Returns a copy of this date-time with a different time-zone,
818
+ * retaining the instant.
819
+ *
820
+ * This method changes the time-zone and retains the instant.
821
+ * This normally results in a change to the local date-time.
822
+ *
823
+ * This method is based on retaining the same instant, thus gaps and overlaps
824
+ * in the local time-line have no effect on the result.
825
+ *
826
+ * To change the offset while keeping the local time,
827
+ * use {@link withZoneSameLocal}.
828
+ *
829
+ * @param {ZoneId} zone - the time-zone to change to, not null
830
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the requested zone, not null
831
+ * @throws DateTimeException if the result exceeds the supported date range
832
+ */
833
+ withZoneSameInstant(zone) {
834
+ requireNonNull(zone, 'zone');
835
+ return this._zone.equals(zone) ? this :
836
+ ZonedDateTime._create(this._dateTime.toEpochSecond(this._offset), this._dateTime.nano(), zone);
837
+ }
838
+
839
+ /**
840
+ * Returns a copy of this date-time with the zone ID set to the offset.
841
+ *
842
+ * This returns a zoned date-time where the zone ID is the same as {@link getOffset}.
843
+ * The local date-time, offset and instant of the result will be the same as in this date-time.
844
+ *
845
+ * Setting the date-time to a fixed single offset means that any future
846
+ * calculations, such as addition or subtraction, have no complex edge cases
847
+ * due to time-zone rules.
848
+ * This might also be useful when sending a zoned date-time across a network,
849
+ * as most protocols, such as ISO-8601, only handle offsets,
850
+ * and not region-based zone IDs.
851
+ *
852
+ * This is equivalent to {@link ZonedDateTime.of}.
853
+ *
854
+ * @return {ZonedDateTime} a {@link ZonedDateTime} with the zone ID set to the offset, not null
855
+ */
856
+ withFixedOffsetZone() {
857
+ return this._zone.equals(this._offset) ? this : new ZonedDateTime(this._dateTime, this._offset, this._offset);
858
+ }
859
+
860
+ //-----------------------------------------------------------------------
861
+ /**
862
+ * Gets the year field.
863
+ *
864
+ * This method returns the primitive `int` value for the year.
865
+ *
866
+ * The year returned by this method is proleptic as per {@link get}.
867
+ * To obtain the year-of-era, use `get(YEAR_OF_ERA)`.
868
+ *
869
+ * @return {number} the year, from MIN_YEAR to MAX_YEAR
870
+ */
871
+ year() {
872
+ return this._dateTime.year();
873
+ }
874
+
875
+ /**
876
+ * Gets the month-of-year field from 1 to 12.
877
+ *
878
+ * This method returns the month as an `int` from 1 to 12.
879
+ * Application code is frequently clearer if the enum {@link Month}
880
+ * is used by calling {@link getMonth}.
881
+ *
882
+ * @return {number} the month-of-year, from 1 to 12
883
+ * @see #month()
884
+ */
885
+ monthValue() {
886
+ return this._dateTime.monthValue();
887
+ }
888
+
889
+ /**
890
+ * Gets the month-of-year field using the {@link Month} enum.
891
+ *
892
+ * This method returns the enum {@link Month} for the month.
893
+ * This avoids confusion as to what `int` values mean.
894
+ * If you need access to the primitive `int` value, use {@link Month#getValue}.
895
+ *
896
+ * @return {Month} the month-of-year, not null
897
+ * @see #getMonthValue()
898
+ */
899
+ month() {
900
+ return this._dateTime.month();
901
+ }
902
+
903
+ /**
904
+ * Gets the day-of-month field.
905
+ *
906
+ * This method returns the primitive `int` value for the day-of-month.
907
+ *
908
+ * @return {number} the day-of-month, from 1 to 31
909
+ */
910
+ dayOfMonth() {
911
+ return this._dateTime.dayOfMonth();
912
+ }
913
+
914
+ /**
915
+ * Gets the day-of-year field.
916
+ *
917
+ * This method returns the primitive `int` value for the day-of-year.
918
+ *
919
+ * @return {number} the day-of-year, from 1 to 365, or 366 in a leap year
920
+ */
921
+ dayOfYear() {
922
+ return this._dateTime.dayOfYear();
923
+ }
924
+
925
+ /**
926
+ * Gets the day-of-week field, which is an enum {@link DayOfWeek}.
927
+ *
928
+ * This method returns the enum {@link DayOfWeek} for the day-of-week.
929
+ * This avoids confusion as to what `int` values mean.
930
+ * If you need access to the primitive `int` value, use {@link DayOfWeek#getValue}.
931
+ *
932
+ * Additional information can be obtained from the {@link DayOfWeek}.
933
+ * This includes textual names of the values.
934
+ *
935
+ * @return {DayOfWeek} the day-of-week, not null
936
+ */
937
+ dayOfWeek() {
938
+ return this._dateTime.dayOfWeek();
939
+ }
940
+
941
+ //-----------------------------------------------------------------------
942
+ /**
943
+ * Gets the hour-of-day field.
944
+ *
945
+ * @return {number} the hour-of-day, from 0 to 23
946
+ */
947
+ hour() {
948
+ return this._dateTime.hour();
949
+ }
950
+
951
+ /**
952
+ * Gets the minute-of-hour field.
953
+ *
954
+ * @return {number} the minute-of-hour, from 0 to 59
955
+ */
956
+ minute() {
957
+ return this._dateTime.minute();
958
+ }
959
+
960
+ /**
961
+ * Gets the second-of-minute field.
962
+ *
963
+ * @return {number} the second-of-minute, from 0 to 59
964
+ */
965
+ second() {
966
+ return this._dateTime.second();
967
+ }
968
+
969
+ /**
970
+ * Gets the nano-of-second field.
971
+ *
972
+ * @return {number} the nano-of-second, from 0 to 999,999,999
973
+ */
974
+ nano() {
975
+ return this._dateTime.nano();
976
+ }
977
+
978
+ //-----------------------------------------------------------------------
979
+
980
+ /**
981
+ * Returns an adjusted copy of this date-time.
982
+ *
983
+ * This returns a new {@link ZonedDateTime}, based on this one, with the date-time adjusted.
984
+ * The adjustment takes place using the specified adjuster strategy object.
985
+ * Read the documentation of the adjuster to understand what adjustment will be made.
986
+ *
987
+ * A simple adjuster might simply set the one of the fields, such as the year field.
988
+ * A more complex adjuster might set the date to the last day of the month.
989
+ * A selection of common adjustments is provided in {@link TemporalAdjusters}.
990
+ * These include finding the 'last day of the month' and 'next Wednesday'.
991
+ * Key date-time classes also implement the {@link TemporalAdjuster} interface,
992
+ * such as {@link Month} and {@link MonthDay}.
993
+ * The adjuster is responsible for handling special cases, such as the varying
994
+ * lengths of month and leap years.
995
+ *
996
+ * For example this code returns a date on the last day of July:
997
+ * <pre>
998
+ * import static org.threeten.bp.Month.*;
999
+ * import static org.threeten.bp.temporal.Adjusters.*;
1000
+ *
1001
+ * result = zonedDateTime.with(JULY).with(lastDayOfMonth());
1002
+ * </pre>
1003
+ *
1004
+ * The classes {@link LocalDate} and {@link LocalTime} implement {@link TemporalAdjuster},
1005
+ * thus this method can be used to change the date, time or offset:
1006
+ * <pre>
1007
+ * result = zonedDateTime.with(date);
1008
+ * result = zonedDateTime.with(time);
1009
+ * </pre>
1010
+ *
1011
+ * {@link ZoneOffset} also implements {@link TemporalAdjuster} however it is less likely
1012
+ * that setting the offset will have the effect you expect. When an offset is passed in,
1013
+ * the local date-time is combined with the new offset to form an {@link Instant}.
1014
+ * The instant and original zone are then used to create the result.
1015
+ * This algorithm means that it is quite likely that the output has a different offset
1016
+ * to the specified offset. It will however work correctly when passing in the offset
1017
+ * applicable for the instant of the zoned date-time, and will work correctly if passing
1018
+ * one of the two valid offsets during a daylight savings overlap when the same local time
1019
+ * occurs twice.
1020
+ *
1021
+ * The result of this method is obtained by invoking the
1022
+ * {@link TemporalAdjuster#adjustInto} method on the
1023
+ * specified adjuster passing `this` as the argument.
1024
+ *
1025
+ * This instance is immutable and unaffected by this method call.
1026
+ *
1027
+ * @param {TemporalAdjuster} adjuster - the adjuster to use, not null
1028
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on `this` with the adjustment made, not null
1029
+ * @throws DateTimeException if the adjustment cannot be made
1030
+ * @throws ArithmeticException if numeric overflow occurs
1031
+ */
1032
+ withAdjuster(adjuster) {
1033
+ // optimizations
1034
+ if (adjuster instanceof LocalDate) {
1035
+ return this._resolveLocal(LocalDateTime.of(adjuster, this._dateTime.toLocalTime()));
1036
+ } else if (adjuster instanceof LocalTime) {
1037
+ return this._resolveLocal(LocalDateTime.of(this._dateTime.toLocalDate(), adjuster));
1038
+ } else if (adjuster instanceof LocalDateTime) {
1039
+ return this._resolveLocal(adjuster);
1040
+ } else if (adjuster instanceof Instant) {
1041
+ const instant = adjuster;
1042
+ return ZonedDateTime._create(instant.epochSecond(), instant.nano(), this._zone);
1043
+ } else if (adjuster instanceof ZoneOffset) {
1044
+ return this._resolveOffset(adjuster);
1045
+ }
1046
+ requireNonNull(adjuster, 'adjuster');
1047
+ return adjuster.adjustInto(this);
1048
+ }
1049
+
1050
+ /**
1051
+ * Returns a copy of this date-time with the specified field set to a new value.
1052
+ *
1053
+ * This returns a {@link ZonedDateTime}, based on this one, with the value
1054
+ * for the specified field changed.
1055
+ * This can be used to change any supported field, such as the year, month or day-of-month.
1056
+ * If it is not possible to set the value, because the field is not supported or for
1057
+ * some other reason, an exception is thrown.
1058
+ *
1059
+ * In some cases, changing the specified field can cause the resulting date-time to become invalid,
1060
+ * such as changing the month from 31st January to February would make the day-of-month invalid.
1061
+ * In cases like this, the field is responsible for resolving the date. Typically it will choose
1062
+ * the previous valid date, which would be the last valid day of February in this example.
1063
+ *
1064
+ * If the field is a {@link ChronoField} then the adjustment is implemented here.
1065
+ *
1066
+ * The {@link INSTANT_SECONDS} field will return a date-time with the specified instant.
1067
+ * The zone and nano-of-second are unchanged.
1068
+ * The result will have an offset derived from the new instant and original zone.
1069
+ * If the new instant value is outside the valid range then a {@link DateTimeException} will be thrown.
1070
+ *
1071
+ * The {@link OFFSET_SECONDS} field will typically be ignored.
1072
+ * The offset of a {@link ZonedDateTime} is controlled primarily by the time-zone.
1073
+ * As such, changing the offset does not generally make sense, because there is only
1074
+ * one valid offset for the local date-time and zone.
1075
+ * If the zoned date-time is in a daylight savings overlap, then the offset is used
1076
+ * to switch between the two valid offsets. In all other cases, the offset is ignored.
1077
+ * If the new offset value is outside the valid range then a {@link DateTimeException} will be thrown.
1078
+ *
1079
+ * The other supported fields (see {@link isSupported}) will behave as in {@link LocalDateTime#with}.
1080
+ * The zone is not part of the calculation and will be unchanged.
1081
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1082
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1083
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1084
+ *
1085
+ * All other {@link ChronoField} instances will throw an {@link UnsupportedTemporalTypeException}.
1086
+ *
1087
+ * If the field is not a {@link ChronoField}, then the result of this method
1088
+ * is obtained by invoking {@link TemporalField.adjustInto}
1089
+ * passing `this` as the argument. In this case, the field determines
1090
+ * whether and how to adjust the instant.
1091
+ *
1092
+ * This instance is immutable and unaffected by this method call.
1093
+ *
1094
+ * @param {TemporalField} field - the field to set in the result, not null
1095
+ * @param {number} newValue - the new value of the field in the result
1096
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on `this` with the specified field set, not null
1097
+ * @throws DateTimeException if the field cannot be set
1098
+ * @throws UnsupportedTemporalTypeException if the field is not supported
1099
+ * @throws ArithmeticException if numeric overflow occurs
1100
+ */
1101
+ withFieldValue(field, newValue) {
1102
+ if (field instanceof ChronoField) {
1103
+ switch (field) {
1104
+ case ChronoField.INSTANT_SECONDS: return ZonedDateTime._create(newValue, this.nano(), this._zone);
1105
+ case ChronoField.OFFSET_SECONDS: {
1106
+ const offset = ZoneOffset.ofTotalSeconds(field.checkValidIntValue(newValue));
1107
+ return this._resolveOffset(offset);
1108
+ }
1109
+ }
1110
+ return this._resolveLocal(this._dateTime.with(field, newValue));
1111
+ }
1112
+ return field.adjustInto(this, newValue);
1113
+ }
1114
+
1115
+ //-----------------------------------------------------------------------
1116
+ /**
1117
+ * Returns a copy of this {@link ZonedDateTime} with the year value altered.
1118
+ *
1119
+ * This operates on the local time-line,
1120
+ * changing the year (see {@link LocalDateTime#withYear}) of the local date-time.
1121
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1122
+ * to obtain the offset.
1123
+ *
1124
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1125
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1126
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1127
+ *
1128
+ * This instance is immutable and unaffected by this method call.
1129
+ *
1130
+ * @param {number} year - the year to set in the result, from MIN_YEAR to MAX_YEAR
1131
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the requested year, not null
1132
+ * @throws DateTimeException if the year value is invalid
1133
+ */
1134
+ withYear(year) {
1135
+ return this._resolveLocal(this._dateTime.withYear(year));
1136
+ }
1137
+
1138
+ /**
1139
+ * Returns a copy of this {@link ZonedDateTime} with the month-of-year value altered.
1140
+ *
1141
+ * This operates on the local time-line,
1142
+ * changing the month (see {@link LocalDateTime#withMonth}) of the local date-time.
1143
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1144
+ * to obtain the offset.
1145
+ *
1146
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1147
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1148
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1149
+ *
1150
+ * This instance is immutable and unaffected by this method call.
1151
+ *
1152
+ * @param {number} month - the month-of-year to set in the result, from 1 (January) to 12 (December)
1153
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the requested month, not null
1154
+ * @throws DateTimeException if the month-of-year value is invalid
1155
+ */
1156
+ withMonth(month) {
1157
+ return this._resolveLocal(this._dateTime.withMonth(month));
1158
+ }
1159
+
1160
+ /**
1161
+ * Returns a copy of this {@link ZonedDateTime} with the day-of-month value altered.
1162
+ *
1163
+ * This operates on the local time-line,
1164
+ * changing the day-of-month (see {@link LocalDateTime#withDayOfMonth}) of the local date-time.
1165
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1166
+ * to obtain the offset.
1167
+ *
1168
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1169
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1170
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1171
+ *
1172
+ * This instance is immutable and unaffected by this method call.
1173
+ *
1174
+ * @param {number} dayOfMonth - the day-of-month to set in the result, from 1 to 28-31
1175
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the requested day, not null
1176
+ * @throws DateTimeException if the day-of-month value is invalid
1177
+ * @throws DateTimeException if the day-of-month is invalid for the month-year
1178
+ */
1179
+ withDayOfMonth(dayOfMonth) {
1180
+ return this._resolveLocal(this._dateTime.withDayOfMonth(dayOfMonth));
1181
+ }
1182
+
1183
+ /**
1184
+ * Returns a copy of this {@link ZonedDateTime} with the day-of-year altered.
1185
+ *
1186
+ * This operates on the local time-line,
1187
+ * changing the day-of-year (see {@link LocalDateTime#withDayOfYear}) of the local date-time.
1188
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1189
+ * to obtain the offset.
1190
+ *
1191
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1192
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1193
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1194
+ *
1195
+ * This instance is immutable and unaffected by this method call.
1196
+ *
1197
+ * @param {number} dayOfYear - the day-of-year to set in the result, from 1 to 365-366
1198
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date with the requested day, not null
1199
+ * @throws DateTimeException if the day-of-year value is invalid
1200
+ * @throws DateTimeException if the day-of-year is invalid for the year
1201
+ */
1202
+ withDayOfYear(dayOfYear) {
1203
+ return this._resolveLocal(this._dateTime.withDayOfYear(dayOfYear));
1204
+ }
1205
+
1206
+ //-----------------------------------------------------------------------
1207
+ /**
1208
+ * Returns a copy of this {@link ZonedDateTime} with the hour-of-day value altered.
1209
+ *
1210
+ * This operates on the local time-line,
1211
+ * changing the time (see {@link LocalDateTime#withHour}) of the local date-time.
1212
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1213
+ * to obtain the offset.
1214
+ *
1215
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1216
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1217
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1218
+ *
1219
+ * This instance is immutable and unaffected by this method call.
1220
+ *
1221
+ * @param {number} hour - the hour-of-day to set in the result, from 0 to 23
1222
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the requested hour, not null
1223
+ * @throws DateTimeException if the hour value is invalid
1224
+ */
1225
+ withHour(hour) {
1226
+ return this._resolveLocal(this._dateTime.withHour(hour));
1227
+ }
1228
+
1229
+ /**
1230
+ * Returns a copy of this {@link ZonedDateTime} with the minute-of-hour value altered.
1231
+ *
1232
+ * This operates on the local time-line,
1233
+ * changing the time (see {@link LocalDateTime#withMinute}) of the local date-time.
1234
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1235
+ * to obtain the offset.
1236
+ *
1237
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1238
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1239
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1240
+ *
1241
+ * This instance is immutable and unaffected by this method call.
1242
+ *
1243
+ * @param {number} minute - the minute-of-hour to set in the result, from 0 to 59
1244
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the requested minute, not null
1245
+ * @throws DateTimeException if the minute value is invalid
1246
+ */
1247
+ withMinute(minute) {
1248
+ return this._resolveLocal(this._dateTime.withMinute(minute));
1249
+ }
1250
+
1251
+ /**
1252
+ * Returns a copy of this {@link ZonedDateTime} with the second-of-minute value altered.
1253
+ *
1254
+ * This operates on the local time-line,
1255
+ * changing the time (see {@link LocalDateTime#withSecond}) of the local date-time.
1256
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1257
+ * to obtain the offset.
1258
+ *
1259
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1260
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1261
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1262
+ *
1263
+ * This instance is immutable and unaffected by this method call.
1264
+ *
1265
+ * @param {number} second - the second-of-minute to set in the result, from 0 to 59
1266
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the requested second, not null
1267
+ * @throws DateTimeException if the second value is invalid
1268
+ */
1269
+ withSecond(second) {
1270
+ return this._resolveLocal(this._dateTime.withSecond(second));
1271
+ }
1272
+
1273
+ /**
1274
+ * Returns a copy of this {@link ZonedDateTime} with the nano-of-second value altered.
1275
+ *
1276
+ * This operates on the local time-line,
1277
+ * changing the time (see {@link LocalDateTime#withNano}) of the local date-time.
1278
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1279
+ * to obtain the offset.
1280
+ *
1281
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1282
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1283
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1284
+ *
1285
+ * This instance is immutable and unaffected by this method call.
1286
+ *
1287
+ * @param {number} nanoOfSecond - the nano-of-second to set in the result, from 0 to 999,999,999
1288
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the requested nanosecond, not null
1289
+ * @throws DateTimeException if the nano value is invalid
1290
+ */
1291
+ withNano(nanoOfSecond) {
1292
+ return this._resolveLocal(this._dateTime.withNano(nanoOfSecond));
1293
+ }
1294
+
1295
+ //-----------------------------------------------------------------------
1296
+ /**
1297
+ * Returns a copy of this {@link ZonedDateTime} with the time truncated.
1298
+ *
1299
+ * Truncation returns a copy of the original date-time with fields
1300
+ * smaller than the specified unit set to zero.
1301
+ * For example, truncating with {@link ChronoUnit#MINUTES}
1302
+ * will set the second-of-minute and nano-of-second field to zero.
1303
+ *
1304
+ * The unit must have a duration (see {@link TemporalUnit#getDuration})
1305
+ * that divides into the length of a standard day without remainder.
1306
+ * This includes all supplied time units on {@link ChronoUnit} and
1307
+ * {@link ChronoUnit#DAYS}. Other units throw an exception.
1308
+ *
1309
+ * This operates on the local time-line, truncating the underlying local date-time.
1310
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID to obtain the offset.
1311
+ *
1312
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1313
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1314
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1315
+ *
1316
+ * This instance is immutable and unaffected by this method call.
1317
+ *
1318
+ * @param {TemporalUnit} unit - the unit to truncate to, not null
1319
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the time truncated, not null
1320
+ * @throws DateTimeException if unable to truncate
1321
+ */
1322
+ truncatedTo(unit) {
1323
+ return this._resolveLocal(this._dateTime.truncatedTo(unit));
1324
+ }
1325
+
1326
+ //-----------------------------------------------------------------------
1327
+
1328
+ /**
1329
+ * Returns a copy of this date-time with the specified period added.
1330
+ *
1331
+ * This method returns a new date-time based on this time with the specified period added.
1332
+ * The amount is typically {@link Period} but may be any other type implementing
1333
+ * the {@link TemporalAmount} interface.
1334
+ * The calculation is delegated to the specified adjuster, which typically calls
1335
+ * back to {@link plus}.
1336
+ *
1337
+ * This instance is immutable and unaffected by this method call.
1338
+ *
1339
+ * @param {!TemporalAmount} amount - the amount to add, not null
1340
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the addition made, not null
1341
+ * @throws DateTimeException if the addition cannot be made
1342
+ * @throws ArithmeticException if numeric overflow occurs
1343
+ */
1344
+ plusAmount(amount) {
1345
+ requireNonNull(amount);
1346
+ return amount.addTo(this);
1347
+ }
1348
+
1349
+ /**
1350
+ * Returns a copy of this date-time with the specified period added.
1351
+ *
1352
+ * This method returns a new date-time based on this date-time with the specified period added.
1353
+ * This can be used to add any period that is defined by a unit, for example to add years, months or days.
1354
+ * The unit is responsible for the details of the calculation, including the resolution
1355
+ * of any edge cases in the calculation.
1356
+ *
1357
+ * The calculation for date and time units differ.
1358
+ *
1359
+ * Date units operate on the local time-line.
1360
+ * The period is first added to the local date-time, then converted back
1361
+ * to a zoned date-time using the zone ID.
1362
+ * The conversion uses {@link ofLocal}
1363
+ * with the offset before the addition.
1364
+ *
1365
+ * Time units operate on the instant time-line.
1366
+ * The period is first added to the local date-time, then converted back to
1367
+ * a zoned date-time using the zone ID.
1368
+ * The conversion uses {@link ofInstant}
1369
+ * with the offset before the addition.
1370
+ *
1371
+ * This instance is immutable and unaffected by this method call.
1372
+ *
1373
+ * @param {number} amountToAdd - the amount of the unit to add to the result, may be negative
1374
+ * @param {TemporalUnit} unit - the unit of the period to add, not null
1375
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the specified period added, not null
1376
+ * @throws DateTimeException if the unit cannot be added to this type
1377
+ */
1378
+ plusAmountUnit(amountToAdd, unit) {
1379
+ if (unit instanceof ChronoUnit) {
1380
+ if (unit.isDateBased()) {
1381
+ return this._resolveLocal(this._dateTime.plus(amountToAdd, unit));
1382
+ } else {
1383
+ return this._resolveInstant(this._dateTime.plus(amountToAdd, unit));
1384
+ }
1385
+ }
1386
+ requireNonNull(unit, 'unit');
1387
+ return unit.addTo(this, amountToAdd);
1388
+ }
1389
+
1390
+ //-----------------------------------------------------------------------
1391
+ /**
1392
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in years added.
1393
+ *
1394
+ * This operates on the local time-line, adding years to the local date-time.
1395
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1396
+ * to obtain the offset.
1397
+ *
1398
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1399
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1400
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1401
+ *
1402
+ * This instance is immutable and unaffected by this method call.
1403
+ *
1404
+ * @param {number} years - the years to add, may be negative
1405
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the years added, not null
1406
+ * @throws DateTimeException if the result exceeds the supported date range
1407
+ */
1408
+ plusYears(years) {
1409
+ return this._resolveLocal(this._dateTime.plusYears(years));
1410
+ }
1411
+
1412
+ /**
1413
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in months added.
1414
+ *
1415
+ * This operates on the local time-line, adding months to the local date-time.
1416
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1417
+ * to obtain the offset.
1418
+ *
1419
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1420
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1421
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1422
+ *
1423
+ * This instance is immutable and unaffected by this method call.
1424
+ *
1425
+ * @param {number} months - the months to add, may be negative
1426
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the months added, not null
1427
+ * @throws DateTimeException if the result exceeds the supported date range
1428
+ */
1429
+ plusMonths(months) {
1430
+ return this._resolveLocal(this._dateTime.plusMonths(months));
1431
+ }
1432
+
1433
+ /**
1434
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in weeks added.
1435
+ *
1436
+ * This operates on the local time-line, adding weeks to the local date-time.
1437
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1438
+ * to obtain the offset.
1439
+ *
1440
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1441
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1442
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1443
+ *
1444
+ * This instance is immutable and unaffected by this method call.
1445
+ *
1446
+ * @param {number} weeks - the weeks to add, may be negative
1447
+ * @return {ZonedDateTime}a {@link ZonedDateTime} based on this date-time with the weeks added, not null
1448
+ * @throws DateTimeException if the result exceeds the supported date range
1449
+ */
1450
+ plusWeeks(weeks) {
1451
+ return this._resolveLocal(this._dateTime.plusWeeks(weeks));
1452
+ }
1453
+
1454
+ /**
1455
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in days added.
1456
+ *
1457
+ * This operates on the local time-line, adding days to the local date-time.
1458
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1459
+ * to obtain the offset.
1460
+ *
1461
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1462
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1463
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1464
+ *
1465
+ * This instance is immutable and unaffected by this method call.
1466
+ *
1467
+ * @param {number} days - the days to add, may be negative
1468
+ * @return {ZonedDateTime}a {@link ZonedDateTime} based on this date-time with the days added, not null
1469
+ * @throws DateTimeException if the result exceeds the supported date range
1470
+ */
1471
+ plusDays(days) {
1472
+ return this._resolveLocal(this._dateTime.plusDays(days));
1473
+ }
1474
+
1475
+ //-----------------------------------------------------------------------
1476
+ /**
1477
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in hours added.
1478
+ *
1479
+ * This operates on the instant time-line, such that adding one hour will
1480
+ * always be a duration of one hour later.
1481
+ * This may cause the local date-time to change by an amount other than one hour.
1482
+ * Note that this is a different approach to that used by days, months and years,
1483
+ * thus adding one day is not the same as adding 24 hours.
1484
+ *
1485
+ * For example, consider a time-zone where the spring DST cutover means that the
1486
+ * local times 01:00 to 01:59 occur twice changing from offset +02:00 to +01:00.
1487
+ *
1488
+ * * Adding one hour to 00:30+02:00 will result in 01:30+02:00
1489
+ * * Adding one hour to 01:30+02:00 will result in 01:30+01:00
1490
+ * * Adding one hour to 01:30+01:00 will result in 02:30+01:00
1491
+ * * Adding three hours to 00:30+02:00 will result in 02:30+01:00
1492
+ *
1493
+ * This instance is immutable and unaffected by this method call.
1494
+ *
1495
+ * @param {number} hours - the hours to add, may be negative
1496
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the hours added, not null
1497
+ * @throws DateTimeException if the result exceeds the supported date range
1498
+ */
1499
+ plusHours(hours) {
1500
+ return this._resolveInstant(this._dateTime.plusHours(hours));
1501
+ }
1502
+
1503
+ /**
1504
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in minutes added.
1505
+ *
1506
+ * This operates on the instant time-line, such that adding one minute will
1507
+ * always be a duration of one minute later.
1508
+ * This may cause the local date-time to change by an amount other than one minute.
1509
+ * Note that this is a different approach to that used by days, months and years.
1510
+ *
1511
+ * This instance is immutable and unaffected by this method call.
1512
+ *
1513
+ * @param {number} minutes - the minutes to add, may be negative
1514
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the minutes added, not null
1515
+ * @throws DateTimeException if the result exceeds the supported date range
1516
+ */
1517
+ plusMinutes(minutes) {
1518
+ return this._resolveInstant(this._dateTime.plusMinutes(minutes));
1519
+ }
1520
+
1521
+ /**
1522
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in seconds added.
1523
+ *
1524
+ * This operates on the instant time-line, such that adding one second will
1525
+ * always be a duration of one second later.
1526
+ * This may cause the local date-time to change by an amount other than one second.
1527
+ * Note that this is a different approach to that used by days, months and years.
1528
+ *
1529
+ * This instance is immutable and unaffected by this method call.
1530
+ *
1531
+ * @param {number} seconds - the seconds to add, may be negative
1532
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the seconds added, not null
1533
+ * @throws DateTimeException if the result exceeds the supported date range
1534
+ */
1535
+ plusSeconds(seconds) {
1536
+ return this._resolveInstant(this._dateTime.plusSeconds(seconds));
1537
+ }
1538
+
1539
+ /**
1540
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in nanoseconds added.
1541
+ *
1542
+ * This operates on the instant time-line, such that adding one nano will
1543
+ * always be a duration of one nano later.
1544
+ * This may cause the local date-time to change by an amount other than one nano.
1545
+ * Note that this is a different approach to that used by days, months and years.
1546
+ *
1547
+ * This instance is immutable and unaffected by this method call.
1548
+ *
1549
+ * @param {number} nanos - the nanos to add, may be negative
1550
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the nanoseconds added, not null
1551
+ * @throws DateTimeException if the result exceeds the supported date range
1552
+ */
1553
+ plusNanos(nanos) {
1554
+ return this._resolveInstant(this._dateTime.plusNanos(nanos));
1555
+ }
1556
+
1557
+ //-----------------------------------------------------------------------
1558
+
1559
+ /**
1560
+ * Returns a copy of this date-time with the specified period subtracted.
1561
+ *
1562
+ * This method returns a new date-time based on this time with the specified period subtracted.
1563
+ * The amount is typically {@link Period} but may be any other type implementing
1564
+ * the {@link TemporalAmount} interface.
1565
+ * The calculation is delegated to the specified adjuster, which typically calls
1566
+ * back to {@link minus}.
1567
+ *
1568
+ * This instance is immutable and unaffected by this method call.
1569
+ *
1570
+ * @param {TemporalAmount} amount - the amount to subtract, not null
1571
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the subtraction made, not null
1572
+ * @throws DateTimeException if the subtraction cannot be made
1573
+ * @throws ArithmeticException if numeric overflow occurs
1574
+ */
1575
+ minusAmount(amount) {
1576
+ requireNonNull(amount, 'amount');
1577
+ return amount.subtractFrom(this);
1578
+ }
1579
+
1580
+ /**
1581
+ * Returns a copy of this date-time with the specified period subtracted.
1582
+ *
1583
+ * This method returns a new date-time based on this date-time with the specified period subtracted.
1584
+ * This can be used to subtract any period that is defined by a unit, for example to subtract years, months or days.
1585
+ * The unit is responsible for the details of the calculation, including the resolution
1586
+ * of any edge cases in the calculation.
1587
+ *
1588
+ * The calculation for date and time units differ.
1589
+ *
1590
+ * Date units operate on the local time-line.
1591
+ * The period is first subtracted from the local date-time, then converted back
1592
+ * to a zoned date-time using the zone ID.
1593
+ * The conversion uses {@link ofLocal}
1594
+ * with the offset before the subtraction.
1595
+ *
1596
+ * Time units operate on the instant time-line.
1597
+ * The period is first subtracted from the local date-time, then converted back to
1598
+ * a zoned date-time using the zone ID.
1599
+ * The conversion uses {@link ofInstant}
1600
+ * with the offset before the subtraction.
1601
+ *
1602
+ * This instance is immutable and unaffected by this method call.
1603
+ *
1604
+ * @param {number} amountToSubtract - the amount of the unit to subtract from the result, may be negative
1605
+ * @param {TemporalUnit} unit - the unit of the period to subtract, not null
1606
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the specified period subtracted, not null
1607
+ * @throws DateTimeException if the unit cannot be added to this type
1608
+ */
1609
+ minusAmountUnit(amountToSubtract, unit) {
1610
+ return this.plusAmountUnit(-1 * amountToSubtract, unit);
1611
+ }
1612
+
1613
+ //-----------------------------------------------------------------------
1614
+ /**
1615
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in years subtracted.
1616
+ *
1617
+ * This operates on the local time-line, subtracting years from the local date-time.
1618
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1619
+ * to obtain the offset.
1620
+ *
1621
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1622
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1623
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1624
+ *
1625
+ * This instance is immutable and unaffected by this method call.
1626
+ *
1627
+ * @param {number} years - the years to subtract, may be negative
1628
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the years subtracted, not null
1629
+ * @throws DateTimeException if the result exceeds the supported date range
1630
+ */
1631
+ minusYears(years) {
1632
+ return this.plusYears(-1 * years);
1633
+ }
1634
+
1635
+ /**
1636
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in months subtracted.
1637
+ *
1638
+ * This operates on the local time-line, subtracting months from the local date-time.
1639
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1640
+ * to obtain the offset.
1641
+ *
1642
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1643
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1644
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1645
+ *
1646
+ * This instance is immutable and unaffected by this method call.
1647
+ *
1648
+ * @param {number} months - the months to subtract, may be negative
1649
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the months subtracted, not null
1650
+ * @throws DateTimeException if the result exceeds the supported date range
1651
+ */
1652
+ minusMonths(months) {
1653
+ return this.plusMonths(-1 * months);
1654
+ }
1655
+
1656
+ /**
1657
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in weeks subtracted.
1658
+ *
1659
+ * This operates on the local time-line, subtracting weeks from the local date-time.
1660
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1661
+ * to obtain the offset.
1662
+ *
1663
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1664
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1665
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1666
+ *
1667
+ * This instance is immutable and unaffected by this method call.
1668
+ *
1669
+ * @param {number} weeks - the weeks to subtract, may be negative
1670
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the weeks subtracted, not null
1671
+ * @throws DateTimeException if the result exceeds the supported date range
1672
+ */
1673
+ minusWeeks(weeks) {
1674
+ return this.plusWeeks(-1 * weeks);
1675
+ }
1676
+
1677
+ /**
1678
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in days subtracted.
1679
+ *
1680
+ * This operates on the local time-line, subtracting days from the local date-time.
1681
+ * This is then converted back to a {@link ZonedDateTime}, using the zone ID
1682
+ * to obtain the offset.
1683
+ *
1684
+ * When converting back to {@link ZonedDateTime}, if the local date-time is in an overlap,
1685
+ * then the offset will be retained if possible, otherwise the earlier offset will be used.
1686
+ * If in a gap, the local date-time will be adjusted forward by the length of the gap.
1687
+ *
1688
+ * This instance is immutable and unaffected by this method call.
1689
+ *
1690
+ * @param {number} days - the days to subtract, may be negative
1691
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the days subtracted, not null
1692
+ * @throws DateTimeException if the result exceeds the supported date range
1693
+ */
1694
+ minusDays(days) {
1695
+ return this.plusDays(-1 * days);
1696
+ }
1697
+
1698
+ //-----------------------------------------------------------------------
1699
+ /**
1700
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in hours subtracted.
1701
+ *
1702
+ * This operates on the instant time-line, such that subtracting one hour will
1703
+ * always be a duration of one hour earlier.
1704
+ * This may cause the local date-time to change by an amount other than one hour.
1705
+ * Note that this is a different approach to that used by days, months and years,
1706
+ * thus subtracting one day is not the same as adding 24 hours.
1707
+ *
1708
+ * For example, consider a time-zone where the spring DST cutover means that the
1709
+ * local times 01:00 to 01:59 occur twice changing from offset +02:00 to +01:00.
1710
+ *
1711
+ * * Subtracting one hour from 02:30+01:00 will result in 01:30+02:00
1712
+ * * Subtracting one hour from 01:30+01:00 will result in 01:30+02:00
1713
+ * * Subtracting one hour from 01:30+02:00 will result in 00:30+01:00
1714
+ * * Subtracting three hours from 02:30+01:00 will result in 00:30+02:00
1715
+ *
1716
+ * This instance is immutable and unaffected by this method call.
1717
+ *
1718
+ * @param {number} hours - the hours to subtract, may be negative
1719
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the hours subtracted, not null
1720
+ * @throws DateTimeException if the result exceeds the supported date range
1721
+ */
1722
+ minusHours(hours) {
1723
+ return this.plusHours(-1 * hours);
1724
+ }
1725
+
1726
+ /**
1727
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in minutes subtracted.
1728
+ *
1729
+ * This operates on the instant time-line, such that subtracting one minute will
1730
+ * always be a duration of one minute earlier.
1731
+ * This may cause the local date-time to change by an amount other than one minute.
1732
+ * Note that this is a different approach to that used by days, months and years.
1733
+ *
1734
+ * This instance is immutable and unaffected by this method call.
1735
+ *
1736
+ * @param {number} minutes - the minutes to subtract, may be negative
1737
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the minutes subtracted, not null
1738
+ * @throws DateTimeException if the result exceeds the supported date range
1739
+ */
1740
+ minusMinutes(minutes) {
1741
+ return this.plusMinutes(-1 * minutes);
1742
+ }
1743
+
1744
+ /**
1745
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in seconds subtracted.
1746
+ *
1747
+ * This operates on the instant time-line, such that subtracting one second will
1748
+ * always be a duration of one second earlier.
1749
+ * This may cause the local date-time to change by an amount other than one second.
1750
+ * Note that this is a different approach to that used by days, months and years.
1751
+ *
1752
+ * This instance is immutable and unaffected by this method call.
1753
+ *
1754
+ * @param {number} seconds - the seconds to subtract, may be negative
1755
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the seconds subtracted, not null
1756
+ * @throws DateTimeException if the result exceeds the supported date range
1757
+ */
1758
+ minusSeconds(seconds) {
1759
+ return this.plusSeconds(-1 * seconds);
1760
+ }
1761
+
1762
+ /**
1763
+ * Returns a copy of this {@link ZonedDateTime} with the specified period in nanoseconds subtracted.
1764
+ *
1765
+ * This operates on the instant time-line, such that subtracting one nano will
1766
+ * always be a duration of one nano earlier.
1767
+ * This may cause the local date-time to change by an amount other than one nano.
1768
+ * Note that this is a different approach to that used by days, months and years.
1769
+ *
1770
+ * This instance is immutable and unaffected by this method call.
1771
+ *
1772
+ * @param {number} nanos - the nanos to subtract, may be negative
1773
+ * @return {ZonedDateTime} a {@link ZonedDateTime} based on this date-time with the nanoseconds subtracted, not null
1774
+ * @throws DateTimeException if the result exceeds the supported date range
1775
+ */
1776
+ minusNanos(nanos) {
1777
+ return this.plusNanos(-1 * nanos);
1778
+ }
1779
+
1780
+ //-----------------------------------------------------------------------
1781
+ /**
1782
+ * Queries this date-time using the specified query.
1783
+ *
1784
+ * This queries this date-time using the specified query strategy object.
1785
+ * The {@link TemporalQuery} object defines the logic to be used to
1786
+ * obtain the result. Read the documentation of the query to understand
1787
+ * what the result of this method will be.
1788
+ *
1789
+ * The result of this method is obtained by invoking the
1790
+ * {@link TemporalQuery#queryFrom} method on the
1791
+ * specified query passing `this` as the argument.
1792
+ *
1793
+ * @param {TemporalQuery} query - the query to invoke, not null
1794
+ * @return {*} the query result, null may be returned (defined by the query)
1795
+ * @throws DateTimeException if unable to query (defined by the query)
1796
+ * @throws ArithmeticException if numeric overflow occurs (defined by the query)
1797
+ */
1798
+ query(query) {
1799
+ if (query === TemporalQueries.localDate()) {
1800
+ return this.toLocalDate();
1801
+ }
1802
+ requireNonNull(query, 'query');
1803
+ return super.query(query);
1804
+ }
1805
+
1806
+ /**
1807
+ * Calculates the period between this date-time and another date-time in
1808
+ * terms of the specified unit.
1809
+ *
1810
+ * This calculates the period between two date-times in terms of a single unit.
1811
+ * The start and end points are `this` and the specified date-time.
1812
+ * The result will be negative if the end is before the start.
1813
+ * For example, the period in days between two date-times can be calculated
1814
+ * using {@link startDateTime.until}.
1815
+ *
1816
+ * The {@link Temporal} passed to this method must be a {@link ZonedDateTime}.
1817
+ * If the time-zone differs between the two zoned date-times, the specified
1818
+ * end date-time is normalized to have the same zone as this date-time.
1819
+ *
1820
+ * The calculation returns a whole number, representing the number of
1821
+ * complete units between the two date-times.
1822
+ * For example, the period in months between 2012-06-15T00:00Z and 2012-08-14T23:59Z
1823
+ * will only be one month as it is one minute short of two months.
1824
+ *
1825
+ * This method operates in association with {@link TemporalUnit#between}.
1826
+ * The result of this method is a `long` representing the amount of
1827
+ * the specified unit. By contrast, the result of {@link between} is an
1828
+ * object that can be used directly in addition/subtraction:
1829
+ * <pre>
1830
+ * long period = start.until(end, MONTHS); // this method
1831
+ * dateTime.plus(MONTHS.between(start, end)); // use in plus/minus
1832
+ * </pre>
1833
+ *
1834
+ * The calculation is implemented in this method for {@link ChronoUnit}.
1835
+ * The units {@link NANOS}, {@link MICROS}, {@link MILLIS}, {@link SECONDS},
1836
+ * {@link MINUTES}, {@link HOURS} and {@link HALF_DAYS}, {@link DAYS},
1837
+ * {@link WEEKS}, {@link MONTHS}, {@link YEARS}, {@link DECADES},
1838
+ * {@link CENTURIES}, {@link MILLENNIA} and {@link ERAS} are supported.
1839
+ * Other {@link ChronoUnit} values will throw an exception.
1840
+ *
1841
+ * The calculation for date and time units differ.
1842
+ *
1843
+ * Date units operate on the local time-line, using the local date-time.
1844
+ * For example, the period from noon on day 1 to noon the following day
1845
+ * in days will always be counted as exactly one day, irrespective of whether
1846
+ * there was a daylight savings change or not.
1847
+ *
1848
+ * Time units operate on the instant time-line.
1849
+ * The calculation effectively converts both zoned date-times to instants
1850
+ * and then calculates the period between the instants.
1851
+ * For example, the period from noon on day 1 to noon the following day
1852
+ * in hours may be 23, 24 or 25 hours (or some other amount) depending on
1853
+ * whether there was a daylight savings change or not.
1854
+ *
1855
+ * If the unit is not a {@link ChronoUnit}, then the result of this method
1856
+ * is obtained by invoking {@link TemporalUnit.between}
1857
+ * passing `this` as the first argument and the input temporal as
1858
+ * the second argument.
1859
+ *
1860
+ * This instance is immutable and unaffected by this method call.
1861
+ *
1862
+ * @param {Temporal} endExclusive the end date-time, which is converted to a {@link ZonedDateTime}, not null
1863
+ * @param {TemporalUnit} unit the unit to measure the period in, not null
1864
+ * @return {number} the amount of the period between this date-time and the end date-time
1865
+ * @throws DateTimeException if the period cannot be calculated
1866
+ * @throws ArithmeticException if numeric overflow occurs
1867
+ */
1868
+ until(endExclusive, unit) {
1869
+ let end = ZonedDateTime.from(endExclusive);
1870
+ if (unit instanceof ChronoUnit) {
1871
+ end = end.withZoneSameInstant(this._zone);
1872
+ if (unit.isDateBased()) {
1873
+ return this._dateTime.until(end._dateTime, unit);
1874
+ } else {
1875
+ const difference = this._offset.totalSeconds() - end._offset.totalSeconds();
1876
+ const adjustedEnd = end._dateTime.plusSeconds(difference);
1877
+ return this._dateTime.until(adjustedEnd, unit);
1878
+ }
1879
+ }
1880
+ return unit.between(this, end);
1881
+ }
1882
+
1883
+ //-----------------------------------------------------------------------
1884
+ /**
1885
+ * Gets the {@link LocalDateTime} part of this date-time.
1886
+ *
1887
+ * This returns a {@link LocalDateTime} with the same year, month, day and time
1888
+ * as this date-time.
1889
+ *
1890
+ * @return {LocalDateTime} the local date-time part of this date-time, not null
1891
+ */
1892
+ toLocalDateTime() {
1893
+ return this._dateTime;
1894
+ }
1895
+
1896
+ /**
1897
+ * Gets the {@link LocalDate} part of this date-time.
1898
+ *
1899
+ * This returns a {@link LocalDate} with the same year, month and day
1900
+ * as this date-time.
1901
+ *
1902
+ * @return {LocalDate} the date part of this date-time, not null
1903
+ */
1904
+ toLocalDate() {
1905
+ return this._dateTime.toLocalDate();
1906
+ }
1907
+
1908
+ /**
1909
+ * Gets the {@link LocalTime} part of this date-time.
1910
+ *
1911
+ * This returns a {@link LocalTime} with the same hour, minute, second and
1912
+ * nanosecond as this date-time.
1913
+ *
1914
+ * @return {LocalTime} the time part of this date-time, not null
1915
+ */
1916
+ toLocalTime() {
1917
+ return this._dateTime.toLocalTime();
1918
+ }
1919
+
1920
+ /**
1921
+ * Converts this date-time to an {@link OffsetDateTime}.
1922
+ *
1923
+ * This creates an offset date-time using the local date-time and offset.
1924
+ * The zone ID is ignored.
1925
+ *
1926
+ * @return {OffsetDateTime} an offset date-time representing the same local date-time and offset, not null
1927
+ */
1928
+ toOffsetDateTime() {
1929
+ return OffsetDateTime.of(this._dateTime, this._offset);
1930
+ }
1931
+
1932
+ //-----------------------------------------------------------------------
1933
+ /**
1934
+ * Checks if this date-time is equal to another date-time.
1935
+ *
1936
+ * The comparison is based on the offset date-time and the zone.
1937
+ * Only objects of type {@link ZonedDateTime} are compared, other types return false.
1938
+ *
1939
+ * @param {*} other the object to check, null returns false
1940
+ * @return {boolean} true if this is equal to the other date-time
1941
+ */
1942
+ equals(other) {
1943
+ if (this === other) {
1944
+ return true;
1945
+ }
1946
+ if (other instanceof ZonedDateTime) {
1947
+ return this._dateTime.equals(other._dateTime) &&
1948
+ this._offset.equals(other._offset) &&
1949
+ this._zone.equals(other._zone);
1950
+ }
1951
+ return false;
1952
+ }
1953
+
1954
+ /**
1955
+ * A hash code for this date-time.
1956
+ *
1957
+ * @return {number} a suitable hash code
1958
+ */
1959
+ hashCode() {
1960
+ return MathUtil.hashCode(this._dateTime.hashCode(), this._offset.hashCode(), this._zone.hashCode());
1961
+ }
1962
+
1963
+ //-----------------------------------------------------------------------
1964
+ /**
1965
+ * Outputs this date-time as a string, such as
1966
+ * `2007-12-03T10:15:30+01:00[Europe/Paris]`.
1967
+ *
1968
+ * The format consists of the {@link LocalDateTime} followed by the {@link ZoneOffset}.
1969
+ * If the {@link ZoneId} is not the same as the offset, then the ID is output.
1970
+ * The output is compatible with ISO-8601 if the offset and ID are the same.
1971
+ *
1972
+ * @return {string} a string representation of this date-time, not null
1973
+ */
1974
+ toString() {
1975
+ let str = this._dateTime.toString() + this._offset.toString();
1976
+ if (this._offset !== this._zone) {
1977
+ str += '[' + this._zone.toString() + ']';
1978
+ }
1979
+ return str;
1980
+ }
1981
+
1982
+ /**
1983
+ *
1984
+ * @return {string} same as {@link ZonedDateTime.toString}
1985
+ */
1986
+ toJSON() {
1987
+ return this.toString();
1988
+ }
1989
+
1990
+ /**
1991
+ * Outputs this date-time as a string using the formatter.
1992
+ *
1993
+ * @param {DateTimeFormatter} formatter the formatter to use, not null
1994
+ * @return {string} the formatted date-time string, not null
1995
+ * @throws DateTimeException if an error occurs during printing
1996
+ */
1997
+ format(formatter) {
1998
+ return super.format(formatter);
1999
+ }
2000
+
2001
+ }
2002
+
2003
+ export function _init(){
2004
+ ZonedDateTime.FROM = createTemporalQuery('ZonedDateTime.FROM', (temporal) => {
2005
+ return ZonedDateTime.from(temporal);
2006
+ });
2007
+ }