@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,1012 @@
1
+ /**
2
+ * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
3
+ * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
4
+ * @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
5
+ */
6
+
7
+ import {requireNonNull, requireInstance} from './assert';
8
+ import {DateTimeException, UnsupportedTemporalTypeException} from './errors';
9
+
10
+ import {Clock} from './Clock';
11
+ import {LocalTime} from './LocalTime';
12
+ import {ZonedDateTime} from './ZonedDateTime';
13
+ import {MathUtil} from './MathUtil';
14
+ import {OffsetDateTime} from './OffsetDateTime';
15
+
16
+ import {Temporal} from './temporal/Temporal';
17
+ import {ChronoField} from './temporal/ChronoField';
18
+ import {ChronoUnit} from './temporal/ChronoUnit';
19
+ import {TemporalQueries} from './temporal/TemporalQueries';
20
+ import {TemporalUnit} from './temporal/TemporalUnit';
21
+ import {createTemporalQuery} from './temporal/TemporalQuery';
22
+ import {DateTimeFormatter} from './format/DateTimeFormatter';
23
+
24
+ const NANOS_PER_MILLI = 1000000;
25
+
26
+ /**
27
+ * An instantaneous point on the time-line.
28
+ *
29
+ * This class models a single instantaneous point on the time-line.
30
+ * This might be used to record event time-stamps in the application.
31
+ *
32
+ * Time-scale
33
+ *
34
+ * The length of the solar day is the standard way that humans measure time.
35
+ * This has traditionally been subdivided into 24 hours of 60 minutes of 60 seconds,
36
+ * forming a 86400 second day.
37
+ *
38
+ * Modern timekeeping is based on atomic clocks which precisely define an SI second
39
+ * relative to the transitions of a Caesium atom. The length of an SI second was defined
40
+ * to be very close to the 86400th fraction of a day.
41
+ *
42
+ * Unfortunately, as the Earth rotates the length of the day varies.
43
+ * In addition, over time the average length of the day is getting longer as the Earth slows.
44
+ * As a result, the length of a solar day in 2012 is slightly longer than 86400 SI seconds.
45
+ * The actual length of any given day and the amount by which the Earth is slowing
46
+ * are not predictable and can only be determined by measurement.
47
+ * The UT1 time-scale captures the accurate length of day, but is only available some
48
+ * time after the day has completed.
49
+ *
50
+ * The UTC time-scale is a standard approach to bundle up all the additional fractions
51
+ * of a second from UT1 into whole seconds, known as *leap-seconds*.
52
+ * A leap-second may be added or removed depending on the Earth's rotational changes.
53
+ * As such, UTC permits a day to have 86399 SI seconds or 86401 SI seconds where
54
+ * necessary in order to keep the day aligned with the Sun.
55
+ *
56
+ * The modern UTC time-scale was introduced in 1972, introducing the concept of whole leap-seconds.
57
+ * Between 1958 and 1972, the definition of UTC was complex, with minor sub-second leaps and
58
+ * alterations to the length of the notional second. As of 2012, discussions are underway
59
+ * to change the definition of UTC again, with the potential to remove leap seconds or
60
+ * introduce other changes.
61
+ *
62
+ * Given the complexity of accurate timekeeping described above, this Java API defines
63
+ * its own time-scale, the *Java Time-Scale*.
64
+ *
65
+ * The Java Time-Scale divides each calendar day into exactly 86400
66
+ * subdivisions, known as seconds. These seconds may differ from the
67
+ * SI second. It closely matches the de facto international civil time
68
+ * scale, the definition of which changes from time to time.
69
+ *
70
+ * The Java Time-Scale has slightly different definitions for different
71
+ * segments of the time-line, each based on the consensus international
72
+ * time scale that is used as the basis for civil time. Whenever the
73
+ * internationally-agreed time scale is modified or replaced, a new
74
+ * segment of the Java Time-Scale must be defined for it. Each segment
75
+ * must meet these requirements:
76
+ *
77
+ * * the Java Time-Scale shall closely match the underlying international
78
+ * civil time scale;
79
+ * * the Java Time-Scale shall exactly match the international civil
80
+ * time scale at noon each day;
81
+ * * the Java Time-Scale shall have a precisely-defined relationship to
82
+ * the international civil time scale.
83
+ *
84
+ * There are currently, as of 2013, two segments in the Java time-scale.
85
+ *
86
+ * For the segment from 1972-11-03 (exact boundary discussed below) until
87
+ * further notice, the consensus international time scale is UTC (with
88
+ * leap seconds). In this segment, the Java Time-Scale is identical to
89
+ * [UTC-SLS](http://www.cl.cam.ac.uk/~mgk25/time/utc-sls/).
90
+ * This is identical to UTC on days that do not have a leap second.
91
+ * On days that do have a leap second, the leap second is spread equally
92
+ * over the last 1000 seconds of the day, maintaining the appearance of
93
+ * exactly 86400 seconds per day.
94
+ *
95
+ * For the segment prior to 1972-11-03, extending back arbitrarily far,
96
+ * the consensus international time scale is defined to be UT1, applied
97
+ * proleptically, which is equivalent to the (mean) solar time on the
98
+ * prime meridian (Greenwich). In this segment, the Java Time-Scale is
99
+ * identical to the consensus international time scale. The exact
100
+ * boundary between the two segments is the instant where UT1 = UTC
101
+ * between 1972-11-03T00:00 and 1972-11-04T12:00.
102
+ *
103
+ * Implementations of the Java time-scale using the JSR-310 API are not
104
+ * required to provide any clock that is sub-second accurate, or that
105
+ * progresses monotonically or smoothly. Implementations are therefore
106
+ * not required to actually perform the UTC-SLS slew or to otherwise be
107
+ * aware of leap seconds. JSR-310 does, however, require that
108
+ * implementations must document the approach they use when defining a
109
+ * clock representing the current instant.
110
+ * See {@link Clock} for details on the available clocks.
111
+ *
112
+ * The Java time-scale is used for all date-time classes.
113
+ * This includes {@link Instant}, {@link LocalDate}, {@link LocalTime}, {@link OffsetDateTime},
114
+ * {@link ZonedDateTime} and {@link Duration}.
115
+ *
116
+ * ### Static properties of Class {@link Instant}
117
+ *
118
+ * Instant.EPOCH
119
+ *
120
+ * Instant.MIN
121
+ *
122
+ * Instant.MAX
123
+ *
124
+ * Instant.MIN_SECONDS
125
+ *
126
+ * Instant.MAX_SECONDS
127
+ *
128
+ */
129
+ export class Instant extends Temporal {
130
+
131
+ /**
132
+ * Obtains the current instant from the system clock, or if specified
133
+ * the current instant from the specified clock.
134
+ *
135
+ * This will query the specified clock to obtain the current time.
136
+ *
137
+ * @param {Clock} [clock=Clock.systemUTC()] - the clock to use, defaults to the system clock
138
+ * @return {Instant} the current instant, not null
139
+ */
140
+ static now(clock = Clock.systemUTC()){
141
+ return clock.instant();
142
+ }
143
+
144
+ /**
145
+ * Obtains an instance of {@link Instant} using seconds from the
146
+ * epoch of 1970-01-01T00:00:00Z.
147
+ *
148
+ * @param {number} epochSecond - the number of seconds from 1970-01-01T00:00:00Z
149
+ * @param {number} nanoAdjustment nanoseconds start from the start of epochSecond, if null the nanosecond field is set to zero.
150
+ * @return {Instant} an instant, not null
151
+ * @throws DateTimeException if the instant exceeds the maximum or minimum instant
152
+ */
153
+ static ofEpochSecond(epochSecond, nanoAdjustment=0){
154
+ const secs = epochSecond + MathUtil.floorDiv(nanoAdjustment, LocalTime.NANOS_PER_SECOND);
155
+ const nos = MathUtil.floorMod(nanoAdjustment, LocalTime.NANOS_PER_SECOND);
156
+ return Instant._create(secs, nos);
157
+ }
158
+
159
+ /**
160
+ * Obtains an instance of {@link Instant} using milliseconds from the
161
+ * epoch of 1970-01-01T00:00:00Z.
162
+ *
163
+ * The seconds and nanoseconds are extracted from the specified milliseconds.
164
+ *
165
+ * @param {number} epochMilli - the number of milliseconds from 1970-01-01T00:00:00Z
166
+ * @return {Instant} an instant, not null
167
+ * @throws DateTimeException if the instant exceeds the maximum or minimum instant
168
+ */
169
+ static ofEpochMilli(epochMilli) {
170
+ const secs = MathUtil.floorDiv(epochMilli, 1000);
171
+ const mos = MathUtil.floorMod(epochMilli, 1000);
172
+ return Instant._create(secs, mos * 1000000);
173
+ }
174
+
175
+ /**
176
+ * Obtains an instance of {@link Instant} from a temporal object.
177
+ *
178
+ * A {@link TemporalAccessor} represents some form of date and time information.
179
+ * This factory converts the arbitrary temporal object to an instance of {@link Instant}.
180
+ *
181
+ * The conversion extracts the {@link ChronoField#INSTANT_SECONDS}
182
+ * and {@link ChronoField#NANO_OF_SECOND} fields.
183
+ *
184
+ * This method matches the signature of the functional interface {@link TemporalQuery}
185
+ * allowing it to be used as a query via method reference, {@link Instant::from}.
186
+ *
187
+ * @param {TemporalAccessor} temporal - the temporal object to convert, not null
188
+ * @return {Instant} the instant, not null
189
+ * @throws DateTimeException if unable to convert to an {@link Instant}
190
+ */
191
+ static from(temporal) {
192
+ try {
193
+ const instantSecs = temporal.getLong(ChronoField.INSTANT_SECONDS);
194
+ const nanoOfSecond = temporal.get(ChronoField.NANO_OF_SECOND);
195
+ return Instant.ofEpochSecond(instantSecs, nanoOfSecond);
196
+ } catch (ex) {
197
+ throw new DateTimeException('Unable to obtain Instant from TemporalAccessor: ' +
198
+ temporal + ', type ' + typeof temporal, ex);
199
+ }
200
+ }
201
+
202
+ /**
203
+ * Obtains an instance of {@link Instant} from a text string such as
204
+ * `2007-12-03T10:15:30.000Z`.
205
+ *
206
+ * The string must represent a valid instant in UTC and is parsed using
207
+ * {@link DateTimeFormatter#ISO_INSTANT}.
208
+ *
209
+ * @param {string} text - the text to parse, not null
210
+ * @return {Instant} the parsed instant, not null
211
+ * @throws DateTimeParseException if the text cannot be parsed
212
+ */
213
+ static parse(text) {
214
+ return DateTimeFormatter.ISO_INSTANT.parse(text, Instant.FROM);
215
+ }
216
+
217
+ /**
218
+ *
219
+ * @param {number} seconds
220
+ * @param {number} nanoOfSecond
221
+ * @returns {Instant}
222
+ * @private
223
+ */
224
+ static _create(seconds, nanoOfSecond){
225
+ if(seconds === 0 && nanoOfSecond === 0){
226
+ return Instant.EPOCH;
227
+ }
228
+ return new Instant(seconds, nanoOfSecond);
229
+ }
230
+
231
+ /**
232
+ *
233
+ * @param {number} seconds
234
+ * @param {number} nanoOfSecond
235
+ * @private
236
+ */
237
+ static _validate(seconds, nanoOfSecond){
238
+ if (seconds < Instant.MIN_SECONDS || seconds > Instant.MAX_SECONDS) {
239
+ throw new DateTimeException('Instant exceeds minimum or maximum instant');
240
+ }
241
+ if (nanoOfSecond < 0 || nanoOfSecond > LocalTime.NANOS_PER_SECOND) {
242
+ throw new DateTimeException('Instant exceeds minimum or maximum instant');
243
+ }
244
+ }
245
+
246
+ /**
247
+ *
248
+ * @param {number} seconds
249
+ * @param {number} nanoOfSecond
250
+ * @private
251
+ */
252
+ constructor(seconds, nanoOfSecond){
253
+ super();
254
+ Instant._validate(seconds, nanoOfSecond);
255
+ this._seconds = MathUtil.safeToInt(seconds);
256
+ this._nanos = MathUtil.safeToInt(nanoOfSecond);
257
+ }
258
+
259
+ /**
260
+ * Checks if the specified field is supported.
261
+ *
262
+ * This checks if this instant can be queried for the specified field.
263
+ * If false, then calling {@link range} and {@link get} will throw an exception.
264
+ *
265
+ * If the field is a {@link ChronoField} then the query is implemented here.
266
+ * The supported fields are:
267
+ *
268
+ * * {@link NANO_OF_SECOND}
269
+ * * {@link MICRO_OF_SECOND}
270
+ * * {@link MILLI_OF_SECOND}
271
+ * * {@link INSTANT_SECONDS}
272
+ *
273
+ * All other {@link ChronoField} instances will return false.
274
+ *
275
+ * If the field is not a {@link ChronoField}, then the result of this method
276
+ * is obtained by invoking {@link TemporalField.isSupportedBy}
277
+ * passing `this` as the argument.
278
+ * Whether the field is supported is determined by the field.
279
+ *
280
+ * @param {TemporalField|TemporalUnit} fieldOrUnit - the field to check, null returns false
281
+ * @return {boolean} true if the field is supported on this instant, false if not
282
+ */
283
+ isSupported(fieldOrUnit) {
284
+ if (fieldOrUnit instanceof ChronoField) {
285
+ return fieldOrUnit === ChronoField.INSTANT_SECONDS || fieldOrUnit === ChronoField.NANO_OF_SECOND || fieldOrUnit === ChronoField.MICRO_OF_SECOND || fieldOrUnit === ChronoField.MILLI_OF_SECOND;
286
+ }
287
+ if (fieldOrUnit instanceof ChronoUnit) {
288
+ return fieldOrUnit.isTimeBased() || fieldOrUnit === ChronoUnit.DAYS;
289
+ }
290
+ return fieldOrUnit != null && fieldOrUnit.isSupportedBy(this);
291
+ }
292
+
293
+ /**
294
+ * Gets the range of valid values for the specified field.
295
+ *
296
+ * The range object expresses the minimum and maximum valid values for a field.
297
+ * This instant is used to enhance the accuracy of the returned range.
298
+ * If it is not possible to return the range, because the field is not supported
299
+ * or for some other reason, an exception is thrown.
300
+ *
301
+ * If the field is a {@link ChronoField} then the query is implemented here.
302
+ * The supported fields (see {@link isSupported}) will return
303
+ * appropriate range instances.
304
+ * All other {@link ChronoField} instances will throw a {@link DateTimeException}.
305
+ *
306
+ * If the field is not a {@link ChronoField}, then the result of this method
307
+ * is obtained by invoking {@link TemporalField.rangeRefinedBy}
308
+ * passing `this` as the argument.
309
+ * Whether the range can be obtained is determined by the field.
310
+ *
311
+ * @param {TemporalField} field - the field to query the range for, not null
312
+ * @return {ValueRange} the range of valid values for the field, not null
313
+ * @throws DateTimeException if the range for the field cannot be obtained
314
+ */
315
+ range(field) {
316
+ return super.range(field);
317
+ }
318
+
319
+ /**
320
+ * Gets the value of the specified field from this instant as an `int`.
321
+ *
322
+ * This queries this instant for the value for the specified field.
323
+ * The returned value will always be within the valid range of values for the field.
324
+ * If it is not possible to return the value, because the field is not supported
325
+ * or for some other reason, an exception is thrown.
326
+ *
327
+ * If the field is a {@link ChronoField} then the query is implemented here.
328
+ * The supported fields (see {@link isSupported}) will return valid
329
+ * values based on this date-time, except {@link INSTANT_SECONDS} which is too
330
+ * large to fit in an `int` and throws a {@link DateTimeException}.
331
+ * All other {@link ChronoField} instances will throw a {@link DateTimeException}.
332
+ *
333
+ * If the field is not a {@link ChronoField}, then the result of this method
334
+ * is obtained by invoking {@link TemporalField.getFrom}
335
+ * passing `this` as the argument. Whether the value can be obtained,
336
+ * and what the value represents, is determined by the field.
337
+ *
338
+ * @param {TemporalField} field - the field to get, not null
339
+ * @return {number} the value for the field
340
+ * @throws DateTimeException if a value for the field cannot be obtained
341
+ * @throws ArithmeticException if numeric overflow occurs
342
+ */
343
+ get(field) {
344
+ return this.getLong(field);
345
+ }
346
+
347
+ /**
348
+ * Gets the value of the specified field from this instant as a `long`.
349
+ *
350
+ * This queries this instant for the value for the specified field.
351
+ * If it is not possible to return the value, because the field is not supported
352
+ * or for some other reason, an exception is thrown.
353
+ *
354
+ * If the field is a {@link ChronoField} then the query is implemented here.
355
+ * The supported fields (see {@link isSupported}) will return valid
356
+ * values based on this date-time.
357
+ * All other {@link ChronoField} instances will throw a {@link DateTimeException}.
358
+ *
359
+ * If the field is not a {@link ChronoField}, then the result of this method
360
+ * is obtained by invoking {@link TemporalField.getFrom}
361
+ * passing `this` as the argument. Whether the value can be obtained,
362
+ * and what the value represents, is determined by the field.
363
+ *
364
+ * @param {TemporalField} field - the field to get, not null
365
+ * @return {number} the value for the field
366
+ * @throws DateTimeException if a value for the field cannot be obtained
367
+ * @throws ArithmeticException if numeric overflow occurs
368
+ */
369
+ getLong(field) {
370
+ if (field instanceof ChronoField) {
371
+ switch (field) {
372
+ case ChronoField.NANO_OF_SECOND: return this._nanos;
373
+ case ChronoField.MICRO_OF_SECOND: return MathUtil.intDiv(this._nanos, 1000);
374
+ case ChronoField.MILLI_OF_SECOND: return MathUtil.intDiv(this._nanos, NANOS_PER_MILLI);
375
+ case ChronoField.INSTANT_SECONDS: return this._seconds;
376
+ }
377
+ throw new UnsupportedTemporalTypeException('Unsupported field: ' + field);
378
+ }
379
+ return field.getFrom(this);
380
+ }
381
+
382
+ /**
383
+ * Gets the number of seconds from the Java epoch of 1970-01-01T00:00:00Z.
384
+ *
385
+ * The epoch second count is a simple incrementing count of seconds where
386
+ * second 0 is 1970-01-01T00:00:00Z.
387
+ * The nanosecond part of the day is returned by {@link getNanosOfSecond}.
388
+ *
389
+ * @return {number} the seconds from the epoch of 1970-01-01T00:00:00Z
390
+ */
391
+ epochSecond(){
392
+ return this._seconds;
393
+ }
394
+
395
+ /**
396
+ * Gets the number of nanoseconds, later along the time-line, from the start
397
+ * of the second.
398
+ *
399
+ * The nanosecond-of-second value measures the total number of nanoseconds from
400
+ * the second returned by {@link getEpochSecond}.
401
+ *
402
+ * @return {number} the nanoseconds within the second, always positive, never exceeds 999,999,999
403
+ */
404
+ nano(){
405
+ return this._nanos;
406
+ }
407
+
408
+ //-------------------------------------------------------------------------
409
+ /**
410
+ * Returns an adjusted copy of this instant.
411
+ *
412
+ * This returns a new {@link Instant}, based on this one, with the date adjusted.
413
+ * The adjustment takes place using the specified adjuster strategy object.
414
+ * Read the documentation of the adjuster to understand what adjustment will be made.
415
+ *
416
+ * The result of this method is obtained by invoking the
417
+ * {@link TemporalAdjuster#adjustInto} method on the
418
+ * specified adjuster passing `this` as the argument.
419
+ *
420
+ * This instance is immutable and unaffected by this method call.
421
+ *
422
+ * @param {!TemporalAdjuster} adjuster - the adjuster to use, not null
423
+ * @return {Instant} an {@link Instant} based on `this` with the adjustment made, not null
424
+ * @throws DateTimeException if the adjustment cannot be made
425
+ * @throws ArithmeticException if numeric overflow occurs
426
+ */
427
+ withAdjuster(adjuster) {
428
+ requireNonNull(adjuster, 'adjuster');
429
+ return adjuster.adjustInto(this);
430
+ }
431
+
432
+ /**
433
+ * Returns a copy of this instant with the specified field set to a new value.
434
+ *
435
+ * This returns a new {@link Instant}, based on this one, with the value
436
+ * for the specified field changed.
437
+ * If it is not possible to set the value, because the field is not supported or for
438
+ * some other reason, an exception is thrown.
439
+ *
440
+ * If the field is a {@link ChronoField} then the adjustment is implemented here.
441
+ * The supported fields behave as follows:
442
+ *
443
+ * * {@link NANO_OF_SECOND} -
444
+ * Returns an {@link Instant} with the specified nano-of-second.
445
+ * The epoch-second will be unchanged.
446
+ * * {@link MICRO_OF_SECOND} -
447
+ * Returns an {@link Instant} with the nano-of-second replaced by the specified
448
+ * micro-of-second multiplied by 1,000. The epoch-second will be unchanged.
449
+ * * {@link MILLI_OF_SECOND} -
450
+ * Returns an {@link Instant} with the nano-of-second replaced by the specified
451
+ * milli-of-second multiplied by 1,000,000. The epoch-second will be unchanged.
452
+ * * {@link INSTANT_SECONDS} -
453
+ * Returns an {@link Instant} with the specified epoch-second.
454
+ * The nano-of-second will be unchanged.
455
+ *
456
+ *
457
+ * In all cases, if the new value is outside the valid range of values for the field
458
+ * then a {@link DateTimeException} will be thrown.
459
+ *
460
+ * All other {@link ChronoField} instances will throw a {@link DateTimeException}.
461
+ *
462
+ * If the field is not a {@link ChronoField}, then the result of this method
463
+ * is obtained by invoking {@link TemporalField.adjustInto}
464
+ * passing `this` as the argument. In this case, the field determines
465
+ * whether and how to adjust the instant.
466
+ *
467
+ * This instance is immutable and unaffected by this method call.
468
+ *
469
+ * @param {TemporalField} field - the field to set in the result, not null
470
+ * @param {number} newValue - the new value of the field in the result
471
+ * @return {Instant} an {@link Instant} based on `this` with the specified field set, not null
472
+ * @throws DateTimeException if the field cannot be set
473
+ * @throws ArithmeticException if numeric overflow occurs
474
+ */
475
+ withFieldValue(field, newValue) {
476
+ requireNonNull(field, 'field');
477
+ if (field instanceof ChronoField) {
478
+ field.checkValidValue(newValue);
479
+ switch (field) {
480
+ case ChronoField.MILLI_OF_SECOND: {
481
+ const nval = newValue * NANOS_PER_MILLI;
482
+ return (nval !== this._nanos? Instant._create(this._seconds, nval) : this);
483
+ }
484
+ case ChronoField.MICRO_OF_SECOND: {
485
+ const nval = newValue * 1000;
486
+ return (nval !== this._nanos? Instant._create(this._seconds, nval) : this);
487
+ }
488
+ case ChronoField.NANO_OF_SECOND: return (newValue !== this._nanos? Instant._create(this._seconds, newValue) : this);
489
+ case ChronoField.INSTANT_SECONDS: return (newValue !== this._seconds ? Instant._create(newValue, this._nanos) : this);
490
+ }
491
+ throw new UnsupportedTemporalTypeException('Unsupported field: ' + field);
492
+ }
493
+ return field.adjustInto(this, newValue);
494
+ }
495
+
496
+ //-----------------------------------------------------------------------
497
+ /**
498
+ * Returns a copy of this {@link Instant} truncated to the specified unit.
499
+ *
500
+ * Truncating the instant returns a copy of the original with fields
501
+ * smaller than the specified unit set to zero.
502
+ * The fields are calculated on the basis of using a UTC offset as seen
503
+ * in {@link toString}.
504
+ * For example, truncating with {@link ChronoUnit#MINUTES} will
505
+ * round down to the nearest minute, setting the seconds and nanoseconds to zero.
506
+ *
507
+ * The unit must have a duration (see {@link TemporalUnit#getDuration})
508
+ * that divides into the length of a standard day without remainder.
509
+ * This includes all supplied time units on {@link ChronoUnit} and
510
+ * {@link ChronoUnit#DAYS}. Other units throw an exception.
511
+ *
512
+ * This instance is immutable and unaffected by this method call.
513
+ *
514
+ * @param {!TemporalUnit} unit - the unit to truncate to, not null
515
+ * @return {Instant} an {@link Instant} based on this instant with the time truncated, not null
516
+ * @throws DateTimeException if the unit is invalid for truncation
517
+ */
518
+ truncatedTo(unit) {
519
+ requireNonNull(unit, 'unit');
520
+ if (unit === ChronoUnit.NANOS) {
521
+ return this;
522
+ }
523
+ const unitDur = unit.duration();
524
+ if (unitDur.seconds() > LocalTime.SECONDS_PER_DAY) {
525
+ throw new DateTimeException('Unit is too large to be used for truncation');
526
+ }
527
+ const dur = unitDur.toNanos();
528
+ if (MathUtil.intMod(LocalTime.NANOS_PER_DAY, dur) !== 0) {
529
+ throw new DateTimeException('Unit must divide into a standard day without remainder');
530
+ }
531
+ const nod = MathUtil.intMod(this._seconds, LocalTime.SECONDS_PER_DAY) * LocalTime.NANOS_PER_SECOND + this._nanos;
532
+ const result = MathUtil.intDiv(nod, dur) * dur;
533
+ return this.plusNanos(result - nod);
534
+ }
535
+
536
+ //-----------------------------------------------------------------------
537
+
538
+ /**
539
+ * @param {!TemporalAmount} amount
540
+ * @return {Instant}
541
+ * @throws DateTimeException
542
+ * @throws ArithmeticException
543
+ */
544
+ plusAmount(amount) {
545
+ requireNonNull(amount, 'amount');
546
+ return amount.addTo(this);
547
+ }
548
+
549
+ /**
550
+ * @param {!number} amountToAdd
551
+ * @param {!TemporalUnit} unit
552
+ * @return {Instant}
553
+ * @throws DateTimeException
554
+ * @throws ArithmeticException
555
+ */
556
+ plusAmountUnit(amountToAdd, unit) {
557
+ requireNonNull(amountToAdd, 'amountToAdd');
558
+ requireNonNull(unit, 'unit');
559
+ requireInstance(unit, TemporalUnit);
560
+ if (unit instanceof ChronoUnit) {
561
+ switch (unit) {
562
+ case ChronoUnit.NANOS: return this.plusNanos(amountToAdd);
563
+ case ChronoUnit.MICROS: return this._plus(MathUtil.intDiv(amountToAdd, 1000000), MathUtil.intMod(amountToAdd, 1000000) * 1000);
564
+ case ChronoUnit.MILLIS: return this.plusMillis(amountToAdd);
565
+ case ChronoUnit.SECONDS: return this.plusSeconds(amountToAdd);
566
+ case ChronoUnit.MINUTES: return this.plusSeconds(MathUtil.safeMultiply(amountToAdd, LocalTime.SECONDS_PER_MINUTE));
567
+ case ChronoUnit.HOURS: return this.plusSeconds(MathUtil.safeMultiply(amountToAdd, LocalTime.SECONDS_PER_HOUR));
568
+ case ChronoUnit.HALF_DAYS: return this.plusSeconds(MathUtil.safeMultiply(amountToAdd, LocalTime.SECONDS_PER_DAY / 2));
569
+ case ChronoUnit.DAYS: return this.plusSeconds(MathUtil.safeMultiply(amountToAdd, LocalTime.SECONDS_PER_DAY));
570
+ }
571
+ throw new UnsupportedTemporalTypeException('Unsupported unit: ' + unit);
572
+ }
573
+ return unit.addTo(this, amountToAdd);
574
+ }
575
+
576
+ /**
577
+ * Returns a copy of this instant with the specified duration in seconds added.
578
+ *
579
+ * This instance is immutable and unaffected by this method call.
580
+ *
581
+ * @param {number} secondsToAdd the seconds to add, positive or negative
582
+ * @return {Instant} an {@link Instant} based on this instant with the specified seconds added, not null
583
+ * @throws DateTimeException if the result exceeds the maximum or minimum instant
584
+ */
585
+ plusSeconds(secondsToAdd) {
586
+ return this._plus(secondsToAdd, 0);
587
+ }
588
+
589
+ /**
590
+ * Returns a copy of this instant with the specified duration in milliseconds added.
591
+ *
592
+ * This instance is immutable and unaffected by this method call.
593
+ *
594
+ * @param {number} millisToAdd - the milliseconds to add, positive or negative
595
+ * @return {Instant} an {@link Instant} based on this instant with the specified milliseconds added, not null
596
+ * @throws DateTimeException if the result exceeds the maximum or minimum instant
597
+ * @throws ArithmeticException if numeric overflow occurs
598
+ */
599
+ plusMillis(millisToAdd) {
600
+ return this._plus(MathUtil.intDiv(millisToAdd, 1000), MathUtil.intMod(millisToAdd, 1000) * NANOS_PER_MILLI);
601
+ }
602
+
603
+ /**
604
+ * Returns a copy of this instant with the specified duration in nanoseconds added.
605
+ *
606
+ * This instance is immutable and unaffected by this method call.
607
+ *
608
+ * @param {number} nanosToAdd - the nanoseconds to add, positive or negative
609
+ * @return {Instant} an {@link Instant} based on this instant with the specified nanoseconds added, not null
610
+ * @throws DateTimeException if the result exceeds the maximum or minimum instant
611
+ */
612
+ plusNanos(nanosToAdd) {
613
+ return this._plus(0, nanosToAdd);
614
+ }
615
+
616
+ /**
617
+ * Returns a copy of this instant with the specified duration added.
618
+ *
619
+ * This instance is immutable and unaffected by this method call.
620
+ *
621
+ * @param {number} secondsToAdd - the seconds to add, positive or negative
622
+ * @param {number} nanosToAdd - the nanos to add, positive or negative
623
+ * @return {Instant} an {@link Instant} based on this instant with the specified seconds added, not null
624
+ * @throws DateTimeException if the result exceeds the maximum or minimum instant
625
+ */
626
+ _plus(secondsToAdd, nanosToAdd) {
627
+ if (secondsToAdd === 0 && nanosToAdd === 0) {
628
+ return this;
629
+ }
630
+ let epochSec = this._seconds + secondsToAdd;
631
+ epochSec = epochSec + MathUtil.intDiv(nanosToAdd, LocalTime.NANOS_PER_SECOND);
632
+ const nanoAdjustment = this._nanos + nanosToAdd % LocalTime.NANOS_PER_SECOND;
633
+ return Instant.ofEpochSecond(epochSec, nanoAdjustment);
634
+ }
635
+
636
+ //-----------------------------------------------------------------------
637
+
638
+ /**
639
+ * @param {!TemporalAmount} amount
640
+ * @return {Instant}
641
+ * @throws DateTimeException
642
+ * @throws ArithmeticException
643
+ */
644
+ minusAmount(amount) {
645
+ requireNonNull(amount, 'amount');
646
+ return amount.subtractFrom(this);
647
+ }
648
+
649
+ /**
650
+ * @param {!number} amountToSubtract
651
+ * @param {!TemporalUnit} unit
652
+ * @return {Instant}
653
+ * @throws DateTimeException
654
+ * @throws ArithmeticException
655
+ */
656
+ minusAmountUnit(amountToSubtract, unit) {
657
+ return this.plusAmountUnit(-1 * amountToSubtract, unit);
658
+ }
659
+
660
+ /**
661
+ * Returns a copy of this instant with the specified duration in seconds subtracted.
662
+ *
663
+ * This instance is immutable and unaffected by this method call.
664
+ *
665
+ * @param {number} secondsToSubtract - the seconds to subtract, positive or negative
666
+ * @return {Instant} an {@link Instant} based on this instant with the specified seconds subtracted, not null
667
+ * @throws DateTimeException if the result exceeds the maximum or minimum instant
668
+ */
669
+ minusSeconds(secondsToSubtract) {
670
+ return this.plusSeconds(secondsToSubtract * -1);
671
+ }
672
+
673
+ /**
674
+ * Returns a copy of this instant with the specified duration in milliseconds subtracted.
675
+ *
676
+ * This instance is immutable and unaffected by this method call.
677
+ *
678
+ * @param {number} millisToSubtract - the milliseconds to subtract, positive or negative
679
+ * @return {Instant} an {@link Instant} based on this instant with the specified milliseconds subtracted, not null
680
+ * @throws DateTimeException if the result exceeds the maximum or minimum instant
681
+ * @throws ArithmeticException if numeric overflow occurs
682
+ */
683
+ minusMillis(millisToSubtract) {
684
+ return this.plusMillis(-1 * millisToSubtract);
685
+ }
686
+
687
+ /**
688
+ * Returns a copy of this instant with the specified duration in nanoseconds subtracted.
689
+ *
690
+ * This instance is immutable and unaffected by this method call.
691
+ *
692
+ * @param {number} nanosToSubtract the nanoseconds to subtract, positive or negative
693
+ * @return {Instant} an {@link Instant} based on this instant with the specified nanoseconds subtracted, not null
694
+ * @throws DateTimeException if the result exceeds the maximum or minimum instant
695
+ * @throws ArithmeticException if numeric overflow occurs
696
+ */
697
+ minusNanos(nanosToSubtract) {
698
+ return this.plusNanos(-1 * nanosToSubtract);
699
+ }
700
+
701
+ //-------------------------------------------------------------------------
702
+ /**
703
+ * Queries this instant using the specified query.
704
+ *
705
+ * This queries this instant using the specified query strategy object.
706
+ * The {@link TemporalQuery} object defines the logic to be used to
707
+ * obtain the result. Read the documentation of the query to understand
708
+ * what the result of this method will be.
709
+ *
710
+ * The result of this method is obtained by invoking the
711
+ * {@link TemporalQuery#queryFrom} method on the
712
+ * specified query passing `this` as the argument.
713
+ *
714
+ * @param {!TemporalQuery} query - the query to invoke, not null
715
+ * @return {*} the query result, null may be returned (defined by the query)
716
+ * @throws DateTimeException if unable to query (defined by the query)
717
+ * @throws ArithmeticException if numeric overflow occurs (defined by the query)
718
+ */
719
+ query(query) {
720
+ requireNonNull(query, 'query');
721
+ if (query === TemporalQueries.precision()) {
722
+ return ChronoUnit.NANOS;
723
+ }
724
+ // inline TemporalAccessor.super.query(query) as an optimization
725
+ if (query === TemporalQueries.localDate() || query === TemporalQueries.localTime() ||
726
+ query === TemporalQueries.chronology() || query === TemporalQueries.zoneId() ||
727
+ query === TemporalQueries.zone() || query === TemporalQueries.offset()) {
728
+ return null;
729
+ }
730
+ return query.queryFrom(this);
731
+ }
732
+
733
+ /**
734
+ * Adjusts the specified temporal object to have this instant.
735
+ *
736
+ * This returns a temporal object of the same observable type as the input
737
+ * with the instant changed to be the same as this.
738
+ *
739
+ * The adjustment is equivalent to using {@link Temporal#with}
740
+ * twice, passing {@link ChronoField#INSTANT_SECONDS} and
741
+ * {@link ChronoField#NANO_OF_SECOND} as the fields.
742
+ *
743
+ * In most cases, it is clearer to reverse the calling pattern by using
744
+ * {@link Temporal#with}:
745
+ * <pre>
746
+ * // these two lines are equivalent, but the second approach is recommended
747
+ * temporal = thisInstant.adjustInto(temporal);
748
+ * temporal = temporal.with(thisInstant);
749
+ * </pre>
750
+ *
751
+ * This instance is immutable and unaffected by this method call.
752
+ *
753
+ * @param {!Temporal} temporal - the target object to be adjusted, not null
754
+ * @return {Temporal} the adjusted object, not null
755
+ * @throws DateTimeException if unable to make the adjustment
756
+ * @throws ArithmeticException if numeric overflow occurs
757
+ */
758
+ adjustInto(temporal) {
759
+ requireNonNull(temporal, 'temporal');
760
+ return temporal.with(ChronoField.INSTANT_SECONDS, this._seconds).with(ChronoField.NANO_OF_SECOND, this._nanos);
761
+ }
762
+
763
+ /**
764
+ * Calculates the period between this instant and another instant in
765
+ * terms of the specified unit.
766
+ *
767
+ * This calculates the period between two instants in terms of a single unit.
768
+ * The start and end points are `this` and the specified instant.
769
+ * The result will be negative if the end is before the start.
770
+ * The calculation returns a whole number, representing the number of
771
+ * complete units between the two instants.
772
+ * The {@link Temporal} passed to this method is converted to a
773
+ * {@link Instant} using {@link from}.
774
+ * For example, the period in days between two dates can be calculated
775
+ * using `startInstant.until(endInstant, SECONDS)`.
776
+ *
777
+ * This method operates in association with {@link TemporalUnit#between}.
778
+ * The result of this method is a `long` representing the amount of
779
+ * the specified unit. By contrast, the result of {@link between} is an
780
+ * object that can be used directly in addition/subtraction:
781
+ * <pre>
782
+ * long period = start.until(end, SECONDS); // this method
783
+ * dateTime.plus(SECONDS.between(start, end)); // use in plus/minus
784
+ * </pre>
785
+ *
786
+ * The calculation is implemented in this method for {@link ChronoUnit}.
787
+ * The units {@link NANOS}, {@link MICROS}, {@link MILLIS}, {@link SECONDS},
788
+ * {@link MINUTES}, {@link HOURS}, {@link HALF_DAYS} and {@link DAYS}
789
+ * are supported. Other {@link ChronoUnit} values will throw an exception.
790
+ *
791
+ * If the unit is not a {@link ChronoUnit}, then the result of this method
792
+ * is obtained by invoking {@link TemporalUnit.between}
793
+ * passing `this` as the first argument and the input temporal as
794
+ * the second argument.
795
+ *
796
+ * This instance is immutable and unaffected by this method call.
797
+ *
798
+ * @param {Temporal} endExclusive - the end date, which is converted to an {@link Instant}, not null
799
+ * @param {TemporalUnit} unit - the unit to measure the period in, not null
800
+ * @return {number} the amount of the period between this date and the end date
801
+ * @throws DateTimeException if the period cannot be calculated
802
+ * @throws ArithmeticException if numeric overflow occurs
803
+ */
804
+ until(endExclusive, unit) {
805
+ requireNonNull(endExclusive, 'endExclusive');
806
+ requireNonNull(unit, 'unit');
807
+ const end = Instant.from(endExclusive);
808
+ if (unit instanceof ChronoUnit) {
809
+ switch (unit) {
810
+ case ChronoUnit.NANOS: return this._nanosUntil(end);
811
+ case ChronoUnit.MICROS: return MathUtil.intDiv(this._nanosUntil(end), 1000);
812
+ case ChronoUnit.MILLIS: return MathUtil.safeSubtract(end.toEpochMilli(), this.toEpochMilli());
813
+ case ChronoUnit.SECONDS: return this._secondsUntil(end);
814
+ case ChronoUnit.MINUTES: return MathUtil.intDiv(this._secondsUntil(end), LocalTime.SECONDS_PER_MINUTE);
815
+ case ChronoUnit.HOURS: return MathUtil.intDiv(this._secondsUntil(end), LocalTime.SECONDS_PER_HOUR);
816
+ case ChronoUnit.HALF_DAYS: return MathUtil.intDiv(this._secondsUntil(end), (12 * LocalTime.SECONDS_PER_HOUR));
817
+ case ChronoUnit.DAYS: return MathUtil.intDiv(this._secondsUntil(end), LocalTime.SECONDS_PER_DAY);
818
+ }
819
+ throw new UnsupportedTemporalTypeException('Unsupported unit: ' + unit);
820
+ }
821
+ return unit.between(this, end);
822
+ }
823
+
824
+ /**
825
+ *
826
+ * @param {Temporal} end
827
+ * @returns {number}
828
+ * @private
829
+ */
830
+ _nanosUntil(end) {
831
+ const secsDiff = MathUtil.safeSubtract(end.epochSecond(), this.epochSecond());
832
+ const totalNanos = MathUtil.safeMultiply(secsDiff, LocalTime.NANOS_PER_SECOND);
833
+ return MathUtil.safeAdd(totalNanos, end.nano() - this.nano());
834
+ }
835
+
836
+ /**
837
+ *
838
+ * @param {Temporal} end
839
+ * @returns {number}
840
+ * @private
841
+ */
842
+ _secondsUntil(end) {
843
+ let secsDiff = MathUtil.safeSubtract(end.epochSecond(), this.epochSecond());
844
+ const nanosDiff = end.nano() - this.nano();
845
+ if (secsDiff > 0 && nanosDiff < 0) {
846
+ secsDiff--;
847
+ } else if (secsDiff < 0 && nanosDiff > 0) {
848
+ secsDiff++;
849
+ }
850
+ return secsDiff;
851
+ }
852
+
853
+ //-----------------------------------------------------------------------
854
+ /**
855
+ * Combines this instant with an offset to create an {@link OffsetDateTime}.
856
+ *
857
+ * This returns an {@link OffsetDateTime} formed from this instant at the
858
+ * specified offset from UTC/Greenwich. An exception will be thrown if the
859
+ * instant is too large to fit into an offset date-time.
860
+ *
861
+ * This method is equivalent to {@link OffsetDateTime#ofInstant}.
862
+ *
863
+ * @param {ZoneOffset} offset - the offset to combine with, not null
864
+ * @return {OffsetDateTime} the offset date-time formed from this instant and the specified offset, not null
865
+ * @throws DateTimeException if the result exceeds the supported range
866
+ */
867
+ atOffset(offset) {
868
+ return OffsetDateTime.ofInstant(this, offset);
869
+ }
870
+
871
+ /**
872
+ * Combines this instant with a time-zone to create a {@link ZonedDateTime}.
873
+ *
874
+ * This returns an {@link ZonedDateTime} formed from this instant at the
875
+ * specified time-zone. An exception will be thrown if the instant is too
876
+ * large to fit into a zoned date-time.
877
+ *
878
+ * This method is equivalent to {@link ZonedDateTime#ofInstant}.
879
+ *
880
+ * @param {ZoneId} zone - the zone to combine with, not null
881
+ * @return {ZonedDateTime} the zoned date-time formed from this instant and the specified zone, not null
882
+ * @throws DateTimeException if the result exceeds the supported range
883
+ */
884
+ atZone(zone) {
885
+ return ZonedDateTime.ofInstant(this, zone);
886
+ }
887
+
888
+ //-----------------------------------------------------------------------
889
+ /**
890
+ * Converts this instant to the number of milliseconds from the epoch
891
+ * of 1970-01-01T00:00:00Z.
892
+ *
893
+ * If this instant represents a point on the time-line too far in the future
894
+ * or past to fit in a `long` milliseconds, then an exception is thrown.
895
+ *
896
+ * If this instant has greater than millisecond precision, then the conversion
897
+ * will drop any excess precision information as though the amount in nanoseconds
898
+ * was subject to integer division by one million.
899
+ *
900
+ * @return {number} the number of milliseconds since the epoch of 1970-01-01T00:00:00Z
901
+ * @throws ArithmeticException if numeric overflow occurs
902
+ */
903
+ toEpochMilli() {
904
+ const millis = MathUtil.safeMultiply(this._seconds, 1000);
905
+ return millis + MathUtil.intDiv(this._nanos, NANOS_PER_MILLI);
906
+ }
907
+
908
+ //-----------------------------------------------------------------------
909
+ /**
910
+ * Compares this instant to the specified instant.
911
+ *
912
+ * The comparison is based on the time-line position of the instants.
913
+ * It is "consistent with equals", as defined by {@link Comparable}.
914
+ *
915
+ * @param {Instant} otherInstant the other instant to compare to, not null
916
+ * @return {number} the comparator value, negative if less, positive if greater
917
+ * @throws NullPointerException if otherInstant is null
918
+ */
919
+ compareTo(otherInstant) {
920
+ requireNonNull(otherInstant, 'otherInstant');
921
+ requireInstance(otherInstant, Instant, 'otherInstant');
922
+ const cmp = MathUtil.compareNumbers(this._seconds, otherInstant._seconds);
923
+ if (cmp !== 0) {
924
+ return cmp;
925
+ }
926
+ return this._nanos - otherInstant._nanos;
927
+ }
928
+
929
+ /**
930
+ * Checks if this instant is after the specified instant.
931
+ *
932
+ * The comparison is based on the time-line position of the instants.
933
+ *
934
+ * @param {Instant} otherInstant the other instant to compare to, not null
935
+ * @return {boolean} true if this instant is after the specified instant
936
+ * @throws NullPointerException if otherInstant is null
937
+ */
938
+ isAfter(otherInstant) {
939
+ return this.compareTo(otherInstant) > 0;
940
+ }
941
+
942
+ /**
943
+ * Checks if this instant is before the specified instant.
944
+ *
945
+ * The comparison is based on the time-line position of the instants.
946
+ *
947
+ * @param {Instant} otherInstant the other instant to compare to, not null
948
+ * @return {boolean} true if this instant is before the specified instant
949
+ * @throws NullPointerException if otherInstant is null
950
+ */
951
+ isBefore(otherInstant) {
952
+ return this.compareTo(otherInstant) < 0;
953
+ }
954
+
955
+ /**
956
+ * Checks if this instant is equal to the specified instant.
957
+ *
958
+ * The comparison is based on the time-line position of the instants.
959
+ *
960
+ * @param {*} other - the other instant, null/ undefined returns false
961
+ * @return {boolean} true if the other instant is equal to this one
962
+ */
963
+ equals(other) {
964
+ if(this === other){
965
+ return true;
966
+ }
967
+ if(other instanceof Instant){
968
+ return this.epochSecond() === other.epochSecond() &&
969
+ this.nano() === other.nano();
970
+ }
971
+ return false;
972
+ }
973
+
974
+ /**
975
+ * Returns a hash code for this instant.
976
+ *
977
+ * @return {number} a suitable hash code
978
+ */
979
+ hashCode() {
980
+ return MathUtil.hashCode(this._seconds, this._nanos);
981
+ }
982
+
983
+ /**
984
+ * A string representation of this instant using ISO-8601 representation.
985
+ *
986
+ * The format used is the same as {@link DateTimeFormatter#ISO_INSTANT}.
987
+ *
988
+ * @return {string} an ISO-8601 representation of this instant, not null
989
+ */
990
+ toString(){
991
+ return DateTimeFormatter.ISO_INSTANT.format(this);
992
+ }
993
+
994
+ /**
995
+ *
996
+ * @return {string} same as {@link LocalDate.toString}
997
+ */
998
+ toJSON() {
999
+ return this.toString();
1000
+ }
1001
+ }
1002
+
1003
+ export function _init() {
1004
+ Instant.MIN_SECONDS = -31619119219200; // -1000000-01-01T00:00:00Z
1005
+ Instant.MAX_SECONDS = 31494816403199; // +1000000-12-31T23:59:59.999999999Z
1006
+ Instant.EPOCH = new Instant(0, 0);
1007
+ Instant.MIN = Instant.ofEpochSecond(Instant.MIN_SECONDS, 0);
1008
+ Instant.MAX = Instant.ofEpochSecond(Instant.MAX_SECONDS, 999999999);
1009
+ Instant.FROM = createTemporalQuery('Instant.FROM', (temporal) => {
1010
+ return Instant.from(temporal);
1011
+ });
1012
+ }