@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,1686 @@
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 {MathUtil} from './MathUtil';
8
+ import {assert, requireNonNull, requireInstance} from './assert';
9
+ import {DateTimeException, UnsupportedTemporalTypeException, IllegalArgumentException} from './errors';
10
+
11
+ import {Clock} from './Clock';
12
+ import {Instant} from './Instant';
13
+ import {LocalDate} from './LocalDate';
14
+ import {LocalTime} from './LocalTime';
15
+ import {OffsetDateTime} from './OffsetDateTime';
16
+ import {ZonedDateTime} from './ZonedDateTime';
17
+ import {ZoneId} from './ZoneId';
18
+ import {ZoneOffset} from './ZoneOffset';
19
+
20
+
21
+ import {DateTimeFormatter} from './format/DateTimeFormatter';
22
+ import {ChronoField} from './temporal/ChronoField';
23
+ import {ChronoUnit} from './temporal/ChronoUnit';
24
+ import {TemporalQueries} from './temporal/TemporalQueries';
25
+ import {createTemporalQuery} from './temporal/TemporalQuery';
26
+
27
+ import {ChronoLocalDateTime} from './chrono/ChronoLocalDateTime';
28
+
29
+ /**
30
+ * A date-time without a time-zone in the ISO-8601 calendar system,
31
+ * such as `2007-12-03T10:15:30`.
32
+ *
33
+ * {@link LocalDateTime} is an immutable date-time object that represents a date-time,
34
+ * often viewed as year-month-day-hour-minute-second. Other date and time fields,
35
+ * such as day-of-year, day-of-week and week-of-year, can also be accessed.
36
+ * Time is represented to nanosecond precision.
37
+ * For example, the value '2nd October 2007 at 13:45.30.123456789' can be
38
+ * stored in a {@link LocalDateTime}.
39
+ *
40
+ * This class does not store or represent a time-zone.
41
+ * Instead, it is a description of the date, as used for birthdays, combined with
42
+ * the local time as seen on a wall clock.
43
+ * It cannot represent an instant on the time-line without additional information
44
+ * such as an offset or time-zone.
45
+ *
46
+ * The ISO-8601 calendar system is the modern civil calendar system used today
47
+ * in most of the world. It is equivalent to the proleptic Gregorian calendar
48
+ * system, in which today's rules for leap years are applied for all time.
49
+ * For most applications written today, the ISO-8601 rules are entirely suitable.
50
+ * However, any application that makes use of historical dates, and requires them
51
+ * to be accurate will find the ISO-8601 approach unsuitable.
52
+ *
53
+ * ### Static properties of Class {@link LocalTime}
54
+ *
55
+ * LocalDateTime.MIN
56
+ *
57
+ * The minimum supported {@link LocalDateTime}, '-999999999-01-01T00:00:00'.
58
+ * This is the local date-time of midnight at the start of the minimum date.
59
+ * This combines {@link LocalDate#MIN} and {@link LocalTime#MIN}.
60
+ * This could be used by an application as a 'far past' date-time.
61
+ *
62
+ * LocalDateTime.MAX
63
+ *
64
+ * The maximum supported {@link LocalDateTime}, '+999999999-12-31T23:59:59.999999999'.
65
+ * This is the local date-time just before midnight at the end of the maximum date.
66
+ * This combines {@link LocalDate#MAX} and {@link LocalTime#MAX}.
67
+ * This could be used by an application as a 'far future' date-time.
68
+ *
69
+ */
70
+ export class LocalDateTime extends ChronoLocalDateTime
71
+ /** extends ChronoLocalDateTime<LocalDate>
72
+ implements Temporal, TemporalAdjuster, Serializable */ {
73
+
74
+
75
+ /**
76
+ * Obtains the current date-time from from the specified clock or the system clock in the specified time-zone.
77
+ *
78
+ * If the argument is an instance of Clock this will query the specified clock to obtain the current date-time.
79
+ * Using this method allows the use of an alternate clock for testing.
80
+ * The alternate clock may be introduced using dependency injection.
81
+ *
82
+ * If the argument is an instance of ZoneId this will query the system clock (see {@link Clock#system}) to obtain the current date-time.
83
+ * Specifying the time-zone avoids dependence on the default time-zone.
84
+ *
85
+ * If nor argument is applied, the system default time zone is used to obtain the current date-time.
86
+ *
87
+ * Using this method will prevent the ability to use an alternate clock for testing
88
+ * because the clock is hard-coded.
89
+ *
90
+ * @param {Clock|ZoneId} clockOrZone - the zone ID or clock to use, if null Clock.systemDefaultZone() is used.
91
+ * @return {LocalDateTime} the current date-time using the system clock, not null
92
+ */
93
+ static now(clockOrZone) {
94
+ if (clockOrZone == null){
95
+ return LocalDateTime._now(Clock.systemDefaultZone());
96
+ } else if (clockOrZone instanceof Clock){
97
+ return LocalDateTime._now(clockOrZone);
98
+ } else {
99
+ return LocalDateTime._now(Clock.system(clockOrZone));
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Obtains the current date-time from the specified clock.
105
+ *
106
+ * This will query the specified clock to obtain the current date-time.
107
+ * Using this method allows the use of an alternate clock for testing.
108
+ * The alternate clock may be introduced using dependency injection.
109
+ *
110
+ * @param {Clock} clock - the clock to use, defaults to Clock.systemDefaultZone()
111
+ * @return {LocalDateTime} the current date-time, not null
112
+ */
113
+ static _now(clock) {
114
+ requireNonNull(clock, 'clock');
115
+ return LocalDateTime.ofInstant(clock.instant(), clock.zone());
116
+
117
+ // this is an alternative implementation with better performance.
118
+ // const epochMilli = clock.millis();
119
+ // const offset = clock.zone().rules().offsetOfEpochMilli(epochMilli);
120
+ // return LocalDateTime._ofEpochMillis(epochMilli, offset);
121
+
122
+ }
123
+
124
+ /**
125
+ * @see comment at {LocalDateTime._now}
126
+ * @param {number} epochMilli
127
+ * @param {ZoneOffset} offset
128
+ * @return {LocalDateTime} the date-time, not null
129
+ *
130
+ */
131
+ static _ofEpochMillis(epochMilli, offset){
132
+ const localSecond = MathUtil.floorDiv(epochMilli, 1000) + offset.totalSeconds();
133
+ const localEpochDay = MathUtil.floorDiv(localSecond, LocalTime.SECONDS_PER_DAY);
134
+ const secsOfDay = MathUtil.floorMod(localSecond, LocalTime.SECONDS_PER_DAY);
135
+ const nanoOfSecond = MathUtil.floorMod(epochMilli, 1000) * 1000000;
136
+ const date = LocalDate.ofEpochDay(localEpochDay);
137
+ const time = LocalTime.ofSecondOfDay(secsOfDay, nanoOfSecond);
138
+ return new LocalDateTime(date, time);
139
+
140
+ }
141
+
142
+ //-----------------------------------------------------------------------
143
+ /**
144
+ * function overloading for {@link LocalDateTime.of}
145
+ *
146
+ * if called with 2 arguments and first argument is an instance of LocalDate and second is an
147
+ * instance of LocalTime, then {@link LocalDateTime.ofDateAndTime} is executed.
148
+ *
149
+ * Otherwise {@link LocalDateTime.ofNumbers} is executed.
150
+ *
151
+ * @returns {LocalDateTime}
152
+ */
153
+ static of(){
154
+ if (arguments.length <= 2){
155
+ return LocalDateTime.ofDateAndTime.apply(this, arguments);
156
+ } else {
157
+ return LocalDateTime.ofNumbers.apply(this, arguments);
158
+ }
159
+ }
160
+ /**
161
+ * Obtains an instance of {@link LocalDateTime} from year, month,
162
+ * day, hour, minute, second and nanosecond.
163
+ *
164
+ * The day must be valid for the year and month, otherwise an exception will be thrown.
165
+ *
166
+ * @param {number} [year] - the year to represent, from MIN_YEAR to MAX_YEAR
167
+ * @param {number} [month] - the month-of-year to represent, from 1 to 12 or from a Month
168
+ * @param {number} [dayOfMonth] - the day-of-month to represent, from 1 to 31
169
+ * @param {number} [hour=0] - the hour-of-day to represent, from 0 to 23
170
+ * @param {number} [minute=0] - the minute-of-hour to represent, from 0 to 59
171
+ * @param {number} [second=0] - the second-of-minute to represent, from 0 to 59
172
+ * @param {number} [nanoOfSecond=0] - the nano-of-second to represent, from 0 to 999,999,999
173
+ * @return {LocalDateTime} the local date-time, not null
174
+ * @throws {DateTimeException} if the value of any field is out of range
175
+ * @throws {DateTimeException} if the day-of-month is invalid for the month-year
176
+ */
177
+ static ofNumbers(year, month, dayOfMonth, hour=0, minute=0, second=0, nanoOfSecond=0) {
178
+ const date = LocalDate.of(year, month, dayOfMonth);
179
+ const time = LocalTime.of(hour, minute, second, nanoOfSecond);
180
+ return new LocalDateTime(date, time);
181
+ }
182
+
183
+ /**
184
+ * Obtains an instance of {@link LocalDateTime} from a date and time.
185
+ *
186
+ * @param {!LocalDate} date - the local date, not null
187
+ * @param {!LocalTime} time - the local time, not null
188
+ * @return {LocalDateTime} the local date-time, not null
189
+ */
190
+ static ofDateAndTime(date, time) {
191
+ requireNonNull(date, 'date');
192
+ requireNonNull(time, 'time');
193
+ return new LocalDateTime(date, time);
194
+ }
195
+
196
+ //-------------------------------------------------------------------------
197
+ /**
198
+ * Obtains an instance of {@link LocalDateTime} from an {@link Instant} and zone ID.
199
+ *
200
+ * This creates a local date-time based on the specified instant.
201
+ * First, the offset from UTC/Greenwich is obtained using the zone ID and instant,
202
+ * which is simple as there is only one valid offset for each instant.
203
+ * Then, the instant and offset are used to calculate the local date-time.
204
+ *
205
+ * @param {!Instant} instant the instant to create the date-time from, not null
206
+ * @param {!ZoneId} [zone=ZoneId.systemDefault()] the time-zone, which may be an offset, defaults to ZoneId.systemDefault()
207
+ * @return {LocalDateTime} the local date-time, not null
208
+ * @throws {DateTimeException} if the result exceeds the supported range
209
+ */
210
+ static ofInstant(instant, zone=ZoneId.systemDefault()) {
211
+ requireNonNull(instant, 'instant');
212
+ requireInstance(instant, Instant, 'instant');
213
+ requireNonNull(zone, 'zone');
214
+ const offset = zone.rules().offset(instant);
215
+ return LocalDateTime.ofEpochSecond(instant.epochSecond(), instant.nano(), offset);
216
+ }
217
+
218
+ /**
219
+ * Obtains an instance of {@link LocalDateTime} using seconds from the
220
+ * epoch of 1970-01-01T00:00:00Z.
221
+ *
222
+ * This allows the {@link ChronoField.INSTANT_SECONDS} epoch-second field
223
+ * to be converted to a local date-time. This is primarily intended for
224
+ * low-level conversions rather than general application usage.
225
+ *
226
+ * @param {number} epochSecond - the number of seconds from the epoch of 1970-01-01T00:00:00Z
227
+ * @param {number|!ZoneOffset} nanoOfSecond - the nanosecond within the second, from 0 to 999,999,999
228
+ * @param {ZoneOffset} offset - the zone offset, not null if called with 3 arguments
229
+ * @return {LocalDateTime} the local date-time, not null
230
+ * @throws {DateTimeException} if the result exceeds the supported range
231
+ */
232
+ static ofEpochSecond(epochSecond=0, nanoOfSecond=0, offset) {
233
+ if(arguments.length === 2 && nanoOfSecond instanceof ZoneOffset){
234
+ offset = nanoOfSecond;
235
+ nanoOfSecond = 0;
236
+ }
237
+ requireNonNull(offset, 'offset');
238
+ const localSecond = epochSecond + offset.totalSeconds(); // overflow caught later
239
+ const localEpochDay = MathUtil.floorDiv(localSecond, LocalTime.SECONDS_PER_DAY);
240
+ const secsOfDay = MathUtil.floorMod(localSecond, LocalTime.SECONDS_PER_DAY);
241
+ const date = LocalDate.ofEpochDay(localEpochDay);
242
+ const time = LocalTime.ofSecondOfDay(secsOfDay, nanoOfSecond);
243
+ return new LocalDateTime(date, time);
244
+ }
245
+
246
+ //-----------------------------------------------------------------------
247
+ /**
248
+ * Obtains an instance of {@link LocalDateTime} from a temporal object.
249
+ *
250
+ * A {@link TemporalAccessor} represents some form of date and time information.
251
+ * This factory converts the arbitrary temporal object to an instance of {@link LocalDateTime}.
252
+ *
253
+ * The conversion extracts and combines {@link LocalDate} and {@link LocalTime}.
254
+ *
255
+ * This method matches the signature of the functional interface {@link TemporalQuery}
256
+ * allowing it to be used as a query via method reference, {@link LocalDateTime::from}.
257
+ *
258
+ * @param {!TemporalAccessor} temporal - the temporal object to convert, not null
259
+ * @return {LocalDateTime} {LocalDateTime} the local date-time, not null
260
+ * @throws {DateTimeException} if unable to convert to a {@link LocalDateTime}
261
+ */
262
+ static from(temporal) {
263
+ requireNonNull(temporal, 'temporal');
264
+ if (temporal instanceof LocalDateTime) {
265
+ return temporal;
266
+ } else if (temporal instanceof ZonedDateTime) {
267
+ return temporal.toLocalDateTime();
268
+ }
269
+ try {
270
+ const date = LocalDate.from(temporal);
271
+ const time = LocalTime.from(temporal);
272
+ return new LocalDateTime(date, time);
273
+ } catch (ex) {
274
+ throw new DateTimeException(`Unable to obtain LocalDateTime TemporalAccessor: ${temporal}, type ${temporal.constructor != null ? temporal.constructor.name : ''}`);
275
+ }
276
+ }
277
+
278
+ //-----------------------------------------------------------------------
279
+ /**
280
+ * Obtains an instance of {@link LocalDateTime} from a text string using a specific formatter.
281
+ *
282
+ * The text is parsed using the formatter, returning a date-time.
283
+ *
284
+ * @param {!string} text - the text to parse, not null
285
+ * @param {DateTimeFormatter} [formatter=DateTimeFormatter.ISO_LOCAL_DATE_TIME] - the formatter to use,
286
+ * defaults to DateTimeFormatter.ISO_LOCAL_DATE_TIME
287
+ * @return {LocalDateTime} the parsed local date-time, not null
288
+ * @throws {DateTimeParseException} if the text cannot be parsed
289
+ */
290
+ static parse(text, formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME) {
291
+ requireNonNull(formatter, 'formatter');
292
+ return formatter.parse(text, LocalDateTime.FROM);
293
+ }
294
+
295
+ //-----------------------------------------------------------------------
296
+ /**
297
+ * Constructor.
298
+ *
299
+ * @param {LocalDate} date - the date part of the date-time, validated not null
300
+ * @param {LocalTime} time - the time part of the date-time, validated not null
301
+ * @private
302
+ */
303
+ constructor(date, time) {
304
+ super();
305
+ requireInstance(date, LocalDate, 'date');
306
+ requireInstance(time, LocalTime, 'time');
307
+ this._date = date;
308
+ this._time = time;
309
+ }
310
+
311
+ /**
312
+ * Returns a copy of this date-time with the new date and time, checking
313
+ * to see if a new object is in fact required.
314
+ *
315
+ * @param {LocalDate} newDate - the date of the new date-time, not null
316
+ * @param {LocalTime} newTime - the time of the new date-time, not null
317
+ * @return {LocalDateTime} the date-time, not null
318
+ */
319
+ _withDateTime(newDate, newTime) {
320
+ if (this._date.equals(newDate) && this._time.equals(newTime)) {
321
+ return this;
322
+ }
323
+ return new LocalDateTime(newDate, newTime);
324
+ }
325
+
326
+ //-----------------------------------------------------------------------
327
+ /**
328
+ * Checks if the specified field is supported.
329
+ *
330
+ * This checks if this date-time can be queried for the specified field.
331
+ * If false, then calling the {@link LocalDateTime.range} range and
332
+ * {@link LocalDateTime.get} get methods will throw an exception.
333
+ *
334
+ * If the field is a {@link ChronoField} then the query is implemented here.
335
+ * The supported fields are:
336
+ *
337
+ * * {@link ChronoField.NANO_OF_SECOND}
338
+ * * {@link ChronoField.NANO_OF_DAY}
339
+ * * {@link ChronoField.MICRO_OF_SECOND}
340
+ * * {@link ChronoField.MICRO_OF_DAY}
341
+ * * {@link ChronoField.MILLI_OF_SECOND}
342
+ * * {@link ChronoField.MILLI_OF_DAY}
343
+ * * {@link ChronoField.SECOND_OF_MINUTE}
344
+ * * {@link ChronoField.SECOND_OF_DAY}
345
+ * * {@link ChronoField.MINUTE_OF_HOUR}
346
+ * * {@link ChronoField.MINUTE_OF_DAY}
347
+ * * {@link ChronoField.HOUR_OF_AMPM}
348
+ * * {@link ChronoField.CLOCK_HOUR_OF_AMPM}
349
+ * * {@link ChronoField.HOUR_OF_DAY}
350
+ * * {@link ChronoField.CLOCK_HOUR_OF_DAY}
351
+ * * {@link ChronoField.AMPM_OF_DAY}
352
+ * * {@link ChronoField.DAY_OF_WEEK}
353
+ * * {@link ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH}
354
+ * * {@link ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR}
355
+ * * {@link ChronoField.DAY_OF_MONTH}
356
+ * * {@link ChronoField.DAY_OF_YEAR}
357
+ * * {@link ChronoField.EPOCH_DAY}
358
+ * * {@link ChronoField.ALIGNED_WEEK_OF_MONTH}
359
+ * * {@link ChronoField.ALIGNED_WEEK_OF_YEAR}
360
+ * * {@link ChronoField.MONTH_OF_YEAR}
361
+ * * {@link ChronoField.EPOCH_MONTH}
362
+ * * {@link ChronoField.YEAR_OF_ERA}
363
+ * * {@link ChronoField.YEAR}
364
+ * * {@link ChronoField.ERA}
365
+ *
366
+ * All other {@link ChronoField} instances will return false.
367
+ *
368
+ * If the field is not a {@link ChronoField}, then the result of this method
369
+ * is obtained by invoking {@link TemporalField.isSupportedBy}
370
+ * passing `this` as the argument.
371
+ * Whether the field is supported is determined by the field.
372
+ *
373
+ * @param {TemporalField|TemporalUnit} fieldOrUnit - the field to check, null returns false
374
+ * @return {boolean} true if the field is supported on this date-time, false if not
375
+ */
376
+ isSupported(fieldOrUnit) {
377
+ if (fieldOrUnit instanceof ChronoField) {
378
+ return fieldOrUnit.isDateBased() || fieldOrUnit.isTimeBased();
379
+ } else if (fieldOrUnit instanceof ChronoUnit) {
380
+ return fieldOrUnit.isDateBased() || fieldOrUnit.isTimeBased();
381
+ }
382
+ return fieldOrUnit != null && fieldOrUnit.isSupportedBy(this);
383
+ }
384
+
385
+ /**
386
+ * Gets the range of valid values for the specified field.
387
+ *
388
+ * The range object expresses the minimum and maximum valid values for a field.
389
+ * This date-time is used to enhance the accuracy of the returned range.
390
+ * If it is not possible to return the range, because the field is not supported
391
+ * or for some other reason, an exception is thrown.
392
+ *
393
+ * If the field is a {@link ChronoField} then the query is implemented here.
394
+ * The supported fields (see {@link isSupported}) will return
395
+ * appropriate range instances.
396
+ * All other {@link ChronoField} instances will throw a {@link DateTimeException}.
397
+ *
398
+ * If the field is not a {@link ChronoField}, then the result of this method
399
+ * is obtained by invoking {@link TemporalField.rangeRefinedBy}
400
+ * passing `this` as the argument.
401
+ * Whether the range can be obtained is determined by the field.
402
+ *
403
+ * @param {!TemporalField} field - the field to query the range for, not null
404
+ * @return {ValueRange} the range of valid values for the field, not null
405
+ * @throws {DateTimeException} if the range for the field cannot be obtained
406
+ */
407
+ range(field) {
408
+ if (field instanceof ChronoField) {
409
+ return (field.isTimeBased() ? this._time.range(field) : this._date.range(field));
410
+ }
411
+ return field.rangeRefinedBy(this);
412
+ }
413
+
414
+ /**
415
+ * Gets the value of the specified field from this date-time as an `int`.
416
+ *
417
+ * This queries this date-time for the value for the specified field.
418
+ * The returned value will always be within the valid range of values for the field.
419
+ * If it is not possible to return the value, because the field is not supported
420
+ * or for some other reason, an exception is thrown.
421
+ *
422
+ * If the field is a {@link ChronoField} then the query is implemented here.
423
+ * The supported fields (see {@link isSupported}) will return valid
424
+ * values based on this date-time, except {@link NANO_OF_DAY}, {@link MICRO_OF_DAY},
425
+ * {@link EPOCH_DAY} and {@link EPOCH_MONTH} which are too large to fit in
426
+ * an `int` and throw a {@link DateTimeException}.
427
+ * All other {@link ChronoField} instances will throw a {@link DateTimeException}.
428
+ *
429
+ * If the field is not a {@link ChronoField}, then the result of this method
430
+ * is obtained by invoking {@link TemporalField.getFrom}
431
+ * passing `this` as the argument. Whether the value can be obtained,
432
+ * and what the value represents, is determined by the field.
433
+ *
434
+ * @param {!TemporalField} field - the field to get, not null
435
+ * @return {number} the value for the field
436
+ * @throws {DateTimeException} if a value for the field cannot be obtained
437
+ * @throws {ArithmeticException} if numeric overflow occurs
438
+ */
439
+ get(field) {
440
+ if (field instanceof ChronoField) {
441
+ return (field.isTimeBased() ? this._time.get(field) : this._date.get(field));
442
+ }
443
+ return super.get(field);
444
+ }
445
+
446
+ /**
447
+ * Gets the value of the specified field from this date-time as a `long`.
448
+ *
449
+ * This queries this date-time for the value for the specified field.
450
+ * If it is not possible to return the value, because the field is not supported
451
+ * or for some other reason, an exception is thrown.
452
+ *
453
+ * If the field is a {@link ChronoField} then the query is implemented here.
454
+ * The supported fields (see {@link isSupported}) will return valid
455
+ * values based on this date-time.
456
+ * All other {@link ChronoField} instances will throw a {@link DateTimeException}.
457
+ *
458
+ * If the field is not a {@link ChronoField}, then the result of this method
459
+ * is obtained by invoking {@link TemporalField.getFrom}
460
+ * passing `this` as the argument. Whether the value can be obtained,
461
+ * and what the value represents, is determined by the field.
462
+ *
463
+ * @param {!TemporalField} field - the field to get, not null
464
+ * @return {number} the value for the field
465
+ * @throws {DateTimeException} if a value for the field cannot be obtained
466
+ * @throws {ArithmeticException} if numeric overflow occurs
467
+ */
468
+ getLong(field) {
469
+ requireNonNull(field, 'field');
470
+ if (field instanceof ChronoField) {
471
+ return (field.isTimeBased() ? this._time.getLong(field) : this._date.getLong(field));
472
+ }
473
+ return field.getFrom(this);
474
+ }
475
+
476
+ //-----------------------------------------------------------------------
477
+ /**
478
+ * Gets the year field.
479
+ *
480
+ * This method returns the primitive `int` value for the year.
481
+ *
482
+ * The year returned by this method is proleptic as per `get(YEAR)`.
483
+ * To obtain the year-of-era, use `get(YEAR_OF_ERA)`.
484
+ *
485
+ * @return {number} the year, from MIN_YEAR to MAX_YEAR
486
+ */
487
+ year() {
488
+ return this._date.year();
489
+ }
490
+
491
+ /**
492
+ * Gets the month-of-year field from 1 to 12.
493
+ *
494
+ * This method returns the month as an `int` from 1 to 12.
495
+ * Application code is frequently clearer if the enum {@link Month}
496
+ * is used by calling {@link getMonth}.
497
+ *
498
+ * @return {number} the month-of-year, from 1 to 12
499
+ * @see #getMonth()
500
+ */
501
+ monthValue() {
502
+ return this._date.monthValue();
503
+ }
504
+
505
+ /**
506
+ * Gets the month-of-year field using the {@link Month} enum.
507
+ *
508
+ * This method returns the enum {@link Month} for the month.
509
+ * This avoids confusion as to what `int` values mean.
510
+ * If you need access to the primitive `int` value, use
511
+ * {@link Month#getValue}.
512
+ *
513
+ * @return {Month} the month-of-year, not null
514
+ * @see #getMonthValue()
515
+ */
516
+ month() {
517
+ return this._date.month();
518
+ }
519
+
520
+ /**
521
+ * Gets the day-of-month field.
522
+ *
523
+ * This method returns the primitive `int` value for the day-of-month.
524
+ *
525
+ * @return {number} the day-of-month, from 1 to 31
526
+ */
527
+ dayOfMonth() {
528
+ return this._date.dayOfMonth();
529
+ }
530
+
531
+ /**
532
+ * Gets the day-of-year field.
533
+ *
534
+ * This method returns the primitive `int` value for the day-of-year.
535
+ *
536
+ * @return {number} the day-of-year, from 1 to 365, or 366 in a leap year
537
+ */
538
+ dayOfYear() {
539
+ return this._date.dayOfYear();
540
+ }
541
+
542
+ /**
543
+ * Gets the day-of-week field, which is an enum {@link DayOfWeek}.
544
+ *
545
+ * This method returns the enum {@link DayOfWeek} for the day-of-week.
546
+ * This avoids confusion as to what `int` values mean.
547
+ * If you need access to the primitive `int` value, use
548
+ * {@link DayOfWeek#getValue}.
549
+ *
550
+ * Additional information can be obtained from the {@link DayOfWeek}.
551
+ * This includes textual names of the values.
552
+ *
553
+ * @return {DayOfWeek} the day-of-week, not null
554
+ */
555
+ dayOfWeek() {
556
+ return this._date.dayOfWeek();
557
+ }
558
+
559
+ //-----------------------------------------------------------------------
560
+ /**
561
+ * Gets the hour-of-day field.
562
+ *
563
+ * @return {number} the hour-of-day, from 0 to 23
564
+ */
565
+ hour() {
566
+ return this._time.hour();
567
+ }
568
+
569
+ /**
570
+ * Gets the minute-of-hour field.
571
+ *
572
+ * @return {number} the minute-of-hour, from 0 to 59
573
+ */
574
+ minute() {
575
+ return this._time.minute();
576
+ }
577
+
578
+ /**
579
+ * Gets the second-of-minute field.
580
+ *
581
+ * @return {number} the second-of-minute, from 0 to 59
582
+ */
583
+ second() {
584
+ return this._time.second();
585
+ }
586
+
587
+ /**
588
+ * Gets the nano-of-second field.
589
+ *
590
+ * @return {number} the nano-of-second, from 0 to 999,999,999
591
+ */
592
+ nano() {
593
+ return this._time.nano();
594
+ }
595
+
596
+ //-----------------------------------------------------------------------
597
+
598
+ /**
599
+ * Returns an adjusted copy of this date-time.
600
+ *
601
+ * This returns a new {@link LocalDateTime}, based on this one, with the date-time adjusted.
602
+ * The adjustment takes place using the specified adjuster strategy object.
603
+ * Read the documentation of the adjuster to understand what adjustment will be made.
604
+ *
605
+ * A simple adjuster might simply set the one of the fields, such as the year field.
606
+ * A more complex adjuster might set the date to the last day of the month.
607
+ * A selection of common adjustments is provided in {@link TemporalAdjusters}.
608
+ * These include finding the 'last day of the month' and 'next Wednesday'.
609
+ * Key date-time classes also implement the {@link TemporalAdjuster} interface,
610
+ * such as {@link Month} and {@link MonthDay}.
611
+ * The adjuster is responsible for handling special cases, such as the varying
612
+ * lengths of month and leap years.
613
+ *
614
+ * For example this code returns a date on the last day of July:
615
+ * <pre>
616
+ * import static org.threeten.bp.Month.*;
617
+ * import static org.threeten.bp.temporal.Adjusters.*;
618
+ *
619
+ * result = localDateTime.with(JULY).with(lastDayOfMonth());
620
+ * </pre>
621
+ *
622
+ * The classes {@link LocalDate} and {@link LocalTime} implement {@link TemporalAdjuster},
623
+ * thus this method can be used to change the date, time or offset:
624
+ * <pre>
625
+ * result = localDateTime.with(date);
626
+ * result = localDateTime.with(time);
627
+ * </pre>
628
+ *
629
+ * The result of this method is obtained by invoking the
630
+ * {@link TemporalAdjuster#adjustInto} method on the
631
+ * specified adjuster passing `this` as the argument.
632
+ *
633
+ * This instance is immutable and unaffected by this method call.
634
+ *
635
+ * @param {TemporalAdjuster} adjuster the adjuster to use, not null
636
+ * @return {LocalDateTime} a {@link LocalDateTime} based on `this` with the adjustment made, not null
637
+ * @throws {DateTimeException} if the adjustment cannot be made
638
+ * @throws {ArithmeticException} if numeric overflow occurs
639
+ */
640
+ withAdjuster(adjuster) {
641
+ requireNonNull(adjuster, 'adjuster');
642
+ // optimizations
643
+ if (adjuster instanceof LocalDate) {
644
+ return this._withDateTime(adjuster, this._time);
645
+ } else if (adjuster instanceof LocalTime) {
646
+ return this._withDateTime(this._date, adjuster);
647
+ } else if (adjuster instanceof LocalDateTime) {
648
+ return adjuster;
649
+ }
650
+ assert(typeof adjuster.adjustInto === 'function', 'adjuster', IllegalArgumentException);
651
+ return adjuster.adjustInto(this);
652
+ }
653
+
654
+ /**
655
+ * Returns a copy of this date-time with the specified field set to a new value.
656
+ *
657
+ * This returns a new {@link LocalDateTime}, based on this one, with the value
658
+ * for the specified field changed.
659
+ * This can be used to change any supported field, such as the year, month or day-of-month.
660
+ * If it is not possible to set the value, because the field is not supported or for
661
+ * some other reason, an exception is thrown.
662
+ *
663
+ * In some cases, changing the specified field can cause the resulting date-time to become invalid,
664
+ * such as changing the month from 31st January to February would make the day-of-month invalid.
665
+ * In cases like this, the field is responsible for resolving the date. Typically it will choose
666
+ * the previous valid date, which would be the last valid day of February in this example.
667
+ *
668
+ * If the field is a {@link ChronoField} then the adjustment is implemented here.
669
+ * The supported fields (see {@link isSupported}) will behave as in
670
+ * {@link LocalDate#with} or {@link LocalTime#with}.
671
+ * All other {@link ChronoField} instances will throw a {@link DateTimeException}.
672
+ *
673
+ * If the field is not a {@link ChronoField}, then the result of this method
674
+ * is obtained by invoking {@link TemporalField.adjustInto}
675
+ * passing `this` as the argument. In this case, the field determines
676
+ * whether and how to adjust the instant.
677
+ *
678
+ * This instance is immutable and unaffected by this method call.
679
+ *
680
+ * @param {TemporalField} field - the field to set in the result, not null
681
+ * @param {number} newValue - the new value of the field in the result
682
+ * @return {LocalDateTime} a {@link LocalDateTime} based on `this` with the specified field set, not null
683
+ * @throws {DateTimeException} if the field cannot be set
684
+ * @throws {ArithmeticException} if numeric overflow occurs
685
+ */
686
+ withFieldValue(field, newValue) {
687
+ requireNonNull(field, 'field');
688
+ if (field instanceof ChronoField) {
689
+ if (field.isTimeBased()) {
690
+ return this._withDateTime(this._date, this._time.with(field, newValue));
691
+ } else {
692
+ return this._withDateTime(this._date.with(field, newValue), this._time);
693
+ }
694
+ }
695
+ return field.adjustInto(this, newValue);
696
+ }
697
+
698
+ //-----------------------------------------------------------------------
699
+ /**
700
+ * Returns a copy of this {@link LocalDateTime} with the year altered.
701
+ * The time does not affect the calculation and will be the same in the result.
702
+ * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month.
703
+ *
704
+ * This instance is immutable and unaffected by this method call.
705
+ *
706
+ * @param {number} year - the year to set in the result, from MIN_YEAR to MAX_YEAR
707
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the requested year, not null
708
+ * @throws {DateTimeException} if the year value is invalid
709
+ */
710
+ withYear(year) {
711
+ return this._withDateTime(this._date.withYear(year), this._time);
712
+ }
713
+
714
+ /**
715
+ * Returns a copy of this {@link LocalDateTime} with the month-of-year altered.
716
+ * The time does not affect the calculation and will be the same in the result.
717
+ * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month.
718
+ *
719
+ * This instance is immutable and unaffected by this method call.
720
+ *
721
+ * @param {!(number|Month)} month - the month-of-year to set in the result, from 1 (January) to 12 (December)
722
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the requested month, not null
723
+ * @throws {DateTimeException} if the month-of-year value is invalid
724
+ */
725
+ withMonth(month) {
726
+ return this._withDateTime(this._date.withMonth(month), this._time);
727
+ }
728
+
729
+ /**
730
+ * Returns a copy of this {@link LocalDateTime} with the day-of-month altered.
731
+ * If the resulting {@link LocalDateTime} is invalid, an exception is thrown.
732
+ * The time does not affect the calculation and will be the same in the result.
733
+ *
734
+ * This instance is immutable and unaffected by this method call.
735
+ *
736
+ * @param {number} dayOfMonth - the day-of-month to set in the result, from 1 to 28-31
737
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the requested day, not null
738
+ * @throws {DateTimeException} if the day-of-month value is invalid
739
+ * @throws {DateTimeException} if the day-of-month is invalid for the month-year
740
+ */
741
+ withDayOfMonth(dayOfMonth) {
742
+ return this._withDateTime(this._date.withDayOfMonth(dayOfMonth), this._time);
743
+ }
744
+
745
+ /**
746
+ * Returns a copy of this {@link LocalDateTime} with the day-of-year altered.
747
+ * If the resulting {@link LocalDateTime} is invalid, an exception is thrown.
748
+ *
749
+ * This instance is immutable and unaffected by this method call.
750
+ *
751
+ * @param {number} dayOfYear - the day-of-year to set in the result, from 1 to 365-366
752
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date with the requested day, not null
753
+ * @throws {DateTimeException} if the day-of-year value is invalid
754
+ * @throws {DateTimeException} if the day-of-year is invalid for the year
755
+ */
756
+ withDayOfYear(dayOfYear) {
757
+ return this._withDateTime(this._date.withDayOfYear(dayOfYear), this._time);
758
+ }
759
+
760
+ //-----------------------------------------------------------------------
761
+ /**
762
+ * Returns a copy of this {@link LocalDateTime} with the hour-of-day value altered.
763
+ *
764
+ * This instance is immutable and unaffected by this method call.
765
+ *
766
+ * @param {number} hour - the hour-of-day to set in the result, from 0 to 23
767
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the requested hour, not null
768
+ * @throws {DateTimeException} if the hour value is invalid
769
+ */
770
+ withHour(hour) {
771
+ const newTime = this._time.withHour(hour);
772
+ return this._withDateTime(this._date, newTime);
773
+ }
774
+
775
+ /**
776
+ * Returns a copy of this {@link LocalDateTime} with the minute-of-hour value altered.
777
+ *
778
+ * This instance is immutable and unaffected by this method call.
779
+ *
780
+ * @param {number} minute - the minute-of-hour to set in the result, from 0 to 59
781
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the requested minute, not null
782
+ * @throws {DateTimeException} if the minute value is invalid
783
+ */
784
+ withMinute(minute) {
785
+ const newTime = this._time.withMinute(minute);
786
+ return this._withDateTime(this._date, newTime);
787
+ }
788
+
789
+ /**
790
+ * Returns a copy of this {@link LocalDateTime} with the second-of-minute value altered.
791
+ *
792
+ * This instance is immutable and unaffected by this method call.
793
+ *
794
+ * @param {number} second - the second-of-minute to set in the result, from 0 to 59
795
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the requested second, not null
796
+ * @throws {DateTimeException} if the second value is invalid
797
+ */
798
+ withSecond(second) {
799
+ const newTime = this._time.withSecond(second);
800
+ return this._withDateTime(this._date, newTime);
801
+ }
802
+
803
+ /**
804
+ * Returns a copy of this {@link LocalDateTime} with the nano-of-second value altered.
805
+ *
806
+ * This instance is immutable and unaffected by this method call.
807
+ *
808
+ * @param {number} nanoOfSecond - the nano-of-second to set in the result, from 0 to 999,999,999
809
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the requested nanosecond, not null
810
+ * @throws {DateTimeException} if the nano value is invalid
811
+ */
812
+ withNano(nanoOfSecond) {
813
+ const newTime = this._time.withNano(nanoOfSecond);
814
+ return this._withDateTime(this._date, newTime);
815
+ }
816
+
817
+ //-----------------------------------------------------------------------
818
+ /**
819
+ * Returns a copy of this {@link LocalDateTime} with the time truncated.
820
+ *
821
+ * Truncation returns a copy of the original date-time with fields
822
+ * smaller than the specified unit set to zero.
823
+ * For example, truncating with {@link ChronoUnit#MINUTES}
824
+ * will set the second-of-minute and nano-of-second field to zero.
825
+ *
826
+ * The unit must have a duration (see {@link TemporalUnit#getDuration})
827
+ * that divides into the length of a standard day without remainder.
828
+ * This includes all supplied time units on {@link ChronoUnit} and
829
+ * {@link ChronoUnit#DAYS}. Other units throw an exception.
830
+ *
831
+ * This instance is immutable and unaffected by this method call.
832
+ *
833
+ * @param {TemporalUnit} unit - the unit to truncate to, not null
834
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the time truncated, not null
835
+ * @throws {DateTimeException} if unable to truncate
836
+ */
837
+ truncatedTo(unit) {
838
+ return this._withDateTime(this._date, this._time.truncatedTo(unit));
839
+ }
840
+
841
+ //-----------------------------------------------------------------------
842
+
843
+ /**
844
+ * Returns a copy of this date-time with the specified period added.
845
+ *
846
+ * This method returns a new date-time based on this time with the specified period added.
847
+ * The amount is typically {@link Period} but may be any other type implementing
848
+ * the {@link TemporalAmount} interface.
849
+ * The calculation is delegated to the specified adjuster, which typically calls
850
+ * back to {@link plus}.
851
+ *
852
+ * This instance is immutable and unaffected by this method call.
853
+ *
854
+ * @param {TemporalAmount} amount - the amount to add, not null
855
+ * @return {LocalDateTime} based on this date-time with the addition made, not null
856
+ * @throws {DateTimeException} if the addition cannot be made
857
+ * @throws {ArithmeticException} if numeric overflow occurs
858
+ */
859
+ plusAmount(amount) {
860
+ requireNonNull(amount, 'amount');
861
+ return amount.addTo(this);
862
+ }
863
+
864
+ /**
865
+ * Returns a copy of this date-time with the specified period added.
866
+ *
867
+ * This method returns a new date-time based on this date-time with the specified period added.
868
+ * This can be used to add any period that is defined by a unit, for example to add years, months or days.
869
+ * The unit is responsible for the details of the calculation, including the resolution
870
+ * of any edge cases in the calculation.
871
+ *
872
+ * This instance is immutable and unaffected by this method call.
873
+ *
874
+ * @param {number} amountToAdd - the amount of the unit to add to the result, may be negative
875
+ * @param {!TemporalUnit} unit - the unit of the period to add, not null
876
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the specified period added, not null
877
+ * @throws {DateTimeException} if the unit cannot be added to this type
878
+ */
879
+ plusAmountUnit(amountToAdd, unit) {
880
+ requireNonNull(unit, 'unit');
881
+ if (unit instanceof ChronoUnit) {
882
+ switch (unit) {
883
+ case ChronoUnit.NANOS: return this.plusNanos(amountToAdd);
884
+ case ChronoUnit.MICROS: return this.plusDays(MathUtil.intDiv(amountToAdd, LocalTime.MICROS_PER_DAY)).plusNanos(MathUtil.intMod(amountToAdd, LocalTime.MICROS_PER_DAY) * 1000);
885
+ case ChronoUnit.MILLIS: return this.plusDays(MathUtil.intDiv(amountToAdd, LocalTime.MILLIS_PER_DAY)).plusNanos(MathUtil.intMod(amountToAdd, LocalTime.MILLIS_PER_DAY) * 1000000);
886
+ case ChronoUnit.SECONDS: return this.plusSeconds(amountToAdd);
887
+ case ChronoUnit.MINUTES: return this.plusMinutes(amountToAdd);
888
+ case ChronoUnit.HOURS: return this.plusHours(amountToAdd);
889
+ case ChronoUnit.HALF_DAYS: return this.plusDays(MathUtil.intDiv(amountToAdd, 256)).plusHours(MathUtil.intMod(amountToAdd, 256) * 12); // no overflow (256 is multiple of 2)
890
+ }
891
+ return this._withDateTime(this._date.plus(amountToAdd, unit), this._time);
892
+ }
893
+ return unit.addTo(this, amountToAdd);
894
+ }
895
+
896
+ //-----------------------------------------------------------------------
897
+ /**
898
+ * Returns a copy of this {@link LocalDateTime} with the specified period in years added.
899
+ *
900
+ * This method adds the specified amount to the years field in three steps:
901
+ *
902
+ * 1. Add the input years to the year field
903
+ * 2. Check if the resulting date would be invalid
904
+ * 3. Adjust the day-of-month to the last valid day if necessary
905
+ *
906
+ * For example, 2008-02-29 (leap year) plus one year would result in the
907
+ * invalid date 2009-02-29 (standard year). Instead of returning an invalid
908
+ * result, the last valid day of the month, 2009-02-28, is selected instead.
909
+ *
910
+ * This instance is immutable and unaffected by this method call.
911
+ *
912
+ * @param {number} years - the years to add, may be negative
913
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the years added, not null
914
+ * @throws {DateTimeException} if the result exceeds the supported date range
915
+ */
916
+ plusYears(years) {
917
+ const newDate = this._date.plusYears(years);
918
+ return this._withDateTime(newDate, this._time);
919
+ }
920
+
921
+ /**
922
+ * Returns a copy of this {@link LocalDateTime} with the specified period in months added.
923
+ *
924
+ * This method adds the specified amount to the months field in three steps:
925
+ *
926
+ * 1. Add the input months to the month-of-year field
927
+ * 2. Check if the resulting date would be invalid
928
+ * 3. Adjust the day-of-month to the last valid day if necessary
929
+ *
930
+ * For example, 2007-03-31 plus one month would result in the invalid date
931
+ * 2007-04-31. Instead of returning an invalid result, the last valid day
932
+ * of the month, 2007-04-30, is selected instead.
933
+ *
934
+ * This instance is immutable and unaffected by this method call.
935
+ *
936
+ * @param {number} months - the months to add, may be negative
937
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the months added, not null
938
+ * @throws {DateTimeException} if the result exceeds the supported date range
939
+ */
940
+ plusMonths(months) {
941
+ const newDate = this._date.plusMonths(months);
942
+ return this._withDateTime(newDate, this._time);
943
+ }
944
+
945
+ /**
946
+ * Returns a copy of this {@link LocalDateTime} with the specified period in weeks added.
947
+ *
948
+ * This method adds the specified amount in weeks to the days field incrementing
949
+ * the month and year fields as necessary to ensure the result remains valid.
950
+ * The result is only invalid if the maximum/minimum year is exceeded.
951
+ *
952
+ * For example, 2008-12-31 plus one week would result in 2009-01-07.
953
+ *
954
+ * This instance is immutable and unaffected by this method call.
955
+ *
956
+ * @param {number} weeks - the weeks to add, may be negative
957
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the weeks added, not null
958
+ * @throws {DateTimeException} if the result exceeds the supported date range
959
+ */
960
+ plusWeeks(weeks) {
961
+ const newDate = this._date.plusWeeks(weeks);
962
+ return this._withDateTime(newDate, this._time);
963
+ }
964
+
965
+ /**
966
+ * Returns a copy of this {@link LocalDateTime} with the specified period in days added.
967
+ *
968
+ * This method adds the specified amount to the days field incrementing the
969
+ * month and year fields as necessary to ensure the result remains valid.
970
+ * The result is only invalid if the maximum/minimum year is exceeded.
971
+ *
972
+ * For example, 2008-12-31 plus one day would result in 2009-01-01.
973
+ *
974
+ * This instance is immutable and unaffected by this method call.
975
+ *
976
+ * @param {number} days - the days to add, may be negative
977
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the days added, not null
978
+ * @throws {DateTimeException} if the result exceeds the supported date range
979
+ */
980
+ plusDays(days) {
981
+ const newDate = this._date.plusDays(days);
982
+ return this._withDateTime(newDate, this._time);
983
+ }
984
+
985
+ //-----------------------------------------------------------------------
986
+ /**
987
+ * Returns a copy of this {@link LocalDateTime} with the specified period in hours added.
988
+ *
989
+ * This instance is immutable and unaffected by this method call.
990
+ *
991
+ * @param {number} hours - the hours to add, may be negative
992
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the hours added, not null
993
+ * @throws {DateTimeException} if the result exceeds the supported date range
994
+ */
995
+ plusHours(hours) {
996
+ return this._plusWithOverflow(this._date, hours, 0, 0, 0, 1);
997
+ }
998
+
999
+ /**
1000
+ * Returns a copy of this {@link LocalDateTime} with the specified period in minutes added.
1001
+ *
1002
+ * This instance is immutable and unaffected by this method call.
1003
+ *
1004
+ * @param {number} minutes - the minutes to add, may be negative
1005
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the minutes added, not null
1006
+ * @throws {DateTimeException} if the result exceeds the supported date range
1007
+ */
1008
+ plusMinutes(minutes) {
1009
+ return this._plusWithOverflow(this._date, 0, minutes, 0, 0, 1);
1010
+ }
1011
+
1012
+ /**
1013
+ * Returns a copy of this {@link LocalDateTime} with the specified period in seconds added.
1014
+ *
1015
+ * This instance is immutable and unaffected by this method call.
1016
+ *
1017
+ * @param {number} seconds - the seconds to add, may be negative
1018
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the seconds added, not null
1019
+ * @throws {DateTimeException} if the result exceeds the supported date range
1020
+ */
1021
+ plusSeconds(seconds) {
1022
+ return this._plusWithOverflow(this._date, 0, 0, seconds, 0, 1);
1023
+ }
1024
+
1025
+ /**
1026
+ * Returns a copy of this {@link LocalDateTime} with the specified period in nanoseconds added.
1027
+ *
1028
+ * This instance is immutable and unaffected by this method call.
1029
+ *
1030
+ * @param {number} nanos - the nanos to add, may be negative
1031
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the nanoseconds added, not null
1032
+ * @throws {DateTimeException} if the result exceeds the supported date range
1033
+ */
1034
+ plusNanos(nanos) {
1035
+ return this._plusWithOverflow(this._date, 0, 0, 0, nanos, 1);
1036
+ }
1037
+
1038
+ //-----------------------------------------------------------------------
1039
+
1040
+ /**
1041
+ * Returns a copy of this date-time with the specified period subtracted.
1042
+ *
1043
+ * This method returns a new date-time based on this time with the specified period subtracted.
1044
+ * The amount is typically {@link Period} but may be any other type implementing
1045
+ * the {@link TemporalAmount} interface.
1046
+ * The calculation is delegated to the specified adjuster, which typically calls
1047
+ * back to {@link minus}.
1048
+ *
1049
+ * This instance is immutable and unaffected by this method call.
1050
+ *
1051
+ * @param {TemporalAmount} amount - the amount to subtract, not null
1052
+ * @return {LocalDateTime} based on this date-time with the subtraction made, not null
1053
+ * @throws {DateTimeException} if the subtraction cannot be made
1054
+ * @throws {ArithmeticException} if numeric overflow occurs
1055
+ */
1056
+ minusAmount(amount) {
1057
+ requireNonNull(amount, 'amount');
1058
+ return amount.subtractFrom(this);
1059
+ }
1060
+
1061
+ /**
1062
+ * Returns a copy of this date-time with the specified period subtracted.
1063
+ *
1064
+ * This method returns a new date-time based on this date-time with the specified period subtracted.
1065
+ * This can be used to subtract any period that is defined by a unit, for example to subtract years, months or days.
1066
+ * The unit is responsible for the details of the calculation, including the resolution
1067
+ * of any edge cases in the calculation.
1068
+ *
1069
+ * This instance is immutable and unaffected by this method call.
1070
+ *
1071
+ * @param {number} amountToSubtract - the amount of the unit to subtract from the result, may be negative
1072
+ * @param {TemporalUnit} unit - the unit of the period to subtract, not null
1073
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the specified period subtracted, not null
1074
+ * @throws {DateTimeException} if the unit cannot be added to this type
1075
+ */
1076
+ minusAmountUnit(amountToSubtract, unit) {
1077
+ requireNonNull(unit, 'unit');
1078
+ return this.plusAmountUnit(-1 * amountToSubtract, unit);
1079
+ }
1080
+
1081
+ //-----------------------------------------------------------------------
1082
+ /**
1083
+ * Returns a copy of this {@link LocalDateTime} with the specified period in years subtracted.
1084
+ *
1085
+ * This method subtracts the specified amount from the years field in three steps:
1086
+ *
1087
+ * 1. Subtract the input years from the year field
1088
+ * 2. Check if the resulting date would be invalid
1089
+ * 3. Adjust the day-of-month to the last valid day if necessary
1090
+ *
1091
+ * For example, 2008-02-29 (leap year) minus one year would result in the
1092
+ * invalid date 2009-02-29 (standard year). Instead of returning an invalid
1093
+ * result, the last valid day of the month, 2009-02-28, is selected instead.
1094
+ *
1095
+ * This instance is immutable and unaffected by this method call.
1096
+ *
1097
+ * @param {number} years - the years to subtract, may be negative
1098
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the years subtracted, not null
1099
+ * @throws {DateTimeException} if the result exceeds the supported date range
1100
+ */
1101
+ minusYears(years) {
1102
+ return this.plusYears(-1 * years);
1103
+ }
1104
+
1105
+ /**
1106
+ * Returns a copy of this {@link LocalDateTime} with the specified period in months subtracted.
1107
+ *
1108
+ * This method subtracts the specified amount from the months field in three steps:
1109
+ *
1110
+ * 1. Subtract the input months from the month-of-year field
1111
+ * 2. Check if the resulting date would be invalid
1112
+ * 3. Adjust the day-of-month to the last valid day if necessary
1113
+ *
1114
+ * For example, 2007-03-31 minus one month would result in the invalid date
1115
+ * 2007-04-31. Instead of returning an invalid result, the last valid day
1116
+ * of the month, 2007-04-30, is selected instead.
1117
+ *
1118
+ * This instance is immutable and unaffected by this method call.
1119
+ *
1120
+ * @param {number} months - the months to subtract, may be negative
1121
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the months subtracted, not null
1122
+ * @throws {DateTimeException} if the result exceeds the supported date range
1123
+ */
1124
+ minusMonths(months) {
1125
+ return this.plusMonths(-1 * months);
1126
+ }
1127
+
1128
+ /**
1129
+ * Returns a copy of this {@link LocalDateTime} with the specified period in weeks subtracted.
1130
+ *
1131
+ * This method subtracts the specified amount in weeks from the days field decrementing
1132
+ * the month and year fields as necessary to ensure the result remains valid.
1133
+ * The result is only invalid if the maximum/minimum year is exceeded.
1134
+ *
1135
+ * For example, 2009-01-07 minus one week would result in 2008-12-31.
1136
+ *
1137
+ * This instance is immutable and unaffected by this method call.
1138
+ *
1139
+ * @param {number} weeks - the weeks to subtract, may be negative
1140
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the weeks subtracted, not null
1141
+ * @throws {DateTimeException} if the result exceeds the supported date range
1142
+ */
1143
+ minusWeeks(weeks) {
1144
+ return this.plusWeeks(-1 * weeks);
1145
+ }
1146
+
1147
+ /**
1148
+ * Returns a copy of this {@link LocalDateTime} with the specified period in days subtracted.
1149
+ *
1150
+ * This method subtracts the specified amount from the days field incrementing the
1151
+ * month and year fields as necessary to ensure the result remains valid.
1152
+ * The result is only invalid if the maximum/minimum year is exceeded.
1153
+ *
1154
+ * For example, 2009-01-01 minus one day would result in 2008-12-31.
1155
+ *
1156
+ * This instance is immutable and unaffected by this method call.
1157
+ *
1158
+ * @param {number} days - the days to subtract, may be negative
1159
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the days subtracted, not null
1160
+ * @throws {DateTimeException} if the result exceeds the supported date range
1161
+ */
1162
+ minusDays(days) {
1163
+ return this.plusDays(-1 * days);
1164
+ }
1165
+
1166
+ //-----------------------------------------------------------------------
1167
+ /**
1168
+ * Returns a copy of this {@link LocalDateTime} with the specified period in hours subtracted.
1169
+ *
1170
+ * This instance is immutable and unaffected by this method call.
1171
+ *
1172
+ * @param {number} hours - the hours to subtract, may be negative
1173
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the hours subtracted, not null
1174
+ * @throws {DateTimeException} if the result exceeds the supported date range
1175
+ */
1176
+ minusHours(hours) {
1177
+ return this._plusWithOverflow(this._date, hours, 0, 0, 0, -1);
1178
+ }
1179
+
1180
+ /**
1181
+ * Returns a copy of this {@link LocalDateTime} with the specified period in minutes subtracted.
1182
+ *
1183
+ * This instance is immutable and unaffected by this method call.
1184
+ *
1185
+ * @param {number} minutes - the minutes to subtract, may be negative
1186
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the minutes subtracted, not null
1187
+ * @throws {DateTimeException} if the result exceeds the supported date range
1188
+ */
1189
+ minusMinutes(minutes) {
1190
+ return this._plusWithOverflow(this._date, 0, minutes, 0, 0, -1);
1191
+ }
1192
+
1193
+ /**
1194
+ * Returns a copy of this {@link LocalDateTime} with the specified period in seconds subtracted.
1195
+ *
1196
+ * This instance is immutable and unaffected by this method call.
1197
+ *
1198
+ * @param {number} seconds - the seconds to subtract, may be negative
1199
+ * @return {LocalDateTime} a {@link LocalDateTime} based on this date-time with the seconds subtracted, not null
1200
+ * @throws {DateTimeException} if the result exceeds the supported date range
1201
+ */
1202
+ minusSeconds(seconds) {
1203
+ return this._plusWithOverflow(this._date, 0, 0, seconds, 0, -1);
1204
+ }
1205
+
1206
+ /**
1207
+ * Returns a copy of this {@link LocalDateTime} with the specified period in nanoseconds subtracted.
1208
+ *
1209
+ * This instance is immutable and unaffected by this method call.
1210
+ *
1211
+ * @param {Number} nanos - the nanos to subtract, may be negative
1212
+ * @return {LocalDateTime} based on this date-time with the nanoseconds subtracted, not null
1213
+ * @throws {DateTimeException} if the result exceeds the supported date range
1214
+ */
1215
+ minusNanos(nanos) {
1216
+ return this._plusWithOverflow(this._date, 0, 0, 0, nanos, -1);
1217
+ }
1218
+
1219
+ //-----------------------------------------------------------------------
1220
+ /**
1221
+ * Returns a copy of this {@link LocalDateTime} with the specified period added.
1222
+ *
1223
+ * This instance is immutable and unaffected by this method call.
1224
+ *
1225
+ * @param {LocalDate} newDate the new date to base the calculation on, not null
1226
+ * @param {Number} hours - the hours to add, may be negative
1227
+ * @param {Number} minutes - the minutes to add, may be negative
1228
+ * @param {Number} seconds - the seconds to add, may be negative
1229
+ * @param {Number} nanos - the nanos to add, may be negative
1230
+ * @param {Number} sign - the sign to determine add or subtract
1231
+ * @return {LocalDateTime} the combined result, not null
1232
+ */
1233
+ _plusWithOverflow(newDate, hours, minutes, seconds, nanos, sign) {
1234
+ // 9223372036854775808 long, 2147483648 int
1235
+ if (hours === 0 && minutes === 0 && seconds === 0 && nanos === 0) {
1236
+ return this._withDateTime(newDate, this._time);
1237
+ }
1238
+ let totDays = MathUtil.intDiv(nanos, LocalTime.NANOS_PER_DAY) + // max/24*60*60*1B
1239
+ MathUtil.intDiv(seconds, LocalTime.SECONDS_PER_DAY) + // max/24*60*60
1240
+ MathUtil.intDiv(minutes, LocalTime.MINUTES_PER_DAY) + // max/24*60
1241
+ MathUtil.intDiv(hours, LocalTime.HOURS_PER_DAY); // max/24
1242
+ totDays *= sign; // total max*0.4237...
1243
+ let totNanos = MathUtil.intMod(nanos, LocalTime.NANOS_PER_DAY) + // max 86400000000000
1244
+ (MathUtil.intMod(seconds, LocalTime.SECONDS_PER_DAY)) * LocalTime.NANOS_PER_SECOND + // max 86400000000000
1245
+ (MathUtil.intMod(minutes, LocalTime.MINUTES_PER_DAY)) * LocalTime.NANOS_PER_MINUTE + // max 86400000000000
1246
+ (MathUtil.intMod(hours, LocalTime.HOURS_PER_DAY)) * LocalTime.NANOS_PER_HOUR; // max 86400000000000
1247
+ const curNoD = this._time.toNanoOfDay(); // max 86400000000000
1248
+ totNanos = totNanos * sign + curNoD; // total 432000000000000
1249
+ totDays += MathUtil.floorDiv(totNanos, LocalTime.NANOS_PER_DAY);
1250
+ const newNoD = MathUtil.floorMod(totNanos, LocalTime.NANOS_PER_DAY);
1251
+ const newTime = (newNoD === curNoD ? this._time : LocalTime.ofNanoOfDay(newNoD));
1252
+ return this._withDateTime(newDate.plusDays(totDays), newTime);
1253
+ }
1254
+
1255
+ //-----------------------------------------------------------------------
1256
+ /**
1257
+ * Queries this date-time using the specified query.
1258
+ *
1259
+ * This queries this date-time using the specified query strategy object.
1260
+ * The {@link TemporalQuery} object defines the logic to be used to
1261
+ * obtain the result. Read the documentation of the query to understand
1262
+ * what the result of this method will be.
1263
+ *
1264
+ * The result of this method is obtained by invoking the
1265
+ * {@link TemporalQuery#queryFrom} method on the
1266
+ * specified query passing `this` as the argument.
1267
+ *
1268
+ * @param {TemporalQuery} query the query to invoke, not null
1269
+ * @return {*} the query result, null may be returned (defined by the query)
1270
+ * @throws {DateTimeException} if unable to query (defined by the query)
1271
+ * @throws {ArithmeticException} if numeric overflow occurs (defined by the query)
1272
+ */
1273
+ query(query) {
1274
+ requireNonNull(query, 'query');
1275
+ if (query === TemporalQueries.localDate()) {
1276
+ return this.toLocalDate();
1277
+ }
1278
+ return super.query(query);
1279
+ }
1280
+
1281
+ /**
1282
+ * Adjusts the specified temporal object to have the same date and time as this object.
1283
+ *
1284
+ * This returns a temporal object of the same observable type as the input
1285
+ * with the date and time changed to be the same as this.
1286
+ *
1287
+ * The adjustment is equivalent to using {@link Temporal#with}
1288
+ * twice, passing {@link ChronoField#EPOCH_DAY} and
1289
+ * {@link ChronoField#NANO_OF_DAY} as the fields.
1290
+ *
1291
+ * In most cases, it is clearer to reverse the calling pattern by using
1292
+ * {@link Temporal#with}:
1293
+ * <pre>
1294
+ * // these two lines are equivalent, but the second approach is recommended
1295
+ * temporal = thisLocalDateTime.adjustInto(temporal);
1296
+ * temporal = temporal.with(thisLocalDateTime);
1297
+ * </pre>
1298
+ *
1299
+ * This instance is immutable and unaffected by this method call.
1300
+ *
1301
+ * @param {TemporalAdjuster} temporal - the target object to be adjusted, not null
1302
+ * @return {LocalDateTime} the adjusted object, not null
1303
+ * @throws {DateTimeException} if unable to make the adjustment
1304
+ * @throws {ArithmeticException} if numeric overflow occurs
1305
+ */
1306
+ adjustInto(temporal) {
1307
+ return super.adjustInto(temporal);
1308
+ }
1309
+
1310
+ /**
1311
+ * Calculates the period between this date-time and another date-time in
1312
+ * terms of the specified unit.
1313
+ *
1314
+ * This calculates the period between two date-times in terms of a single unit.
1315
+ * The start and end points are `this` and the specified date-time.
1316
+ * The result will be negative if the end is before the start.
1317
+ * The {@link Temporal} passed to this method must be a {@link LocalDateTime}.
1318
+ * For example, the period in days between two date-times can be calculated
1319
+ * using `startDateTime.until(endDateTime, DAYS)`.
1320
+ *
1321
+ * The calculation returns a whole number, representing the number of
1322
+ * complete units between the two date-times.
1323
+ * For example, the period in months between 2012-06-15T00:00 and 2012-08-14T23:59
1324
+ * will only be one month as it is one minute short of two months.
1325
+ *
1326
+ * This method operates in association with {@link TemporalUnit#between}.
1327
+ * The result of this method is a `long` representing the amount of
1328
+ * the specified unit. By contrast, the result of {@link between} is an
1329
+ * object that can be used directly in addition/subtraction:
1330
+ * <pre>
1331
+ * long period = start.until(end, MONTHS); // this method
1332
+ * dateTime.plus(MONTHS.between(start, end)); // use in plus/minus
1333
+ * </pre>
1334
+ *
1335
+ * The calculation is implemented in this method for {@link ChronoUnit}.
1336
+ * The units {@link NANOS}, {@link MICROS}, {@link MILLIS}, {@link SECONDS},
1337
+ * {@link MINUTES}, {@link HOURS} and {@link HALF_DAYS}, {@link DAYS},
1338
+ * {@link WEEKS}, {@link MONTHS}, {@link YEARS}, {@link DECADES},
1339
+ * {@link CENTURIES}, {@link MILLENNIA} and {@link ERAS} are supported.
1340
+ * Other {@link ChronoUnit} values will throw an exception.
1341
+ *
1342
+ * If the unit is not a {@link ChronoUnit}, then the result of this method
1343
+ * is obtained by invoking {@link TemporalUnit.between}
1344
+ * passing `this` as the first argument and the input temporal as
1345
+ * the second argument.
1346
+ *
1347
+ * This instance is immutable and unaffected by this method call.
1348
+ *
1349
+ * @param {Temporal} endExclusive - the end date-time, which is converted to a {@link LocalDateTime}, not null
1350
+ * @param {TemporalUnit} unit - the unit to measure the period in, not null
1351
+ * @return {number} the amount of the period between this date-time and the end date-time
1352
+ * @throws {DateTimeException} if the period cannot be calculated
1353
+ * @throws {ArithmeticException} if numeric overflow occurs
1354
+ */
1355
+ until(endExclusive, unit) {
1356
+ requireNonNull(endExclusive, 'endExclusive');
1357
+ requireNonNull(unit, 'unit');
1358
+ const end = LocalDateTime.from(endExclusive);
1359
+ if (unit instanceof ChronoUnit) {
1360
+ if (unit.isTimeBased()) {
1361
+ let daysUntil = this._date.daysUntil(end._date);
1362
+ let timeUntil = end._time.toNanoOfDay() - this._time.toNanoOfDay();
1363
+ if (daysUntil > 0 && timeUntil < 0) {
1364
+ daysUntil--;
1365
+ timeUntil += LocalTime.NANOS_PER_DAY;
1366
+ } else if (daysUntil < 0 && timeUntil > 0) {
1367
+ daysUntil++;
1368
+ timeUntil -= LocalTime.NANOS_PER_DAY;
1369
+ }
1370
+ let amount = daysUntil;
1371
+ switch (unit) {
1372
+ case ChronoUnit.NANOS:
1373
+ amount = MathUtil.safeMultiply(amount, LocalTime.NANOS_PER_DAY);
1374
+ return MathUtil.safeAdd(amount, timeUntil);
1375
+ case ChronoUnit.MICROS:
1376
+ amount = MathUtil.safeMultiply(amount, LocalTime.MICROS_PER_DAY);
1377
+ return MathUtil.safeAdd(amount, MathUtil.intDiv(timeUntil, 1000));
1378
+ case ChronoUnit.MILLIS:
1379
+ amount = MathUtil.safeMultiply(amount, LocalTime.MILLIS_PER_DAY);
1380
+ return MathUtil.safeAdd(amount, MathUtil.intDiv(timeUntil, 1000000));
1381
+ case ChronoUnit.SECONDS:
1382
+ amount = MathUtil.safeMultiply(amount, LocalTime.SECONDS_PER_DAY);
1383
+ return MathUtil.safeAdd(amount, MathUtil.intDiv(timeUntil, LocalTime.NANOS_PER_SECOND));
1384
+ case ChronoUnit.MINUTES:
1385
+ amount = MathUtil.safeMultiply(amount, LocalTime.MINUTES_PER_DAY);
1386
+ return MathUtil.safeAdd(amount, MathUtil.intDiv(timeUntil, LocalTime.NANOS_PER_MINUTE));
1387
+ case ChronoUnit.HOURS:
1388
+ amount = MathUtil.safeMultiply(amount, LocalTime.HOURS_PER_DAY);
1389
+ return MathUtil.safeAdd(amount, MathUtil.intDiv(timeUntil, LocalTime.NANOS_PER_HOUR));
1390
+ case ChronoUnit.HALF_DAYS:
1391
+ amount = MathUtil.safeMultiply(amount, 2);
1392
+ return MathUtil.safeAdd(amount, MathUtil.intDiv(timeUntil, (LocalTime.NANOS_PER_HOUR * 12)));
1393
+ }
1394
+ throw new UnsupportedTemporalTypeException('Unsupported unit: ' + unit);
1395
+ }
1396
+ let endDate = end._date;
1397
+ const endTime = end._time;
1398
+ if (endDate.isAfter(this._date) && endTime.isBefore(this._time)) {
1399
+ endDate = endDate.minusDays(1);
1400
+ } else if (endDate.isBefore(this._date) && endTime.isAfter(this._time)) {
1401
+ endDate = endDate.plusDays(1);
1402
+ }
1403
+ return this._date.until(endDate, unit);
1404
+ }
1405
+ return unit.between(this, end);
1406
+ }
1407
+
1408
+ //-----------------------------------------------------------------------
1409
+ /**
1410
+ * Combines this date-time with an offset to create an {@link OffsetDateTime}.
1411
+ *
1412
+ * This returns an {@link OffsetDateTime} formed from this date-time at the specified offset.
1413
+ * All possible combinations of date-time and offset are valid.
1414
+ *
1415
+ * @param {ZoneOffset} offset the offset to combine with, not null
1416
+ * @return {OffsetDateTime} the offset date-time formed from this date-time and the specified offset, not null
1417
+ */
1418
+ atOffset(offset) {
1419
+ return OffsetDateTime.of(this, offset);
1420
+ }
1421
+
1422
+ /**
1423
+ * Combines this date-time with a time-zone to create a {@link ZonedDateTime}.
1424
+ *
1425
+ * This returns a {@link ZonedDateTime} formed from this date-time at the
1426
+ * specified time-zone. The result will match this date-time as closely as possible.
1427
+ * Time-zone rules, such as daylight savings, mean that not every local date-time
1428
+ * is valid for the specified zone, thus the local date-time may be adjusted.
1429
+ *
1430
+ * The local date-time is resolved to a single instant on the time-line.
1431
+ * This is achieved by finding a valid offset from UTC/Greenwich for the local
1432
+ * date-time as defined by the {@link ZoneRules} of the zone ID.
1433
+ *
1434
+ * In most cases, there is only one valid offset for a local date-time.
1435
+ * In the case of an overlap, where clocks are set back, there are two valid offsets.
1436
+ * This method uses the earlier offset typically corresponding to 'summer'.
1437
+ *
1438
+ * In the case of a gap, where clocks jump forward, there is no valid offset.
1439
+ * Instead, the local date-time is adjusted to be later by the length of the gap.
1440
+ * For a typical one hour daylight savings change, the local date-time will be
1441
+ * moved one hour later into the offset typically corresponding to 'summer'.
1442
+ *
1443
+ * To obtain the later offset during an overlap, call
1444
+ * {@link ZonedDateTime#withLaterOffsetAtOverlap} on the result of this method.
1445
+ * To throw an exception when there is a gap or overlap, use
1446
+ * {@link ZonedDateTime#ofStrict}.
1447
+ *
1448
+ * @param {ZoneId} zone the time-zone to use, not null
1449
+ * @return {ZonedDateTime} the zoned date-time formed from this date-time, not null
1450
+ */
1451
+ atZone(zone) {
1452
+ return ZonedDateTime.of(this, zone);
1453
+ }
1454
+
1455
+ //-----------------------------------------------------------------------
1456
+ /**
1457
+ * Gets the {@link LocalDate} part of this date-time.
1458
+ *
1459
+ * This returns a {@link LocalDate} with the same year, month and day
1460
+ * as this date-time.
1461
+ *
1462
+ * @return {LocalDate} the date part of this date-time, not null
1463
+ */
1464
+ toLocalDate() {
1465
+ return this._date;
1466
+ }
1467
+
1468
+ /**
1469
+ * Gets the {@link LocalTime} part of this date-time.
1470
+ *
1471
+ * This returns a {@link LocalTime} with the same hour, minute, second and
1472
+ * nanosecond as this date-time.
1473
+ *
1474
+ * @return {LocalTime} the time part of this date-time, not null
1475
+ */
1476
+ toLocalTime() {
1477
+ return this._time;
1478
+ }
1479
+
1480
+ //-----------------------------------------------------------------------
1481
+ /**
1482
+ * Compares this date-time to another date-time.
1483
+ *
1484
+ * The comparison is primarily based on the date-time, from earliest to latest.
1485
+ * It is 'consistent with equals', as defined by {@link Comparable}.
1486
+ *
1487
+ * If all the date-times being compared are instances of {@link LocalDateTime},
1488
+ * then the comparison will be entirely based on the date-time.
1489
+ * If some dates being compared are in different chronologies, then the
1490
+ * chronology is also considered, see {@link ChronoLocalDateTime#compareTo}.
1491
+ *
1492
+ * @param {!LocalDateTime} other - the other date-time to compare to, not null
1493
+ * @return {number} the comparator value, negative if less, positive if greater
1494
+ */
1495
+ compareTo(other) {
1496
+ requireNonNull(other, 'other');
1497
+ requireInstance(other, LocalDateTime, 'other');
1498
+ return this._compareTo0(other);
1499
+ // return super.compareTo(other); if not instance of LocalDateTime
1500
+ }
1501
+
1502
+ /**
1503
+ *
1504
+ * @param {!LocalDateTime} other
1505
+ * @returns {number}
1506
+ * @private
1507
+ */
1508
+ _compareTo0(other) {
1509
+ let cmp = this._date.compareTo(other.toLocalDate());
1510
+ if (cmp === 0) {
1511
+ cmp = this._time.compareTo(other.toLocalTime());
1512
+ }
1513
+ return cmp;
1514
+ }
1515
+
1516
+ /**
1517
+ * Checks if this date-time is after the specified date-time.
1518
+ *
1519
+ * This checks to see if this date-time represents a point on the
1520
+ * local time-line after the other date-time.
1521
+ * <pre>
1522
+ * LocalDate a = LocalDateTime.of(2012, 6, 30, 12, 00);
1523
+ * LocalDate b = LocalDateTime.of(2012, 7, 1, 12, 00);
1524
+ * a.isAfter(b) == false
1525
+ * a.isAfter(a) == false
1526
+ * b.isAfter(a) == true
1527
+ * </pre>
1528
+ *
1529
+ * This method only considers the position of the two date-times on the local time-line.
1530
+ * It does not take into account the chronology, or calendar system.
1531
+ * This is different from the comparison in {@link compareTo},
1532
+ * but is the same approach as {@link DATE_TIME_COMPARATOR}.
1533
+ *
1534
+ * @param {LocalDateTime} other - the other date-time to compare to, not null
1535
+ * @return {boolean} true if this date-time is after the specified date-time
1536
+ */
1537
+ isAfter(other) {
1538
+ return this.compareTo(other) > 0;
1539
+ // return super.isAfter(other); if not instance of LocalDateTime
1540
+ }
1541
+
1542
+ /**
1543
+ * Checks if this date-time is before the specified date-time.
1544
+ *
1545
+ * This checks to see if this date-time represents a point on the
1546
+ * local time-line before the other date-time.
1547
+ * <pre>
1548
+ * LocalDate a = LocalDateTime.of(2012, 6, 30, 12, 00);
1549
+ * LocalDate b = LocalDateTime.of(2012, 7, 1, 12, 00);
1550
+ * a.isBefore(b) == true
1551
+ * a.isBefore(a) == false
1552
+ * b.isBefore(a) == false
1553
+ * </pre>
1554
+ *
1555
+ * This method only considers the position of the two date-times on the local time-line.
1556
+ * It does not take into account the chronology, or calendar system.
1557
+ * This is different from the comparison in {@link compareTo},
1558
+ * but is the same approach as {@link DATE_TIME_COMPARATOR}.
1559
+ *
1560
+ * @param {LocalDateTime} other - the other date-time to compare to, not null
1561
+ * @return {boolean} true if this date-time is before the specified date-time
1562
+ */
1563
+ isBefore(other) {
1564
+ return this.compareTo(other) < 0;
1565
+ // return super.isBefore(other); if not instance of LocalDateTime
1566
+ }
1567
+
1568
+ /**
1569
+ * Checks if this date-time is equal to the specified date-time.
1570
+ *
1571
+ * This checks to see if this date-time represents the same point on the
1572
+ * local time-line as the other date-time.
1573
+ * <pre>
1574
+ * LocalDate a = LocalDateTime.of(2012, 6, 30, 12, 00);
1575
+ * LocalDate b = LocalDateTime.of(2012, 7, 1, 12, 00);
1576
+ * a.isEqual(b) == false
1577
+ * a.isEqual(a) == true
1578
+ * b.isEqual(a) == false
1579
+ * </pre>
1580
+ *
1581
+ * This method only considers the position of the two date-times on the local time-line.
1582
+ * It does not take into account the chronology, or calendar system.
1583
+ * This is different from the comparison in {@link compareTo},
1584
+ * but is the same approach as {@link DATE_TIME_COMPARATOR}.
1585
+ *
1586
+ * @param {LocalDateTime} other - the other date-time to compare to, not null
1587
+ * @return {boolean} true if this date-time is equal to the specified date-time
1588
+ */
1589
+ isEqual(other) {
1590
+ return this.compareTo(other) === 0;
1591
+ // return super.isEqual(other); if not instance of LocalDateTime
1592
+ }
1593
+
1594
+ //-----------------------------------------------------------------------
1595
+ /**
1596
+ * Checks if this date-time is equal to another date-time.
1597
+ *
1598
+ * Compares this {@link LocalDateTime} with another ensuring that the date-time is the same.
1599
+ * Only objects of type {@link LocalDateTime} are compared, other types return false.
1600
+ *
1601
+ * @param {*} other - the object to check, null returns false
1602
+ * @return {boolean} true if this is equal to the other date-time
1603
+ */
1604
+ equals(other) {
1605
+ if (this === other) {
1606
+ return true;
1607
+ }
1608
+ if (other instanceof LocalDateTime) {
1609
+ return this._date.equals(other._date) && this._time.equals(other._time);
1610
+ }
1611
+ return false;
1612
+ }
1613
+
1614
+ /**
1615
+ * A hash code for this date-time.
1616
+ *
1617
+ * @return {number} a suitable hash code
1618
+ */
1619
+ hashCode() {
1620
+ return this._date.hashCode() ^ this._time.hashCode();
1621
+ }
1622
+
1623
+ //-----------------------------------------------------------------------
1624
+ /**
1625
+ * Outputs this date-time as a string, such as `2007-12-03T10:15:30`.
1626
+ *
1627
+ * The output will be one of the following ISO-8601 formats:
1628
+ *
1629
+ * * `yyyy-MM-dd'T'HH:mm`
1630
+ * * `yyyy-MM-dd'T'HH:mm:ss`
1631
+ * * `yyyy-MM-dd'T'HH:mm:ss.SSS`
1632
+ * * `yyyy-MM-dd'T'HH:mm:ss.SSSSSS`
1633
+ * * `yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS`
1634
+ *
1635
+ * The format used will be the shortest that outputs the full value of
1636
+ * the time where the omitted parts are implied to be zero.
1637
+ *
1638
+ * @return {string} a string representation of this date-time, not null
1639
+ */
1640
+ toString() {
1641
+ return this._date.toString() + 'T' + this._time.toString();
1642
+ }
1643
+
1644
+ /**
1645
+ *
1646
+ * @return {string} same as {@link LocalDateTime.toString}
1647
+ */
1648
+ toJSON() {
1649
+ return this.toString();
1650
+ }
1651
+
1652
+ /**
1653
+ * Outputs this date-time as a string using the formatter.
1654
+ *
1655
+ * @param {!DateTimeFormatter} formatter the formatter to use, not null
1656
+ * @return {String} the formatted date-time string, not null
1657
+ * @throws {DateTimeException} if an error occurs during printing
1658
+ */
1659
+ format(formatter) {
1660
+ requireNonNull(formatter, 'formatter');
1661
+ return formatter.format(this);
1662
+ }
1663
+
1664
+ }
1665
+
1666
+ export function _init(){
1667
+ /**
1668
+ * The minimum supported {@link LocalDateTime}, '-999999999-01-01T00:00:00'.
1669
+ * This is the local date-time of midnight at the start of the minimum date.
1670
+ * This combines {@link LocalDate#MIN} and {@link LocalTime#MIN}.
1671
+ * This could be used by an application as a 'far past' date-time.
1672
+ */
1673
+ LocalDateTime.MIN = LocalDateTime.of(LocalDate.MIN, LocalTime.MIN);
1674
+
1675
+ /**
1676
+ * The maximum supported {@link LocalDateTime}, '+999999999-12-31T23:59:59.999999999'.
1677
+ * This is the local date-time just before midnight at the end of the maximum date.
1678
+ * This combines {@link LocalDate#MAX} and {@link LocalTime#MAX}.
1679
+ * This could be used by an application as a 'far future' date-time.
1680
+ */
1681
+ LocalDateTime.MAX = LocalDateTime.of(LocalDate.MAX, LocalTime.MAX);
1682
+
1683
+ LocalDateTime.FROM = createTemporalQuery('LocalDateTime.FROM', (temporal) => {
1684
+ return LocalDateTime.from(temporal);
1685
+ });
1686
+ }