rbs 4.1.0.pre.2-java

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 (574) hide show
  1. checksums.yaml +7 -0
  2. data/.clang-format +75 -0
  3. data/.clangd +2 -0
  4. data/.github/dependabot.yml +24 -0
  5. data/.github/workflows/bundle-update.yml +63 -0
  6. data/.github/workflows/c-check.yml +61 -0
  7. data/.github/workflows/comments.yml +37 -0
  8. data/.github/workflows/dependabot.yml +30 -0
  9. data/.github/workflows/jruby.yml +67 -0
  10. data/.github/workflows/milestone.yml +83 -0
  11. data/.github/workflows/ruby.yml +158 -0
  12. data/.github/workflows/rust.yml +184 -0
  13. data/.github/workflows/truffleruby.yml +54 -0
  14. data/.github/workflows/typecheck.yml +39 -0
  15. data/.github/workflows/wasm.yml +53 -0
  16. data/.github/workflows/windows.yml +49 -0
  17. data/.gitignore +38 -0
  18. data/.rubocop.yml +72 -0
  19. data/BSDL +22 -0
  20. data/CHANGELOG.md +2292 -0
  21. data/COPYING +56 -0
  22. data/README.md +240 -0
  23. data/Rakefile +869 -0
  24. data/Steepfile +53 -0
  25. data/config.yml +913 -0
  26. data/core/array.rbs +4142 -0
  27. data/core/basic_object.rbs +376 -0
  28. data/core/binding.rbs +148 -0
  29. data/core/builtin.rbs +278 -0
  30. data/core/class.rbs +223 -0
  31. data/core/comparable.rbs +192 -0
  32. data/core/complex.rbs +812 -0
  33. data/core/constants.rbs +96 -0
  34. data/core/data.rbs +415 -0
  35. data/core/dir.rbs +993 -0
  36. data/core/encoding.rbs +1368 -0
  37. data/core/enumerable.rbs +2506 -0
  38. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  39. data/core/enumerator/product.rbs +92 -0
  40. data/core/enumerator.rbs +705 -0
  41. data/core/env.rbs +6 -0
  42. data/core/errno.rbs +682 -0
  43. data/core/errors.rbs +789 -0
  44. data/core/exception.rbs +485 -0
  45. data/core/false_class.rbs +82 -0
  46. data/core/fiber.rbs +570 -0
  47. data/core/fiber_error.rbs +11 -0
  48. data/core/file.rbs +2045 -0
  49. data/core/file_constants.rbs +463 -0
  50. data/core/file_stat.rbs +534 -0
  51. data/core/file_test.rbs +331 -0
  52. data/core/float.rbs +1316 -0
  53. data/core/gc.rbs +788 -0
  54. data/core/global_variables.rbs +184 -0
  55. data/core/hash.rbs +2183 -0
  56. data/core/integer.rbs +1374 -0
  57. data/core/io/buffer.rbs +995 -0
  58. data/core/io/wait.rbs +48 -0
  59. data/core/io.rbs +3472 -0
  60. data/core/kernel.rbs +3172 -0
  61. data/core/marshal.rbs +207 -0
  62. data/core/match_data.rbs +637 -0
  63. data/core/math.rbs +770 -0
  64. data/core/method.rbs +422 -0
  65. data/core/module.rbs +1856 -0
  66. data/core/nil_class.rbs +210 -0
  67. data/core/numeric.rbs +832 -0
  68. data/core/object.rbs +108 -0
  69. data/core/object_space/weak_key_map.rbs +166 -0
  70. data/core/object_space.rbs +197 -0
  71. data/core/pathname.rbs +1322 -0
  72. data/core/proc.rbs +905 -0
  73. data/core/process.rbs +2316 -0
  74. data/core/ractor.rbs +924 -0
  75. data/core/random.rbs +255 -0
  76. data/core/range.rbs +1209 -0
  77. data/core/rational.rbs +502 -0
  78. data/core/rb_config.rbs +88 -0
  79. data/core/rbs/ops.rbs +154 -0
  80. data/core/rbs/unnamed/argf.rbs +1236 -0
  81. data/core/rbs/unnamed/env_class.rbs +1214 -0
  82. data/core/rbs/unnamed/main_class.rbs +123 -0
  83. data/core/rbs/unnamed/random.rbs +186 -0
  84. data/core/refinement.rbs +59 -0
  85. data/core/regexp.rbs +1974 -0
  86. data/core/ruby.rbs +53 -0
  87. data/core/ruby_vm.rbs +809 -0
  88. data/core/rubygems/basic_specification.rbs +6 -0
  89. data/core/rubygems/config_file.rbs +38 -0
  90. data/core/rubygems/dependency_installer.rbs +6 -0
  91. data/core/rubygems/errors.rbs +109 -0
  92. data/core/rubygems/installer.rbs +15 -0
  93. data/core/rubygems/path_support.rbs +6 -0
  94. data/core/rubygems/platform.rbs +7 -0
  95. data/core/rubygems/request_set.rbs +49 -0
  96. data/core/rubygems/requirement.rbs +148 -0
  97. data/core/rubygems/rubygems.rbs +1105 -0
  98. data/core/rubygems/source_list.rbs +15 -0
  99. data/core/rubygems/specification.rbs +23 -0
  100. data/core/rubygems/stream_ui.rbs +5 -0
  101. data/core/rubygems/uninstaller.rbs +10 -0
  102. data/core/rubygems/version.rbs +293 -0
  103. data/core/set.rbs +751 -0
  104. data/core/signal.rbs +110 -0
  105. data/core/string.rbs +5532 -0
  106. data/core/struct.rbs +668 -0
  107. data/core/symbol.rbs +482 -0
  108. data/core/thread.rbs +1826 -0
  109. data/core/thread_group.rbs +79 -0
  110. data/core/time.rbs +1793 -0
  111. data/core/trace_point.rbs +483 -0
  112. data/core/true_class.rbs +98 -0
  113. data/core/unbound_method.rbs +337 -0
  114. data/core/warning.rbs +87 -0
  115. data/docs/CONTRIBUTING.md +107 -0
  116. data/docs/aliases.md +79 -0
  117. data/docs/architecture.md +110 -0
  118. data/docs/collection.md +192 -0
  119. data/docs/config.md +171 -0
  120. data/docs/data_and_struct.md +86 -0
  121. data/docs/encoding.md +56 -0
  122. data/docs/gem.md +56 -0
  123. data/docs/inline.md +634 -0
  124. data/docs/rbs_by_example.md +309 -0
  125. data/docs/repo.md +125 -0
  126. data/docs/rust.md +96 -0
  127. data/docs/sigs.md +167 -0
  128. data/docs/stdlib.md +147 -0
  129. data/docs/syntax.md +940 -0
  130. data/docs/tools.md +17 -0
  131. data/docs/type_fingerprint.md +21 -0
  132. data/docs/wasm_serialization.md +80 -0
  133. data/exe/rbs +7 -0
  134. data/ext/rbs_extension/ast_translation.c +1855 -0
  135. data/ext/rbs_extension/ast_translation.h +41 -0
  136. data/ext/rbs_extension/class_constants.c +187 -0
  137. data/ext/rbs_extension/class_constants.h +104 -0
  138. data/ext/rbs_extension/compat.h +10 -0
  139. data/ext/rbs_extension/extconf.rb +40 -0
  140. data/ext/rbs_extension/legacy_location.c +294 -0
  141. data/ext/rbs_extension/legacy_location.h +82 -0
  142. data/ext/rbs_extension/main.c +613 -0
  143. data/ext/rbs_extension/rbs_extension.h +16 -0
  144. data/ext/rbs_extension/rbs_string_bridging.c +9 -0
  145. data/ext/rbs_extension/rbs_string_bridging.h +24 -0
  146. data/goodcheck.yml +91 -0
  147. data/include/rbs/ast.h +1047 -0
  148. data/include/rbs/defines.h +99 -0
  149. data/include/rbs/lexer.h +207 -0
  150. data/include/rbs/location.h +40 -0
  151. data/include/rbs/parser.h +153 -0
  152. data/include/rbs/serialize.h +39 -0
  153. data/include/rbs/string.h +47 -0
  154. data/include/rbs/util/rbs_allocator.h +59 -0
  155. data/include/rbs/util/rbs_assert.h +20 -0
  156. data/include/rbs/util/rbs_buffer.h +83 -0
  157. data/include/rbs/util/rbs_constant_pool.h +155 -0
  158. data/include/rbs/util/rbs_encoding.h +282 -0
  159. data/include/rbs/util/rbs_unescape.h +24 -0
  160. data/include/rbs.h +14 -0
  161. data/lib/rbs/ancestor_graph.rb +92 -0
  162. data/lib/rbs/annotate/annotations.rb +199 -0
  163. data/lib/rbs/annotate/formatter.rb +82 -0
  164. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  165. data/lib/rbs/annotate/rdoc_source.rb +131 -0
  166. data/lib/rbs/annotate.rb +8 -0
  167. data/lib/rbs/ast/annotation.rb +29 -0
  168. data/lib/rbs/ast/comment.rb +29 -0
  169. data/lib/rbs/ast/declarations.rb +472 -0
  170. data/lib/rbs/ast/directives.rb +49 -0
  171. data/lib/rbs/ast/members.rb +451 -0
  172. data/lib/rbs/ast/ruby/annotations.rb +451 -0
  173. data/lib/rbs/ast/ruby/comment_block.rb +247 -0
  174. data/lib/rbs/ast/ruby/declarations.rb +291 -0
  175. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +28 -0
  176. data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
  177. data/lib/rbs/ast/ruby/members.rb +762 -0
  178. data/lib/rbs/ast/type_param.rb +235 -0
  179. data/lib/rbs/ast/visitor.rb +137 -0
  180. data/lib/rbs/buffer.rb +189 -0
  181. data/lib/rbs/builtin_names.rb +58 -0
  182. data/lib/rbs/cli/colored_io.rb +48 -0
  183. data/lib/rbs/cli/diff.rb +84 -0
  184. data/lib/rbs/cli/validate.rb +294 -0
  185. data/lib/rbs/cli.rb +1253 -0
  186. data/lib/rbs/collection/cleaner.rb +38 -0
  187. data/lib/rbs/collection/config/lockfile.rb +92 -0
  188. data/lib/rbs/collection/config/lockfile_generator.rb +269 -0
  189. data/lib/rbs/collection/config.rb +81 -0
  190. data/lib/rbs/collection/installer.rb +32 -0
  191. data/lib/rbs/collection/sources/base.rb +14 -0
  192. data/lib/rbs/collection/sources/git.rb +265 -0
  193. data/lib/rbs/collection/sources/local.rb +81 -0
  194. data/lib/rbs/collection/sources/rubygems.rb +48 -0
  195. data/lib/rbs/collection/sources/stdlib.rb +50 -0
  196. data/lib/rbs/collection/sources.rb +38 -0
  197. data/lib/rbs/collection.rb +16 -0
  198. data/lib/rbs/constant.rb +28 -0
  199. data/lib/rbs/definition.rb +415 -0
  200. data/lib/rbs/definition_builder/ancestor_builder.rb +678 -0
  201. data/lib/rbs/definition_builder/method_builder.rb +295 -0
  202. data/lib/rbs/definition_builder.rb +1054 -0
  203. data/lib/rbs/diff.rb +131 -0
  204. data/lib/rbs/environment/class_entry.rb +69 -0
  205. data/lib/rbs/environment/module_entry.rb +66 -0
  206. data/lib/rbs/environment/use_map.rb +77 -0
  207. data/lib/rbs/environment.rb +1028 -0
  208. data/lib/rbs/environment_loader.rb +167 -0
  209. data/lib/rbs/environment_walker.rb +155 -0
  210. data/lib/rbs/errors.rb +634 -0
  211. data/lib/rbs/factory.rb +18 -0
  212. data/lib/rbs/file_finder.rb +28 -0
  213. data/lib/rbs/inline_parser/comment_association.rb +117 -0
  214. data/lib/rbs/inline_parser.rb +568 -0
  215. data/lib/rbs/location_aux.rb +170 -0
  216. data/lib/rbs/locator.rb +247 -0
  217. data/lib/rbs/method_type.rb +145 -0
  218. data/lib/rbs/namespace.rb +154 -0
  219. data/lib/rbs/parser/lex_result.rb +15 -0
  220. data/lib/rbs/parser/token.rb +23 -0
  221. data/lib/rbs/parser_aux.rb +142 -0
  222. data/lib/rbs/prototype/helpers.rb +197 -0
  223. data/lib/rbs/prototype/node_usage.rb +99 -0
  224. data/lib/rbs/prototype/rb.rb +816 -0
  225. data/lib/rbs/prototype/rbi.rb +625 -0
  226. data/lib/rbs/prototype/runtime/helpers.rb +59 -0
  227. data/lib/rbs/prototype/runtime/reflection.rb +19 -0
  228. data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
  229. data/lib/rbs/prototype/runtime.rb +680 -0
  230. data/lib/rbs/repository.rb +127 -0
  231. data/lib/rbs/resolver/constant_resolver.rb +219 -0
  232. data/lib/rbs/resolver/type_name_resolver.rb +167 -0
  233. data/lib/rbs/rewriter.rb +70 -0
  234. data/lib/rbs/sorter.rb +198 -0
  235. data/lib/rbs/source.rb +99 -0
  236. data/lib/rbs/substitution.rb +83 -0
  237. data/lib/rbs/subtractor.rb +204 -0
  238. data/lib/rbs/test/errors.rb +80 -0
  239. data/lib/rbs/test/guaranteed.rb +30 -0
  240. data/lib/rbs/test/hook.rb +212 -0
  241. data/lib/rbs/test/observer.rb +19 -0
  242. data/lib/rbs/test/setup.rb +84 -0
  243. data/lib/rbs/test/setup_helper.rb +50 -0
  244. data/lib/rbs/test/tester.rb +167 -0
  245. data/lib/rbs/test/type_check.rb +457 -0
  246. data/lib/rbs/test.rb +112 -0
  247. data/lib/rbs/type_alias_dependency.rb +100 -0
  248. data/lib/rbs/type_alias_regularity.rb +126 -0
  249. data/lib/rbs/type_name.rb +122 -0
  250. data/lib/rbs/types.rb +1604 -0
  251. data/lib/rbs/unit_test/convertibles.rb +177 -0
  252. data/lib/rbs/unit_test/spy.rb +138 -0
  253. data/lib/rbs/unit_test/type_assertions.rb +383 -0
  254. data/lib/rbs/unit_test/with_aliases.rb +145 -0
  255. data/lib/rbs/unit_test.rb +6 -0
  256. data/lib/rbs/validator.rb +186 -0
  257. data/lib/rbs/variance_calculator.rb +189 -0
  258. data/lib/rbs/vendorer.rb +71 -0
  259. data/lib/rbs/version.rb +5 -0
  260. data/lib/rbs/wasm/deserializer.rb +213 -0
  261. data/lib/rbs/wasm/jars/asm-analysis.jar +0 -0
  262. data/lib/rbs/wasm/jars/asm-commons.jar +0 -0
  263. data/lib/rbs/wasm/jars/asm-tree.jar +0 -0
  264. data/lib/rbs/wasm/jars/asm-util.jar +0 -0
  265. data/lib/rbs/wasm/jars/asm.jar +0 -0
  266. data/lib/rbs/wasm/jars/compiler.jar +0 -0
  267. data/lib/rbs/wasm/jars/log.jar +0 -0
  268. data/lib/rbs/wasm/jars/runtime.jar +0 -0
  269. data/lib/rbs/wasm/jars/wasi.jar +0 -0
  270. data/lib/rbs/wasm/jars/wasm.jar +0 -0
  271. data/lib/rbs/wasm/location.rb +61 -0
  272. data/lib/rbs/wasm/parser.rb +137 -0
  273. data/lib/rbs/wasm/rbs_parser.wasm +0 -0
  274. data/lib/rbs/wasm/runtime.rb +217 -0
  275. data/lib/rbs/wasm/serialization_schema.rb +110 -0
  276. data/lib/rbs/writer.rb +424 -0
  277. data/lib/rbs.rb +117 -0
  278. data/lib/rdoc/discover.rb +20 -0
  279. data/lib/rdoc_plugin/parser.rb +163 -0
  280. data/rbs.gemspec +68 -0
  281. data/schema/annotation.json +14 -0
  282. data/schema/comment.json +26 -0
  283. data/schema/decls.json +326 -0
  284. data/schema/function.json +87 -0
  285. data/schema/location.json +56 -0
  286. data/schema/members.json +266 -0
  287. data/schema/methodType.json +50 -0
  288. data/schema/typeParam.json +52 -0
  289. data/schema/types.json +317 -0
  290. data/sig/ancestor_builder.rbs +163 -0
  291. data/sig/ancestor_graph.rbs +60 -0
  292. data/sig/annotate/annotations.rbs +102 -0
  293. data/sig/annotate/formatter.rbs +24 -0
  294. data/sig/annotate/rdoc_annotater.rbs +85 -0
  295. data/sig/annotate/rdoc_source.rbs +32 -0
  296. data/sig/annotation.rbs +27 -0
  297. data/sig/ast/ruby/annotations.rbs +470 -0
  298. data/sig/ast/ruby/comment_block.rbs +127 -0
  299. data/sig/ast/ruby/declarations.rbs +158 -0
  300. data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
  301. data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
  302. data/sig/ast/ruby/members.rbs +198 -0
  303. data/sig/buffer.rbs +108 -0
  304. data/sig/builtin_names.rbs +44 -0
  305. data/sig/cli/colored_io.rbs +15 -0
  306. data/sig/cli/diff.rbs +15 -0
  307. data/sig/cli/validate.rbs +47 -0
  308. data/sig/cli.rbs +89 -0
  309. data/sig/collection/cleaner.rbs +13 -0
  310. data/sig/collection/config/lockfile.rbs +74 -0
  311. data/sig/collection/config/lockfile_generator.rbs +68 -0
  312. data/sig/collection/config.rbs +46 -0
  313. data/sig/collection/installer.rbs +17 -0
  314. data/sig/collection/sources.rbs +214 -0
  315. data/sig/collection.rbs +4 -0
  316. data/sig/comment.rbs +26 -0
  317. data/sig/constant.rbs +21 -0
  318. data/sig/declarations.rbs +274 -0
  319. data/sig/definition.rbs +232 -0
  320. data/sig/definition_builder.rbs +181 -0
  321. data/sig/diff.rbs +28 -0
  322. data/sig/directives.rbs +77 -0
  323. data/sig/environment/class_entry.rbs +50 -0
  324. data/sig/environment/module_entry.rbs +50 -0
  325. data/sig/environment.rbs +286 -0
  326. data/sig/environment_loader.rbs +111 -0
  327. data/sig/environment_walker.rbs +65 -0
  328. data/sig/errors.rbs +408 -0
  329. data/sig/factory.rbs +5 -0
  330. data/sig/file_finder.rbs +28 -0
  331. data/sig/inline_parser/comment_association.rbs +71 -0
  332. data/sig/inline_parser.rbs +126 -0
  333. data/sig/location.rbs +135 -0
  334. data/sig/locator.rbs +56 -0
  335. data/sig/manifest.yaml +5 -0
  336. data/sig/members.rbs +258 -0
  337. data/sig/method_builder.rbs +89 -0
  338. data/sig/method_types.rbs +58 -0
  339. data/sig/namespace.rbs +161 -0
  340. data/sig/parser.rbs +164 -0
  341. data/sig/prototype/helpers.rbs +29 -0
  342. data/sig/prototype/node_usage.rbs +20 -0
  343. data/sig/prototype/rb.rbs +96 -0
  344. data/sig/prototype/rbi.rbs +75 -0
  345. data/sig/prototype/runtime.rbs +182 -0
  346. data/sig/rbs.rbs +21 -0
  347. data/sig/rdoc/rbs.rbs +67 -0
  348. data/sig/repository.rbs +85 -0
  349. data/sig/resolver/constant_resolver.rbs +92 -0
  350. data/sig/resolver/context.rbs +34 -0
  351. data/sig/resolver/type_name_resolver.rbs +61 -0
  352. data/sig/rewriter.rbs +45 -0
  353. data/sig/shims/bundler.rbs +38 -0
  354. data/sig/shims/enumerable.rbs +5 -0
  355. data/sig/shims/rubygems.rbs +19 -0
  356. data/sig/sorter.rbs +41 -0
  357. data/sig/source.rbs +48 -0
  358. data/sig/substitution.rbs +48 -0
  359. data/sig/subtractor.rbs +37 -0
  360. data/sig/test/errors.rbs +52 -0
  361. data/sig/test/guranteed.rbs +9 -0
  362. data/sig/test/type_check.rbs +19 -0
  363. data/sig/test.rbs +82 -0
  364. data/sig/type_alias_dependency.rbs +53 -0
  365. data/sig/type_alias_regularity.rbs +98 -0
  366. data/sig/type_param.rbs +115 -0
  367. data/sig/typename.rbs +89 -0
  368. data/sig/types.rbs +578 -0
  369. data/sig/unit_test/convertibles.rbs +154 -0
  370. data/sig/unit_test/spy.rbs +22 -0
  371. data/sig/unit_test/type_assertions.rbs +211 -0
  372. data/sig/unit_test/with_aliases.rbs +136 -0
  373. data/sig/use_map.rbs +35 -0
  374. data/sig/util.rbs +9 -0
  375. data/sig/validator.rbs +63 -0
  376. data/sig/variance_calculator.rbs +87 -0
  377. data/sig/vendorer.rbs +51 -0
  378. data/sig/version.rbs +3 -0
  379. data/sig/visitor.rbs +47 -0
  380. data/sig/wasm/deserializer.rbs +66 -0
  381. data/sig/wasm/serialization_schema.rbs +13 -0
  382. data/sig/writer.rbs +127 -0
  383. data/src/ast.c +1628 -0
  384. data/src/lexer.c +3217 -0
  385. data/src/lexer.re +155 -0
  386. data/src/lexstate.c +217 -0
  387. data/src/location.c +31 -0
  388. data/src/parser.c +4255 -0
  389. data/src/serialize.c +958 -0
  390. data/src/string.c +41 -0
  391. data/src/util/rbs_allocator.c +162 -0
  392. data/src/util/rbs_assert.c +19 -0
  393. data/src/util/rbs_buffer.c +54 -0
  394. data/src/util/rbs_constant_pool.c +268 -0
  395. data/src/util/rbs_encoding.c +21308 -0
  396. data/src/util/rbs_unescape.c +167 -0
  397. data/stdlib/abbrev/0/abbrev.rbs +66 -0
  398. data/stdlib/abbrev/0/array.rbs +26 -0
  399. data/stdlib/base64/0/base64.rbs +355 -0
  400. data/stdlib/benchmark/0/benchmark.rbs +452 -0
  401. data/stdlib/bigdecimal/0/big_decimal.rbs +1647 -0
  402. data/stdlib/bigdecimal-math/0/big_math.rbs +280 -0
  403. data/stdlib/bigdecimal-math/0/manifest.yaml +2 -0
  404. data/stdlib/cgi/0/core.rbs +911 -0
  405. data/stdlib/cgi/0/manifest.yaml +4 -0
  406. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  407. data/stdlib/coverage/0/coverage.rbs +266 -0
  408. data/stdlib/csv/0/csv.rbs +3776 -0
  409. data/stdlib/csv/0/manifest.yaml +3 -0
  410. data/stdlib/date/0/date.rbs +1598 -0
  411. data/stdlib/date/0/date_time.rbs +617 -0
  412. data/stdlib/date/0/time.rbs +26 -0
  413. data/stdlib/dbm/0/dbm.rbs +421 -0
  414. data/stdlib/delegate/0/delegator.rbs +187 -0
  415. data/stdlib/delegate/0/kernel.rbs +47 -0
  416. data/stdlib/delegate/0/simple_delegator.rbs +96 -0
  417. data/stdlib/did_you_mean/0/did_you_mean.rbs +344 -0
  418. data/stdlib/digest/0/digest.rbs +687 -0
  419. data/stdlib/erb/0/erb.rbs +933 -0
  420. data/stdlib/etc/0/etc.rbs +884 -0
  421. data/stdlib/fileutils/0/fileutils.rbs +1753 -0
  422. data/stdlib/find/0/find.rbs +49 -0
  423. data/stdlib/forwardable/0/forwardable.rbs +271 -0
  424. data/stdlib/io-console/0/io-console.rbs +414 -0
  425. data/stdlib/ipaddr/0/ipaddr.rbs +436 -0
  426. data/stdlib/json/0/json.rbs +1963 -0
  427. data/stdlib/kconv/0/kconv.rbs +166 -0
  428. data/stdlib/logger/0/formatter.rbs +45 -0
  429. data/stdlib/logger/0/log_device.rbs +100 -0
  430. data/stdlib/logger/0/logger.rbs +796 -0
  431. data/stdlib/logger/0/manifest.yaml +2 -0
  432. data/stdlib/logger/0/period.rbs +17 -0
  433. data/stdlib/logger/0/severity.rbs +34 -0
  434. data/stdlib/minitest/0/kernel.rbs +42 -0
  435. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +52 -0
  436. data/stdlib/minitest/0/minitest/assertion.rbs +17 -0
  437. data/stdlib/minitest/0/minitest/assertions.rbs +590 -0
  438. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +23 -0
  439. data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
  440. data/stdlib/minitest/0/minitest/benchmark.rbs +259 -0
  441. data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
  442. data/stdlib/minitest/0/minitest/compress.rbs +13 -0
  443. data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
  444. data/stdlib/minitest/0/minitest/expectation.rbs +2 -0
  445. data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
  446. data/stdlib/minitest/0/minitest/guard.rbs +64 -0
  447. data/stdlib/minitest/0/minitest/mock.rbs +64 -0
  448. data/stdlib/minitest/0/minitest/parallel/executor.rbs +46 -0
  449. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +5 -0
  450. data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
  451. data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
  452. data/stdlib/minitest/0/minitest/pride_io.rbs +62 -0
  453. data/stdlib/minitest/0/minitest/pride_lol.rbs +19 -0
  454. data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
  455. data/stdlib/minitest/0/minitest/reportable.rbs +53 -0
  456. data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
  457. data/stdlib/minitest/0/minitest/result.rbs +28 -0
  458. data/stdlib/minitest/0/minitest/runnable.rbs +163 -0
  459. data/stdlib/minitest/0/minitest/skip.rbs +6 -0
  460. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
  461. data/stdlib/minitest/0/minitest/spec/dsl.rbs +129 -0
  462. data/stdlib/minitest/0/minitest/spec.rbs +11 -0
  463. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +81 -0
  464. data/stdlib/minitest/0/minitest/summary_reporter.rbs +18 -0
  465. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
  466. data/stdlib/minitest/0/minitest/test.rbs +69 -0
  467. data/stdlib/minitest/0/minitest/unexpected_error.rbs +12 -0
  468. data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
  469. data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
  470. data/stdlib/minitest/0/minitest/unit.rbs +4 -0
  471. data/stdlib/minitest/0/minitest.rbs +115 -0
  472. data/stdlib/monitor/0/monitor.rbs +363 -0
  473. data/stdlib/mutex_m/0/mutex_m.rbs +104 -0
  474. data/stdlib/net-http/0/manifest.yaml +3 -0
  475. data/stdlib/net-http/0/net-http.rbs +5580 -0
  476. data/stdlib/net-protocol/0/manifest.yaml +2 -0
  477. data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
  478. data/stdlib/net-smtp/0/manifest.yaml +2 -0
  479. data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
  480. data/stdlib/nkf/0/nkf.rbs +402 -0
  481. data/stdlib/objspace/0/objspace.rbs +470 -0
  482. data/stdlib/observable/0/observable.rbs +217 -0
  483. data/stdlib/open-uri/0/manifest.yaml +4 -0
  484. data/stdlib/open-uri/0/open-uri.rbs +433 -0
  485. data/stdlib/open3/0/open3.rbs +606 -0
  486. data/stdlib/openssl/0/manifest.yaml +3 -0
  487. data/stdlib/openssl/0/openssl.rbs +12231 -0
  488. data/stdlib/optparse/0/optparse.rbs +1734 -0
  489. data/stdlib/pathname/0/pathname.rbs +36 -0
  490. data/stdlib/pp/0/manifest.yaml +2 -0
  491. data/stdlib/pp/0/pp.rbs +301 -0
  492. data/stdlib/prettyprint/0/prettyprint.rbs +383 -0
  493. data/stdlib/pstore/0/pstore.rbs +608 -0
  494. data/stdlib/psych/0/core_ext.rbs +12 -0
  495. data/stdlib/psych/0/dbm.rbs +237 -0
  496. data/stdlib/psych/0/manifest.yaml +3 -0
  497. data/stdlib/psych/0/psych.rbs +455 -0
  498. data/stdlib/psych/0/store.rbs +57 -0
  499. data/stdlib/pty/0/pty.rbs +240 -0
  500. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  501. data/stdlib/rdoc/0/code_object.rbs +52 -0
  502. data/stdlib/rdoc/0/comment.rbs +61 -0
  503. data/stdlib/rdoc/0/context.rbs +153 -0
  504. data/stdlib/rdoc/0/markup.rbs +117 -0
  505. data/stdlib/rdoc/0/options.rbs +76 -0
  506. data/stdlib/rdoc/0/parser.rbs +56 -0
  507. data/stdlib/rdoc/0/rdoc.rbs +393 -0
  508. data/stdlib/rdoc/0/ri.rbs +17 -0
  509. data/stdlib/rdoc/0/store.rbs +48 -0
  510. data/stdlib/rdoc/0/top_level.rbs +97 -0
  511. data/stdlib/resolv/0/manifest.yaml +3 -0
  512. data/stdlib/resolv/0/resolv.rbs +1787 -0
  513. data/stdlib/ripper/0/ripper.rbs +1654 -0
  514. data/stdlib/securerandom/0/manifest.yaml +2 -0
  515. data/stdlib/securerandom/0/securerandom.rbs +49 -0
  516. data/stdlib/shellwords/0/shellwords.rbs +229 -0
  517. data/stdlib/singleton/0/singleton.rbs +134 -0
  518. data/stdlib/socket/0/addrinfo.rbs +666 -0
  519. data/stdlib/socket/0/basic_socket.rbs +590 -0
  520. data/stdlib/socket/0/constants.rbs +2295 -0
  521. data/stdlib/socket/0/ip_socket.rbs +94 -0
  522. data/stdlib/socket/0/socket.rbs +4170 -0
  523. data/stdlib/socket/0/socket_error.rbs +5 -0
  524. data/stdlib/socket/0/tcp_server.rbs +192 -0
  525. data/stdlib/socket/0/tcp_socket.rbs +87 -0
  526. data/stdlib/socket/0/udp_socket.rbs +133 -0
  527. data/stdlib/socket/0/unix_server.rbs +169 -0
  528. data/stdlib/socket/0/unix_socket.rbs +172 -0
  529. data/stdlib/stringio/0/stringio.rbs +1681 -0
  530. data/stdlib/strscan/0/string_scanner.rbs +1648 -0
  531. data/stdlib/tempfile/0/tempfile.rbs +483 -0
  532. data/stdlib/time/0/time.rbs +434 -0
  533. data/stdlib/timeout/0/timeout.rbs +137 -0
  534. data/stdlib/tmpdir/0/tmpdir.rbs +69 -0
  535. data/stdlib/tsort/0/cyclic.rbs +8 -0
  536. data/stdlib/tsort/0/interfaces.rbs +20 -0
  537. data/stdlib/tsort/0/tsort.rbs +410 -0
  538. data/stdlib/uri/0/common.rbs +621 -0
  539. data/stdlib/uri/0/file.rbs +118 -0
  540. data/stdlib/uri/0/ftp.rbs +13 -0
  541. data/stdlib/uri/0/generic.rbs +1116 -0
  542. data/stdlib/uri/0/http.rbs +104 -0
  543. data/stdlib/uri/0/https.rbs +14 -0
  544. data/stdlib/uri/0/ldap.rbs +230 -0
  545. data/stdlib/uri/0/ldaps.rbs +14 -0
  546. data/stdlib/uri/0/mailto.rbs +92 -0
  547. data/stdlib/uri/0/rfc2396_parser.rbs +189 -0
  548. data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
  549. data/stdlib/uri/0/ws.rbs +13 -0
  550. data/stdlib/uri/0/wss.rbs +9 -0
  551. data/stdlib/yaml/0/manifest.yaml +2 -0
  552. data/stdlib/yaml/0/yaml.rbs +1 -0
  553. data/stdlib/zlib/0/buf_error.rbs +10 -0
  554. data/stdlib/zlib/0/data_error.rbs +10 -0
  555. data/stdlib/zlib/0/deflate.rbs +211 -0
  556. data/stdlib/zlib/0/error.rbs +20 -0
  557. data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
  558. data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
  559. data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
  560. data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
  561. data/stdlib/zlib/0/gzip_file.rbs +156 -0
  562. data/stdlib/zlib/0/gzip_reader.rbs +293 -0
  563. data/stdlib/zlib/0/gzip_writer.rbs +168 -0
  564. data/stdlib/zlib/0/inflate.rbs +180 -0
  565. data/stdlib/zlib/0/mem_error.rbs +10 -0
  566. data/stdlib/zlib/0/need_dict.rbs +13 -0
  567. data/stdlib/zlib/0/stream_end.rbs +11 -0
  568. data/stdlib/zlib/0/stream_error.rbs +11 -0
  569. data/stdlib/zlib/0/version_error.rbs +11 -0
  570. data/stdlib/zlib/0/zlib.rbs +449 -0
  571. data/stdlib/zlib/0/zstream.rbs +201 -0
  572. data/wasm/README.md +59 -0
  573. data/wasm/rbs_wasm.c +411 -0
  574. metadata +660 -0
data/core/time.rbs ADDED
@@ -0,0 +1,1793 @@
1
+ # <!-- rdoc-file=timev.rb -->
2
+ # A `Time` object represents a date and time:
3
+ #
4
+ # Time.new(2000, 1, 1, 0, 0, 0) # => 2000-01-01 00:00:00 -0600
5
+ #
6
+ # Although its value can be expressed as a single numeric (see [Epoch
7
+ # Seconds](rdoc-ref:Time@Epoch+Seconds) below), it can be convenient to deal
8
+ # with the value by parts:
9
+ #
10
+ # t = Time.new(-2000, 1, 1, 0, 0, 0.0)
11
+ # # => -2000-01-01 00:00:00 -0600
12
+ # t.year # => -2000
13
+ # t.month # => 1
14
+ # t.mday # => 1
15
+ # t.hour # => 0
16
+ # t.min # => 0
17
+ # t.sec # => 0
18
+ # t.subsec # => 0
19
+ #
20
+ # t = Time.new(2000, 12, 31, 23, 59, 59.5)
21
+ # # => 2000-12-31 23:59:59.5 -0600
22
+ # t.year # => 2000
23
+ # t.month # => 12
24
+ # t.mday # => 31
25
+ # t.hour # => 23
26
+ # t.min # => 59
27
+ # t.sec # => 59
28
+ # t.subsec # => (1/2)
29
+ #
30
+ # ## Epoch Seconds
31
+ #
32
+ # *Epoch seconds* is the exact number of seconds (including fractional
33
+ # subseconds) since the Unix Epoch, January 1, 1970.
34
+ #
35
+ # You can retrieve that value exactly using method Time.to_r:
36
+ #
37
+ # Time.at(0).to_r # => (0/1)
38
+ # Time.at(0.999999).to_r # => (9007190247541737/9007199254740992)
39
+ #
40
+ # Other retrieval methods such as Time#to_i and Time#to_f may return a value
41
+ # that rounds or truncates subseconds.
42
+ #
43
+ # ## Time Resolution
44
+ #
45
+ # A `Time` object derived from the system clock (for example, by method
46
+ # Time.now) has the resolution supported by the system.
47
+ #
48
+ # ## Time Internal Representation
49
+ #
50
+ # Conceptually, Time class uses a rational value to represent the number of
51
+ # seconds from *Epoch*, 1970-01-01 00:00:00 UTC. There are no boundary or
52
+ # resolution limitations. The value can be obtained using Time#to_r.
53
+ #
54
+ # The Time class always uses the Gregorian calendar. I.e. the proleptic
55
+ # Gregorian calendar is used. Other calendars, such as Julian calendar, are not
56
+ # supported.
57
+ #
58
+ # The implementation uses a signed 63 bit integer, Integer (Bignum) object or
59
+ # Ratoinal object to represent a rational value. (The signed 63 bit integer is
60
+ # used regardless of 32 and 64 bit environments.) The value represents the
61
+ # number of nanoseconds from *Epoch*. The signed 63 bit integer can represent
62
+ # 1823-11-12 to 2116-02-20. When Integer or Rational object is used (before
63
+ # 1823, after 2116, under nanosecond), Time works slower than when the signed 63
64
+ # bit integer is used.
65
+ #
66
+ # Ruby uses the C function `localtime` and `gmtime` to map between the number
67
+ # and 6-tuple (year,month,day,hour,minute,second). `localtime` is used for local
68
+ # time and `gmtime` is used for UTC.
69
+ #
70
+ # Integer and Rational has no range limit, but the localtime and gmtime has
71
+ # range limits due to the C types `time_t` and `struct tm`. If that limit is
72
+ # exceeded, Ruby extrapolates the localtime function.
73
+ #
74
+ # `time_t` can represent 1901-12-14 to 2038-01-19 if it is 32 bit signed
75
+ # integer, -292277022657-01-27 to 292277026596-12-05 if it is 64 bit signed
76
+ # integer. However `localtime` on some platforms doesn't supports negative
77
+ # `time_t` (before 1970).
78
+ #
79
+ # `struct tm` has *tm_year* member to represent years. (<code>tm_year = 0</code>
80
+ # means the year 1900.) It is defined as `int` in the C standard. *tm_year* can
81
+ # represent years between -2147481748 to 2147485547 if `int` is 32 bit.
82
+ #
83
+ # Ruby supports leap seconds as far as if the C function `localtime` and
84
+ # `gmtime` supports it. They use the tz database in most Unix systems. The tz
85
+ # database has timezones which supports leap seconds. For example, "Asia/Tokyo"
86
+ # doesn't support leap seconds but "right/Asia/Tokyo" supports leap seconds. So,
87
+ # Ruby supports leap seconds if the TZ environment variable is set to
88
+ # "right/Asia/Tokyo" in most Unix systems.
89
+ #
90
+ # ## Examples
91
+ #
92
+ # All of these examples were done using the EST timezone which is GMT-5.
93
+ #
94
+ # ### Creating a New `Time` Instance
95
+ #
96
+ # You can create a new instance of Time with Time.new. This will use the current
97
+ # system time. Time.now is an alias for this. You can also pass parts of the
98
+ # time to Time.new such as year, month, minute, etc. When you want to construct
99
+ # a time this way you must pass at least a year. If you pass the year with
100
+ # nothing else time will default to January 1 of that year at 00:00:00 with the
101
+ # current system timezone. Here are some examples:
102
+ #
103
+ # Time.new(2002) #=> 2002-01-01 00:00:00 -0500
104
+ # Time.new(2002, 10) #=> 2002-10-01 00:00:00 -0500
105
+ # Time.new(2002, 10, 31) #=> 2002-10-31 00:00:00 -0500
106
+ #
107
+ # You can pass a UTC offset:
108
+ #
109
+ # Time.new(2002, 10, 31, 2, 2, 2, "+02:00") #=> 2002-10-31 02:02:02 +0200
110
+ #
111
+ # Or [a timezone object](rdoc-ref:Time@Timezone+Objects):
112
+ #
113
+ # zone = timezone("Europe/Athens") # Eastern European Time, UTC+2
114
+ # Time.new(2002, 10, 31, 2, 2, 2, zone) #=> 2002-10-31 02:02:02 +0200
115
+ #
116
+ # You can also use Time.local and Time.utc to infer local and UTC timezones
117
+ # instead of using the current system setting.
118
+ #
119
+ # You can also create a new time using Time.at which takes the number of seconds
120
+ # (with subsecond) since the [Unix
121
+ # Epoch](https://en.wikipedia.org/wiki/Unix_time).
122
+ #
123
+ # Time.at(628232400) #=> 1989-11-28 00:00:00 -0500
124
+ #
125
+ # ### Working with an Instance of `Time`
126
+ #
127
+ # Once you have an instance of Time there is a multitude of things you can do
128
+ # with it. Below are some examples. For all of the following examples, we will
129
+ # work on the assumption that you have done the following:
130
+ #
131
+ # t = Time.new(1993, 02, 24, 12, 0, 0, "+09:00")
132
+ #
133
+ # Was that a monday?
134
+ #
135
+ # t.monday? #=> false
136
+ #
137
+ # What year was that again?
138
+ #
139
+ # t.year #=> 1993
140
+ #
141
+ # Was it daylight savings at the time?
142
+ #
143
+ # t.dst? #=> false
144
+ #
145
+ # What's the day a year later?
146
+ #
147
+ # t + (60*60*24*365) #=> 1994-02-24 12:00:00 +0900
148
+ #
149
+ # How many seconds was that since the Unix Epoch?
150
+ #
151
+ # t.to_i #=> 730522800
152
+ #
153
+ # You can also do standard functions like compare two times.
154
+ #
155
+ # t1 = Time.new(2010)
156
+ # t2 = Time.new(2011)
157
+ #
158
+ # t1 == t2 #=> false
159
+ # t1 == t1 #=> true
160
+ # t1 < t2 #=> true
161
+ # t1 > t2 #=> false
162
+ #
163
+ # Time.new(2010,10,31).between?(t1, t2) #=> true
164
+ #
165
+ # ## What's Here
166
+ #
167
+ # First, what's elsewhere. Class `Time`:
168
+ #
169
+ # * Inherits from [class Object](rdoc-ref:Object@What-27s+Here).
170
+ # * Includes [module Comparable](rdoc-ref:Comparable@What-27s+Here).
171
+ #
172
+ # Here, class `Time` provides methods that are useful for:
173
+ #
174
+ # * [Creating Time objects](rdoc-ref:Time@Methods+for+Creating).
175
+ # * [Fetching Time values](rdoc-ref:Time@Methods+for+Fetching).
176
+ # * [Querying a Time object](rdoc-ref:Time@Methods+for+Querying).
177
+ # * [Comparing Time objects](rdoc-ref:Time@Methods+for+Comparing).
178
+ # * [Converting a Time object](rdoc-ref:Time@Methods+for+Converting).
179
+ # * [Rounding a Time](rdoc-ref:Time@Methods+for+Rounding).
180
+ #
181
+ # ### Methods for Creating
182
+ #
183
+ # * ::new: Returns a new time from specified arguments (year, month, etc.),
184
+ # including an optional timezone value.
185
+ # * ::local (aliased as ::mktime): Same as ::new, except the timezone is the
186
+ # local timezone.
187
+ # * ::utc (aliased as ::gm): Same as ::new, except the timezone is UTC.
188
+ # * ::at: Returns a new time based on seconds since epoch.
189
+ # * ::now: Returns a new time based on the current system time.
190
+ # * #+ (plus): Returns a new time increased by the given number of seconds.
191
+ # * #- (minus): Returns a new time decreased by the given number of seconds.
192
+ #
193
+ # ### Methods for Fetching
194
+ #
195
+ # * #year: Returns the year of the time.
196
+ # * #month (aliased as #mon): Returns the month of the time.
197
+ # * #mday (aliased as #day): Returns the day of the month.
198
+ # * #hour: Returns the hours value for the time.
199
+ # * #min: Returns the minutes value for the time.
200
+ # * #sec: Returns the seconds value for the time.
201
+ # * #usec (aliased as #tv_usec): Returns the number of microseconds in the
202
+ # subseconds value of the time.
203
+ # * #nsec (aliased as #tv_nsec: Returns the number of nanoseconds in the
204
+ # subsecond part of the time.
205
+ # * #subsec: Returns the subseconds value for the time.
206
+ # * #wday: Returns the integer weekday value of the time (0 == Sunday).
207
+ # * #yday: Returns the integer yearday value of the time (1 == January 1).
208
+ # * #hash: Returns the integer hash value for the time.
209
+ # * #utc_offset (aliased as #gmt_offset and #gmtoff): Returns the offset in
210
+ # seconds between time and UTC.
211
+ # * #to_f: Returns the float number of seconds since epoch for the time.
212
+ # * #to_i (aliased as #tv_sec): Returns the integer number of seconds since
213
+ # epoch for the time.
214
+ # * #to_r: Returns the Rational number of seconds since epoch for the time.
215
+ # * #zone: Returns a string representation of the timezone of the time.
216
+ #
217
+ # ### Methods for Querying
218
+ #
219
+ # * #utc? (aliased as #gmt?): Returns whether the time is UTC.
220
+ # * #dst? (aliased as #isdst): Returns whether the time is DST (daylight
221
+ # saving time).
222
+ # * #sunday?: Returns whether the time is a Sunday.
223
+ # * #monday?: Returns whether the time is a Monday.
224
+ # * #tuesday?: Returns whether the time is a Tuesday.
225
+ # * #wednesday?: Returns whether the time is a Wednesday.
226
+ # * #thursday?: Returns whether the time is a Thursday.
227
+ # * #friday?: Returns whether time is a Friday.
228
+ # * #saturday?: Returns whether the time is a Saturday.
229
+ #
230
+ # ### Methods for Comparing
231
+ #
232
+ # * #<=>: Compares `self` to another time.
233
+ # * #eql?: Returns whether the time is equal to another time.
234
+ #
235
+ # ### Methods for Converting
236
+ #
237
+ # * #asctime (aliased as #ctime): Returns the time as a string.
238
+ # * #inspect: Returns the time in detail as a string.
239
+ # * #strftime: Returns the time as a string, according to a given format.
240
+ # * #to_a: Returns a 10-element array of values from the time.
241
+ # * #to_s: Returns a string representation of the time.
242
+ # * #getutc (aliased as #getgm): Returns a new time converted to UTC.
243
+ # * #getlocal: Returns a new time converted to local time.
244
+ # * #utc (aliased as #gmtime): Converts time to UTC in place.
245
+ # * #localtime: Converts time to local time in place.
246
+ # * #deconstruct_keys: Returns a hash of time components used in
247
+ # pattern-matching.
248
+ #
249
+ # ### Methods for Rounding
250
+ #
251
+ # * #round:Returns a new time with subseconds rounded.
252
+ # * #ceil: Returns a new time with subseconds raised to a ceiling.
253
+ # * #floor: Returns a new time with subseconds lowered to a floor.
254
+ #
255
+ # For the forms of argument `zone`, see [Timezone
256
+ # Specifiers](rdoc-ref:Time@Timezone+Specifiers).
257
+ #
258
+ # ## Timezone Specifiers
259
+ #
260
+ # Certain `Time` methods accept arguments that specify timezones:
261
+ #
262
+ # * Time.at: keyword argument <code>in:</code>.
263
+ # * Time.new: positional argument `zone` or keyword argument <code>in:</code>.
264
+ # * Time.now: keyword argument <code>in:</code>.
265
+ # * Time#getlocal: positional argument `zone`.
266
+ # * Time#localtime: positional argument `zone`.
267
+ #
268
+ # The value given with any of these must be one of the following (each detailed
269
+ # below):
270
+ #
271
+ # * [Hours/minutes offset](rdoc-ref:Time@Hours-2FMinutes+Offsets).
272
+ # * [Single-letter offset](rdoc-ref:Time@Single-Letter+Offsets).
273
+ # * [Integer offset](rdoc-ref:Time@Integer+Offsets).
274
+ # * [Timezone object](rdoc-ref:Time@Timezone+Objects).
275
+ # * [Timezone name](rdoc-ref:Time@Timezone+Names).
276
+ #
277
+ # ### Hours/Minutes Offsets
278
+ #
279
+ # The zone value may be a string offset from UTC in the form
280
+ # <code>'+HH:MM'</code> or <code>'-HH:MM'</code>, where:
281
+ #
282
+ # * `HH` is the 2-digit hour in the range <code>0..23</code>.
283
+ # * `MM` is the 2-digit minute in the range <code>0..59</code>.
284
+ #
285
+ # Examples:
286
+ #
287
+ # t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
288
+ # Time.at(t, in: '-23:59') # => 1999-12-31 20:16:01 -2359
289
+ # Time.at(t, in: '+23:59') # => 2000-01-02 20:14:01 +2359
290
+ #
291
+ # ### Single-Letter Offsets
292
+ #
293
+ # The zone value may be a letter in the range <code>'A'..'I'</code> or
294
+ # <code>'K'..'Z'</code>; see [List of military time
295
+ # zones](https://en.wikipedia.org/wiki/List_of_military_time_zones):
296
+ #
297
+ # t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
298
+ # Time.at(t, in: 'A') # => 2000-01-01 21:15:01 +0100
299
+ # Time.at(t, in: 'I') # => 2000-01-02 05:15:01 +0900
300
+ # Time.at(t, in: 'K') # => 2000-01-02 06:15:01 +1000
301
+ # Time.at(t, in: 'Y') # => 2000-01-01 08:15:01 -1200
302
+ # Time.at(t, in: 'Z') # => 2000-01-01 20:15:01 UTC
303
+ #
304
+ # ### Integer Offsets
305
+ #
306
+ # The zone value may be an integer number of seconds in the range
307
+ # <code>-86399..86399</code>:
308
+ #
309
+ # t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
310
+ # Time.at(t, in: -86399) # => 1999-12-31 20:15:02 -235959
311
+ # Time.at(t, in: 86399) # => 2000-01-02 20:15:00 +235959
312
+ #
313
+ # ### Timezone Objects
314
+ #
315
+ # The zone value may be an object responding to certain timezone methods, an
316
+ # instance of [Timezone](https://github.com/panthomakos/timezone) and
317
+ # [TZInfo](https://tzinfo.github.io) for example.
318
+ #
319
+ # The timezone methods are:
320
+ #
321
+ # * `local_to_utc`:
322
+ #
323
+ # Called when Time.new is invoked with `tz` as the value of positional
324
+ # argument `zone` or keyword argument <code>in:</code>.
325
+ #
326
+ # Argument
327
+ # : a [Time-like object](rdoc-ref:Time@Time-Like+Objects).
328
+ #
329
+ # Returns
330
+ # : a [Time-like object](rdoc-ref:Time@Time-Like+Objects) in the UTC
331
+ # timezone.
332
+ #
333
+ #
334
+ # * `utc_to_local`:
335
+ #
336
+ # Called when Time.at or Time.now is invoked with `tz` as the value for
337
+ # keyword argument <code>in:</code>, and when Time#getlocal or
338
+ # Time#localtime is called with `tz` as the value for positional argument
339
+ # `zone`.
340
+ #
341
+ # The UTC offset will be calculated as the difference between the original
342
+ # time and the returned object as an `Integer`. If the object is in fixed
343
+ # offset, its `utc_offset` is also counted.
344
+ #
345
+ # Argument
346
+ # : a [Time-like object](rdoc-ref:Time@Time-Like+Objects).
347
+ #
348
+ # Returns
349
+ # : a [Time-like object](rdoc-ref:Time@Time-Like+Objects) in the local
350
+ # timezone.
351
+ #
352
+ #
353
+ # A custom timezone class may have these instance methods, which will be called
354
+ # if defined:
355
+ #
356
+ # * `abbr`:
357
+ #
358
+ # Called when Time#strftime is invoked with a format involving
359
+ # <code>%Z</code>.
360
+ #
361
+ # Argument
362
+ # : a [Time-like object](rdoc-ref:Time@Time-Like+Objects).
363
+ #
364
+ # Returns
365
+ # : a string abbreviation for the timezone name.
366
+ #
367
+ #
368
+ # * <code>dst?</code>:
369
+ #
370
+ # Called when Time.at or Time.now is invoked with `tz` as the value for
371
+ # keyword argument <code>in:</code>, and when Time#getlocal or
372
+ # Time#localtime is called with `tz` as the value for positional argument
373
+ # `zone`.
374
+ #
375
+ # Argument
376
+ # : a [Time-like object](rdoc-ref:Time@Time-Like+Objects).
377
+ #
378
+ # Returns
379
+ # : whether the time is daylight saving time.
380
+ #
381
+ #
382
+ # * `name`:
383
+ #
384
+ # Called when <code>Marshal.dump(t)</code> is invoked
385
+ #
386
+ # Argument
387
+ # : none.
388
+ #
389
+ # Returns
390
+ # : the string name of the timezone.
391
+ #
392
+ #
393
+ # #### `Time`-Like Objects
394
+ #
395
+ # A `Time`-like object is a container object capable of interfacing with
396
+ # timezone libraries for timezone conversion.
397
+ #
398
+ # The argument to the timezone conversion methods above will have attributes
399
+ # similar to Time, except that timezone related attributes are meaningless.
400
+ #
401
+ # The objects returned by `local_to_utc` and `utc_to_local` methods of the
402
+ # timezone object may be of the same class as their arguments, of arbitrary
403
+ # object classes, or of class Integer.
404
+ #
405
+ # For a returned class other than `Integer`, the class must have the following
406
+ # methods:
407
+ #
408
+ # * `year`
409
+ # * `mon`
410
+ # * `mday`
411
+ # * `hour`
412
+ # * `min`
413
+ # * `sec`
414
+ # * `isdst`
415
+ # * `to_i`
416
+ #
417
+ # For a returned `Integer`, its components, decomposed in UTC, are interpreted
418
+ # as times in the specified timezone.
419
+ #
420
+ # ### Timezone Names
421
+ #
422
+ # If the class (the receiver of class methods, or the class of the receiver of
423
+ # instance methods) has `find_timezone` singleton method, this method is called
424
+ # to achieve the corresponding timezone object from a timezone name.
425
+ #
426
+ # For example, using [Timezone](https://github.com/panthomakos/timezone):
427
+ # class TimeWithTimezone < Time
428
+ # require 'timezone'
429
+ # def self.find_timezone(z) = Timezone[z]
430
+ # end
431
+ #
432
+ # TimeWithTimezone.now(in: "America/New_York") #=> 2023-12-25 00:00:00 -0500
433
+ # TimeWithTimezone.new("2023-12-25 America/New_York") #=> 2023-12-25 00:00:00 -0500
434
+ #
435
+ # Or, using [TZInfo](https://tzinfo.github.io):
436
+ # class TimeWithTZInfo < Time
437
+ # require 'tzinfo'
438
+ # def self.find_timezone(z) = TZInfo::Timezone.get(z)
439
+ # end
440
+ #
441
+ # TimeWithTZInfo.now(in: "America/New_York") #=> 2023-12-25 00:00:00 -0500
442
+ # TimeWithTZInfo.new("2023-12-25 America/New_York") #=> 2023-12-25 00:00:00 -0500
443
+ #
444
+ # You can define this method per subclasses, or on the toplevel Time class.
445
+ #
446
+ class Time < Object
447
+ # A type that's used for timeouts.
448
+ #
449
+ # All numeric types implement this, but custom classes can also implement it if desired.
450
+ #
451
+ # Usage of `Time::_Timeout` is fairly common throughout the stdlib, such as in `Kernel#sleep`,
452
+ # `IO#timeout=`, and `TCPSocket#new`'s `connet_timeout` field.
453
+ interface _Timeout
454
+ # Returns `[seconds, nanoseconds]`.
455
+ #
456
+ # The `seconds` should be a whole number of seconds, whereas the `nanoseconds` should be smaller
457
+ # than one. For example, `3.125.divmod(1)` would yield `[3, 0.125]`
458
+ def divmod: (1) -> [int, _TimeoutNSecs]
459
+ end
460
+
461
+ # The nanoseconds part of `Time::_Timeout`'s return value. See it for details
462
+ interface _TimeoutNSecs
463
+ # Convert `self` into a whole number of seconds.
464
+ def *: (1_000_000_000) -> int
465
+ end
466
+
467
+ include Comparable
468
+
469
+ # <!--
470
+ # rdoc-file=timev.rb
471
+ # - at(time, subsec = false, unit = :microsecond, in: nil)
472
+ # -->
473
+ # Returns a new `Time` object based on the given arguments.
474
+ #
475
+ # Required argument `time` may be either of:
476
+ #
477
+ # * A `Time` object, whose value is the basis for the returned time; also
478
+ # influenced by optional keyword argument <code>in:</code> (see below).
479
+ # * A numeric number of [Epoch seconds](rdoc-ref:Time@Epoch+Seconds) for the
480
+ # returned time.
481
+ #
482
+ # Examples:
483
+ #
484
+ # t = Time.new(2000, 12, 31, 23, 59, 59) # => 2000-12-31 23:59:59 -0600
485
+ # secs = t.to_i # => 978328799
486
+ # Time.at(secs) # => 2000-12-31 23:59:59 -0600
487
+ # Time.at(secs + 0.5) # => 2000-12-31 23:59:59.5 -0600
488
+ # Time.at(1000000000) # => 2001-09-08 20:46:40 -0500
489
+ # Time.at(0) # => 1969-12-31 18:00:00 -0600
490
+ # Time.at(-1000000000) # => 1938-04-24 17:13:20 -0500
491
+ #
492
+ # Optional numeric argument `subsec` and optional symbol argument `units` work
493
+ # together to specify subseconds for the returned time; argument `units`
494
+ # specifies the units for `subsec`:
495
+ #
496
+ # * <code>:millisecond</code>: `subsec` in milliseconds:
497
+ #
498
+ # Time.at(secs, 0, :millisecond) # => 2000-12-31 23:59:59 -0600
499
+ # Time.at(secs, 500, :millisecond) # => 2000-12-31 23:59:59.5 -0600
500
+ # Time.at(secs, 1000, :millisecond) # => 2001-01-01 00:00:00 -0600
501
+ # Time.at(secs, -1000, :millisecond) # => 2000-12-31 23:59:58 -0600
502
+ #
503
+ # * <code>:microsecond</code> or <code>:usec</code>: `subsec` in microseconds:
504
+ #
505
+ # Time.at(secs, 0, :microsecond) # => 2000-12-31 23:59:59 -0600
506
+ # Time.at(secs, 500000, :microsecond) # => 2000-12-31 23:59:59.5 -0600
507
+ # Time.at(secs, 1000000, :microsecond) # => 2001-01-01 00:00:00 -0600
508
+ # Time.at(secs, -1000000, :microsecond) # => 2000-12-31 23:59:58 -0600
509
+ #
510
+ # * <code>:nanosecond</code> or <code>:nsec</code>: `subsec` in nanoseconds:
511
+ #
512
+ # Time.at(secs, 0, :nanosecond) # => 2000-12-31 23:59:59 -0600
513
+ # Time.at(secs, 500000000, :nanosecond) # => 2000-12-31 23:59:59.5 -0600
514
+ # Time.at(secs, 1000000000, :nanosecond) # => 2001-01-01 00:00:00 -0600
515
+ # Time.at(secs, -1000000000, :nanosecond) # => 2000-12-31 23:59:58 -0600
516
+ #
517
+ # Optional keyword argument <code>in: zone</code> specifies the timezone for the
518
+ # returned time:
519
+ #
520
+ # Time.at(secs, in: '+12:00') # => 2001-01-01 17:59:59 +1200
521
+ # Time.at(secs, in: '-12:00') # => 2000-12-31 17:59:59 -1200
522
+ #
523
+ # For the forms of argument `zone`, see [Timezone
524
+ # Specifiers](rdoc-ref:Time@Timezone+Specifiers).
525
+ #
526
+ def self.at: (Time, ?in: String | Integer | nil) -> Time
527
+ | (Numeric, ?in: String | Integer | nil) -> Time
528
+ | (Integer sec_i, Numeric msec, subsec_unit msec, ?in: String | Integer | nil) -> Time
529
+
530
+ type subsec_unit = :msec | :millisecond | :usec | :microsecond | :nsec | :nanosecond
531
+
532
+ # <!-- rdoc-file=time.c -->
533
+ # Returns a new `Time` object based the on given arguments, in the UTC timezone.
534
+ #
535
+ # With one to seven arguments given, the arguments are interpreted as in the
536
+ # first calling sequence above:
537
+ #
538
+ # Time.utc(year, month = 1, mday = 1, hour = 0, min = 0, sec = 0, usec = 0)
539
+ #
540
+ # Examples:
541
+ #
542
+ # Time.utc(2000) # => 2000-01-01 00:00:00 UTC
543
+ # Time.utc(-2000) # => -2000-01-01 00:00:00 UTC
544
+ #
545
+ # There are no minimum and maximum values for the required argument `year`.
546
+ #
547
+ # For the optional arguments:
548
+ #
549
+ # * `month`: Month in range (1..12), or case-insensitive 3-letter month name:
550
+ #
551
+ # Time.utc(2000, 1) # => 2000-01-01 00:00:00 UTC
552
+ # Time.utc(2000, 12) # => 2000-12-01 00:00:00 UTC
553
+ # Time.utc(2000, 'jan') # => 2000-01-01 00:00:00 UTC
554
+ # Time.utc(2000, 'JAN') # => 2000-01-01 00:00:00 UTC
555
+ #
556
+ # * `mday`: Month day in range(1..31):
557
+ #
558
+ # Time.utc(2000, 1, 1) # => 2000-01-01 00:00:00 UTC
559
+ # Time.utc(2000, 1, 31) # => 2000-01-31 00:00:00 UTC
560
+ #
561
+ # * `hour`: Hour in range (0..23), or 24 if `min`, `sec`, and `usec` are zero:
562
+ #
563
+ # Time.utc(2000, 1, 1, 0) # => 2000-01-01 00:00:00 UTC
564
+ # Time.utc(2000, 1, 1, 23) # => 2000-01-01 23:00:00 UTC
565
+ # Time.utc(2000, 1, 1, 24) # => 2000-01-02 00:00:00 UTC
566
+ #
567
+ # * `min`: Minute in range (0..59):
568
+ #
569
+ # Time.utc(2000, 1, 1, 0, 0) # => 2000-01-01 00:00:00 UTC
570
+ # Time.utc(2000, 1, 1, 0, 59) # => 2000-01-01 00:59:00 UTC
571
+ #
572
+ # * `sec`: Second in range (0..59), or 60 if `usec` is zero:
573
+ #
574
+ # Time.utc(2000, 1, 1, 0, 0, 0) # => 2000-01-01 00:00:00 UTC
575
+ # Time.utc(2000, 1, 1, 0, 0, 59) # => 2000-01-01 00:00:59 UTC
576
+ # Time.utc(2000, 1, 1, 0, 0, 60) # => 2000-01-01 00:01:00 UTC
577
+ #
578
+ # * `usec`: Microsecond in range (0..999999):
579
+ #
580
+ # Time.utc(2000, 1, 1, 0, 0, 0, 0) # => 2000-01-01 00:00:00 UTC
581
+ # Time.utc(2000, 1, 1, 0, 0, 0, 999999) # => 2000-01-01 00:00:00.999999 UTC
582
+ #
583
+ # The values may be:
584
+ #
585
+ # * Integers, as above.
586
+ # * Numerics convertible to integers:
587
+ #
588
+ # Time.utc(Float(0.0), Rational(1, 1), 1.0, 0.0, 0.0, 0.0, 0.0)
589
+ # # => 0000-01-01 00:00:00 UTC
590
+ #
591
+ # * String integers:
592
+ #
593
+ # a = %w[0 1 1 0 0 0 0 0]
594
+ # # => ["0", "1", "1", "0", "0", "0", "0", "0"]
595
+ # Time.utc(*a) # => 0000-01-01 00:00:00 UTC
596
+ #
597
+ # When exactly ten arguments are given, the arguments are interpreted as in the
598
+ # second calling sequence above:
599
+ #
600
+ # Time.utc(sec, min, hour, mday, month, year, dummy, dummy, dummy, dummy)
601
+ #
602
+ # where the `dummy` arguments are ignored:
603
+ #
604
+ # a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
605
+ # # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
606
+ # Time.utc(*a) # => 0005-04-03 02:01:00 UTC
607
+ #
608
+ # This form is useful for creating a `Time` object from a 10-element array
609
+ # returned by Time.to_a:
610
+ #
611
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6) # => 2000-01-02 03:04:05 +000006
612
+ # a = t.to_a # => [5, 4, 3, 2, 1, 2000, 0, 2, false, nil]
613
+ # Time.utc(*a) # => 2000-01-02 03:04:05 UTC
614
+ #
615
+ # The two forms have their first six arguments in common, though in different
616
+ # orders; the ranges of these common arguments are the same for both forms; see
617
+ # above.
618
+ #
619
+ # Raises an exception if the number of arguments is eight, nine, or greater than
620
+ # ten.
621
+ #
622
+ # Related: Time.local.
623
+ #
624
+ def self.gm: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
625
+
626
+ # <!--
627
+ # rdoc-file=time.c
628
+ # - Time.local(year, month = 1, mday = 1, hour = 0, min = 0, sec = 0, usec = 0) -> new_time
629
+ # - Time.local(sec, min, hour, mday, month, year, dummy, dummy, dummy, dummy) -> new_time
630
+ # -->
631
+ # Like Time.utc, except that the returned `Time` object has the local timezone,
632
+ # not the UTC timezone:
633
+ #
634
+ # # With seven arguments.
635
+ # Time.local(0, 1, 2, 3, 4, 5, 6)
636
+ # # => 0000-01-02 03:04:05.000006 -0600
637
+ # # With exactly ten arguments.
638
+ # Time.local(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
639
+ # # => 0005-04-03 02:01:00 -0600
640
+ #
641
+ def self.local: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
642
+
643
+ # <!--
644
+ # rdoc-file=timev.rb
645
+ # - now(in: nil)
646
+ # -->
647
+ # Creates a new `Time` object from the current system time. This is the same as
648
+ # Time.new without arguments.
649
+ #
650
+ # Time.now # => 2009-06-24 12:39:54 +0900
651
+ # Time.now(in: '+04:00') # => 2009-06-24 07:39:54 +0400
652
+ #
653
+ # For forms of argument `zone`, see [Timezone
654
+ # Specifiers](rdoc-ref:Time@Timezone+Specifiers).
655
+ #
656
+ def self.now: (?in: String | Integer | nil) -> Time
657
+
658
+ # <!--
659
+ # rdoc-file=time.c
660
+ # - Time.utc(year, month = 1, mday = 1, hour = 0, min = 0, sec = 0, usec = 0) -> new_time
661
+ # - Time.utc(sec, min, hour, mday, month, year, dummy, dummy, dummy, dummy) -> new_time
662
+ # -->
663
+ # Returns a new `Time` object based the on given arguments, in the UTC timezone.
664
+ #
665
+ # With one to seven arguments given, the arguments are interpreted as in the
666
+ # first calling sequence above:
667
+ #
668
+ # Time.utc(year, month = 1, mday = 1, hour = 0, min = 0, sec = 0, usec = 0)
669
+ #
670
+ # Examples:
671
+ #
672
+ # Time.utc(2000) # => 2000-01-01 00:00:00 UTC
673
+ # Time.utc(-2000) # => -2000-01-01 00:00:00 UTC
674
+ #
675
+ # There are no minimum and maximum values for the required argument `year`.
676
+ #
677
+ # For the optional arguments:
678
+ #
679
+ # * `month`: Month in range (1..12), or case-insensitive 3-letter month name:
680
+ #
681
+ # Time.utc(2000, 1) # => 2000-01-01 00:00:00 UTC
682
+ # Time.utc(2000, 12) # => 2000-12-01 00:00:00 UTC
683
+ # Time.utc(2000, 'jan') # => 2000-01-01 00:00:00 UTC
684
+ # Time.utc(2000, 'JAN') # => 2000-01-01 00:00:00 UTC
685
+ #
686
+ # * `mday`: Month day in range(1..31):
687
+ #
688
+ # Time.utc(2000, 1, 1) # => 2000-01-01 00:00:00 UTC
689
+ # Time.utc(2000, 1, 31) # => 2000-01-31 00:00:00 UTC
690
+ #
691
+ # * `hour`: Hour in range (0..23), or 24 if `min`, `sec`, and `usec` are zero:
692
+ #
693
+ # Time.utc(2000, 1, 1, 0) # => 2000-01-01 00:00:00 UTC
694
+ # Time.utc(2000, 1, 1, 23) # => 2000-01-01 23:00:00 UTC
695
+ # Time.utc(2000, 1, 1, 24) # => 2000-01-02 00:00:00 UTC
696
+ #
697
+ # * `min`: Minute in range (0..59):
698
+ #
699
+ # Time.utc(2000, 1, 1, 0, 0) # => 2000-01-01 00:00:00 UTC
700
+ # Time.utc(2000, 1, 1, 0, 59) # => 2000-01-01 00:59:00 UTC
701
+ #
702
+ # * `sec`: Second in range (0..59), or 60 if `usec` is zero:
703
+ #
704
+ # Time.utc(2000, 1, 1, 0, 0, 0) # => 2000-01-01 00:00:00 UTC
705
+ # Time.utc(2000, 1, 1, 0, 0, 59) # => 2000-01-01 00:00:59 UTC
706
+ # Time.utc(2000, 1, 1, 0, 0, 60) # => 2000-01-01 00:01:00 UTC
707
+ #
708
+ # * `usec`: Microsecond in range (0..999999):
709
+ #
710
+ # Time.utc(2000, 1, 1, 0, 0, 0, 0) # => 2000-01-01 00:00:00 UTC
711
+ # Time.utc(2000, 1, 1, 0, 0, 0, 999999) # => 2000-01-01 00:00:00.999999 UTC
712
+ #
713
+ # The values may be:
714
+ #
715
+ # * Integers, as above.
716
+ # * Numerics convertible to integers:
717
+ #
718
+ # Time.utc(Float(0.0), Rational(1, 1), 1.0, 0.0, 0.0, 0.0, 0.0)
719
+ # # => 0000-01-01 00:00:00 UTC
720
+ #
721
+ # * String integers:
722
+ #
723
+ # a = %w[0 1 1 0 0 0 0 0]
724
+ # # => ["0", "1", "1", "0", "0", "0", "0", "0"]
725
+ # Time.utc(*a) # => 0000-01-01 00:00:00 UTC
726
+ #
727
+ # When exactly ten arguments are given, the arguments are interpreted as in the
728
+ # second calling sequence above:
729
+ #
730
+ # Time.utc(sec, min, hour, mday, month, year, dummy, dummy, dummy, dummy)
731
+ #
732
+ # where the `dummy` arguments are ignored:
733
+ #
734
+ # a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
735
+ # # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
736
+ # Time.utc(*a) # => 0005-04-03 02:01:00 UTC
737
+ #
738
+ # This form is useful for creating a `Time` object from a 10-element array
739
+ # returned by Time.to_a:
740
+ #
741
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6) # => 2000-01-02 03:04:05 +000006
742
+ # a = t.to_a # => [5, 4, 3, 2, 1, 2000, 0, 2, false, nil]
743
+ # Time.utc(*a) # => 2000-01-02 03:04:05 UTC
744
+ #
745
+ # The two forms have their first six arguments in common, though in different
746
+ # orders; the ranges of these common arguments are the same for both forms; see
747
+ # above.
748
+ #
749
+ # Raises an exception if the number of arguments is eight, nine, or greater than
750
+ # ten.
751
+ #
752
+ # Related: Time.local.
753
+ #
754
+ def self.utc: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
755
+
756
+ # <!--
757
+ # rdoc-file=time.c
758
+ # - self + numeric -> new_time
759
+ # -->
760
+ # Returns a new `Time` object whose value is the sum of the numeric value of
761
+ # `self` and the given `numeric`:
762
+ #
763
+ # t = Time.new(2000) # => 2000-01-01 00:00:00 -0600
764
+ # t + (60 * 60 * 24) # => 2000-01-02 00:00:00 -0600
765
+ # t + 0.5 # => 2000-01-01 00:00:00.5 -0600
766
+ #
767
+ # Related: Time#-.
768
+ #
769
+ def +: (Numeric arg0) -> Time
770
+
771
+ # <!--
772
+ # rdoc-file=time.c
773
+ # - self - numeric -> new_time
774
+ # - self - other_time -> float
775
+ # -->
776
+ # When `numeric` is given, returns a new `Time` object whose value is the
777
+ # difference of the numeric value of `self` and `numeric`:
778
+ #
779
+ # t = Time.new(2000) # => 2000-01-01 00:00:00 -0600
780
+ # t - (60 * 60 * 24) # => 1999-12-31 00:00:00 -0600
781
+ # t - 0.5 # => 1999-12-31 23:59:59.5 -0600
782
+ #
783
+ # When `other_time` is given, returns a Float whose value is the difference of
784
+ # the numeric values of `self` and `other_time` in seconds:
785
+ #
786
+ # t - t # => 0.0
787
+ #
788
+ # Related: Time#+.
789
+ #
790
+ def -: (Time arg0) -> Float
791
+ | (Numeric arg0) -> Time
792
+
793
+ def <: (Time arg0) -> bool
794
+
795
+ def <=: (Time arg0) -> bool
796
+
797
+ # <!--
798
+ # rdoc-file=time.c
799
+ # - self <=> other_time -> -1, 0, +1, or nil
800
+ # -->
801
+ # Compares `self` with `other_time`; returns:
802
+ #
803
+ # * <code>-1</code>, if `self` is less than `other_time`.
804
+ # * `0`, if `self` is equal to `other_time`.
805
+ # * `1`, if `self` is greater then `other_time`.
806
+ # * `nil`, if `self` and `other_time` are incomparable.
807
+ #
808
+ # Examples:
809
+ #
810
+ # t = Time.now # => 2007-11-19 08:12:12 -0600
811
+ # t2 = t + 2592000 # => 2007-12-19 08:12:12 -0600
812
+ # t <=> t2 # => -1
813
+ # t2 <=> t # => 1
814
+ #
815
+ # t = Time.now # => 2007-11-19 08:13:38 -0600
816
+ # t2 = t + 0.1 # => 2007-11-19 08:13:38 -0600
817
+ # t.nsec # => 98222999
818
+ # t2.nsec # => 198222999
819
+ # t <=> t2 # => -1
820
+ # t2 <=> t # => 1
821
+ # t <=> t # => 0
822
+ #
823
+ def <=>: (Time other) -> Integer
824
+ | (untyped other) -> Integer?
825
+
826
+ def >: (Time arg0) -> bool
827
+
828
+ def >=: (Time arg0) -> bool
829
+
830
+ # <!-- rdoc-file=time.c -->
831
+ # Returns a string representation of `self`, formatted by <code>strftime('%a %b
832
+ # %e %T %Y')</code> or its shorthand version <code>strftime('%c')</code>; see
833
+ # [Formats for Dates and Times](rdoc-ref:strftime_formatting.rdoc):
834
+ #
835
+ # t = Time.new(2000, 12, 31, 23, 59, 59, 0.5)
836
+ # t.ctime # => "Sun Dec 31 23:59:59 2000"
837
+ # t.strftime('%a %b %e %T %Y') # => "Sun Dec 31 23:59:59 2000"
838
+ # t.strftime('%c') # => "Sun Dec 31 23:59:59 2000"
839
+ #
840
+ # Related: Time#to_s, Time#inspect:
841
+ #
842
+ # t.inspect # => "2000-12-31 23:59:59.5 +000001"
843
+ # t.to_s # => "2000-12-31 23:59:59 +0000"
844
+ #
845
+ def asctime: () -> String
846
+
847
+ # <!--
848
+ # rdoc-file=time.c
849
+ # - ctime -> string
850
+ # -->
851
+ # Returns a string representation of `self`, formatted by <code>strftime('%a %b
852
+ # %e %T %Y')</code> or its shorthand version <code>strftime('%c')</code>; see
853
+ # [Formats for Dates and Times](rdoc-ref:strftime_formatting.rdoc):
854
+ #
855
+ # t = Time.new(2000, 12, 31, 23, 59, 59, 0.5)
856
+ # t.ctime # => "Sun Dec 31 23:59:59 2000"
857
+ # t.strftime('%a %b %e %T %Y') # => "Sun Dec 31 23:59:59 2000"
858
+ # t.strftime('%c') # => "Sun Dec 31 23:59:59 2000"
859
+ #
860
+ # Related: Time#to_s, Time#inspect:
861
+ #
862
+ # t.inspect # => "2000-12-31 23:59:59.5 +000001"
863
+ # t.to_s # => "2000-12-31 23:59:59 +0000"
864
+ #
865
+ def ctime: () -> String
866
+
867
+ # <!-- rdoc-file=time.c -->
868
+ # Returns the integer day of the month for `self`, in range (1..31):
869
+ #
870
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
871
+ # # => 2000-01-02 03:04:05 +000006
872
+ # t.mday # => 2
873
+ #
874
+ # Related: Time#year, Time#hour, Time#min.
875
+ #
876
+ def day: () -> Integer
877
+
878
+ # <!--
879
+ # rdoc-file=time.c
880
+ # - deconstruct_keys(array_of_names_or_nil) -> hash
881
+ # -->
882
+ # Returns a hash of the name/value pairs, to use in pattern matching. Possible
883
+ # keys are: <code>:year</code>, <code>:month</code>, <code>:day</code>,
884
+ # <code>:yday</code>, <code>:wday</code>, <code>:hour</code>, <code>:min</code>,
885
+ # <code>:sec</code>, <code>:subsec</code>, <code>:dst</code>,
886
+ # <code>:zone</code>.
887
+ #
888
+ # Possible usages:
889
+ #
890
+ # t = Time.utc(2022, 10, 5, 21, 25, 30)
891
+ #
892
+ # if t in wday: 3, day: ..7 # uses deconstruct_keys underneath
893
+ # puts "first Wednesday of the month"
894
+ # end
895
+ # #=> prints "first Wednesday of the month"
896
+ #
897
+ # case t
898
+ # in year: ...2022
899
+ # puts "too old"
900
+ # in month: ..9
901
+ # puts "quarter 1-3"
902
+ # in wday: 1..5, month:
903
+ # puts "working day in month #{month}"
904
+ # end
905
+ # #=> prints "working day in month 10"
906
+ #
907
+ # Note that deconstruction by pattern can also be combined with class check:
908
+ #
909
+ # if t in Time(wday: 3, day: ..7)
910
+ # puts "first Wednesday of the month"
911
+ # end
912
+ #
913
+ def deconstruct_keys: (Array[Symbol]?) -> Hash[Symbol, Integer]
914
+
915
+ # <!-- rdoc-file=time.c -->
916
+ # Returns `true` if `self` is in daylight saving time, `false` otherwise:
917
+ #
918
+ # t = Time.local(2000, 1, 1) # => 2000-01-01 00:00:00 -0600
919
+ # t.zone # => "Central Standard Time"
920
+ # t.dst? # => false
921
+ # t = Time.local(2000, 7, 1) # => 2000-07-01 00:00:00 -0500
922
+ # t.zone # => "Central Daylight Time"
923
+ # t.dst? # => true
924
+ #
925
+ def dst?: () -> bool
926
+
927
+ # <!--
928
+ # rdoc-file=time.c
929
+ # - eql?(other_time)
930
+ # -->
931
+ # Returns `true` if `self` and `other_time` are both `Time` objects with the
932
+ # exact same time value.
933
+ #
934
+ def eql?: (untyped arg0) -> bool
935
+
936
+ # <!--
937
+ # rdoc-file=time.c
938
+ # - friday? -> true or false
939
+ # -->
940
+ # Returns `true` if `self` represents a Friday, `false` otherwise:
941
+ #
942
+ # t = Time.utc(2000, 1, 7) # => 2000-01-07 00:00:00 UTC
943
+ # t.friday? # => true
944
+ #
945
+ # Related: Time#saturday?, Time#sunday?, Time#monday?.
946
+ #
947
+ def friday?: () -> bool
948
+
949
+ # <!--
950
+ # rdoc-file=time.c
951
+ # - getutc -> new_time
952
+ # -->
953
+ # Returns a new `Time` object representing the value of `self` converted to the
954
+ # UTC timezone:
955
+ #
956
+ # local = Time.local(2000) # => 2000-01-01 00:00:00 -0600
957
+ # local.utc? # => false
958
+ # utc = local.getutc # => 2000-01-01 06:00:00 UTC
959
+ # utc.utc? # => true
960
+ # utc == local # => true
961
+ #
962
+ def getgm: () -> Time
963
+
964
+ # <!--
965
+ # rdoc-file=time.c
966
+ # - getlocal(zone = nil) -> new_time
967
+ # -->
968
+ # Returns a new `Time` object representing the value of `self` converted to a
969
+ # given timezone; if `zone` is `nil`, the local timezone is used:
970
+ #
971
+ # t = Time.utc(2000) # => 2000-01-01 00:00:00 UTC
972
+ # t.getlocal # => 1999-12-31 18:00:00 -0600
973
+ # t.getlocal('+12:00') # => 2000-01-01 12:00:00 +1200
974
+ #
975
+ # For forms of argument `zone`, see [Timezone
976
+ # Specifiers](rdoc-ref:Time@Timezone+Specifiers).
977
+ #
978
+ def getlocal: (?Integer utc_offset) -> Time
979
+
980
+ # <!-- rdoc-file=time.c -->
981
+ # Returns a new `Time` object representing the value of `self` converted to the
982
+ # UTC timezone:
983
+ #
984
+ # local = Time.local(2000) # => 2000-01-01 00:00:00 -0600
985
+ # local.utc? # => false
986
+ # utc = local.getutc # => 2000-01-01 06:00:00 UTC
987
+ # utc.utc? # => true
988
+ # utc == local # => true
989
+ #
990
+ def getutc: () -> Time
991
+
992
+ # <!-- rdoc-file=time.c -->
993
+ # Returns `true` if `self` represents a time in UTC (GMT):
994
+ #
995
+ # now = Time.now
996
+ # # => 2022-08-18 10:24:13.5398485 -0500
997
+ # now.utc? # => false
998
+ # now.getutc.utc? # => true
999
+ # utc = Time.utc(2000, 1, 1, 20, 15, 1)
1000
+ # # => 2000-01-01 20:15:01 UTC
1001
+ # utc.utc? # => true
1002
+ #
1003
+ # `Time` objects created with these methods are considered to be in UTC:
1004
+ #
1005
+ # * Time.utc
1006
+ # * Time#utc
1007
+ # * Time#getutc
1008
+ #
1009
+ # Objects created in other ways will not be treated as UTC even if the
1010
+ # environment variable "TZ" is "UTC".
1011
+ #
1012
+ # Related: Time.utc.
1013
+ #
1014
+ def gmt?: () -> bool
1015
+
1016
+ # <!-- rdoc-file=time.c -->
1017
+ # Returns the offset in seconds between the timezones of UTC and `self`:
1018
+ #
1019
+ # Time.utc(2000, 1, 1).utc_offset # => 0
1020
+ # Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours.
1021
+ #
1022
+ def gmt_offset: () -> Integer
1023
+
1024
+ # <!--
1025
+ # rdoc-file=time.c
1026
+ # - utc -> self
1027
+ # -->
1028
+ # Returns `self`, converted to the UTC timezone:
1029
+ #
1030
+ # t = Time.new(2000) # => 2000-01-01 00:00:00 -0600
1031
+ # t.utc? # => false
1032
+ # t.utc # => 2000-01-01 06:00:00 UTC
1033
+ # t.utc? # => true
1034
+ #
1035
+ # Related: Time#getutc (returns a new converted `Time` object).
1036
+ #
1037
+ def gmtime: () -> Time
1038
+
1039
+ # <!--
1040
+ # rdoc-file=time.c
1041
+ # - hash -> integer
1042
+ # -->
1043
+ # Returns the integer hash code for `self`.
1044
+ #
1045
+ # Related: Object#hash.
1046
+ #
1047
+ def hash: () -> Integer
1048
+
1049
+ # <!--
1050
+ # rdoc-file=time.c
1051
+ # - hour -> integer
1052
+ # -->
1053
+ # Returns the integer hour of the day for `self`, in range (0..23):
1054
+ #
1055
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
1056
+ # # => 2000-01-02 03:04:05 +000006
1057
+ # t.hour # => 3
1058
+ #
1059
+ # Related: Time#year, Time#mon, Time#min.
1060
+ #
1061
+ def hour: () -> Integer
1062
+
1063
+ # <!--
1064
+ # rdoc-file=timev.rb
1065
+ # - Time.new(year = nil, mon = nil, mday = nil, hour = nil, min = nil, sec = nil, zone = nil, in: nil, precision: 9)
1066
+ # -->
1067
+ # Returns a new `Time` object based on the given arguments, by default in the
1068
+ # local timezone.
1069
+ #
1070
+ # With no positional arguments, returns the value of Time.now:
1071
+ #
1072
+ # Time.new # => 2021-04-24 17:27:46.0512465 -0500
1073
+ #
1074
+ # With one string argument that represents a time, returns a new `Time` object
1075
+ # based on the given argument, in the local timezone.
1076
+ #
1077
+ # Time.new('2000-12-31 23:59:59.5') # => 2000-12-31 23:59:59.5 -0600
1078
+ # Time.new('2000-12-31 23:59:59.5 +0900') # => 2000-12-31 23:59:59.5 +0900
1079
+ # Time.new('2000-12-31 23:59:59.5', in: '+0900') # => 2000-12-31 23:59:59.5 +0900
1080
+ # Time.new('2000-12-31 23:59:59.5') # => 2000-12-31 23:59:59.5 -0600
1081
+ # Time.new('2000-12-31 23:59:59.56789', precision: 3) # => 2000-12-31 23:59:59.567 -0600
1082
+ #
1083
+ # With one to six arguments, returns a new `Time` object based on the given
1084
+ # arguments, in the local timezone.
1085
+ #
1086
+ # Time.new(2000, 1, 2, 3, 4, 5) # => 2000-01-02 03:04:05 -0600
1087
+ #
1088
+ # For the positional arguments (other than `zone`):
1089
+ #
1090
+ # * `year`: Year, with no range limits:
1091
+ #
1092
+ # Time.new(999999999) # => 999999999-01-01 00:00:00 -0600
1093
+ # Time.new(-999999999) # => -999999999-01-01 00:00:00 -0600
1094
+ #
1095
+ # * `month`: Month in range (1..12), or case-insensitive 3-letter month name:
1096
+ #
1097
+ # Time.new(2000, 1) # => 2000-01-01 00:00:00 -0600
1098
+ # Time.new(2000, 12) # => 2000-12-01 00:00:00 -0600
1099
+ # Time.new(2000, 'jan') # => 2000-01-01 00:00:00 -0600
1100
+ # Time.new(2000, 'JAN') # => 2000-01-01 00:00:00 -0600
1101
+ #
1102
+ # * `mday`: Month day in range(1..31):
1103
+ #
1104
+ # Time.new(2000, 1, 1) # => 2000-01-01 00:00:00 -0600
1105
+ # Time.new(2000, 1, 31) # => 2000-01-31 00:00:00 -0600
1106
+ #
1107
+ # * `hour`: Hour in range (0..23), or 24 if `min`, `sec`, and `usec` are zero:
1108
+ #
1109
+ # Time.new(2000, 1, 1, 0) # => 2000-01-01 00:00:00 -0600
1110
+ # Time.new(2000, 1, 1, 23) # => 2000-01-01 23:00:00 -0600
1111
+ # Time.new(2000, 1, 1, 24) # => 2000-01-02 00:00:00 -0600
1112
+ #
1113
+ # * `min`: Minute in range (0..59):
1114
+ #
1115
+ # Time.new(2000, 1, 1, 0, 0) # => 2000-01-01 00:00:00 -0600
1116
+ # Time.new(2000, 1, 1, 0, 59) # => 2000-01-01 00:59:00 -0600
1117
+ #
1118
+ # * `sec`: Second in range (0...61):
1119
+ #
1120
+ # Time.new(2000, 1, 1, 0, 0, 0) # => 2000-01-01 00:00:00 -0600
1121
+ # Time.new(2000, 1, 1, 0, 0, 59) # => 2000-01-01 00:00:59 -0600
1122
+ # Time.new(2000, 1, 1, 0, 0, 60) # => 2000-01-01 00:01:00 -0600
1123
+ #
1124
+ # `sec` may be Float or Rational.
1125
+ #
1126
+ # Time.new(2000, 1, 1, 0, 0, 59.5) # => 2000-12-31 23:59:59.5 +0900
1127
+ # Time.new(2000, 1, 1, 0, 0, 59.7r) # => 2000-12-31 23:59:59.7 +0900
1128
+ #
1129
+ # These values may be:
1130
+ #
1131
+ # * Integers, as above.
1132
+ # * Numerics convertible to integers:
1133
+ #
1134
+ # Time.new(Float(0.0), Rational(1, 1), 1.0, 0.0, 0.0, 0.0)
1135
+ # # => 0000-01-01 00:00:00 -0600
1136
+ #
1137
+ # * String integers:
1138
+ #
1139
+ # a = %w[0 1 1 0 0 0]
1140
+ # # => ["0", "1", "1", "0", "0", "0"]
1141
+ # Time.new(*a) # => 0000-01-01 00:00:00 -0600
1142
+ #
1143
+ # When positional argument `zone` or keyword argument <code>in:</code> is given,
1144
+ # the new `Time` object is in the specified timezone. For the forms of argument
1145
+ # `zone`, see [Timezone Specifiers](rdoc-ref:Time@Timezone+Specifiers):
1146
+ #
1147
+ # Time.new(2000, 1, 1, 0, 0, 0, '+12:00')
1148
+ # # => 2000-01-01 00:00:00 +1200
1149
+ # Time.new(2000, 1, 1, 0, 0, 0, in: '-12:00')
1150
+ # # => 2000-01-01 00:00:00 -1200
1151
+ # Time.new(in: '-12:00')
1152
+ # # => 2022-08-23 08:49:26.1941467 -1200
1153
+ #
1154
+ # Since <code>in:</code> keyword argument just provides the default, so if the
1155
+ # first argument in single string form contains time zone information, this
1156
+ # keyword argument will be silently ignored.
1157
+ #
1158
+ # Time.new('2000-01-01 00:00:00 +0100', in: '-0500').utc_offset # => 3600
1159
+ #
1160
+ # * `precision`: maximum effective digits in sub-second part, default is 9.
1161
+ # More digits will be truncated, as other operations of `Time`. Ignored
1162
+ # unless the first argument is a string.
1163
+ #
1164
+ def initialize: (?Integer year, ?Integer? month, ?Integer? day, ?Integer? hour, ?Integer? min, ?Numeric? sec, ?String | Integer | nil) -> void
1165
+ | (?Integer year, ?Integer? month, ?Integer? day, ?Integer? hour, ?Integer? min, ?Numeric? sec, in: String | Integer | nil) -> void
1166
+ | (String, ?in: string | int | nil, ?precision: int) -> void
1167
+
1168
+ # <!--
1169
+ # rdoc-file=time.c
1170
+ # - inspect -> string
1171
+ # -->
1172
+ # Returns a string representation of `self` with subseconds:
1173
+ #
1174
+ # t = Time.new(2000, 12, 31, 23, 59, 59, 0.5)
1175
+ # t.inspect # => "2000-12-31 23:59:59.5 +000001"
1176
+ #
1177
+ # Related: Time#ctime, Time#to_s:
1178
+ #
1179
+ # t.ctime # => "Sun Dec 31 23:59:59 2000"
1180
+ # t.to_s # => "2000-12-31 23:59:59 +0000"
1181
+ #
1182
+ def inspect: () -> String
1183
+
1184
+ # <!--
1185
+ # rdoc-file=time.c
1186
+ # - dst? -> true or false
1187
+ # -->
1188
+ # Returns `true` if `self` is in daylight saving time, `false` otherwise:
1189
+ #
1190
+ # t = Time.local(2000, 1, 1) # => 2000-01-01 00:00:00 -0600
1191
+ # t.zone # => "Central Standard Time"
1192
+ # t.dst? # => false
1193
+ # t = Time.local(2000, 7, 1) # => 2000-07-01 00:00:00 -0500
1194
+ # t.zone # => "Central Daylight Time"
1195
+ # t.dst? # => true
1196
+ #
1197
+ def isdst: () -> bool
1198
+
1199
+ # <!-- rdoc-file=lib/time.rb -->
1200
+ # Parses `time` as a dateTime defined by the XML Schema and converts it to a
1201
+ # Time object. The format is a restricted version of the format defined by ISO
1202
+ # 8601.
1203
+ #
1204
+ # ArgumentError is raised if `time` is not compliant with the format or if the
1205
+ # Time class cannot represent the specified time.
1206
+ #
1207
+ # See #xmlschema for more information on this format.
1208
+ #
1209
+ # require 'time'
1210
+ #
1211
+ # Time.xmlschema("2011-10-05T22:26:12-04:00")
1212
+ # #=> 2011-10-05 22:26:12-04:00
1213
+ #
1214
+ # You must require 'time' to use this method.
1215
+ #
1216
+ alias iso8601 xmlschema
1217
+
1218
+ # <!--
1219
+ # rdoc-file=time.c
1220
+ # - localtime -> self or new_time
1221
+ # - localtime(zone) -> new_time
1222
+ # -->
1223
+ # With no argument given:
1224
+ #
1225
+ # * Returns `self` if `self` is a local time.
1226
+ # * Otherwise returns a new `Time` in the user's local timezone:
1227
+ #
1228
+ # t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
1229
+ # t.localtime # => 2000-01-01 14:15:01 -0600
1230
+ #
1231
+ # With argument `zone` given, returns the new `Time` object created by
1232
+ # converting `self` to the given time zone:
1233
+ #
1234
+ # t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
1235
+ # t.localtime("-09:00") # => 2000-01-01 11:15:01 -0900
1236
+ #
1237
+ # For forms of argument `zone`, see [Timezone
1238
+ # Specifiers](rdoc-ref:Time@Timezone+Specifiers).
1239
+ #
1240
+ def localtime: (?String utc_offset) -> Time
1241
+
1242
+ # <!--
1243
+ # rdoc-file=time.c
1244
+ # - mday -> integer
1245
+ # -->
1246
+ # Returns the integer day of the month for `self`, in range (1..31):
1247
+ #
1248
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
1249
+ # # => 2000-01-02 03:04:05 +000006
1250
+ # t.mday # => 2
1251
+ #
1252
+ # Related: Time#year, Time#hour, Time#min.
1253
+ #
1254
+ def mday: () -> Integer
1255
+
1256
+ # <!--
1257
+ # rdoc-file=time.c
1258
+ # - min -> integer
1259
+ # -->
1260
+ # Returns the integer minute of the hour for `self`, in range (0..59):
1261
+ #
1262
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
1263
+ # # => 2000-01-02 03:04:05 +000006
1264
+ # t.min # => 4
1265
+ #
1266
+ # Related: Time#year, Time#mon, Time#sec.
1267
+ #
1268
+ def min: () -> Integer
1269
+
1270
+ # <!--
1271
+ # rdoc-file=time.c
1272
+ # - mon -> integer
1273
+ # -->
1274
+ # Returns the integer month of the year for `self`, in range (1..12):
1275
+ #
1276
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
1277
+ # # => 2000-01-02 03:04:05 +000006
1278
+ # t.mon # => 1
1279
+ #
1280
+ # Related: Time#year, Time#hour, Time#min.
1281
+ #
1282
+ def mon: () -> Integer
1283
+
1284
+ # <!--
1285
+ # rdoc-file=time.c
1286
+ # - monday? -> true or false
1287
+ # -->
1288
+ # Returns `true` if `self` represents a Monday, `false` otherwise:
1289
+ #
1290
+ # t = Time.utc(2000, 1, 3) # => 2000-01-03 00:00:00 UTC
1291
+ # t.monday? # => true
1292
+ #
1293
+ # Related: Time#tuesday?, Time#wednesday?, Time#thursday?.
1294
+ #
1295
+ def monday?: () -> bool
1296
+
1297
+ # <!-- rdoc-file=time.c -->
1298
+ # Returns the number of nanoseconds in the subseconds part of `self` in the
1299
+ # range (0..999_999_999); lower-order digits are truncated, not rounded:
1300
+ #
1301
+ # t = Time.now # => 2022-07-11 15:04:53.3219637 -0500
1302
+ # t.nsec # => 321963700
1303
+ #
1304
+ # Related: Time#subsec (returns exact subseconds).
1305
+ #
1306
+ def nsec: () -> Integer
1307
+
1308
+ # <!--
1309
+ # rdoc-file=time.c
1310
+ # - round(ndigits = 0) -> new_time
1311
+ # -->
1312
+ # Returns a new `Time` object whose numeric value is that of `self`, with its
1313
+ # seconds value rounded to precision `ndigits`:
1314
+ #
1315
+ # t = Time.utc(2010, 3, 30, 5, 43, 25.123456789r)
1316
+ # t # => 2010-03-30 05:43:25.123456789 UTC
1317
+ # t.round # => 2010-03-30 05:43:25 UTC
1318
+ # t.round(0) # => 2010-03-30 05:43:25 UTC
1319
+ # t.round(1) # => 2010-03-30 05:43:25.1 UTC
1320
+ # t.round(2) # => 2010-03-30 05:43:25.12 UTC
1321
+ # t.round(3) # => 2010-03-30 05:43:25.123 UTC
1322
+ # t.round(4) # => 2010-03-30 05:43:25.1235 UTC
1323
+ #
1324
+ # t = Time.utc(1999, 12,31, 23, 59, 59)
1325
+ # t # => 1999-12-31 23:59:59 UTC
1326
+ # (t + 0.4).round # => 1999-12-31 23:59:59 UTC
1327
+ # (t + 0.49).round # => 1999-12-31 23:59:59 UTC
1328
+ # (t + 0.5).round # => 2000-01-01 00:00:00 UTC
1329
+ # (t + 1.4).round # => 2000-01-01 00:00:00 UTC
1330
+ # (t + 1.49).round # => 2000-01-01 00:00:00 UTC
1331
+ # (t + 1.5).round # => 2000-01-01 00:00:01 UTC
1332
+ #
1333
+ # Related: Time#ceil, Time#floor.
1334
+ #
1335
+ def round: (?int ndigits) -> Time
1336
+
1337
+ # <!--
1338
+ # rdoc-file=time.c
1339
+ # - saturday? -> true or false
1340
+ # -->
1341
+ # Returns `true` if `self` represents a Saturday, `false` otherwise:
1342
+ #
1343
+ # t = Time.utc(2000, 1, 1) # => 2000-01-01 00:00:00 UTC
1344
+ # t.saturday? # => true
1345
+ #
1346
+ # Related: Time#sunday?, Time#monday?, Time#tuesday?.
1347
+ #
1348
+ def saturday?: () -> bool
1349
+
1350
+ # <!--
1351
+ # rdoc-file=time.c
1352
+ # - sec -> integer
1353
+ # -->
1354
+ # Returns the integer second of the minute for `self`, in range (0..60):
1355
+ #
1356
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
1357
+ # # => 2000-01-02 03:04:05 +000006
1358
+ # t.sec # => 5
1359
+ #
1360
+ # Note: the second value may be 60 when there is a [leap
1361
+ # second](https://en.wikipedia.org/wiki/Leap_second).
1362
+ #
1363
+ # Related: Time#year, Time#mon, Time#min.
1364
+ #
1365
+ def sec: () -> Integer
1366
+
1367
+ # <!--
1368
+ # rdoc-file=time.c
1369
+ # - strftime(format_string) -> string
1370
+ # -->
1371
+ # Returns a string representation of `self`, formatted according to the given
1372
+ # string `format`. See [Formats for Dates and
1373
+ # Times](rdoc-ref:strftime_formatting.rdoc).
1374
+ #
1375
+ def strftime: (String arg0) -> String
1376
+
1377
+ # <!--
1378
+ # rdoc-file=time.c
1379
+ # - subsec -> numeric
1380
+ # -->
1381
+ # Returns the exact subseconds for `self` as a Numeric (Integer or Rational):
1382
+ #
1383
+ # t = Time.now # => 2022-07-11 15:11:36.8490302 -0500
1384
+ # t.subsec # => (4245151/5000000)
1385
+ #
1386
+ # If the subseconds is zero, returns integer zero:
1387
+ #
1388
+ # t = Time.new(2000, 1, 1, 2, 3, 4) # => 2000-01-01 02:03:04 -0600
1389
+ # t.subsec # => 0
1390
+ #
1391
+ def subsec: () -> (0 | Rational)
1392
+
1393
+ # <!--
1394
+ # rdoc-file=time.c
1395
+ # - sunday? -> true or false
1396
+ # -->
1397
+ # Returns `true` if `self` represents a Sunday, `false` otherwise:
1398
+ #
1399
+ # t = Time.utc(2000, 1, 2) # => 2000-01-02 00:00:00 UTC
1400
+ # t.sunday? # => true
1401
+ #
1402
+ # Related: Time#monday?, Time#tuesday?, Time#wednesday?.
1403
+ #
1404
+ def sunday?: () -> bool
1405
+
1406
+ # <!--
1407
+ # rdoc-file=time.c
1408
+ # - thursday? -> true or false
1409
+ # -->
1410
+ # Returns `true` if `self` represents a Thursday, `false` otherwise:
1411
+ #
1412
+ # t = Time.utc(2000, 1, 6) # => 2000-01-06 00:00:00 UTC
1413
+ # t.thursday? # => true
1414
+ #
1415
+ # Related: Time#friday?, Time#saturday?, Time#sunday?.
1416
+ #
1417
+ def thursday?: () -> bool
1418
+
1419
+ # <!--
1420
+ # rdoc-file=time.c
1421
+ # - to_a -> array
1422
+ # -->
1423
+ # Returns a 10-element array of values representing `self`:
1424
+ #
1425
+ # Time.utc(2000, 1, 1).to_a
1426
+ # # => [0, 0, 0, 1, 1, 2000, 6, 1, false, "UTC"]
1427
+ # # [sec, min, hour, day, mon, year, wday, yday, dst?, zone]
1428
+ #
1429
+ # The returned array is suitable for use as an argument to Time.utc or
1430
+ # Time.local to create a new `Time` object.
1431
+ #
1432
+ def to_a: () -> [ Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, bool, String? ]
1433
+
1434
+ # <!--
1435
+ # rdoc-file=time.c
1436
+ # - to_f -> float
1437
+ # -->
1438
+ # Returns the value of `self` as a Float number [Epoch
1439
+ # seconds](rdoc-ref:Time@Epoch+Seconds); subseconds are included.
1440
+ #
1441
+ # The stored value of `self` is a [Rational](rdoc-ref:Rational@#method-i-to_f),
1442
+ # which means that the returned value may be approximate:
1443
+ #
1444
+ # Time.utc(1970, 1, 1, 0, 0, 0).to_f # => 0.0
1445
+ # Time.utc(1970, 1, 1, 0, 0, 0, 999999).to_f # => 0.999999
1446
+ # Time.utc(1950, 1, 1, 0, 0, 0).to_f # => -631152000.0
1447
+ # Time.utc(1990, 1, 1, 0, 0, 0).to_f # => 631152000.0
1448
+ #
1449
+ # Related: Time#to_i, Time#to_r.
1450
+ #
1451
+ def to_f: () -> Float
1452
+
1453
+ # <!--
1454
+ # rdoc-file=time.c
1455
+ # - to_i -> integer
1456
+ # -->
1457
+ # Returns the value of `self` as integer [Epoch
1458
+ # seconds](rdoc-ref:Time@Epoch+Seconds); subseconds are truncated (not rounded):
1459
+ #
1460
+ # Time.utc(1970, 1, 1, 0, 0, 0).to_i # => 0
1461
+ # Time.utc(1970, 1, 1, 0, 0, 0, 999999).to_i # => 0
1462
+ # Time.utc(1950, 1, 1, 0, 0, 0).to_i # => -631152000
1463
+ # Time.utc(1990, 1, 1, 0, 0, 0).to_i # => 631152000
1464
+ #
1465
+ # Related: Time#to_f Time#to_r.
1466
+ #
1467
+ def to_i: () -> Integer
1468
+
1469
+ # <!--
1470
+ # rdoc-file=time.c
1471
+ # - to_r -> rational
1472
+ # -->
1473
+ # Returns the value of `self` as a Rational exact number of [Epoch
1474
+ # seconds](rdoc-ref:Time@Epoch+Seconds);
1475
+ #
1476
+ # Time.now.to_r # => (16571402750320203/10000000)
1477
+ #
1478
+ # Related: Time#to_f, Time#to_i.
1479
+ #
1480
+ def to_r: () -> Rational
1481
+
1482
+ # <!--
1483
+ # rdoc-file=time.c
1484
+ # - to_s -> string
1485
+ # -->
1486
+ # Returns a string representation of `self`, without subseconds:
1487
+ #
1488
+ # t = Time.new(2000, 12, 31, 23, 59, 59, 0.5)
1489
+ # t.to_s # => "2000-12-31 23:59:59 +0000"
1490
+ #
1491
+ # Related: Time#ctime, Time#inspect:
1492
+ #
1493
+ # t.ctime # => "Sun Dec 31 23:59:59 2000"
1494
+ # t.inspect # => "2000-12-31 23:59:59.5 +000001"
1495
+ #
1496
+ def to_s: () -> String
1497
+
1498
+ # <!--
1499
+ # rdoc-file=time.c
1500
+ # - tuesday? -> true or false
1501
+ # -->
1502
+ # Returns `true` if `self` represents a Tuesday, `false` otherwise:
1503
+ #
1504
+ # t = Time.utc(2000, 1, 4) # => 2000-01-04 00:00:00 UTC
1505
+ # t.tuesday? # => true
1506
+ #
1507
+ # Related: Time#wednesday?, Time#thursday?, Time#friday?.
1508
+ #
1509
+ def tuesday?: () -> bool
1510
+
1511
+ # <!--
1512
+ # rdoc-file=time.c
1513
+ # - nsec -> integer
1514
+ # -->
1515
+ # Returns the number of nanoseconds in the subseconds part of `self` in the
1516
+ # range (0..999_999_999); lower-order digits are truncated, not rounded:
1517
+ #
1518
+ # t = Time.now # => 2022-07-11 15:04:53.3219637 -0500
1519
+ # t.nsec # => 321963700
1520
+ #
1521
+ # Related: Time#subsec (returns exact subseconds).
1522
+ #
1523
+ def tv_nsec: () -> Integer
1524
+
1525
+ # <!-- rdoc-file=time.c -->
1526
+ # Returns the value of `self` as integer [Epoch
1527
+ # seconds](rdoc-ref:Time@Epoch+Seconds); subseconds are truncated (not rounded):
1528
+ #
1529
+ # Time.utc(1970, 1, 1, 0, 0, 0).to_i # => 0
1530
+ # Time.utc(1970, 1, 1, 0, 0, 0, 999999).to_i # => 0
1531
+ # Time.utc(1950, 1, 1, 0, 0, 0).to_i # => -631152000
1532
+ # Time.utc(1990, 1, 1, 0, 0, 0).to_i # => 631152000
1533
+ #
1534
+ # Related: Time#to_f Time#to_r.
1535
+ #
1536
+ def tv_sec: () -> Integer
1537
+
1538
+ # <!--
1539
+ # rdoc-file=time.c
1540
+ # - usec -> integer
1541
+ # -->
1542
+ # Returns the number of microseconds in the subseconds part of `self` in the
1543
+ # range (0..999_999); lower-order digits are truncated, not rounded:
1544
+ #
1545
+ # t = Time.now # => 2022-07-11 14:59:47.5484697 -0500
1546
+ # t.usec # => 548469
1547
+ #
1548
+ # Related: Time#subsec (returns exact subseconds).
1549
+ #
1550
+ def tv_usec: () -> Integer
1551
+
1552
+ # <!-- rdoc-file=time.c -->
1553
+ # Returns the number of microseconds in the subseconds part of `self` in the
1554
+ # range (0..999_999); lower-order digits are truncated, not rounded:
1555
+ #
1556
+ # t = Time.now # => 2022-07-11 14:59:47.5484697 -0500
1557
+ # t.usec # => 548469
1558
+ #
1559
+ # Related: Time#subsec (returns exact subseconds).
1560
+ #
1561
+ def usec: () -> Integer
1562
+
1563
+ # <!-- rdoc-file=time.c -->
1564
+ # Returns `self`, converted to the UTC timezone:
1565
+ #
1566
+ # t = Time.new(2000) # => 2000-01-01 00:00:00 -0600
1567
+ # t.utc? # => false
1568
+ # t.utc # => 2000-01-01 06:00:00 UTC
1569
+ # t.utc? # => true
1570
+ #
1571
+ # Related: Time#getutc (returns a new converted `Time` object).
1572
+ #
1573
+ def utc: () -> Time
1574
+
1575
+ # <!--
1576
+ # rdoc-file=time.c
1577
+ # - utc? -> true or false
1578
+ # -->
1579
+ # Returns `true` if `self` represents a time in UTC (GMT):
1580
+ #
1581
+ # now = Time.now
1582
+ # # => 2022-08-18 10:24:13.5398485 -0500
1583
+ # now.utc? # => false
1584
+ # now.getutc.utc? # => true
1585
+ # utc = Time.utc(2000, 1, 1, 20, 15, 1)
1586
+ # # => 2000-01-01 20:15:01 UTC
1587
+ # utc.utc? # => true
1588
+ #
1589
+ # `Time` objects created with these methods are considered to be in UTC:
1590
+ #
1591
+ # * Time.utc
1592
+ # * Time#utc
1593
+ # * Time#getutc
1594
+ #
1595
+ # Objects created in other ways will not be treated as UTC even if the
1596
+ # environment variable "TZ" is "UTC".
1597
+ #
1598
+ # Related: Time.utc.
1599
+ #
1600
+ def utc?: () -> bool
1601
+
1602
+ # <!-- rdoc-file=time.c -->
1603
+ # Returns the offset in seconds between the timezones of UTC and `self`:
1604
+ #
1605
+ # Time.utc(2000, 1, 1).utc_offset # => 0
1606
+ # Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours.
1607
+ #
1608
+ def utc_offset: () -> Integer
1609
+
1610
+ # <!--
1611
+ # rdoc-file=time.c
1612
+ # - wday -> integer
1613
+ # -->
1614
+ # Returns the integer day of the week for `self`, in range (0..6), with Sunday
1615
+ # as zero.
1616
+ #
1617
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
1618
+ # # => 2000-01-02 03:04:05 +000006
1619
+ # t.wday # => 0
1620
+ # t.sunday? # => true
1621
+ #
1622
+ # Related: Time#year, Time#hour, Time#min.
1623
+ #
1624
+ def wday: () -> Integer
1625
+
1626
+ # <!--
1627
+ # rdoc-file=time.c
1628
+ # - wednesday? -> true or false
1629
+ # -->
1630
+ # Returns `true` if `self` represents a Wednesday, `false` otherwise:
1631
+ #
1632
+ # t = Time.utc(2000, 1, 5) # => 2000-01-05 00:00:00 UTC
1633
+ # t.wednesday? # => true
1634
+ #
1635
+ # Related: Time#thursday?, Time#friday?, Time#saturday?.
1636
+ #
1637
+ def wednesday?: () -> bool
1638
+
1639
+ # <!--
1640
+ # rdoc-file=lib/time.rb
1641
+ # - xmlschema(fraction_digits=0)
1642
+ # -->
1643
+ # Returns a string which represents the time as a dateTime defined by XML
1644
+ # Schema:
1645
+ #
1646
+ # CCYY-MM-DDThh:mm:ssTZD
1647
+ # CCYY-MM-DDThh:mm:ss.sssTZD
1648
+ #
1649
+ # where TZD is Z or [+-]hh:mm.
1650
+ #
1651
+ # If self is a UTC time, Z is used as TZD. [+-]hh:mm is used otherwise.
1652
+ #
1653
+ # `fraction_digits` specifies a number of digits to use for fractional seconds.
1654
+ # Its default value is 0.
1655
+ #
1656
+ # require 'time'
1657
+ #
1658
+ # t = Time.now
1659
+ # t.iso8601 # => "2011-10-05T22:26:12-04:00"
1660
+ #
1661
+ # You must require 'time' to use this method.
1662
+ #
1663
+ def xmlschema: (?Integer fraction_digits) -> String
1664
+
1665
+ # <!--
1666
+ # rdoc-file=time.c
1667
+ # - yday -> integer
1668
+ # -->
1669
+ # Returns the integer day of the year of `self`, in range (1..366).
1670
+ #
1671
+ # Time.new(2000, 1, 1).yday # => 1
1672
+ # Time.new(2000, 12, 31).yday # => 366
1673
+ #
1674
+ def yday: () -> Integer
1675
+
1676
+ # <!--
1677
+ # rdoc-file=time.c
1678
+ # - year -> integer
1679
+ # -->
1680
+ # Returns the integer year for `self`:
1681
+ #
1682
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
1683
+ # # => 2000-01-02 03:04:05 +000006
1684
+ # t.year # => 2000
1685
+ #
1686
+ # Related: Time#mon, Time#hour, Time#min.
1687
+ #
1688
+ def year: () -> Integer
1689
+
1690
+ # <!--
1691
+ # rdoc-file=time.c
1692
+ # - time.zone -> string or timezone
1693
+ # -->
1694
+ # Returns the string name of the time zone for `self`:
1695
+ #
1696
+ # Time.utc(2000, 1, 1).zone # => "UTC"
1697
+ # Time.new(2000, 1, 1).zone # => "Central Standard Time"
1698
+ #
1699
+ def zone: () -> String?
1700
+
1701
+ # <!-- rdoc-file=time.c -->
1702
+ # Like Time.utc, except that the returned `Time` object has the local timezone,
1703
+ # not the UTC timezone:
1704
+ #
1705
+ # # With seven arguments.
1706
+ # Time.local(0, 1, 2, 3, 4, 5, 6)
1707
+ # # => 0000-01-02 03:04:05.000006 -0600
1708
+ # # With exactly ten arguments.
1709
+ # Time.local(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
1710
+ # # => 0005-04-03 02:01:00 -0600
1711
+ #
1712
+ def self.mktime: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
1713
+
1714
+ # <!--
1715
+ # rdoc-file=time.c
1716
+ # - utc_offset -> integer
1717
+ # -->
1718
+ # Returns the offset in seconds between the timezones of UTC and `self`:
1719
+ #
1720
+ # Time.utc(2000, 1, 1).utc_offset # => 0
1721
+ # Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours.
1722
+ #
1723
+ def gmtoff: () -> Integer
1724
+
1725
+ # <!-- rdoc-file=time.c -->
1726
+ # Returns the integer month of the year for `self`, in range (1..12):
1727
+ #
1728
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
1729
+ # # => 2000-01-02 03:04:05 +000006
1730
+ # t.mon # => 1
1731
+ #
1732
+ # Related: Time#year, Time#hour, Time#min.
1733
+ #
1734
+ def month: () -> Integer
1735
+
1736
+ # <!--
1737
+ # rdoc-file=time.c
1738
+ # - floor(ndigits = 0) -> new_time
1739
+ # -->
1740
+ # Returns a new `Time` object whose numerical value is less than or equal to
1741
+ # `self` with its seconds truncated to precision `ndigits`:
1742
+ #
1743
+ # t = Time.utc(2010, 3, 30, 5, 43, 25.123456789r)
1744
+ # t # => 2010-03-30 05:43:25.123456789 UTC
1745
+ # t.floor # => 2010-03-30 05:43:25 UTC
1746
+ # t.floor(2) # => 2010-03-30 05:43:25.12 UTC
1747
+ # t.floor(4) # => 2010-03-30 05:43:25.1234 UTC
1748
+ # t.floor(6) # => 2010-03-30 05:43:25.123456 UTC
1749
+ # t.floor(8) # => 2010-03-30 05:43:25.12345678 UTC
1750
+ # t.floor(10) # => 2010-03-30 05:43:25.123456789 UTC
1751
+ #
1752
+ # t = Time.utc(1999, 12, 31, 23, 59, 59)
1753
+ # t # => 1999-12-31 23:59:59 UTC
1754
+ # (t + 0.4).floor # => 1999-12-31 23:59:59 UTC
1755
+ # (t + 0.9).floor # => 1999-12-31 23:59:59 UTC
1756
+ # (t + 1.4).floor # => 2000-01-01 00:00:00 UTC
1757
+ # (t + 1.9).floor # => 2000-01-01 00:00:00 UTC
1758
+ #
1759
+ # Related: Time#ceil, Time#round.
1760
+ #
1761
+ def floor: (?int ndigits) -> Time
1762
+
1763
+ # <!--
1764
+ # rdoc-file=time.c
1765
+ # - ceil(ndigits = 0) -> new_time
1766
+ # -->
1767
+ # Returns a new `Time` object whose numerical value is greater than or equal to
1768
+ # `self` with its seconds truncated to precision `ndigits`:
1769
+ #
1770
+ # t = Time.utc(2010, 3, 30, 5, 43, 25.123456789r)
1771
+ # t # => 2010-03-30 05:43:25.123456789 UTC
1772
+ # t.ceil # => 2010-03-30 05:43:26 UTC
1773
+ # t.ceil(2) # => 2010-03-30 05:43:25.13 UTC
1774
+ # t.ceil(4) # => 2010-03-30 05:43:25.1235 UTC
1775
+ # t.ceil(6) # => 2010-03-30 05:43:25.123457 UTC
1776
+ # t.ceil(8) # => 2010-03-30 05:43:25.12345679 UTC
1777
+ # t.ceil(10) # => 2010-03-30 05:43:25.123456789 UTC
1778
+ #
1779
+ # t = Time.utc(1999, 12, 31, 23, 59, 59)
1780
+ # t # => 1999-12-31 23:59:59 UTC
1781
+ # (t + 0.4).ceil # => 2000-01-01 00:00:00 UTC
1782
+ # (t + 0.9).ceil # => 2000-01-01 00:00:00 UTC
1783
+ # (t + 1.4).ceil # => 2000-01-01 00:00:01 UTC
1784
+ # (t + 1.9).ceil # => 2000-01-01 00:00:01 UTC
1785
+ #
1786
+ # Related: Time#floor, Time#round.
1787
+ #
1788
+ def ceil: (?int ndigits) -> Time
1789
+ end
1790
+
1791
+ Time::RFC2822_DAY_NAME: Array[String]
1792
+
1793
+ Time::RFC2822_MONTH_NAME: Array[String]