rbs 2.8.4 → 3.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (434) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +12 -4
  3. data/.github/workflows/comments.yml +11 -11
  4. data/.github/workflows/dependabot.yml +30 -0
  5. data/.github/workflows/ruby.yml +40 -49
  6. data/.github/workflows/typecheck.yml +36 -0
  7. data/.github/workflows/windows.yml +28 -0
  8. data/.gitignore +1 -0
  9. data/.rubocop.yml +42 -2
  10. data/CHANGELOG.md +845 -1
  11. data/README.md +64 -4
  12. data/Rakefile +198 -18
  13. data/Steepfile +11 -11
  14. data/config.yml +311 -0
  15. data/core/array.rbs +2189 -1914
  16. data/core/basic_object.rbs +59 -84
  17. data/core/binding.rbs +7 -69
  18. data/core/builtin.rbs +210 -11
  19. data/core/class.rbs +37 -0
  20. data/core/comparable.rbs +23 -25
  21. data/core/complex.rbs +449 -227
  22. data/core/constants.rbs +29 -21
  23. data/core/data.rbs +415 -0
  24. data/core/dir.rbs +698 -415
  25. data/core/encoding.rbs +468 -843
  26. data/core/enumerable.rbs +495 -455
  27. data/core/enumerator/product.rbs +92 -0
  28. data/core/enumerator.rbs +106 -9
  29. data/core/env.rbs +1 -1
  30. data/core/errno.rbs +506 -605
  31. data/core/errors.rbs +15 -17
  32. data/core/exception.rbs +361 -145
  33. data/core/false_class.rbs +39 -26
  34. data/core/fiber.rbs +121 -14
  35. data/core/file.rbs +1262 -320
  36. data/core/file_test.rbs +62 -45
  37. data/core/float.rbs +187 -208
  38. data/core/gc.rbs +446 -196
  39. data/core/global_variables.rbs +29 -29
  40. data/core/hash.rbs +242 -349
  41. data/core/integer.rbs +246 -308
  42. data/core/io/buffer.rbs +373 -122
  43. data/core/io/wait.rbs +29 -17
  44. data/core/io.rbs +1881 -1518
  45. data/core/kernel.rbs +2116 -1538
  46. data/core/marshal.rbs +24 -14
  47. data/core/match_data.rbs +413 -166
  48. data/core/math.rbs +531 -291
  49. data/core/method.rbs +101 -32
  50. data/core/module.rbs +228 -64
  51. data/core/nil_class.rbs +106 -47
  52. data/core/numeric.rbs +206 -292
  53. data/core/object.rbs +73 -1168
  54. data/core/object_space/weak_key_map.rbs +166 -0
  55. data/core/object_space.rbs +5 -3
  56. data/core/proc.rbs +280 -39
  57. data/core/process.rbs +1318 -658
  58. data/core/ractor.rbs +200 -134
  59. data/core/random.rbs +21 -4
  60. data/core/range.rbs +309 -153
  61. data/core/rational.rbs +4 -12
  62. data/core/rb_config.rbs +64 -43
  63. data/core/rbs/unnamed/argf.rbs +411 -147
  64. data/core/rbs/unnamed/env_class.rbs +137 -253
  65. data/core/rbs/unnamed/random.rbs +49 -26
  66. data/core/refinement.rbs +16 -1
  67. data/core/regexp.rbs +1568 -862
  68. data/core/ruby_vm.rbs +719 -7
  69. data/core/rubygems/config_file.rbs +3 -0
  70. data/core/rubygems/errors.rbs +69 -6
  71. data/core/rubygems/rubygems.rbs +71 -17
  72. data/core/rubygems/version.rbs +11 -7
  73. data/{stdlib/set/0 → core}/set.rbs +80 -91
  74. data/core/signal.rbs +14 -8
  75. data/core/string.rbs +1732 -1607
  76. data/core/struct.rbs +467 -95
  77. data/core/symbol.rbs +215 -245
  78. data/core/thread.rbs +133 -89
  79. data/core/thread_group.rbs +9 -9
  80. data/core/time.rbs +1141 -841
  81. data/core/trace_point.rbs +181 -121
  82. data/core/true_class.rbs +58 -32
  83. data/core/unbound_method.rbs +103 -30
  84. data/core/warning.rbs +50 -5
  85. data/docs/CONTRIBUTING.md +1 -1
  86. data/docs/architecture.md +110 -0
  87. data/docs/collection.md +59 -5
  88. data/docs/data_and_struct.md +86 -0
  89. data/docs/gem.md +57 -0
  90. data/docs/rbs_by_example.md +16 -35
  91. data/docs/repo.md +1 -1
  92. data/docs/sigs.md +7 -7
  93. data/docs/stdlib.md +63 -5
  94. data/docs/syntax.md +255 -61
  95. data/docs/tools.md +1 -0
  96. data/ext/rbs_extension/extconf.rb +10 -0
  97. data/ext/rbs_extension/lexer.c +1741 -1548
  98. data/ext/rbs_extension/lexer.h +11 -1
  99. data/ext/rbs_extension/lexer.re +12 -6
  100. data/ext/rbs_extension/lexstate.c +26 -3
  101. data/ext/rbs_extension/location.c +119 -111
  102. data/ext/rbs_extension/location.h +32 -7
  103. data/ext/rbs_extension/main.c +3 -0
  104. data/ext/rbs_extension/parser.c +883 -481
  105. data/ext/rbs_extension/parserstate.c +65 -25
  106. data/ext/rbs_extension/parserstate.h +13 -3
  107. data/ext/rbs_extension/rbs_extension.h +1 -10
  108. data/ext/rbs_extension/unescape.c +7 -47
  109. data/goodcheck.yml +2 -2
  110. data/{ext/rbs_extension → include/rbs}/constants.h +26 -15
  111. data/include/rbs/ruby_objs.h +72 -0
  112. data/include/rbs.h +7 -0
  113. data/lib/rbs/annotate/annotations.rb +3 -3
  114. data/lib/rbs/annotate/formatter.rb +13 -3
  115. data/lib/rbs/annotate/rdoc_annotator.rb +1 -1
  116. data/lib/rbs/annotate/rdoc_source.rb +12 -3
  117. data/lib/rbs/ast/declarations.rb +85 -2
  118. data/lib/rbs/ast/directives.rb +39 -0
  119. data/lib/rbs/ast/members.rb +49 -15
  120. data/lib/rbs/ast/type_param.rb +104 -15
  121. data/lib/rbs/ast/visitor.rb +137 -0
  122. data/lib/rbs/buffer.rb +5 -0
  123. data/lib/rbs/cli/colored_io.rb +48 -0
  124. data/lib/rbs/cli/diff.rb +83 -0
  125. data/lib/rbs/cli/validate.rb +356 -0
  126. data/lib/rbs/cli.rb +253 -143
  127. data/lib/rbs/collection/cleaner.rb +8 -1
  128. data/lib/rbs/collection/config/lockfile.rb +92 -0
  129. data/lib/rbs/collection/config/lockfile_generator.rb +154 -65
  130. data/lib/rbs/collection/config.rb +19 -46
  131. data/lib/rbs/collection/installer.rb +12 -13
  132. data/lib/rbs/collection/sources/base.rb +2 -2
  133. data/lib/rbs/collection/sources/git.rb +146 -69
  134. data/lib/rbs/collection/sources/local.rb +81 -0
  135. data/lib/rbs/collection/sources/rubygems.rb +10 -12
  136. data/lib/rbs/collection/sources/stdlib.rb +14 -13
  137. data/lib/rbs/collection/sources.rb +15 -2
  138. data/lib/rbs/collection.rb +2 -1
  139. data/lib/rbs/definition.rb +13 -16
  140. data/lib/rbs/definition_builder/ancestor_builder.rb +100 -24
  141. data/lib/rbs/definition_builder/method_builder.rb +4 -4
  142. data/lib/rbs/definition_builder.rb +489 -584
  143. data/lib/rbs/diff.rb +125 -0
  144. data/lib/rbs/environment/use_map.rb +77 -0
  145. data/lib/rbs/environment.rb +406 -105
  146. data/lib/rbs/environment_loader.rb +48 -44
  147. data/lib/rbs/environment_walker.rb +1 -1
  148. data/lib/rbs/errors.rb +175 -56
  149. data/lib/rbs/file_finder.rb +28 -0
  150. data/lib/rbs/location_aux.rb +8 -7
  151. data/lib/rbs/locator.rb +37 -15
  152. data/lib/rbs/method_type.rb +23 -0
  153. data/lib/rbs/namespace.rb +1 -0
  154. data/lib/rbs/parser/lex_result.rb +15 -0
  155. data/lib/rbs/parser/token.rb +23 -0
  156. data/lib/rbs/parser_aux.rb +22 -13
  157. data/lib/rbs/prototype/helpers.rb +48 -22
  158. data/lib/rbs/prototype/node_usage.rb +99 -0
  159. data/lib/rbs/prototype/rb.rb +125 -31
  160. data/lib/rbs/prototype/rbi.rb +49 -36
  161. data/lib/rbs/prototype/runtime/helpers.rb +59 -0
  162. data/lib/rbs/prototype/runtime/reflection.rb +19 -0
  163. data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
  164. data/lib/rbs/prototype/runtime.rb +273 -159
  165. data/lib/rbs/resolver/constant_resolver.rb +24 -8
  166. data/lib/rbs/resolver/type_name_resolver.rb +41 -7
  167. data/lib/rbs/sorter.rb +153 -123
  168. data/lib/rbs/substitution.rb +19 -0
  169. data/lib/rbs/subtractor.rb +201 -0
  170. data/lib/rbs/test/errors.rb +24 -11
  171. data/lib/rbs/test/guaranteed.rb +30 -0
  172. data/lib/rbs/test/hook.rb +45 -40
  173. data/lib/rbs/test/setup.rb +1 -1
  174. data/lib/rbs/test/tester.rb +1 -1
  175. data/lib/rbs/test/type_check.rb +120 -23
  176. data/lib/rbs/test.rb +6 -3
  177. data/lib/rbs/type_alias_dependency.rb +13 -3
  178. data/lib/rbs/type_alias_regularity.rb +21 -14
  179. data/lib/rbs/type_name.rb +18 -13
  180. data/lib/rbs/types.rb +352 -18
  181. data/lib/rbs/unit_test/convertibles.rb +176 -0
  182. data/lib/rbs/unit_test/spy.rb +136 -0
  183. data/lib/rbs/unit_test/type_assertions.rb +341 -0
  184. data/lib/rbs/unit_test/with_aliases.rb +143 -0
  185. data/lib/rbs/unit_test.rb +6 -0
  186. data/lib/rbs/validator.rb +55 -30
  187. data/lib/rbs/variance_calculator.rb +26 -23
  188. data/lib/rbs/vendorer.rb +3 -3
  189. data/lib/rbs/version.rb +1 -1
  190. data/lib/rbs/writer.rb +69 -22
  191. data/lib/rbs.rb +7 -2
  192. data/lib/rdoc/discover.rb +1 -1
  193. data/lib/rdoc_plugin/parser.rb +5 -5
  194. data/rbs.gemspec +12 -2
  195. data/schema/decls.json +1 -1
  196. data/schema/members.json +15 -10
  197. data/sig/ancestor_builder.rbs +4 -0
  198. data/sig/ancestor_graph.rbs +22 -2
  199. data/sig/annotate/formatter.rbs +2 -2
  200. data/sig/annotate/rdoc_annotater.rbs +1 -1
  201. data/sig/cli/colored_io.rbs +15 -0
  202. data/sig/cli/diff.rbs +21 -0
  203. data/sig/cli/validate.rbs +43 -0
  204. data/sig/cli.rbs +4 -0
  205. data/sig/collection/config/lockfile.rbs +74 -0
  206. data/sig/collection/config/lockfile_generator.rbs +66 -0
  207. data/sig/collection/config.rbs +5 -48
  208. data/sig/collection/installer.rbs +1 -1
  209. data/sig/collection/sources.rbs +105 -33
  210. data/sig/constant.rbs +1 -1
  211. data/sig/declarations.rbs +42 -3
  212. data/sig/definition.rbs +26 -10
  213. data/sig/definition_builder.rbs +103 -81
  214. data/sig/diff.rbs +28 -0
  215. data/sig/directives.rbs +61 -0
  216. data/sig/environment.rbs +175 -29
  217. data/sig/environment_loader.rbs +20 -18
  218. data/sig/errors.rbs +123 -2
  219. data/sig/file_finder.rbs +28 -0
  220. data/sig/location.rbs +0 -3
  221. data/sig/locator.rbs +14 -2
  222. data/sig/manifest.yaml +0 -1
  223. data/sig/members.rbs +32 -9
  224. data/sig/method_types.rbs +10 -4
  225. data/sig/namespace.rbs +2 -3
  226. data/sig/parser.rbs +55 -16
  227. data/sig/prototype/helpers.rbs +4 -0
  228. data/sig/prototype/node_usage.rbs +20 -0
  229. data/sig/prototype/rb.rbs +10 -2
  230. data/sig/prototype/rbi.rbs +2 -0
  231. data/sig/prototype/runtime.rbs +182 -0
  232. data/sig/rbs.rbs +1 -1
  233. data/sig/rdoc/rbs.rbs +4 -0
  234. data/sig/repository.rbs +7 -5
  235. data/sig/resolver/constant_resolver.rbs +3 -4
  236. data/sig/resolver/context.rbs +1 -1
  237. data/sig/resolver/type_name_resolver.rbs +5 -1
  238. data/sig/shims/bundler.rbs +38 -0
  239. data/sig/shims/rubygems.rbs +19 -0
  240. data/sig/sorter.rbs +23 -5
  241. data/sig/substitution.rbs +6 -0
  242. data/sig/subtractor.rbs +37 -0
  243. data/sig/test/errors.rbs +52 -0
  244. data/sig/test/guranteed.rbs +9 -0
  245. data/sig/test/type_check.rbs +19 -0
  246. data/sig/test.rbs +82 -0
  247. data/sig/type_alias_dependency.rbs +31 -0
  248. data/sig/type_alias_regularity.rbs +12 -6
  249. data/sig/type_param.rbs +45 -9
  250. data/sig/typename.rbs +8 -5
  251. data/sig/types.rbs +119 -12
  252. data/sig/unit_test/convertibles.rbs +154 -0
  253. data/sig/unit_test/spy.rbs +28 -0
  254. data/sig/unit_test/type_assertions.rbs +194 -0
  255. data/sig/unit_test/with_aliases.rbs +136 -0
  256. data/sig/use_map.rbs +35 -0
  257. data/sig/validator.rbs +12 -5
  258. data/sig/variance_calculator.rbs +3 -1
  259. data/sig/vendorer.rbs +1 -1
  260. data/sig/visitor.rbs +47 -0
  261. data/sig/writer.rbs +6 -2
  262. data/src/constants.c +153 -0
  263. data/src/ruby_objs.c +793 -0
  264. data/stdlib/base64/0/base64.rbs +298 -45
  265. data/stdlib/benchmark/0/benchmark.rbs +12 -3
  266. data/stdlib/bigdecimal/0/big_decimal.rbs +62 -198
  267. data/stdlib/cgi/0/core.rbs +68 -15
  268. data/stdlib/cgi/0/manifest.yaml +1 -0
  269. data/stdlib/coverage/0/coverage.rbs +50 -11
  270. data/stdlib/csv/0/csv.rbs +90 -119
  271. data/stdlib/csv/0/manifest.yaml +1 -0
  272. data/stdlib/date/0/date.rbs +806 -735
  273. data/stdlib/date/0/date_time.rbs +70 -211
  274. data/stdlib/dbm/0/dbm.rbs +0 -2
  275. data/stdlib/delegate/0/delegator.rbs +184 -0
  276. data/stdlib/delegate/0/kernel.rbs +47 -0
  277. data/stdlib/delegate/0/simple_delegator.rbs +96 -0
  278. data/stdlib/did_you_mean/0/did_you_mean.rbs +3 -8
  279. data/stdlib/digest/0/digest.rbs +48 -35
  280. data/stdlib/erb/0/erb.rbs +15 -39
  281. data/stdlib/etc/0/etc.rbs +174 -54
  282. data/stdlib/fileutils/0/fileutils.rbs +1234 -385
  283. data/stdlib/forwardable/0/forwardable.rbs +4 -4
  284. data/stdlib/io-console/0/io-console.rbs +82 -17
  285. data/stdlib/ipaddr/0/ipaddr.rbs +11 -6
  286. data/stdlib/json/0/json.rbs +434 -151
  287. data/stdlib/kconv/0/kconv.rbs +166 -0
  288. data/stdlib/logger/0/formatter.rbs +0 -2
  289. data/stdlib/logger/0/log_device.rbs +1 -3
  290. data/stdlib/logger/0/logger.rbs +465 -328
  291. data/stdlib/minitest/0/kernel.rbs +2 -2
  292. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +4 -1
  293. data/stdlib/minitest/0/minitest/assertion.rbs +1 -0
  294. data/stdlib/minitest/0/minitest/assertions.rbs +58 -13
  295. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +7 -0
  296. data/stdlib/minitest/0/minitest/bench_spec.rbs +8 -8
  297. data/stdlib/minitest/0/minitest/benchmark.rbs +17 -16
  298. data/stdlib/minitest/0/minitest/compress.rbs +13 -0
  299. data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
  300. data/stdlib/minitest/0/minitest/mock.rbs +9 -5
  301. data/stdlib/minitest/0/minitest/parallel/executor.rbs +4 -0
  302. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +0 -1
  303. data/stdlib/minitest/0/minitest/pride_io.rbs +8 -0
  304. data/stdlib/minitest/0/minitest/pride_lol.rbs +2 -0
  305. data/stdlib/minitest/0/minitest/progress_reporter.rbs +1 -1
  306. data/stdlib/minitest/0/minitest/reportable.rbs +2 -0
  307. data/stdlib/minitest/0/minitest/runnable.rbs +33 -1
  308. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +1 -1
  309. data/stdlib/minitest/0/minitest/spec/dsl.rbs +10 -6
  310. data/stdlib/minitest/0/minitest/spec.rbs +1 -1
  311. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +5 -0
  312. data/stdlib/minitest/0/minitest/summary_reporter.rbs +0 -7
  313. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +7 -7
  314. data/stdlib/minitest/0/minitest/test.rbs +7 -14
  315. data/stdlib/minitest/0/minitest/unexpected_error.rbs +2 -0
  316. data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
  317. data/stdlib/minitest/0/minitest/unit.rbs +1 -2
  318. data/stdlib/minitest/0/minitest.rbs +41 -892
  319. data/stdlib/monitor/0/monitor.rbs +91 -10
  320. data/stdlib/mutex_m/0/mutex_m.rbs +0 -2
  321. data/stdlib/net-http/0/manifest.yaml +1 -1
  322. data/stdlib/net-http/0/net-http.rbs +3858 -964
  323. data/stdlib/net-protocol/0/manifest.yaml +2 -0
  324. data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
  325. data/stdlib/net-smtp/0/manifest.yaml +2 -0
  326. data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
  327. data/stdlib/nkf/0/nkf.rbs +35 -5
  328. data/stdlib/objspace/0/objspace.rbs +40 -18
  329. data/stdlib/observable/0/observable.rbs +217 -0
  330. data/stdlib/open-uri/0/manifest.yaml +4 -0
  331. data/stdlib/open-uri/0/open-uri.rbs +393 -0
  332. data/stdlib/open3/0/open3.rbs +147 -0
  333. data/stdlib/openssl/0/manifest.yaml +1 -0
  334. data/stdlib/openssl/0/openssl.rbs +681 -316
  335. data/stdlib/optparse/0/optparse.rbs +100 -65
  336. data/stdlib/pathname/0/pathname.rbs +24 -15
  337. data/stdlib/pp/0/manifest.yaml +2 -0
  338. data/stdlib/pp/0/pp.rbs +300 -0
  339. data/stdlib/prettyprint/0/prettyprint.rbs +2 -6
  340. data/stdlib/pstore/0/pstore.rbs +370 -156
  341. data/stdlib/psych/0/core_ext.rbs +12 -0
  342. data/stdlib/{yaml → psych}/0/dbm.rbs +3 -3
  343. data/stdlib/psych/0/manifest.yaml +3 -0
  344. data/stdlib/psych/0/psych.rbs +402 -0
  345. data/stdlib/{yaml → psych}/0/store.rbs +2 -2
  346. data/stdlib/pty/0/pty.rbs +63 -11
  347. data/stdlib/rdoc/0/code_object.rbs +51 -0
  348. data/stdlib/rdoc/0/comment.rbs +59 -0
  349. data/stdlib/rdoc/0/context.rbs +153 -0
  350. data/stdlib/rdoc/0/markup.rbs +117 -0
  351. data/stdlib/rdoc/0/parser.rbs +56 -0
  352. data/stdlib/rdoc/0/rdoc.rbs +13 -380
  353. data/stdlib/rdoc/0/ri.rbs +17 -0
  354. data/stdlib/rdoc/0/store.rbs +48 -0
  355. data/stdlib/rdoc/0/top_level.rbs +97 -0
  356. data/stdlib/resolv/0/resolv.rbs +16 -79
  357. data/stdlib/ripper/0/ripper.rbs +1648 -0
  358. data/stdlib/securerandom/0/securerandom.rbs +7 -2
  359. data/stdlib/shellwords/0/shellwords.rbs +11 -12
  360. data/stdlib/singleton/0/singleton.rbs +0 -3
  361. data/stdlib/socket/0/addrinfo.rbs +13 -18
  362. data/stdlib/socket/0/basic_socket.rbs +5 -10
  363. data/stdlib/socket/0/ip_socket.rbs +0 -2
  364. data/stdlib/socket/0/socket.rbs +77 -46
  365. data/stdlib/socket/0/tcp_server.rbs +0 -5
  366. data/stdlib/socket/0/tcp_socket.rbs +36 -3
  367. data/stdlib/socket/0/udp_socket.rbs +4 -5
  368. data/stdlib/socket/0/unix_server.rbs +0 -5
  369. data/stdlib/socket/0/unix_socket.rbs +2 -4
  370. data/{core/string_io.rbs → stdlib/stringio/0/stringio.rbs} +188 -107
  371. data/stdlib/strscan/0/string_scanner.rbs +1269 -425
  372. data/stdlib/tempfile/0/tempfile.rbs +224 -61
  373. data/stdlib/time/0/time.rbs +48 -35
  374. data/stdlib/timeout/0/timeout.rbs +17 -8
  375. data/stdlib/tmpdir/0/tmpdir.rbs +10 -3
  376. data/stdlib/tsort/0/tsort.rbs +0 -4
  377. data/stdlib/uri/0/common.rbs +271 -144
  378. data/stdlib/uri/0/file.rbs +5 -0
  379. data/stdlib/uri/0/ftp.rbs +1 -1
  380. data/stdlib/uri/0/generic.rbs +26 -22
  381. data/stdlib/uri/0/http.rbs +4 -4
  382. data/stdlib/uri/0/ldap.rbs +1 -1
  383. data/stdlib/uri/0/mailto.rbs +84 -0
  384. data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
  385. data/stdlib/yaml/0/manifest.yaml +1 -2
  386. data/stdlib/yaml/0/yaml.rbs +1 -199
  387. data/stdlib/zlib/0/buf_error.rbs +10 -0
  388. data/stdlib/zlib/0/data_error.rbs +10 -0
  389. data/stdlib/zlib/0/deflate.rbs +210 -0
  390. data/stdlib/zlib/0/error.rbs +20 -0
  391. data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
  392. data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
  393. data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
  394. data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
  395. data/stdlib/zlib/0/gzip_file.rbs +156 -0
  396. data/stdlib/zlib/0/gzip_reader.rbs +293 -0
  397. data/stdlib/zlib/0/gzip_writer.rbs +166 -0
  398. data/stdlib/zlib/0/inflate.rbs +180 -0
  399. data/stdlib/zlib/0/mem_error.rbs +10 -0
  400. data/stdlib/zlib/0/need_dict.rbs +13 -0
  401. data/stdlib/zlib/0/stream_end.rbs +11 -0
  402. data/stdlib/zlib/0/stream_error.rbs +11 -0
  403. data/stdlib/zlib/0/version_error.rbs +11 -0
  404. data/stdlib/zlib/0/zlib.rbs +1 -3
  405. data/stdlib/zlib/0/zstream.rbs +200 -0
  406. data/templates/include/rbs/constants.h.erb +20 -0
  407. data/templates/include/rbs/ruby_objs.h.erb +10 -0
  408. data/templates/src/constants.c.erb +36 -0
  409. data/templates/src/ruby_objs.c.erb +27 -0
  410. data/templates/template.rb +122 -0
  411. metadata +136 -36
  412. data/Gemfile +0 -33
  413. data/Gemfile.lock +0 -118
  414. data/core/deprecated.rbs +0 -9
  415. data/ext/rbs_extension/constants.c +0 -135
  416. data/ext/rbs_extension/ruby_objs.c +0 -525
  417. data/ext/rbs_extension/ruby_objs.h +0 -43
  418. data/lib/rbs/constant_table.rb +0 -167
  419. data/lib/rbs/parser_compat/lexer_error.rb +0 -6
  420. data/lib/rbs/parser_compat/located_value.rb +0 -7
  421. data/lib/rbs/parser_compat/semantics_error.rb +0 -6
  422. data/lib/rbs/parser_compat/syntax_error.rb +0 -6
  423. data/lib/rbs/test/spy.rb +0 -6
  424. data/lib/rbs/type_name_resolver.rb +0 -67
  425. data/sig/constant_table.rbs +0 -30
  426. data/sig/shims/abstract_syntax_tree.rbs +0 -25
  427. data/sig/shims/pp.rbs +0 -3
  428. data/sig/shims/ripper.rbs +0 -8
  429. data/sig/shims.rbs +0 -69
  430. data/sig/type_name_resolver.rbs +0 -26
  431. data/stdlib/minitest/0/manifest.yaml +0 -2
  432. data/stdlib/prime/0/integer-extension.rbs +0 -41
  433. data/stdlib/prime/0/manifest.yaml +0 -2
  434. data/stdlib/prime/0/prime.rbs +0 -372
@@ -1,144 +1,96 @@
1
1
  # <!-- rdoc-file=ext/date/date_core.c -->
2
- # date and datetime class - Tadayoshi Funaba 1998-2011
2
+ # Class Date provides methods for storing and manipulating calendar dates.
3
3
  #
4
- # 'date' provides two classes: Date and DateTime.
4
+ # Consider using [class Time](rdoc-ref:Time) instead of class Date if:
5
5
  #
6
- # ## Terms and Definitions
6
+ # * You need both dates and times; Date handles only dates.
7
+ # * You need only Gregorian dates (and not Julian dates); see [Julian and
8
+ # Gregorian Calendars](rdoc-ref:date/calendars.rdoc).
7
9
  #
8
- # Some terms and definitions are based on ISO 8601 and JIS X 0301.
10
+ # A Date object, once created, is immutable, and cannot be modified.
9
11
  #
10
- # ### Calendar Date
12
+ # ## Creating a Date
11
13
  #
12
- # The calendar date is a particular day of a calendar year, identified by its
13
- # ordinal number within a calendar month within that year.
14
+ # You can create a date for the current date, using Date.today:
14
15
  #
15
- # In those classes, this is so-called "civil".
16
+ # Date.today # => #<Date: 1999-12-31>
16
17
  #
17
- # ### Ordinal Date
18
+ # You can create a specific date from various combinations of arguments:
18
19
  #
19
- # The ordinal date is a particular day of a calendar year identified by its
20
- # ordinal number within the year.
20
+ # * Date.new takes integer year, month, and day-of-month:
21
21
  #
22
- # In those classes, this is so-called "ordinal".
22
+ # Date.new(1999, 12, 31) # => #<Date: 1999-12-31>
23
23
  #
24
- # ### Week Date
24
+ # * Date.ordinal takes integer year and day-of-year:
25
25
  #
26
- # The week date is a date identified by calendar week and day numbers.
26
+ # Date.ordinal(1999, 365) # => #<Date: 1999-12-31>
27
27
  #
28
- # The calendar week is a seven day period within a calendar year, starting on a
29
- # Monday and identified by its ordinal number within the year; the first
30
- # calendar week of the year is the one that includes the first Thursday of that
31
- # year. In the Gregorian calendar, this is equivalent to the week which includes
32
- # January 4.
28
+ # * Date.jd takes integer Julian day:
33
29
  #
34
- # In those classes, this is so-called "commercial".
30
+ # Date.jd(2451544) # => #<Date: 1999-12-31>
35
31
  #
36
- # ### Julian Day Number
32
+ # * Date.commercial takes integer commercial data (year, week, day-of-week):
37
33
  #
38
- # The Julian day number is in elapsed days since noon (Greenwich Mean Time) on
39
- # January 1, 4713 BCE (in the Julian calendar).
34
+ # Date.commercial(1999, 52, 5) # => #<Date: 1999-12-31>
40
35
  #
41
- # In this document, the astronomical Julian day number is the same as the
42
- # original Julian day number. And the chronological Julian day number is a
43
- # variation of the Julian day number. Its days begin at midnight on local time.
36
+ # * Date.parse takes a string, which it parses heuristically:
44
37
  #
45
- # In this document, when the term "Julian day number" simply appears, it just
46
- # refers to "chronological Julian day number", not the original.
38
+ # Date.parse('1999-12-31') # => #<Date: 1999-12-31>
39
+ # Date.parse('31-12-1999') # => #<Date: 1999-12-31>
40
+ # Date.parse('1999-365') # => #<Date: 1999-12-31>
41
+ # Date.parse('1999-W52-5') # => #<Date: 1999-12-31>
47
42
  #
48
- # In those classes, those are so-called "ajd" and "jd".
43
+ # * Date.strptime takes a date string and a format string, then parses the
44
+ # date string according to the format string:
49
45
  #
50
- # ### Modified Julian Day Number
46
+ # Date.strptime('1999-12-31', '%Y-%m-%d') # => #<Date: 1999-12-31>
47
+ # Date.strptime('31-12-1999', '%d-%m-%Y') # => #<Date: 1999-12-31>
48
+ # Date.strptime('1999-365', '%Y-%j') # => #<Date: 1999-12-31>
49
+ # Date.strptime('1999-W52-5', '%G-W%V-%u') # => #<Date: 1999-12-31>
50
+ # Date.strptime('1999 52 5', '%Y %U %w') # => #<Date: 1999-12-31>
51
+ # Date.strptime('1999 52 5', '%Y %W %u') # => #<Date: 1999-12-31>
52
+ # Date.strptime('fri31dec99', '%a%d%b%y') # => #<Date: 1999-12-31>
51
53
  #
52
- # The modified Julian day number is in elapsed days since midnight (Coordinated
53
- # Universal Time) on November 17, 1858 CE (in the Gregorian calendar).
54
+ # See also the specialized methods in ["Specialized Format Strings" in Formats
55
+ # for Dates and
56
+ # Times](rdoc-ref:strftime_formatting.rdoc@Specialized+Format+Strings)
54
57
  #
55
- # In this document, the astronomical modified Julian day number is the same as
56
- # the original modified Julian day number. And the chronological modified Julian
57
- # day number is a variation of the modified Julian day number. Its days begin at
58
- # midnight on local time.
58
+ # ## Argument `limit`
59
59
  #
60
- # In this document, when the term "modified Julian day number" simply appears,
61
- # it just refers to "chronological modified Julian day number", not the
62
- # original.
60
+ # Certain singleton methods in Date that parse string arguments also take
61
+ # optional keyword argument `limit`, which can limit the length of the string
62
+ # argument.
63
63
  #
64
- # In those classes, those are so-called "amjd" and "mjd".
64
+ # When `limit` is:
65
65
  #
66
- # ## Date
67
- #
68
- # A subclass of Object that includes the Comparable module and easily handles
69
- # date.
70
- #
71
- # A Date object is created with Date::new, Date::jd, Date::ordinal,
72
- # Date::commercial, Date::parse, Date::strptime, Date::today, Time#to_date, etc.
73
- #
74
- # require 'date'
75
- #
76
- # Date.new(2001,2,3)
77
- # #=> #<Date: 2001-02-03 ...>
78
- # Date.jd(2451944)
79
- # #=> #<Date: 2001-02-03 ...>
80
- # Date.ordinal(2001,34)
81
- # #=> #<Date: 2001-02-03 ...>
82
- # Date.commercial(2001,5,6)
83
- # #=> #<Date: 2001-02-03 ...>
84
- # Date.parse('2001-02-03')
85
- # #=> #<Date: 2001-02-03 ...>
86
- # Date.strptime('03-02-2001', '%d-%m-%Y')
87
- # #=> #<Date: 2001-02-03 ...>
88
- # Time.new(2001,2,3).to_date
89
- # #=> #<Date: 2001-02-03 ...>
90
- #
91
- # All date objects are immutable; hence cannot modify themselves.
92
- #
93
- # The concept of a date object can be represented as a tuple of the day count,
94
- # the offset and the day of calendar reform.
95
- #
96
- # The day count denotes the absolute position of a temporal dimension. The
97
- # offset is relative adjustment, which determines decoded local time with the
98
- # day count. The day of calendar reform denotes the start day of the new style.
99
- # The old style of the West is the Julian calendar which was adopted by Caesar.
100
- # The new style is the Gregorian calendar, which is the current civil calendar
101
- # of many countries.
102
- #
103
- # The day count is virtually the astronomical Julian day number. The offset in
104
- # this class is usually zero, and cannot be specified directly.
105
- #
106
- # A Date object can be created with an optional argument, the day of calendar
107
- # reform as a Julian day number, which should be 2298874 to 2426355 or
108
- # negative/positive infinity. The default value is `Date::ITALY`
109
- # (2299161=1582-10-15). See also sample/cal.rb.
110
- #
111
- # $ ruby sample/cal.rb -c it 10 1582
112
- # October 1582
113
- # S M Tu W Th F S
114
- # 1 2 3 4 15 16
115
- # 17 18 19 20 21 22 23
116
- # 24 25 26 27 28 29 30
117
- # 31
118
- #
119
- # $ ruby sample/cal.rb -c gb 9 1752
120
- # September 1752
121
- # S M Tu W Th F S
122
- # 1 2 14 15 16
123
- # 17 18 19 20 21 22 23
124
- # 24 25 26 27 28 29 30
125
- #
126
- # A Date object has various methods. See each reference.
127
- #
128
- # d = Date.parse('3rd Feb 2001')
129
- # #=> #<Date: 2001-02-03 ...>
130
- # d.year #=> 2001
131
- # d.mon #=> 2
132
- # d.mday #=> 3
133
- # d.wday #=> 6
134
- # d += 1 #=> #<Date: 2001-02-04 ...>
135
- # d.strftime('%a %d %b %Y') #=> "Sun 04 Feb 2001"
66
+ # * Non-negative: raises ArgumentError if the string length is greater than
67
+ # *limit*.
68
+ # * Other numeric or `nil`: ignores `limit`.
69
+ # * Other non-numeric: raises TypeError.
136
70
  #
137
71
  class Date
138
72
  # <!--
139
73
  # rdoc-file=ext/date/date_core.c
140
- # - new(p1 = v1, p2 = v2, p3 = v3, p4 = v4)
74
+ # - Date.new(year = -4712, month = 1, mday = 1, start = Date::ITALY) -> date
141
75
  # -->
76
+ # Returns a new Date object constructed from the given arguments:
77
+ #
78
+ # Date.new(2022).to_s # => "2022-01-01"
79
+ # Date.new(2022, 2).to_s # => "2022-02-01"
80
+ # Date.new(2022, 2, 4).to_s # => "2022-02-04"
81
+ #
82
+ # Argument `month` should be in range (1..12) or range (-12..-1); when the
83
+ # argument is negative, counts backward from the end of the year:
84
+ #
85
+ # Date.new(2022, -11, 4).to_s # => "2022-02-04"
86
+ #
87
+ # Argument `mday` should be in range (1..n) or range (-n..-1) where `n` is the
88
+ # number of days in the month; when the argument is negative, counts backward
89
+ # from the end of the month.
90
+ #
91
+ # See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
92
+ #
93
+ # Related: Date.jd.
142
94
  #
143
95
  def initialize: (?Integer year, ?Integer month, ?Integer mday, ?Integer start) -> void
144
96
 
@@ -146,485 +98,629 @@ class Date
146
98
 
147
99
  # <!--
148
100
  # rdoc-file=ext/date/date_core.c
149
- # - Date._httpdate(string, limit: 128) -> hash
101
+ # - Date._httpdate(string, limit: 128) -> hash
150
102
  # -->
151
- # Returns a hash of parsed elements.
103
+ # Returns a hash of values parsed from `string`, which should be a valid [HTTP
104
+ # date format](rdoc-ref:strftime_formatting.rdoc@HTTP+Format):
105
+ #
106
+ # d = Date.new(2001, 2, 3)
107
+ # s = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
108
+ # Date._httpdate(s)
109
+ # # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"GMT", :offset=>0}
152
110
  #
153
- # Raise an ArgumentError when the string length is longer than *limit*. You can
154
- # stop this check by passing `limit: nil`, but note that it may take a long time
155
- # to parse.
111
+ # Related: Date.httpdate (returns a Date object).
156
112
  #
157
113
  def self._httpdate: (String str) -> Hash[Symbol, Integer]
158
114
 
159
115
  # <!--
160
116
  # rdoc-file=ext/date/date_core.c
161
- # - Date._iso8601(string, limit: 128) -> hash
117
+ # - Date._iso8601(string, limit: 128) -> hash
162
118
  # -->
163
- # Returns a hash of parsed elements.
119
+ # Returns a hash of values parsed from `string`, which should contain an [ISO
120
+ # 8601 formatted
121
+ # date](rdoc-ref:strftime_formatting.rdoc@ISO+8601+Format+Specifications):
164
122
  #
165
- # Raise an ArgumentError when the string length is longer than *limit*. You can
166
- # stop this check by passing `limit: nil`, but note that it may take a long time
167
- # to parse.
123
+ # d = Date.new(2001, 2, 3)
124
+ # s = d.iso8601 # => "2001-02-03"
125
+ # Date._iso8601(s) # => {:mday=>3, :year=>2001, :mon=>2}
126
+ #
127
+ # See argument [limit](rdoc-ref:Date@Argument+limit).
128
+ #
129
+ # Related: Date.iso8601 (returns a Date object).
168
130
  #
169
131
  def self._iso8601: (String str) -> Hash[Symbol, Integer]
170
132
 
171
133
  # <!--
172
134
  # rdoc-file=ext/date/date_core.c
173
- # - Date._jisx0301(string, limit: 128) -> hash
135
+ # - Date._jisx0301(string, limit: 128) -> hash
174
136
  # -->
175
- # Returns a hash of parsed elements.
137
+ # Returns a hash of values parsed from `string`, which should be a valid [JIS X
138
+ # 0301 date format](rdoc-ref:strftime_formatting.rdoc@JIS+X+0301+Format):
139
+ #
140
+ # d = Date.new(2001, 2, 3)
141
+ # s = d.jisx0301 # => "H13.02.03"
142
+ # Date._jisx0301(s) # => {:year=>2001, :mon=>2, :mday=>3}
176
143
  #
177
- # Raise an ArgumentError when the string length is longer than *limit*. You can
178
- # stop this check by passing `limit: nil`, but note that it may take a long time
179
- # to parse.
144
+ # See argument [limit](rdoc-ref:Date@Argument+limit).
145
+ #
146
+ # Related: Date.jisx0301 (returns a Date object).
180
147
  #
181
148
  def self._jisx0301: (String str) -> Hash[Symbol, Integer]
182
149
 
183
150
  # <!--
184
151
  # rdoc-file=ext/date/date_core.c
185
- # - Date._parse(string[, comp=true], limit: 128) -> hash
152
+ # - Date._parse(string, comp = true, limit: 128) -> hash
186
153
  # -->
187
- # Parses the given representation of date and time, and returns a hash of parsed
188
- # elements.
154
+ # **Note**: This method recognizes many forms in `string`, but it is not a
155
+ # validator. For formats, see ["Specialized Format Strings" in Formats for Dates
156
+ # and Times](rdoc-ref:strftime_formatting.rdoc@Specialized+Format+Strings)
157
+ #
158
+ # If `string` does not specify a valid date, the result is unpredictable;
159
+ # consider using Date._strptime instead.
189
160
  #
190
- # This method *does not* function as a validator. If the input string does not
191
- # match valid formats strictly, you may get a cryptic result. Should consider
192
- # to use `Date._strptime` or `DateTime._strptime` instead of this method as
193
- # possible.
161
+ # Returns a hash of values parsed from `string`:
194
162
  #
195
- # If the optional second argument is true and the detected year is in the range
196
- # "00" to "99", considers the year a 2-digit form and makes it full.
163
+ # Date._parse('2001-02-03') # => {:year=>2001, :mon=>2, :mday=>3}
197
164
  #
198
- # Date._parse('2001-02-03') #=> {:year=>2001, :mon=>2, :mday=>3}
165
+ # If `comp` is `true` and the given year is in the range `(0..99)`, the current
166
+ # century is supplied; otherwise, the year is taken as given:
199
167
  #
200
- # Raise an ArgumentError when the string length is longer than *limit*. You can
201
- # stop this check by passing `limit: nil`, but note that it may take a long time
202
- # to parse.
168
+ # Date._parse('01-02-03', true) # => {:year=>2001, :mon=>2, :mday=>3}
169
+ # Date._parse('01-02-03', false) # => {:year=>1, :mon=>2, :mday=>3}
170
+ #
171
+ # See argument [limit](rdoc-ref:Date@Argument+limit).
172
+ #
173
+ # Related: Date.parse(returns a Date object).
203
174
  #
204
175
  def self._parse: (String str, ?boolish complete) -> Hash[Symbol, Integer]
205
176
 
206
177
  # <!--
207
178
  # rdoc-file=ext/date/date_core.c
208
- # - Date._rfc2822(string, limit: 128) -> hash
209
- # - Date._rfc822(string, limit: 128) -> hash
179
+ # - Date._rfc2822(string, limit: 128) -> hash
210
180
  # -->
211
- # Returns a hash of parsed elements.
181
+ # Returns a hash of values parsed from `string`, which should be a valid [RFC
182
+ # 2822 date format](rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format):
183
+ #
184
+ # d = Date.new(2001, 2, 3)
185
+ # s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
186
+ # Date._rfc2822(s)
187
+ # # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"+0000", :offset=>0}
212
188
  #
213
- # Raise an ArgumentError when the string length is longer than *limit*. You can
214
- # stop this check by passing `limit: nil`, but note that it may take a long time
215
- # to parse.
189
+ # See argument [limit](rdoc-ref:Date@Argument+limit).
190
+ #
191
+ # Related: Date.rfc2822 (returns a Date object).
216
192
  #
217
193
  def self._rfc2822: (String str) -> Hash[Symbol, Integer | String]
218
194
 
219
195
  # <!--
220
196
  # rdoc-file=ext/date/date_core.c
221
- # - Date._rfc3339(string, limit: 128) -> hash
197
+ # - Date._rfc3339(string, limit: 128) -> hash
222
198
  # -->
223
- # Returns a hash of parsed elements.
199
+ # Returns a hash of values parsed from `string`, which should be a valid [RFC
200
+ # 3339 format](rdoc-ref:strftime_formatting.rdoc@RFC+3339+Format):
201
+ #
202
+ # d = Date.new(2001, 2, 3)
203
+ # s = d.rfc3339 # => "2001-02-03T00:00:00+00:00"
204
+ # Date._rfc3339(s)
205
+ # # => {:year=>2001, :mon=>2, :mday=>3, :hour=>0, :min=>0, :sec=>0, :zone=>"+00:00", :offset=>0}
224
206
  #
225
- # Raise an ArgumentError when the string length is longer than *limit*. You can
226
- # stop this check by passing `limit: nil`, but note that it may take a long time
227
- # to parse.
207
+ # See argument [limit](rdoc-ref:Date@Argument+limit).
208
+ #
209
+ # Related: Date.rfc3339 (returns a Date object).
228
210
  #
229
211
  def self._rfc3339: (String str) -> Hash[Symbol, Integer | String]
230
212
 
231
213
  # <!--
232
214
  # rdoc-file=ext/date/date_core.c
233
- # - Date._rfc2822(string, limit: 128) -> hash
234
- # - Date._rfc822(string, limit: 128) -> hash
215
+ # - Date._rfc2822(string, limit: 128) -> hash
235
216
  # -->
236
- # Returns a hash of parsed elements.
217
+ # Returns a hash of values parsed from `string`, which should be a valid [RFC
218
+ # 2822 date format](rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format):
219
+ #
220
+ # d = Date.new(2001, 2, 3)
221
+ # s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
222
+ # Date._rfc2822(s)
223
+ # # => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"+0000", :offset=>0}
224
+ #
225
+ # See argument [limit](rdoc-ref:Date@Argument+limit).
237
226
  #
238
- # Raise an ArgumentError when the string length is longer than *limit*. You can
239
- # stop this check by passing `limit: nil`, but note that it may take a long time
240
- # to parse.
227
+ # Related: Date.rfc2822 (returns a Date object).
241
228
  #
242
229
  def self._rfc822: (String str) -> Hash[Symbol, Integer | String]
243
230
 
244
231
  # <!--
245
232
  # rdoc-file=ext/date/date_core.c
246
- # - Date._strptime(string[, format='%F']) -> hash
233
+ # - Date._strptime(string, format = '%F') -> hash
247
234
  # -->
248
- # Parses the given representation of date and time with the given template, and
249
- # returns a hash of parsed elements. _strptime does not support specification
250
- # of flags and width unlike strftime.
235
+ # Returns a hash of values parsed from `string` according to the given `format`:
236
+ #
237
+ # Date._strptime('2001-02-03', '%Y-%m-%d') # => {:year=>2001, :mon=>2, :mday=>3}
238
+ #
239
+ # For other formats, see [Formats for Dates and
240
+ # Times](rdoc-ref:strftime_formatting.rdoc). (Unlike Date.strftime, does not
241
+ # support flags and width.)
251
242
  #
252
- # Date._strptime('2001-02-03', '%Y-%m-%d')
253
- # #=> {:year=>2001, :mon=>2, :mday=>3}
243
+ # See also [strptime(3)](https://man7.org/linux/man-pages/man3/strptime.3.html).
254
244
  #
255
- # See also strptime(3) and #strftime.
245
+ # Related: Date.strptime (returns a Date object).
256
246
  #
257
247
  def self._strptime: (String str, ?String format) -> Hash[Symbol, Integer]
258
248
 
259
249
  # <!--
260
250
  # rdoc-file=ext/date/date_core.c
261
- # - Date._xmlschema(string, limit: 128) -> hash
251
+ # - Date._xmlschema(string, limit: 128) -> hash
262
252
  # -->
263
- # Returns a hash of parsed elements.
253
+ # Returns a hash of values parsed from `string`, which should be a valid XML
254
+ # date format:
264
255
  #
265
- # Raise an ArgumentError when the string length is longer than *limit*. You can
266
- # stop this check by passing `limit: nil`, but note that it may take a long time
267
- # to parse.
256
+ # d = Date.new(2001, 2, 3)
257
+ # s = d.xmlschema # => "2001-02-03"
258
+ # Date._xmlschema(s) # => {:year=>2001, :mon=>2, :mday=>3}
259
+ #
260
+ # See argument [limit](rdoc-ref:Date@Argument+limit).
261
+ #
262
+ # Related: Date.xmlschema (returns a Date object).
268
263
  #
269
264
  def self._xmlschema: (String str) -> Hash[Symbol, Integer]
270
265
 
271
266
  # <!--
272
267
  # rdoc-file=ext/date/date_core.c
273
- # - Date.civil([year=-4712[, month=1[, mday=1[, start=Date::ITALY]]]]) -> date
274
- # - Date.new([year=-4712[, month=1[, mday=1[, start=Date::ITALY]]]]) -> date
268
+ # - civil(*args)
275
269
  # -->
276
- # Creates a date object denoting the given calendar date.
277
- #
278
- # In this class, BCE years are counted astronomically. Thus, the year before
279
- # the year 1 is the year zero, and the year preceding the year zero is the year
280
- # -1. The month and the day of month should be a negative or a positive number
281
- # (as a relative month/day from the end of year/month when negative). They
282
- # should not be zero.
283
- #
284
- # The last argument should be a Julian day number which denotes the day of
285
- # calendar reform. Date::ITALY (2299161=1582-10-15), Date::ENGLAND
286
- # (2361222=1752-09-14), Date::GREGORIAN (the proleptic Gregorian calendar) and
287
- # Date::JULIAN (the proleptic Julian calendar) can be specified as a day of
288
- # calendar reform.
289
- #
290
- # Date.new(2001) #=> #<Date: 2001-01-01 ...>
291
- # Date.new(2001,2,3) #=> #<Date: 2001-02-03 ...>
292
- # Date.new(2001,2,-1) #=> #<Date: 2001-02-28 ...>
293
- #
294
- # See also ::jd.
270
+ # Same as Date.new.
295
271
  #
296
272
  def self.civil: (?Integer year, ?Integer month, ?Integer mday, ?Integer start) -> Date
297
273
 
298
274
  # <!--
299
275
  # rdoc-file=ext/date/date_core.c
300
- # - Date.commercial([cwyear=-4712[, cweek=1[, cwday=1[, start=Date::ITALY]]]]) -> date
276
+ # - Date.commercial(cwyear = -4712, cweek = 1, cwday = 1, start = Date::ITALY) -> date
301
277
  # -->
302
- # Creates a date object denoting the given week date.
278
+ # Returns a new Date object constructed from the arguments.
279
+ #
280
+ # Argument `cwyear` gives the year, and should be an integer.
281
+ #
282
+ # Argument `cweek` gives the index of the week within the year, and should be in
283
+ # range (1..53) or (-53..-1); in some years, 53 or -53 will be out-of-range; if
284
+ # negative, counts backward from the end of the year:
285
+ #
286
+ # Date.commercial(2022, 1, 1).to_s # => "2022-01-03"
287
+ # Date.commercial(2022, 52, 1).to_s # => "2022-12-26"
288
+ #
289
+ # Argument `cwday` gives the indes of the weekday within the week, and should be
290
+ # in range (1..7) or (-7..-1); 1 or -7 is Monday; if negative, counts backward
291
+ # from the end of the week:
292
+ #
293
+ # Date.commercial(2022, 1, 1).to_s # => "2022-01-03"
294
+ # Date.commercial(2022, 1, -7).to_s # => "2022-01-03"
295
+ #
296
+ # When `cweek` is 1:
297
+ #
298
+ # * If January 1 is a Friday, Saturday, or Sunday, the first week begins in
299
+ # the week after:
300
+ #
301
+ # Date::ABBR_DAYNAMES[Date.new(2023, 1, 1).wday] # => "Sun"
302
+ # Date.commercial(2023, 1, 1).to_s # => "2023-01-02"
303
+ # Date.commercial(2023, 1, 7).to_s # => "2023-01-08"
303
304
  #
304
- # The week and the day of week should be a negative or a positive number (as a
305
- # relative week/day from the end of year/week when negative). They should not
306
- # be zero.
305
+ # * Otherwise, the first week is the week of January 1, which may mean some of
306
+ # the days fall on the year before:
307
307
  #
308
- # Date.commercial(2001) #=> #<Date: 2001-01-01 ...>
309
- # Date.commercial(2002) #=> #<Date: 2001-12-31 ...>
310
- # Date.commercial(2001,5,6) #=> #<Date: 2001-02-03 ...>
308
+ # Date::ABBR_DAYNAMES[Date.new(2020, 1, 1).wday] # => "Wed"
309
+ # Date.commercial(2020, 1, 1).to_s # => "2019-12-30"
310
+ # Date.commercial(2020, 1, 7).to_s # => "2020-01-05"
311
311
  #
312
- # See also ::jd and ::new.
312
+ # See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
313
+ #
314
+ # Related: Date.jd, Date.new, Date.ordinal.
313
315
  #
314
316
  def self.commercial: (?Integer cwyear, ?Integer cweek, ?Integer cwday, ?Integer start) -> Date
315
317
 
316
318
  # <!--
317
319
  # rdoc-file=ext/date/date_core.c
318
- # - Date.gregorian_leap?(year) -> bool
319
- # - Date.leap?(year) -> bool
320
+ # - Date.gregorian_leap?(year) -> true or false
320
321
  # -->
321
- # Returns true if the given year is a leap year of the proleptic Gregorian
322
- # calendar.
322
+ # Returns `true` if the given year is a leap year in the [proleptic Gregorian
323
+ # calendar](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar), `false`
324
+ # otherwise:
325
+ #
326
+ # Date.gregorian_leap?(2000) # => true
327
+ # Date.gregorian_leap?(2001) # => false
323
328
  #
324
- # Date.gregorian_leap?(1900) #=> false
325
- # Date.gregorian_leap?(2000) #=> true
329
+ # Related: Date.julian_leap?.
326
330
  #
327
331
  def self.gregorian_leap?: (Integer year) -> bool
328
332
 
329
333
  # <!--
330
334
  # rdoc-file=ext/date/date_core.c
331
- # - Date.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY], limit: 128) -> date
335
+ # - Date.httpdate(string = 'Mon, 01 Jan -4712 00:00:00 GMT', start = Date::ITALY, limit: 128) -> date
332
336
  # -->
333
- # Creates a new Date object by parsing from a string according to some RFC 2616
334
- # format.
337
+ # Returns a new Date object with values parsed from `string`, which should be a
338
+ # valid [HTTP date format](rdoc-ref:strftime_formatting.rdoc@HTTP+Format):
339
+ #
340
+ # d = Date.new(2001, 2, 3)
341
+ # s = d.httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
342
+ # Date.httpdate(s) # => #<Date: 2001-02-03>
335
343
  #
336
- # Date.httpdate('Sat, 03 Feb 2001 00:00:00 GMT')
337
- # #=> #<Date: 2001-02-03 ...>
344
+ # See:
338
345
  #
339
- # Raise an ArgumentError when the string length is longer than *limit*. You can
340
- # stop this check by passing `limit: nil`, but note that it may take a long time
341
- # to parse.
346
+ # * Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
347
+ # * Argument [limit](rdoc-ref:Date@Argument+limit).
348
+ #
349
+ # Related: Date._httpdate (returns a hash).
342
350
  #
343
351
  def self.httpdate: (String str, ?Integer start) -> Date
344
352
 
345
353
  # <!--
346
354
  # rdoc-file=ext/date/date_core.c
347
- # - Date.iso8601(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
355
+ # - Date.iso8601(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
348
356
  # -->
349
- # Creates a new Date object by parsing from a string according to some typical
350
- # ISO 8601 formats.
357
+ # Returns a new Date object with values parsed from `string`, which should
358
+ # contain an [ISO 8601 formatted
359
+ # date](rdoc-ref:strftime_formatting.rdoc@ISO+8601+Format+Specifications):
360
+ #
361
+ # d = Date.new(2001, 2, 3)
362
+ # s = d.iso8601 # => "2001-02-03"
363
+ # Date.iso8601(s) # => #<Date: 2001-02-03>
351
364
  #
352
- # Date.iso8601('2001-02-03') #=> #<Date: 2001-02-03 ...>
353
- # Date.iso8601('20010203') #=> #<Date: 2001-02-03 ...>
354
- # Date.iso8601('2001-W05-6') #=> #<Date: 2001-02-03 ...>
365
+ # See:
355
366
  #
356
- # Raise an ArgumentError when the string length is longer than *limit*. You can
357
- # stop this check by passing `limit: nil`, but note that it may take a long time
358
- # to parse.
367
+ # * Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
368
+ # * Argument [limit](rdoc-ref:Date@Argument+limit).
369
+ #
370
+ # Related: Date._iso8601 (returns a hash).
359
371
  #
360
372
  def self.iso8601: (String str, ?Integer start) -> Date
361
373
 
362
374
  # <!--
363
375
  # rdoc-file=ext/date/date_core.c
364
- # - Date.jd([jd=0[, start=Date::ITALY]]) -> date
376
+ # - Date.jd(jd = 0, start = Date::ITALY) -> date
365
377
  # -->
366
- # Creates a date object denoting the given chronological Julian day number.
378
+ # Returns a new Date object formed from the arguments:
379
+ #
380
+ # Date.jd(2451944).to_s # => "2001-02-03"
381
+ # Date.jd(2451945).to_s # => "2001-02-04"
382
+ # Date.jd(0).to_s # => "-4712-01-01"
383
+ #
384
+ # The returned date is:
385
+ #
386
+ # * Gregorian, if the argument is greater than or equal to `start`:
367
387
  #
368
- # Date.jd(2451944) #=> #<Date: 2001-02-03 ...>
369
- # Date.jd(2451945) #=> #<Date: 2001-02-04 ...>
370
- # Date.jd(0) #=> #<Date: -4712-01-01 ...>
388
+ # Date::ITALY # => 2299161
389
+ # Date.jd(Date::ITALY).gregorian? # => true
390
+ # Date.jd(Date::ITALY + 1).gregorian? # => true
371
391
  #
372
- # See also ::new.
392
+ # * Julian, otherwise
393
+ #
394
+ # Date.jd(Date::ITALY - 1).julian? # => true
395
+ #
396
+ # See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
397
+ #
398
+ # Related: Date.new.
373
399
  #
374
400
  def self.jd: (Integer jd, ?Integer start) -> Date
375
401
 
376
402
  # <!--
377
403
  # rdoc-file=ext/date/date_core.c
378
- # - Date.jisx0301(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
404
+ # - Date.jisx0301(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
379
405
  # -->
380
- # Creates a new Date object by parsing from a string according to some typical
381
- # JIS X 0301 formats.
406
+ # Returns a new Date object with values parsed from `string`, which should be a
407
+ # valid [JIS X 0301
408
+ # format](rdoc-ref:strftime_formatting.rdoc@JIS+X+0301+Format):
382
409
  #
383
- # Date.jisx0301('H13.02.03') #=> #<Date: 2001-02-03 ...>
410
+ # d = Date.new(2001, 2, 3)
411
+ # s = d.jisx0301 # => "H13.02.03"
412
+ # Date.jisx0301(s) # => #<Date: 2001-02-03>
384
413
  #
385
414
  # For no-era year, legacy format, Heisei is assumed.
386
415
  #
387
- # Date.jisx0301('13.02.03') #=> #<Date: 2001-02-03 ...>
416
+ # Date.jisx0301('13.02.03') # => #<Date: 2001-02-03>
417
+ #
418
+ # See:
419
+ #
420
+ # * Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
421
+ # * Argument [limit](rdoc-ref:Date@Argument+limit).
388
422
  #
389
- # Raise an ArgumentError when the string length is longer than *limit*. You can
390
- # stop this check by passing `limit: nil`, but note that it may take a long time
391
- # to parse.
423
+ # Related: Date._jisx0301 (returns a hash).
392
424
  #
393
425
  def self.jisx0301: (String str, ?Integer start) -> Date
394
426
 
395
427
  # <!--
396
428
  # rdoc-file=ext/date/date_core.c
397
- # - Date.julian_leap?(year) -> bool
429
+ # - Date.julian_leap?(year) -> true or false
398
430
  # -->
399
- # Returns true if the given year is a leap year of the proleptic Julian
400
- # calendar.
431
+ # Returns `true` if the given year is a leap year in the [proleptic Julian
432
+ # calendar](https://en.wikipedia.org/wiki/Proleptic_Julian_calendar), `false`
433
+ # otherwise:
401
434
  #
402
- # Date.julian_leap?(1900) #=> true
403
- # Date.julian_leap?(1901) #=> false
435
+ # Date.julian_leap?(1900) # => true
436
+ # Date.julian_leap?(1901) # => false
437
+ #
438
+ # Related: Date.gregorian_leap?.
404
439
  #
405
440
  def self.julian_leap?: (Integer year) -> bool
406
441
 
407
442
  # <!--
408
443
  # rdoc-file=ext/date/date_core.c
409
- # - Date.gregorian_leap?(year) -> bool
410
- # - Date.leap?(year) -> bool
444
+ # - Date.gregorian_leap?(year) -> true or false
411
445
  # -->
412
- # Returns true if the given year is a leap year of the proleptic Gregorian
413
- # calendar.
446
+ # Returns `true` if the given year is a leap year in the [proleptic Gregorian
447
+ # calendar](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar), `false`
448
+ # otherwise:
449
+ #
450
+ # Date.gregorian_leap?(2000) # => true
451
+ # Date.gregorian_leap?(2001) # => false
414
452
  #
415
- # Date.gregorian_leap?(1900) #=> false
416
- # Date.gregorian_leap?(2000) #=> true
453
+ # Related: Date.julian_leap?.
417
454
  #
418
455
  def self.leap?: (Integer year) -> bool
419
456
 
420
457
  # <!--
421
458
  # rdoc-file=ext/date/date_core.c
422
- # - Date.ordinal([year=-4712[, yday=1[, start=Date::ITALY]]]) -> date
459
+ # - Date.ordinal(year = -4712, yday = 1, start = Date::ITALY) -> date
423
460
  # -->
424
- # Creates a date object denoting the given ordinal date.
461
+ # Returns a new Date object formed fom the arguments.
462
+ #
463
+ # With no arguments, returns the date for January 1, -4712:
464
+ #
465
+ # Date.ordinal.to_s # => "-4712-01-01"
466
+ #
467
+ # With argument `year`, returns the date for January 1 of that year:
425
468
  #
426
- # The day of year should be a negative or a positive number (as a relative day
427
- # from the end of year when negative). It should not be zero.
469
+ # Date.ordinal(2001).to_s # => "2001-01-01"
470
+ # Date.ordinal(-2001).to_s # => "-2001-01-01"
428
471
  #
429
- # Date.ordinal(2001) #=> #<Date: 2001-01-01 ...>
430
- # Date.ordinal(2001,34) #=> #<Date: 2001-02-03 ...>
431
- # Date.ordinal(2001,-1) #=> #<Date: 2001-12-31 ...>
472
+ # With positive argument `yday` == `n`, returns the date for the `nth` day of
473
+ # the given year:
432
474
  #
433
- # See also ::jd and ::new.
475
+ # Date.ordinal(2001, 14).to_s # => "2001-01-14"
476
+ #
477
+ # With negative argument `yday`, counts backward from the end of the year:
478
+ #
479
+ # Date.ordinal(2001, -14).to_s # => "2001-12-18"
480
+ #
481
+ # Raises an exception if `yday` is zero or out of range.
482
+ #
483
+ # See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
484
+ #
485
+ # Related: Date.jd, Date.new.
434
486
  #
435
487
  def self.ordinal: (?Integer year, ?Integer yday, ?Integer start) -> Date
436
488
 
437
489
  # <!--
438
490
  # rdoc-file=ext/date/date_core.c
439
- # - Date.parse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]], limit: 128) -> date
491
+ # - Date.parse(string = '-4712-01-01', comp = true, start = Date::ITALY, limit: 128) -> date
440
492
  # -->
441
- # Parses the given representation of date and time, and creates a date object.
493
+ # **Note**: This method recognizes many forms in `string`, but it is not a
494
+ # validator. For formats, see ["Specialized Format Strings" in Formats for Dates
495
+ # and Times](rdoc-ref:strftime_formatting.rdoc@Specialized+Format+Strings) If
496
+ # `string` does not specify a valid date, the result is unpredictable; consider
497
+ # using Date._strptime instead.
442
498
  #
443
- # This method *does not* function as a validator. If the input string does not
444
- # match valid formats strictly, you may get a cryptic result. Should consider
445
- # to use `Date.strptime` instead of this method as possible.
499
+ # Returns a new Date object with values parsed from `string`:
446
500
  #
447
- # If the optional second argument is true and the detected year is in the range
448
- # "00" to "99", considers the year a 2-digit form and makes it full.
501
+ # Date.parse('2001-02-03') # => #<Date: 2001-02-03>
502
+ # Date.parse('20010203') # => #<Date: 2001-02-03>
503
+ # Date.parse('3rd Feb 2001') # => #<Date: 2001-02-03>
449
504
  #
450
- # Date.parse('2001-02-03') #=> #<Date: 2001-02-03 ...>
451
- # Date.parse('20010203') #=> #<Date: 2001-02-03 ...>
452
- # Date.parse('3rd Feb 2001') #=> #<Date: 2001-02-03 ...>
505
+ # If `comp` is `true` and the given year is in the range `(0..99)`, the current
506
+ # century is supplied; otherwise, the year is taken as given:
453
507
  #
454
- # Raise an ArgumentError when the string length is longer than *limit*. You can
455
- # stop this check by passing `limit: nil`, but note that it may take a long time
456
- # to parse.
508
+ # Date.parse('01-02-03', true) # => #<Date: 2001-02-03>
509
+ # Date.parse('01-02-03', false) # => #<Date: 0001-02-03>
457
510
  #
458
- def self.parse: (String str, ?boolish complete, ?Integer start) -> Date
511
+ # See:
512
+ #
513
+ # * Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
514
+ # * Argument [limit](rdoc-ref:Date@Argument+limit).
515
+ #
516
+ # Related: Date._parse (returns a hash).
517
+ #
518
+ def self.parse: (?String str, ?boolish complete, ?Integer start) -> Date
459
519
 
460
520
  # <!--
461
521
  # rdoc-file=ext/date/date_core.c
462
- # - Date.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> date
463
- # - Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> date
522
+ # - Date.rfc2822(string = 'Mon, 1 Jan -4712 00:00:00 +0000', start = Date::ITALY, limit: 128) -> date
464
523
  # -->
465
- # Creates a new Date object by parsing from a string according to some typical
466
- # RFC 2822 formats.
524
+ # Returns a new Date object with values parsed from `string`, which should be a
525
+ # valid [RFC 2822 date
526
+ # format](rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format):
527
+ #
528
+ # d = Date.new(2001, 2, 3)
529
+ # s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
530
+ # Date.rfc2822(s) # => #<Date: 2001-02-03>
467
531
  #
468
- # Date.rfc2822('Sat, 3 Feb 2001 00:00:00 +0000')
469
- # #=> #<Date: 2001-02-03 ...>
532
+ # See:
470
533
  #
471
- # Raise an ArgumentError when the string length is longer than *limit*. You can
472
- # stop this check by passing `limit: nil`, but note that it may take a long time
473
- # to parse.
534
+ # * Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
535
+ # * Argument [limit](rdoc-ref:Date@Argument+limit).
536
+ #
537
+ # Related: Date._rfc2822 (returns a hash).
474
538
  #
475
539
  def self.rfc2822: (String str, ?Integer start) -> Date
476
540
 
477
541
  # <!--
478
542
  # rdoc-file=ext/date/date_core.c
479
- # - Date.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> date
543
+ # - Date.rfc3339(string = '-4712-01-01T00:00:00+00:00', start = Date::ITALY, limit: 128) -> date
480
544
  # -->
481
- # Creates a new Date object by parsing from a string according to some typical
482
- # RFC 3339 formats.
545
+ # Returns a new Date object with values parsed from `string`, which should be a
546
+ # valid [RFC 3339 format](rdoc-ref:strftime_formatting.rdoc@RFC+3339+Format):
547
+ #
548
+ # d = Date.new(2001, 2, 3)
549
+ # s = d.rfc3339 # => "2001-02-03T00:00:00+00:00"
550
+ # Date.rfc3339(s) # => #<Date: 2001-02-03>
551
+ #
552
+ # See:
483
553
  #
484
- # Date.rfc3339('2001-02-03T04:05:06+07:00') #=> #<Date: 2001-02-03 ...>
554
+ # * Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
555
+ # * Argument [limit](rdoc-ref:Date@Argument+limit).
485
556
  #
486
- # Raise an ArgumentError when the string length is longer than *limit*. You can
487
- # stop this check by passing `limit: nil`, but note that it may take a long time
488
- # to parse.
557
+ # Related: Date._rfc3339 (returns a hash).
489
558
  #
490
559
  def self.rfc3339: (String str, ?Integer start) -> Date
491
560
 
492
561
  # <!--
493
562
  # rdoc-file=ext/date/date_core.c
494
- # - Date.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> date
495
- # - Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> date
563
+ # - Date.rfc2822(string = 'Mon, 1 Jan -4712 00:00:00 +0000', start = Date::ITALY, limit: 128) -> date
496
564
  # -->
497
- # Creates a new Date object by parsing from a string according to some typical
498
- # RFC 2822 formats.
565
+ # Returns a new Date object with values parsed from `string`, which should be a
566
+ # valid [RFC 2822 date
567
+ # format](rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format):
568
+ #
569
+ # d = Date.new(2001, 2, 3)
570
+ # s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
571
+ # Date.rfc2822(s) # => #<Date: 2001-02-03>
572
+ #
573
+ # See:
499
574
  #
500
- # Date.rfc2822('Sat, 3 Feb 2001 00:00:00 +0000')
501
- # #=> #<Date: 2001-02-03 ...>
575
+ # * Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
576
+ # * Argument [limit](rdoc-ref:Date@Argument+limit).
502
577
  #
503
- # Raise an ArgumentError when the string length is longer than *limit*. You can
504
- # stop this check by passing `limit: nil`, but note that it may take a long time
505
- # to parse.
578
+ # Related: Date._rfc2822 (returns a hash).
506
579
  #
507
580
  def self.rfc822: (String str, ?Integer start) -> Date
508
581
 
509
582
  # <!--
510
583
  # rdoc-file=ext/date/date_core.c
511
- # - Date.strptime([string='-4712-01-01'[, format='%F'[, start=Date::ITALY]]]) -> date
584
+ # - Date.strptime(string = '-4712-01-01', format = '%F', start = Date::ITALY) -> date
512
585
  # -->
513
- # Parses the given representation of date and time with the given template, and
514
- # creates a date object. strptime does not support specification of flags and
515
- # width unlike strftime.
586
+ # Returns a new Date object with values parsed from `string`, according to the
587
+ # given `format`:
516
588
  #
517
- # Date.strptime('2001-02-03', '%Y-%m-%d') #=> #<Date: 2001-02-03 ...>
518
- # Date.strptime('03-02-2001', '%d-%m-%Y') #=> #<Date: 2001-02-03 ...>
519
- # Date.strptime('2001-034', '%Y-%j') #=> #<Date: 2001-02-03 ...>
520
- # Date.strptime('2001-W05-6', '%G-W%V-%u') #=> #<Date: 2001-02-03 ...>
521
- # Date.strptime('2001 04 6', '%Y %U %w') #=> #<Date: 2001-02-03 ...>
522
- # Date.strptime('2001 05 6', '%Y %W %u') #=> #<Date: 2001-02-03 ...>
523
- # Date.strptime('sat3feb01', '%a%d%b%y') #=> #<Date: 2001-02-03 ...>
589
+ # Date.strptime('2001-02-03', '%Y-%m-%d') # => #<Date: 2001-02-03>
590
+ # Date.strptime('03-02-2001', '%d-%m-%Y') # => #<Date: 2001-02-03>
591
+ # Date.strptime('2001-034', '%Y-%j') # => #<Date: 2001-02-03>
592
+ # Date.strptime('2001-W05-6', '%G-W%V-%u') # => #<Date: 2001-02-03>
593
+ # Date.strptime('2001 04 6', '%Y %U %w') # => #<Date: 2001-02-03>
594
+ # Date.strptime('2001 05 6', '%Y %W %u') # => #<Date: 2001-02-03>
595
+ # Date.strptime('sat3feb01', '%a%d%b%y') # => #<Date: 2001-02-03>
524
596
  #
525
- # See also strptime(3) and #strftime.
597
+ # For other formats, see [Formats for Dates and
598
+ # Times](rdoc-ref:strftime_formatting.rdoc). (Unlike Date.strftime, does not
599
+ # support flags and width.)
600
+ #
601
+ # See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
602
+ #
603
+ # See also [strptime(3)](https://man7.org/linux/man-pages/man3/strptime.3.html).
604
+ #
605
+ # Related: Date._strptime (returns a hash).
526
606
  #
527
607
  def self.strptime: (String str, ?String format, ?Integer start) -> Date
528
608
 
529
609
  # <!--
530
610
  # rdoc-file=ext/date/date_core.c
531
- # - Date.today([start=Date::ITALY]) -> date
611
+ # - Date.today(start = Date::ITALY) -> date
532
612
  # -->
533
- # Creates a date object denoting the present day.
613
+ # Returns a new Date object constructed from the present date:
534
614
  #
535
- # Date.today #=> #<Date: 2011-06-11 ...>
615
+ # Date.today.to_s # => "2022-07-06"
616
+ #
617
+ # See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
536
618
  #
537
619
  def self.today: (?Integer start) -> Date
538
620
 
539
621
  # <!--
540
622
  # rdoc-file=ext/date/date_core.c
541
- # - Date.valid_civil?(year, month, mday[, start=Date::ITALY]) -> bool
542
- # - Date.valid_date?(year, month, mday[, start=Date::ITALY]) -> bool
623
+ # - Date.valid_civil?(year, month, mday, start = Date::ITALY) -> true or false
543
624
  # -->
544
- # Returns true if the given calendar date is valid, and false if not. Valid in
545
- # this context is whether the arguments passed to this method would be accepted
546
- # by ::new.
625
+ # Returns `true` if the arguments define a valid ordinal date, `false`
626
+ # otherwise:
627
+ #
628
+ # Date.valid_date?(2001, 2, 3) # => true
629
+ # Date.valid_date?(2001, 2, 29) # => false
630
+ # Date.valid_date?(2001, 2, -1) # => true
547
631
  #
548
- # Date.valid_date?(2001,2,3) #=> true
549
- # Date.valid_date?(2001,2,29) #=> false
550
- # Date.valid_date?(2001,2,-1) #=> true
632
+ # See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
551
633
  #
552
- # See also ::jd and ::civil.
634
+ # Related: Date.jd, Date.new.
553
635
  #
554
636
  def self.valid_civil?: (Integer year, Integer month, Integer mday, ?Integer start) -> bool
555
637
 
556
638
  # <!--
557
639
  # rdoc-file=ext/date/date_core.c
558
- # - Date.valid_commercial?(cwyear, cweek, cwday[, start=Date::ITALY]) -> bool
640
+ # - Date.valid_commercial?(cwyear, cweek, cwday, start = Date::ITALY) -> true or false
559
641
  # -->
560
- # Returns true if the given week date is valid, and false if not.
642
+ # Returns `true` if the arguments define a valid commercial date, `false`
643
+ # otherwise:
561
644
  #
562
- # Date.valid_commercial?(2001,5,6) #=> true
563
- # Date.valid_commercial?(2001,5,8) #=> false
645
+ # Date.valid_commercial?(2001, 5, 6) # => true
646
+ # Date.valid_commercial?(2001, 5, 8) # => false
564
647
  #
565
- # See also ::jd and ::commercial.
648
+ # See Date.commercial.
649
+ #
650
+ # See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
651
+ #
652
+ # Related: Date.jd, Date.commercial.
566
653
  #
567
654
  def self.valid_commercial?: (Integer cwyear, Integer cweek, Integer cwday, ?Integer start) -> bool
568
655
 
569
656
  # <!--
570
657
  # rdoc-file=ext/date/date_core.c
571
- # - Date.valid_civil?(year, month, mday[, start=Date::ITALY]) -> bool
572
- # - Date.valid_date?(year, month, mday[, start=Date::ITALY]) -> bool
658
+ # - Date.valid_civil?(year, month, mday, start = Date::ITALY) -> true or false
573
659
  # -->
574
- # Returns true if the given calendar date is valid, and false if not. Valid in
575
- # this context is whether the arguments passed to this method would be accepted
576
- # by ::new.
660
+ # Returns `true` if the arguments define a valid ordinal date, `false`
661
+ # otherwise:
662
+ #
663
+ # Date.valid_date?(2001, 2, 3) # => true
664
+ # Date.valid_date?(2001, 2, 29) # => false
665
+ # Date.valid_date?(2001, 2, -1) # => true
577
666
  #
578
- # Date.valid_date?(2001,2,3) #=> true
579
- # Date.valid_date?(2001,2,29) #=> false
580
- # Date.valid_date?(2001,2,-1) #=> true
667
+ # See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
581
668
  #
582
- # See also ::jd and ::civil.
669
+ # Related: Date.jd, Date.new.
583
670
  #
584
671
  def self.valid_date?: (Integer year, Integer month, Integer mday, ?Integer start) -> bool
585
672
 
586
673
  # <!--
587
674
  # rdoc-file=ext/date/date_core.c
588
- # - Date.valid_jd?(jd[, start=Date::ITALY]) -> bool
675
+ # - Date.valid_jd?(jd, start = Date::ITALY) -> true
589
676
  # -->
590
- # Just returns true. It's nonsense, but is for symmetry.
677
+ # Implemented for compatibility; returns `true` unless `jd` is invalid (i.e.,
678
+ # not a Numeric).
591
679
  #
592
- # Date.valid_jd?(2451944) #=> true
680
+ # Date.valid_jd?(2451944) # => true
593
681
  #
594
- # See also ::jd.
682
+ # See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
683
+ #
684
+ # Related: Date.jd.
595
685
  #
596
686
  def self.valid_jd?: (Integer jd, ?Integer start) -> bool
597
687
 
598
688
  # <!--
599
689
  # rdoc-file=ext/date/date_core.c
600
- # - Date.valid_ordinal?(year, yday[, start=Date::ITALY]) -> bool
690
+ # - Date.valid_ordinal?(year, yday, start = Date::ITALY) -> true or false
601
691
  # -->
602
- # Returns true if the given ordinal date is valid, and false if not.
692
+ # Returns `true` if the arguments define a valid ordinal date, `false`
693
+ # otherwise:
694
+ #
695
+ # Date.valid_ordinal?(2001, 34) # => true
696
+ # Date.valid_ordinal?(2001, 366) # => false
603
697
  #
604
- # Date.valid_ordinal?(2001,34) #=> true
605
- # Date.valid_ordinal?(2001,366) #=> false
698
+ # See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
606
699
  #
607
- # See also ::jd and ::ordinal.
700
+ # Related: Date.jd, Date.ordinal.
608
701
  #
609
702
  def self.valid_ordinal?: (Integer year, Integer yday, ?Integer start) -> bool
610
703
 
611
704
  # <!--
612
705
  # rdoc-file=ext/date/date_core.c
613
- # - Date.xmlschema(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
706
+ # - Date.xmlschema(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
614
707
  # -->
615
- # Creates a new Date object by parsing from a string according to some typical
616
- # XML Schema formats.
708
+ # Returns a new Date object with values parsed from `string`, which should be a
709
+ # valid XML date format:
617
710
  #
618
- # Date.xmlschema('2001-02-03') #=> #<Date: 2001-02-03 ...>
711
+ # d = Date.new(2001, 2, 3)
712
+ # s = d.xmlschema # => "2001-02-03"
713
+ # Date.xmlschema(s) # => #<Date: 2001-02-03>
619
714
  #
620
- # Raise an ArgumentError when the string length is longer than *limit*. You can
621
- # stop this check by passing `limit: nil`, but note that it may take a long time
622
- # to parse.
715
+ # See:
716
+ #
717
+ # * Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
718
+ # * Argument [limit](rdoc-ref:Date@Argument+limit).
719
+ #
720
+ # Related: Date._xmlschema (returns a hash).
623
721
  #
624
722
  def self.xmlschema: (String str, ?Integer start) -> Date
625
723
 
626
- public
627
-
628
724
  # <!--
629
725
  # rdoc-file=ext/date/date_core.c
630
726
  # - d + other -> date
@@ -647,10 +743,10 @@ class Date
647
743
  # rdoc-file=ext/date/date_core.c
648
744
  # - d - other -> date or rational
649
745
  # -->
650
- # Returns the difference between the two dates if the other is a date object.
651
- # If the other is a numeric value, returns a date object pointing `other` days
652
- # before self. If the other is a fractional number, assumes its precision is at
653
- # most nanosecond.
746
+ # If the other is a date object, returns a Rational whose value is the
747
+ # difference between the two dates in days. If the other is a numeric value,
748
+ # returns a date object pointing `other` days before self. If the other is a
749
+ # fractional number, assumes its precision is at most nanosecond.
654
750
  #
655
751
  # Date.new(2001,2,3) - 1 #=> #<Date: 2001-02-02 ...>
656
752
  # DateTime.new(2001,2,3) - Rational(1,2)
@@ -667,85 +763,133 @@ class Date
667
763
  # rdoc-file=ext/date/date_core.c
668
764
  # - d << n -> date
669
765
  # -->
670
- # Returns a date object pointing `n` months before self. The argument `n` should
671
- # be a numeric value.
766
+ # Returns a new Date object representing the date `n` months earlier; `n` should
767
+ # be a numeric:
672
768
  #
673
- # Date.new(2001,2,3) << 1 #=> #<Date: 2001-01-03 ...>
674
- # Date.new(2001,2,3) << -2 #=> #<Date: 2001-04-03 ...>
769
+ # (Date.new(2001, 2, 3) << 1).to_s # => "2001-01-03"
770
+ # (Date.new(2001, 2, 3) << -2).to_s # => "2001-04-03"
675
771
  #
676
- # When the same day does not exist for the corresponding month, the last day of
677
- # the month is used instead:
772
+ # When the same day does not exist for the new month, the last day of that month
773
+ # is used instead:
678
774
  #
679
- # Date.new(2001,3,28) << 1 #=> #<Date: 2001-02-28 ...>
680
- # Date.new(2001,3,31) << 1 #=> #<Date: 2001-02-28 ...>
775
+ # (Date.new(2001, 3, 31) << 1).to_s # => "2001-02-28"
776
+ # (Date.new(2001, 3, 31) << -6).to_s # => "2001-09-30"
681
777
  #
682
- # This also results in the following, possibly unexpected, behavior:
778
+ # This results in the following, possibly unexpected, behaviors:
683
779
  #
684
- # Date.new(2001,3,31) << 2 #=> #<Date: 2001-01-31 ...>
685
- # Date.new(2001,3,31) << 1 << 1 #=> #<Date: 2001-01-28 ...>
780
+ # d0 = Date.new(2001, 3, 31)
781
+ # d0 << 2 # => #<Date: 2001-01-31>
782
+ # d0 << 1 << 1 # => #<Date: 2001-01-28>
686
783
  #
687
- # Date.new(2001,3,31) << 1 << -1 #=> #<Date: 2001-03-28 ...>
784
+ # d0 = Date.new(2001, 3, 31)
785
+ # d1 = d0 << 1 # => #<Date: 2001-02-28>
786
+ # d2 = d1 << -1 # => #<Date: 2001-03-28>
688
787
  #
689
788
  def <<: (Integer month) -> Date
690
789
 
691
790
  # <!--
692
791
  # rdoc-file=ext/date/date_core.c
693
- # - d <=> other -> -1, 0, +1 or nil
792
+ # - self <=> other -> -1, 0, 1 or nil
694
793
  # -->
695
- # Compares the two dates and returns -1, zero, 1 or nil. The other should be a
696
- # date object or a numeric value as an astronomical Julian day number.
794
+ # Compares `self` and `other`, returning:
795
+ #
796
+ # * `-1` if `other` is larger.
797
+ # * `0` if the two are equal.
798
+ # * `1` if `other` is smaller.
799
+ # * `nil` if the two are incomparable.
800
+ #
801
+ # Argument `other` may be:
697
802
  #
698
- # Date.new(2001,2,3) <=> Date.new(2001,2,4) #=> -1
699
- # Date.new(2001,2,3) <=> Date.new(2001,2,3) #=> 0
700
- # Date.new(2001,2,3) <=> Date.new(2001,2,2) #=> 1
701
- # Date.new(2001,2,3) <=> Object.new #=> nil
702
- # Date.new(2001,2,3) <=> Rational(4903887,2) #=> 0
803
+ # * Another Date object:
703
804
  #
704
- # See also Comparable.
805
+ # d = Date.new(2022, 7, 27) # => #<Date: 2022-07-27 ((2459788j,0s,0n),+0s,2299161j)>
806
+ # prev_date = d.prev_day # => #<Date: 2022-07-26 ((2459787j,0s,0n),+0s,2299161j)>
807
+ # next_date = d.next_day # => #<Date: 2022-07-28 ((2459789j,0s,0n),+0s,2299161j)>
808
+ # d <=> next_date # => -1
809
+ # d <=> d # => 0
810
+ # d <=> prev_date # => 1
811
+ #
812
+ # * A DateTime object:
813
+ #
814
+ # d <=> DateTime.new(2022, 7, 26) # => 1
815
+ # d <=> DateTime.new(2022, 7, 27) # => 0
816
+ # d <=> DateTime.new(2022, 7, 28) # => -1
817
+ #
818
+ # * A numeric (compares `self.ajd` to `other`):
819
+ #
820
+ # d <=> 2459788 # => -1
821
+ # d <=> 2459787 # => 1
822
+ # d <=> 2459786 # => 1
823
+ # d <=> d.ajd # => 0
824
+ #
825
+ # * Any other object:
826
+ #
827
+ # d <=> Object.new # => nil
705
828
  #
706
829
  def <=>: (untyped other) -> Integer?
707
830
 
708
831
  # <!--
709
832
  # rdoc-file=ext/date/date_core.c
710
- # - d === other -> bool
833
+ # - self === other -> true, false, or nil.
711
834
  # -->
712
- # Returns true if they are the same day.
835
+ # Returns `true` if `self` and `other` represent the same date, `false` if not,
836
+ # `nil` if the two are not comparable.
837
+ #
838
+ # Argument `other` may be:
839
+ #
840
+ # * Another Date object:
841
+ #
842
+ # d = Date.new(2022, 7, 27) # => #<Date: 2022-07-27 ((2459788j,0s,0n),+0s,2299161j)>
843
+ # prev_date = d.prev_day # => #<Date: 2022-07-26 ((2459787j,0s,0n),+0s,2299161j)>
844
+ # next_date = d.next_day # => #<Date: 2022-07-28 ((2459789j,0s,0n),+0s,2299161j)>
845
+ # d === prev_date # => false
846
+ # d === d # => true
847
+ # d === next_date # => false
848
+ #
849
+ # * A DateTime object:
713
850
  #
714
- # Date.new(2001,2,3) === Date.new(2001,2,3)
715
- # #=> true
716
- # Date.new(2001,2,3) === Date.new(2001,2,4)
717
- # #=> false
718
- # DateTime.new(2001,2,3) === DateTime.new(2001,2,3,12)
719
- # #=> true
720
- # DateTime.new(2001,2,3) === DateTime.new(2001,2,3,0,0,0,'+24:00')
721
- # #=> true
722
- # DateTime.new(2001,2,3) === DateTime.new(2001,2,4,0,0,0,'+24:00')
723
- # #=> false
851
+ # d === DateTime.new(2022, 7, 26) # => false
852
+ # d === DateTime.new(2022, 7, 27) # => true
853
+ # d === DateTime.new(2022, 7, 28) # => false
854
+ #
855
+ # * A numeric (compares `self.jd` to `other`):
856
+ #
857
+ # d === 2459788 # => true
858
+ # d === 2459787 # => false
859
+ # d === 2459786 # => false
860
+ # d === d.jd # => true
861
+ #
862
+ # * An object not comparable:
863
+ #
864
+ # d === Object.new # => nil
724
865
  #
725
866
  def ===: (Date other) -> bool
726
867
 
727
868
  # <!--
728
869
  # rdoc-file=ext/date/date_core.c
729
- # - d >> n -> date
870
+ # - d >> n -> new_date
730
871
  # -->
731
- # Returns a date object pointing `n` months after self. The argument `n` should
732
- # be a numeric value.
872
+ # Returns a new Date object representing the date `n` months later; `n` should
873
+ # be a numeric:
733
874
  #
734
- # Date.new(2001,2,3) >> 1 #=> #<Date: 2001-03-03 ...>
735
- # Date.new(2001,2,3) >> -2 #=> #<Date: 2000-12-03 ...>
875
+ # (Date.new(2001, 2, 3) >> 1).to_s # => "2001-03-03"
876
+ # (Date.new(2001, 2, 3) >> -2).to_s # => "2000-12-03"
736
877
  #
737
- # When the same day does not exist for the corresponding month, the last day of
738
- # the month is used instead:
878
+ # When the same day does not exist for the new month, the last day of that month
879
+ # is used instead:
739
880
  #
740
- # Date.new(2001,1,28) >> 1 #=> #<Date: 2001-02-28 ...>
741
- # Date.new(2001,1,31) >> 1 #=> #<Date: 2001-02-28 ...>
881
+ # (Date.new(2001, 1, 31) >> 1).to_s # => "2001-02-28"
882
+ # (Date.new(2001, 1, 31) >> -4).to_s # => "2000-09-30"
742
883
  #
743
- # This also results in the following, possibly unexpected, behavior:
884
+ # This results in the following, possibly unexpected, behaviors:
744
885
  #
745
- # Date.new(2001,1,31) >> 2 #=> #<Date: 2001-03-31 ...>
746
- # Date.new(2001,1,31) >> 1 >> 1 #=> #<Date: 2001-03-28 ...>
886
+ # d0 = Date.new(2001, 1, 31)
887
+ # d1 = d0 >> 1 # => #<Date: 2001-02-28>
888
+ # d2 = d1 >> 1 # => #<Date: 2001-03-28>
747
889
  #
748
- # Date.new(2001,1,31) >> 1 >> -1 #=> #<Date: 2001-01-28 ...>
890
+ # d0 = Date.new(2001, 1, 31)
891
+ # d1 = d0 >> 1 # => #<Date: 2001-02-28>
892
+ # d2 = d1 >> -1 # => #<Date: 2001-01-28>
749
893
  #
750
894
  def >>: (Integer month) -> Date
751
895
 
@@ -775,143 +919,186 @@ class Date
775
919
 
776
920
  # <!--
777
921
  # rdoc-file=ext/date/date_core.c
778
- # - d.asctime -> string
779
- # - d.ctime -> string
922
+ # - asctime -> string
780
923
  # -->
781
- # Returns a string in asctime(3) format (but without "n\0" at the end). This
782
- # method is equivalent to strftime('%c').
924
+ # Equivalent to #strftime with argument `'%a %b %e %T %Y'` (or its [shorthand
925
+ # form](rdoc-ref:strftime_formatting.rdoc@Shorthand+Conversion+Specifiers)
926
+ # `'%c'`):
927
+ #
928
+ # Date.new(2001, 2, 3).asctime # => "Sat Feb 3 00:00:00 2001"
783
929
  #
784
- # See also asctime(3) or ctime(3).
930
+ # See [asctime](https://linux.die.net/man/3/asctime).
785
931
  #
786
932
  def asctime: () -> String
787
933
 
788
934
  # <!-- rdoc-file=ext/date/date_core.c -->
789
- # Returns a string in asctime(3) format (but without "n\0" at the end). This
790
- # method is equivalent to strftime('%c').
935
+ # Equivalent to #strftime with argument `'%a %b %e %T %Y'` (or its [shorthand
936
+ # form](rdoc-ref:strftime_formatting.rdoc@Shorthand+Conversion+Specifiers)
937
+ # `'%c'`):
791
938
  #
792
- # See also asctime(3) or ctime(3).
939
+ # Date.new(2001, 2, 3).asctime # => "Sat Feb 3 00:00:00 2001"
940
+ #
941
+ # See [asctime](https://linux.die.net/man/3/asctime).
793
942
  #
794
943
  def ctime: () -> String
795
944
 
796
945
  # <!--
797
946
  # rdoc-file=ext/date/date_core.c
798
- # - d.cwday -> fixnum
947
+ # - cwday -> integer
799
948
  # -->
800
- # Returns the day of calendar week (1-7, Monday is 1).
949
+ # Returns the commercial-date weekday index for `self` (see Date.commercial); 1
950
+ # is Monday:
801
951
  #
802
- # Date.new(2001,2,3).cwday #=> 6
952
+ # Date.new(2001, 2, 3).cwday # => 6
803
953
  #
804
954
  def cwday: () -> Integer
805
955
 
806
956
  # <!--
807
957
  # rdoc-file=ext/date/date_core.c
808
- # - d.cweek -> fixnum
958
+ # - cweek -> integer
809
959
  # -->
810
- # Returns the calendar week number (1-53).
960
+ # Returns commercial-date week index for `self` (see Date.commercial):
811
961
  #
812
- # Date.new(2001,2,3).cweek #=> 5
962
+ # Date.new(2001, 2, 3).cweek # => 5
813
963
  #
814
964
  def cweek: () -> Integer
815
965
 
816
966
  # <!--
817
967
  # rdoc-file=ext/date/date_core.c
818
- # - d.cwyear -> integer
968
+ # - cwyear -> integer
819
969
  # -->
820
- # Returns the calendar week based year.
970
+ # Returns commercial-date year for `self` (see Date.commercial):
821
971
  #
822
- # Date.new(2001,2,3).cwyear #=> 2001
823
- # Date.new(2000,1,1).cwyear #=> 1999
972
+ # Date.new(2001, 2, 3).cwyear # => 2001
973
+ # Date.new(2000, 1, 1).cwyear # => 1999
824
974
  #
825
975
  def cwyear: () -> Integer
826
976
 
827
977
  # <!-- rdoc-file=ext/date/date_core.c -->
828
- # Returns the day of the month (1-31).
978
+ # Returns the day of the month in range (1..31):
829
979
  #
830
- # Date.new(2001,2,3).mday #=> 3
980
+ # Date.new(2001, 2, 3).mday # => 3
831
981
  #
832
982
  def day: () -> Integer
833
983
 
834
984
  # <!--
835
985
  # rdoc-file=ext/date/date_core.c
836
- # - d.downto(min) -> enumerator
837
- # - d.downto(min){|date| ...} -> self
986
+ # - deconstruct_keys(array_of_names_or_nil) -> hash
838
987
  # -->
839
- # This method is equivalent to step(min, -1){|date| ...}.
988
+ # Returns a hash of the name/value pairs, to use in pattern matching. Possible
989
+ # keys are: `:year`, `:month`, `:day`, `:wday`, `:yday`.
990
+ #
991
+ # Possible usages:
992
+ #
993
+ # d = Date.new(2022, 10, 5)
994
+ #
995
+ # if d in wday: 3, day: ..7 # uses deconstruct_keys underneath
996
+ # puts "first Wednesday of the month"
997
+ # end
998
+ # #=> prints "first Wednesday of the month"
999
+ #
1000
+ # case d
1001
+ # in year: ...2022
1002
+ # puts "too old"
1003
+ # in month: ..9
1004
+ # puts "quarter 1-3"
1005
+ # in wday: 1..5, month:
1006
+ # puts "working day in month #{month}"
1007
+ # end
1008
+ # #=> prints "working day in month 10"
1009
+ #
1010
+ # Note that deconstruction by pattern can also be combined with class check:
1011
+ #
1012
+ # if d in Date(wday: 3, day: ..7)
1013
+ # puts "first Wednesday of the month"
1014
+ # end
1015
+ #
1016
+ def deconstruct_keys: (Array[Symbol]?) -> Hash[Symbol, Integer]
1017
+
1018
+ # <!--
1019
+ # rdoc-file=ext/date/date_core.c
1020
+ # - downto(min){|date| ... } -> self
1021
+ # -->
1022
+ # Equivalent to #step with arguments `min` and `-1`.
840
1023
  #
841
1024
  def downto: (Date min) { (Date) -> untyped } -> Date
842
1025
  | (Date min) -> Enumerator[Date, Date]
843
1026
 
844
1027
  # <!--
845
1028
  # rdoc-file=ext/date/date_core.c
846
- # - d.england -> date
1029
+ # - england -> new_date
847
1030
  # -->
848
- # This method is equivalent to new_start(Date::ENGLAND).
1031
+ # Equivalent to Date#new_start with argument Date::ENGLAND.
849
1032
  #
850
1033
  def england: () -> Date
851
1034
 
852
1035
  # <!--
853
1036
  # rdoc-file=ext/date/date_core.c
854
- # - d.friday? -> bool
1037
+ # - friday? -> true or false
855
1038
  # -->
856
- # Returns true if the date is Friday.
1039
+ # Returns `true` if `self` is a Friday, `false` otherwise.
857
1040
  #
858
1041
  def friday?: () -> bool
859
1042
 
860
1043
  # <!--
861
1044
  # rdoc-file=ext/date/date_core.c
862
- # - d.gregorian -> date
1045
+ # - gregorian -> new_date
863
1046
  # -->
864
- # This method is equivalent to new_start(Date::GREGORIAN).
1047
+ # Equivalent to Date#new_start with argument Date::GREGORIAN.
865
1048
  #
866
1049
  def gregorian: () -> Date
867
1050
 
868
1051
  # <!--
869
1052
  # rdoc-file=ext/date/date_core.c
870
- # - d.gregorian? -> bool
1053
+ # - gregorian? -> true or false
871
1054
  # -->
872
- # Returns true if the date is on or after the day of calendar reform.
1055
+ # Returns `true` if the date is on or after the date of calendar reform, `false`
1056
+ # otherwise:
873
1057
  #
874
- # Date.new(1582,10,15).gregorian? #=> true
875
- # (Date.new(1582,10,15) - 1).gregorian? #=> false
1058
+ # Date.new(1582, 10, 15).gregorian? # => true
1059
+ # (Date.new(1582, 10, 15) - 1).gregorian? # => false
876
1060
  #
877
1061
  def gregorian?: () -> bool
878
1062
 
879
1063
  # <!--
880
1064
  # rdoc-file=ext/date/date_core.c
881
- # - d.httpdate -> string
1065
+ # - httpdate -> string
882
1066
  # -->
883
- # This method is equivalent to strftime('%a, %d %b %Y %T GMT'). See also RFC
884
- # 2616.
1067
+ # Equivalent to #strftime with argument `'%a, %d %b %Y %T GMT'`; see [Formats
1068
+ # for Dates and Times](rdoc-ref:strftime_formatting.rdoc):
1069
+ #
1070
+ # Date.new(2001, 2, 3).httpdate # => "Sat, 03 Feb 2001 00:00:00 GMT"
885
1071
  #
886
1072
  def httpdate: () -> String
887
1073
 
888
1074
  # <!--
889
1075
  # rdoc-file=ext/date/date_core.c
890
- # - d.inspect -> string
1076
+ # - inspect -> string
891
1077
  # -->
892
- # Returns the value as a string for inspection.
1078
+ # Returns a string representation of `self`:
893
1079
  #
894
- # Date.new(2001,2,3).inspect
895
- # #=> "#<Date: 2001-02-03>"
896
- # DateTime.new(2001,2,3,4,5,6,'-7').inspect
897
- # #=> "#<DateTime: 2001-02-03T04:05:06-07:00>"
1080
+ # Date.new(2001, 2, 3).inspect
1081
+ # # => "#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>"
898
1082
  #
899
1083
  def inspect: () -> String
900
1084
 
901
1085
  # <!--
902
1086
  # rdoc-file=ext/date/date_core.c
903
- # - d.iso8601 -> string
904
- # - d.xmlschema -> string
1087
+ # - iso8601 -> string
905
1088
  # -->
906
- # This method is equivalent to strftime('%F').
1089
+ # Equivalent to #strftime with argument `'%Y-%m-%d'` (or its [shorthand
1090
+ # form](rdoc-ref:strftime_formatting.rdoc@Shorthand+Conversion+Specifiers)
1091
+ # `'%F'`);
1092
+ #
1093
+ # Date.new(2001, 2, 3).iso8601 # => "2001-02-03"
907
1094
  #
908
1095
  def iso8601: () -> String
909
1096
 
910
1097
  # <!--
911
1098
  # rdoc-file=ext/date/date_core.c
912
- # - d.italy -> date
1099
+ # - italy -> new_date
913
1100
  # -->
914
- # This method is equivalent to new_start(Date::ITALY).
1101
+ # Equivalent to Date#new_start with argument Date::ITALY.
915
1102
  #
916
1103
  def italy: () -> Date
917
1104
 
@@ -929,63 +1116,64 @@ class Date
929
1116
 
930
1117
  # <!--
931
1118
  # rdoc-file=ext/date/date_core.c
932
- # - d.jisx0301 -> string
1119
+ # - jisx0301 -> string
933
1120
  # -->
934
- # Returns a string in a JIS X 0301 format.
1121
+ # Returns a string representation of the date in `self` in JIS X 0301 format.
935
1122
  #
936
- # Date.new(2001,2,3).jisx0301 #=> "H13.02.03"
1123
+ # Date.new(2001, 2, 3).jisx0301 # => "H13.02.03"
937
1124
  #
938
1125
  def jisx0301: () -> String
939
1126
 
940
1127
  # <!--
941
1128
  # rdoc-file=ext/date/date_core.c
942
- # - d.julian -> date
1129
+ # - julian -> new_date
943
1130
  # -->
944
- # This method is equivalent to new_start(Date::JULIAN).
1131
+ # Equivalent to Date#new_start with argument Date::JULIAN.
945
1132
  #
946
1133
  def julian: () -> Date
947
1134
 
948
1135
  # <!--
949
1136
  # rdoc-file=ext/date/date_core.c
950
- # - d.julian? -> bool
1137
+ # - d.julian? -> true or false
951
1138
  # -->
952
- # Returns true if the date is before the day of calendar reform.
1139
+ # Returns `true` if the date is before the date of calendar reform, `false`
1140
+ # otherwise:
953
1141
  #
954
- # Date.new(1582,10,15).julian? #=> false
955
- # (Date.new(1582,10,15) - 1).julian? #=> true
1142
+ # (Date.new(1582, 10, 15) - 1).julian? # => true
1143
+ # Date.new(1582, 10, 15).julian? # => false
956
1144
  #
957
1145
  def julian?: () -> bool
958
1146
 
959
1147
  # <!--
960
1148
  # rdoc-file=ext/date/date_core.c
961
- # - d.ld -> integer
1149
+ # - ld -> integer
962
1150
  # -->
963
- # Returns the Lilian day number. This is a whole number, which is adjusted by
964
- # the offset as the local time.
1151
+ # Returns the [Lilian day number](https://en.wikipedia.org/wiki/Lilian_date),
1152
+ # which is the number of days since the beginning of the Gregorian calendar,
1153
+ # October 15, 1582.
965
1154
  #
966
- # Date.new(2001,2,3).ld #=> 152784
1155
+ # Date.new(2001, 2, 3).ld # => 152784
967
1156
  #
968
1157
  def ld: () -> Integer
969
1158
 
970
1159
  # <!--
971
1160
  # rdoc-file=ext/date/date_core.c
972
- # - d.leap? -> bool
1161
+ # - leap? -> true or false
973
1162
  # -->
974
- # Returns true if the year is a leap year.
1163
+ # Returns `true` if the year is a leap year, `false` otherwise:
975
1164
  #
976
- # Date.new(2000).leap? #=> true
977
- # Date.new(2001).leap? #=> false
1165
+ # Date.new(2000).leap? # => true
1166
+ # Date.new(2001).leap? # => false
978
1167
  #
979
1168
  def leap?: () -> bool
980
1169
 
981
1170
  # <!--
982
1171
  # rdoc-file=ext/date/date_core.c
983
- # - d.mday -> fixnum
984
- # - d.day -> fixnum
1172
+ # - mday -> integer
985
1173
  # -->
986
- # Returns the day of the month (1-31).
1174
+ # Returns the day of the month in range (1..31):
987
1175
  #
988
- # Date.new(2001,2,3).mday #=> 3
1176
+ # Date.new(2001, 2, 3).mday # => 3
989
1177
  #
990
1178
  def mday: () -> Integer
991
1179
 
@@ -1003,376 +1191,250 @@ class Date
1003
1191
 
1004
1192
  # <!--
1005
1193
  # rdoc-file=ext/date/date_core.c
1006
- # - d.mon -> fixnum
1007
- # - d.month -> fixnum
1194
+ # - mon -> integer
1008
1195
  # -->
1009
- # Returns the month (1-12).
1196
+ # Returns the month in range (1..12):
1010
1197
  #
1011
- # Date.new(2001,2,3).mon #=> 2
1198
+ # Date.new(2001, 2, 3).mon # => 2
1012
1199
  #
1013
1200
  def mon: () -> Integer
1014
1201
 
1015
1202
  # <!--
1016
1203
  # rdoc-file=ext/date/date_core.c
1017
- # - d.monday? -> bool
1204
+ # - monday? -> true or false
1018
1205
  # -->
1019
- # Returns true if the date is Monday.
1206
+ # Returns `true` if `self` is a Monday, `false` otherwise.
1020
1207
  #
1021
1208
  def monday?: () -> bool
1022
1209
 
1023
1210
  # <!-- rdoc-file=ext/date/date_core.c -->
1024
- # Returns the month (1-12).
1211
+ # Returns the month in range (1..12):
1025
1212
  #
1026
- # Date.new(2001,2,3).mon #=> 2
1213
+ # Date.new(2001, 2, 3).mon # => 2
1027
1214
  #
1028
1215
  def month: () -> Integer
1029
1216
 
1030
1217
  # <!--
1031
1218
  # rdoc-file=ext/date/date_core.c
1032
- # - d.new_start([start=Date::ITALY]) -> date
1219
+ # - new_start(start = Date::ITALY]) -> new_date
1033
1220
  # -->
1034
- # Duplicates self and resets its day of calendar reform.
1221
+ # Returns a copy of `self` with the given `start` value:
1222
+ #
1223
+ # d0 = Date.new(2000, 2, 3)
1224
+ # d0.julian? # => false
1225
+ # d1 = d0.new_start(Date::JULIAN)
1226
+ # d1.julian? # => true
1035
1227
  #
1036
- # d = Date.new(1582,10,15)
1037
- # d.new_start(Date::JULIAN) #=> #<Date: 1582-10-05 ...>
1228
+ # See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
1038
1229
  #
1039
1230
  def new_start: (?Integer start) -> Date
1040
1231
 
1041
1232
  # <!--
1042
1233
  # rdoc-file=ext/date/date_core.c
1043
- # - d.succ -> date
1044
- # - d.next -> date
1234
+ # - d.next -> new_date
1045
1235
  # -->
1046
- # Returns a date object denoting the following day.
1236
+ # Returns a new Date object representing the following day:
1237
+ #
1238
+ # d = Date.new(2001, 2, 3)
1239
+ # d.to_s # => "2001-02-03"
1240
+ # d.next.to_s # => "2001-02-04"
1047
1241
  #
1048
1242
  def next: () -> Date
1049
1243
 
1050
1244
  # <!--
1051
1245
  # rdoc-file=ext/date/date_core.c
1052
- # - d.next_day([n=1]) -> date
1246
+ # - next_day(n = 1) -> new_date
1053
1247
  # -->
1054
- # This method is equivalent to d + n.
1248
+ # Equivalent to Date#+ with argument `n`.
1055
1249
  #
1056
1250
  def next_day: (?Integer day) -> Date
1057
1251
 
1058
1252
  # <!--
1059
1253
  # rdoc-file=ext/date/date_core.c
1060
- # - d.next_month([n=1]) -> date
1254
+ # - next_month(n = 1) -> new_date
1061
1255
  # -->
1062
- # This method is equivalent to d >> n.
1063
- #
1064
- # See Date#>> for examples.
1256
+ # Equivalent to #>> with argument `n`.
1065
1257
  #
1066
1258
  def next_month: (?Integer month) -> Date
1067
1259
 
1068
1260
  # <!--
1069
1261
  # rdoc-file=ext/date/date_core.c
1070
- # - d.next_year([n=1]) -> date
1262
+ # - next_year(n = 1) -> new_date
1071
1263
  # -->
1072
- # This method is equivalent to d >> (n * 12).
1073
- #
1074
- # Date.new(2001,2,3).next_year #=> #<Date: 2002-02-03 ...>
1075
- # Date.new(2008,2,29).next_year #=> #<Date: 2009-02-28 ...>
1076
- # Date.new(2008,2,29).next_year(4) #=> #<Date: 2012-02-29 ...>
1077
- #
1078
- # See also Date#>>.
1264
+ # Equivalent to #>> with argument `n * 12`.
1079
1265
  #
1080
1266
  def next_year: (?Integer year) -> Date
1081
1267
 
1082
1268
  # <!--
1083
1269
  # rdoc-file=ext/date/date_core.c
1084
- # - d.prev_day([n=1]) -> date
1270
+ # - prev_day(n = 1) -> new_date
1085
1271
  # -->
1086
- # This method is equivalent to d - n.
1272
+ # Equivalent to Date#- with argument `n`.
1087
1273
  #
1088
1274
  def prev_day: (?Integer day) -> Date
1089
1275
 
1090
1276
  # <!--
1091
1277
  # rdoc-file=ext/date/date_core.c
1092
- # - d.prev_month([n=1]) -> date
1278
+ # - prev_month(n = 1) -> new_date
1093
1279
  # -->
1094
- # This method is equivalent to d << n.
1095
- #
1096
- # See Date#<< for examples.
1280
+ # Equivalent to #<< with argument `n`.
1097
1281
  #
1098
1282
  def prev_month: (?Integer month) -> Date
1099
1283
 
1100
1284
  # <!--
1101
1285
  # rdoc-file=ext/date/date_core.c
1102
- # - d.prev_year([n=1]) -> date
1286
+ # - prev_year(n = 1) -> new_date
1103
1287
  # -->
1104
- # This method is equivalent to d << (n * 12).
1105
- #
1106
- # Date.new(2001,2,3).prev_year #=> #<Date: 2000-02-03 ...>
1107
- # Date.new(2008,2,29).prev_year #=> #<Date: 2007-02-28 ...>
1108
- # Date.new(2008,2,29).prev_year(4) #=> #<Date: 2004-02-29 ...>
1109
- #
1110
- # See also Date#<<.
1288
+ # Equivalent to #<< with argument `n * 12`.
1111
1289
  #
1112
1290
  def prev_year: (?Integer year) -> Date
1113
1291
 
1114
1292
  # <!--
1115
1293
  # rdoc-file=ext/date/date_core.c
1116
- # - d.rfc2822 -> string
1117
- # - d.rfc822 -> string
1294
+ # - rfc2822 -> string
1118
1295
  # -->
1119
- # This method is equivalent to strftime('%a, %-d %b %Y %T %z').
1296
+ # Equivalent to #strftime with argument `'%a, %-d %b %Y %T %z'`; see [Formats
1297
+ # for Dates and Times](rdoc-ref:strftime_formatting.rdoc):
1298
+ #
1299
+ # Date.new(2001, 2, 3).rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
1120
1300
  #
1121
1301
  def rfc2822: () -> String
1122
1302
 
1123
1303
  # <!--
1124
1304
  # rdoc-file=ext/date/date_core.c
1125
- # - d.rfc3339 -> string
1305
+ # - rfc3339 -> string
1126
1306
  # -->
1127
- # This method is equivalent to strftime('%FT%T%:z').
1307
+ # Equivalent to #strftime with argument `'%FT%T%:z'`; see [Formats for Dates and
1308
+ # Times](rdoc-ref:strftime_formatting.rdoc):
1309
+ #
1310
+ # Date.new(2001, 2, 3).rfc3339 # => "2001-02-03T00:00:00+00:00"
1128
1311
  #
1129
1312
  def rfc3339: () -> String
1130
1313
 
1131
1314
  # <!-- rdoc-file=ext/date/date_core.c -->
1132
- # Creates a new Date object by parsing from a string according to some typical
1133
- # RFC 2822 formats.
1315
+ # Returns a new Date object with values parsed from `string`, which should be a
1316
+ # valid [RFC 2822 date
1317
+ # format](rdoc-ref:strftime_formatting.rdoc@RFC+2822+Format):
1318
+ #
1319
+ # d = Date.new(2001, 2, 3)
1320
+ # s = d.rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
1321
+ # Date.rfc2822(s) # => #<Date: 2001-02-03>
1134
1322
  #
1135
- # Date.rfc2822('Sat, 3 Feb 2001 00:00:00 +0000')
1136
- # #=> #<Date: 2001-02-03 ...>
1323
+ # See:
1137
1324
  #
1138
- # Raise an ArgumentError when the string length is longer than *limit*. You can
1139
- # stop this check by passing `limit: nil`, but note that it may take a long time
1140
- # to parse.
1325
+ # * Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
1326
+ # * Argument [limit](rdoc-ref:Date@Argument+limit).
1327
+ #
1328
+ # Related: Date._rfc2822 (returns a hash).
1141
1329
  #
1142
1330
  def rfc822: () -> String
1143
1331
 
1144
1332
  # <!--
1145
1333
  # rdoc-file=ext/date/date_core.c
1146
- # - d.saturday? -> bool
1334
+ # - saturday? -> true or false
1147
1335
  # -->
1148
- # Returns true if the date is Saturday.
1336
+ # Returns `true` if `self` is a Saturday, `false` otherwise.
1149
1337
  #
1150
1338
  def saturday?: () -> bool
1151
1339
 
1152
1340
  # <!--
1153
1341
  # rdoc-file=ext/date/date_core.c
1154
- # - d.start -> float
1342
+ # - start -> float
1155
1343
  # -->
1156
- # Returns the Julian day number denoting the day of calendar reform.
1344
+ # Returns the Julian start date for calendar reform; if not an infinity, the
1345
+ # returned value is suitable for passing to Date#jd:
1346
+ #
1347
+ # d = Date.new(2001, 2, 3, Date::ITALY)
1348
+ # s = d.start # => 2299161.0
1349
+ # Date.jd(s).to_s # => "1582-10-15"
1157
1350
  #
1158
- # Date.new(2001,2,3).start #=> 2299161.0
1159
- # Date.new(2001,2,3,Date::GREGORIAN).start #=> -Infinity
1351
+ # d = Date.new(2001, 2, 3, Date::ENGLAND)
1352
+ # s = d.start # => 2361222.0
1353
+ # Date.jd(s).to_s # => "1752-09-14"
1354
+ #
1355
+ # Date.new(2001, 2, 3, Date::GREGORIAN).start # => -Infinity
1356
+ # Date.new(2001, 2, 3, Date::JULIAN).start # => Infinity
1357
+ #
1358
+ # See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
1160
1359
  #
1161
1360
  def start: () -> Float
1162
1361
 
1163
1362
  # <!--
1164
1363
  # rdoc-file=ext/date/date_core.c
1165
- # - d.step(limit[, step=1]) -> enumerator
1166
- # - d.step(limit[, step=1]){|date| ...} -> self
1364
+ # - step(limit, step = 1){|date| ... } -> self
1167
1365
  # -->
1168
- # Iterates evaluation of the given block, which takes a date object. The limit
1169
- # should be a date object.
1366
+ # Calls the block with specified dates; returns `self`.
1367
+ #
1368
+ # * The first `date` is `self`.
1369
+ # * Each successive `date` is `date + step`, where `step` is the numeric step
1370
+ # size in days.
1371
+ # * The last date is the last one that is before or equal to `limit`, which
1372
+ # should be a Date object.
1373
+ #
1374
+ # Example:
1375
+ #
1376
+ # limit = Date.new(2001, 12, 31)
1377
+ # Date.new(2001).step(limit){|date| p date.to_s if date.mday == 31 }
1170
1378
  #
1171
- # Date.new(2001).step(Date.new(2001,-1,-1)).select{|d| d.sunday?}.size
1172
- # #=> 52
1379
+ # Output:
1380
+ #
1381
+ # "2001-01-31"
1382
+ # "2001-03-31"
1383
+ # "2001-05-31"
1384
+ # "2001-07-31"
1385
+ # "2001-08-31"
1386
+ # "2001-10-31"
1387
+ # "2001-12-31"
1388
+ #
1389
+ # Returns an Enumerator if no block is given.
1173
1390
  #
1174
1391
  def step: (Date limit, ?Integer step) { (Date) -> untyped } -> Date
1175
1392
  | (Date limit, ?Integer step) -> ::Enumerator[Date, Date]
1176
1393
 
1177
1394
  # <!--
1178
1395
  # rdoc-file=ext/date/date_core.c
1179
- # - d.strftime([format='%F']) -> string
1180
- # -->
1181
- # Formats date according to the directives in the given format string. The
1182
- # directives begin with a percent (%) character. Any text not listed as a
1183
- # directive will be passed through to the output string.
1184
- #
1185
- # A directive consists of a percent (%) character, zero or more flags, an
1186
- # optional minimum field width, an optional modifier, and a conversion specifier
1187
- # as follows.
1188
- #
1189
- # %<flags><width><modifier><conversion>
1190
- #
1191
- # Flags:
1192
- # - don't pad a numerical output.
1193
- # _ use spaces for padding.
1194
- # 0 use zeros for padding.
1195
- # ^ upcase the result string.
1196
- # # change case.
1197
- #
1198
- # The minimum field width specifies the minimum width.
1199
- #
1200
- # The modifiers are "E", "O", ":", "::" and ":::". "E" and "O" are ignored. No
1201
- # effect to result currently.
1202
- #
1203
- # Format directives:
1204
- #
1205
- # Date (Year, Month, Day):
1206
- # %Y - Year with century (can be negative, 4 digits at least)
1207
- # -0001, 0000, 1995, 2009, 14292, etc.
1208
- # %C - year / 100 (round down. 20 in 2009)
1209
- # %y - year % 100 (00..99)
1210
- #
1211
- # %m - Month of the year, zero-padded (01..12)
1212
- # %_m blank-padded ( 1..12)
1213
- # %-m no-padded (1..12)
1214
- # %B - The full month name (``January'')
1215
- # %^B uppercased (``JANUARY'')
1216
- # %b - The abbreviated month name (``Jan'')
1217
- # %^b uppercased (``JAN'')
1218
- # %h - Equivalent to %b
1219
- #
1220
- # %d - Day of the month, zero-padded (01..31)
1221
- # %-d no-padded (1..31)
1222
- # %e - Day of the month, blank-padded ( 1..31)
1223
- #
1224
- # %j - Day of the year (001..366)
1225
- #
1226
- # Time (Hour, Minute, Second, Subsecond):
1227
- # %H - Hour of the day, 24-hour clock, zero-padded (00..23)
1228
- # %k - Hour of the day, 24-hour clock, blank-padded ( 0..23)
1229
- # %I - Hour of the day, 12-hour clock, zero-padded (01..12)
1230
- # %l - Hour of the day, 12-hour clock, blank-padded ( 1..12)
1231
- # %P - Meridian indicator, lowercase (``am'' or ``pm'')
1232
- # %p - Meridian indicator, uppercase (``AM'' or ``PM'')
1233
- #
1234
- # %M - Minute of the hour (00..59)
1235
- #
1236
- # %S - Second of the minute (00..60)
1237
- #
1238
- # %L - Millisecond of the second (000..999)
1239
- # %N - Fractional seconds digits, default is 9 digits (nanosecond)
1240
- # %3N millisecond (3 digits) %15N femtosecond (15 digits)
1241
- # %6N microsecond (6 digits) %18N attosecond (18 digits)
1242
- # %9N nanosecond (9 digits) %21N zeptosecond (21 digits)
1243
- # %12N picosecond (12 digits) %24N yoctosecond (24 digits)
1244
- #
1245
- # Time zone:
1246
- # %z - Time zone as hour and minute offset from UTC (e.g. +0900)
1247
- # %:z - hour and minute offset from UTC with a colon (e.g. +09:00)
1248
- # %::z - hour, minute and second offset from UTC (e.g. +09:00:00)
1249
- # %:::z - hour, minute and second offset from UTC
1250
- # (e.g. +09, +09:30, +09:30:30)
1251
- # %Z - Equivalent to %:z (e.g. +09:00)
1252
- #
1253
- # Weekday:
1254
- # %A - The full weekday name (``Sunday'')
1255
- # %^A uppercased (``SUNDAY'')
1256
- # %a - The abbreviated name (``Sun'')
1257
- # %^a uppercased (``SUN'')
1258
- # %u - Day of the week (Monday is 1, 1..7)
1259
- # %w - Day of the week (Sunday is 0, 0..6)
1260
- #
1261
- # ISO 8601 week-based year and week number:
1262
- # The week 1 of YYYY starts with a Monday and includes YYYY-01-04.
1263
- # The days in the year before the first week are in the last week of
1264
- # the previous year.
1265
- # %G - The week-based year
1266
- # %g - The last 2 digits of the week-based year (00..99)
1267
- # %V - Week number of the week-based year (01..53)
1268
- #
1269
- # Week number:
1270
- # The week 1 of YYYY starts with a Sunday or Monday (according to %U
1271
- # or %W). The days in the year before the first week are in week 0.
1272
- # %U - Week number of the year. The week starts with Sunday. (00..53)
1273
- # %W - Week number of the year. The week starts with Monday. (00..53)
1274
- #
1275
- # Seconds since the Unix Epoch:
1276
- # %s - Number of seconds since 1970-01-01 00:00:00 UTC.
1277
- # %Q - Number of milliseconds since 1970-01-01 00:00:00 UTC.
1278
- #
1279
- # Literal string:
1280
- # %n - Newline character (\n)
1281
- # %t - Tab character (\t)
1282
- # %% - Literal ``%'' character
1283
- #
1284
- # Combination:
1285
- # %c - date and time (%a %b %e %T %Y)
1286
- # %D - Date (%m/%d/%y)
1287
- # %F - The ISO 8601 date format (%Y-%m-%d)
1288
- # %v - VMS date (%e-%^b-%Y)
1289
- # %x - Same as %D
1290
- # %X - Same as %T
1291
- # %r - 12-hour time (%I:%M:%S %p)
1292
- # %R - 24-hour time (%H:%M)
1293
- # %T - 24-hour time (%H:%M:%S)
1294
- # %+ - date(1) (%a %b %e %H:%M:%S %Z %Y)
1295
- #
1296
- # This method is similar to the strftime() function defined in ISO C and POSIX.
1297
- # Several directives (%a, %A, %b, %B, %c, %p, %r, %x, %X, %E*, %O* and %Z) are
1298
- # locale dependent in the function. However, this method is locale independent.
1299
- # So, the result may differ even if the same format string is used in other
1300
- # systems such as C. It is good practice to avoid %x and %X because there are
1301
- # corresponding locale independent representations, %D and %T.
1302
- #
1303
- # Examples:
1304
- #
1305
- # d = DateTime.new(2007,11,19,8,37,48,"-06:00")
1306
- # #=> #<DateTime: 2007-11-19T08:37:48-0600 ...>
1307
- # d.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007"
1308
- # d.strftime("at %I:%M%p") #=> "at 08:37AM"
1309
- #
1310
- # Various ISO 8601 formats:
1311
- # %Y%m%d => 20071119 Calendar date (basic)
1312
- # %F => 2007-11-19 Calendar date (extended)
1313
- # %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month
1314
- # %Y => 2007 Calendar date, reduced accuracy, specific year
1315
- # %C => 20 Calendar date, reduced accuracy, specific century
1316
- # %Y%j => 2007323 Ordinal date (basic)
1317
- # %Y-%j => 2007-323 Ordinal date (extended)
1318
- # %GW%V%u => 2007W471 Week date (basic)
1319
- # %G-W%V-%u => 2007-W47-1 Week date (extended)
1320
- # %GW%V => 2007W47 Week date, reduced accuracy, specific week (basic)
1321
- # %G-W%V => 2007-W47 Week date, reduced accuracy, specific week (extended)
1322
- # %H%M%S => 083748 Local time (basic)
1323
- # %T => 08:37:48 Local time (extended)
1324
- # %H%M => 0837 Local time, reduced accuracy, specific minute (basic)
1325
- # %H:%M => 08:37 Local time, reduced accuracy, specific minute (extended)
1326
- # %H => 08 Local time, reduced accuracy, specific hour
1327
- # %H%M%S,%L => 083748,000 Local time with decimal fraction, comma as decimal sign (basic)
1328
- # %T,%L => 08:37:48,000 Local time with decimal fraction, comma as decimal sign (extended)
1329
- # %H%M%S.%L => 083748.000 Local time with decimal fraction, full stop as decimal sign (basic)
1330
- # %T.%L => 08:37:48.000 Local time with decimal fraction, full stop as decimal sign (extended)
1331
- # %H%M%S%z => 083748-0600 Local time and the difference from UTC (basic)
1332
- # %T%:z => 08:37:48-06:00 Local time and the difference from UTC (extended)
1333
- # %Y%m%dT%H%M%S%z => 20071119T083748-0600 Date and time of day for calendar date (basic)
1334
- # %FT%T%:z => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended)
1335
- # %Y%jT%H%M%S%z => 2007323T083748-0600 Date and time of day for ordinal date (basic)
1336
- # %Y-%jT%T%:z => 2007-323T08:37:48-06:00 Date and time of day for ordinal date (extended)
1337
- # %GW%V%uT%H%M%S%z => 2007W471T083748-0600 Date and time of day for week date (basic)
1338
- # %G-W%V-%uT%T%:z => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended)
1339
- # %Y%m%dT%H%M => 20071119T0837 Calendar date and local time (basic)
1340
- # %FT%R => 2007-11-19T08:37 Calendar date and local time (extended)
1341
- # %Y%jT%H%MZ => 2007323T0837Z Ordinal date and UTC of day (basic)
1342
- # %Y-%jT%RZ => 2007-323T08:37Z Ordinal date and UTC of day (extended)
1343
- # %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic)
1344
- # %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended)
1345
- #
1346
- # See also strftime(3) and ::strptime.
1396
+ # - strftime(format = '%F') -> string
1397
+ # -->
1398
+ # Returns a string representation of the date in `self`, formatted according the
1399
+ # given `format`:
1400
+ #
1401
+ # Date.new(2001, 2, 3).strftime # => "2001-02-03"
1402
+ #
1403
+ # For other formats, see [Formats for Dates and
1404
+ # Times](rdoc-ref:strftime_formatting.rdoc).
1347
1405
  #
1348
1406
  def strftime: (?String format) -> String
1349
1407
 
1350
1408
  # <!-- rdoc-file=ext/date/date_core.c -->
1351
- # Returns a date object denoting the following day.
1409
+ # Returns a new Date object representing the following day:
1410
+ #
1411
+ # d = Date.new(2001, 2, 3)
1412
+ # d.to_s # => "2001-02-03"
1413
+ # d.next.to_s # => "2001-02-04"
1352
1414
  #
1353
1415
  def succ: () -> Date
1354
1416
 
1355
1417
  # <!--
1356
1418
  # rdoc-file=ext/date/date_core.c
1357
- # - d.sunday? -> bool
1419
+ # - sunday? -> true or false
1358
1420
  # -->
1359
- # Returns true if the date is Sunday.
1421
+ # Returns `true` if `self` is a Sunday, `false` otherwise.
1360
1422
  #
1361
1423
  def sunday?: () -> bool
1362
1424
 
1363
1425
  # <!--
1364
1426
  # rdoc-file=ext/date/date_core.c
1365
- # - d.thursday? -> bool
1427
+ # - thursday? -> true or false
1366
1428
  # -->
1367
- # Returns true if the date is Thursday.
1429
+ # Returns `true` if `self` is a Thursday, `false` otherwise.
1368
1430
  #
1369
1431
  def thursday?: () -> bool
1370
1432
 
1371
1433
  # <!--
1372
1434
  # rdoc-file=ext/date/date_core.c
1373
- # - d.to_date -> self
1435
+ # - to_date -> self
1374
1436
  # -->
1375
- # Returns self.
1437
+ # Returns `self`.
1376
1438
  #
1377
1439
  def to_date: () -> Date
1378
1440
 
@@ -1380,89 +1442,98 @@ class Date
1380
1442
  # rdoc-file=ext/date/date_core.c
1381
1443
  # - d.to_datetime -> datetime
1382
1444
  # -->
1383
- # Returns a DateTime object which denotes self.
1445
+ # Returns a DateTime whose value is the same as `self`:
1446
+ #
1447
+ # Date.new(2001, 2, 3).to_datetime # => #<DateTime: 2001-02-03T00:00:00+00:00>
1384
1448
  #
1385
1449
  def to_datetime: () -> DateTime
1386
1450
 
1387
1451
  # <!--
1388
1452
  # rdoc-file=ext/date/date_core.c
1389
- # - d.to_s -> string
1453
+ # - to_s -> string
1390
1454
  # -->
1391
- # Returns a string in an ISO 8601 format. (This method doesn't use the expanded
1392
- # representations.)
1455
+ # Returns a string representation of the date in `self` in [ISO 8601 extended
1456
+ # date format](rdoc-ref:strftime_formatting.rdoc@ISO+8601+Format+Specifications)
1457
+ # (`'%Y-%m-%d'`):
1393
1458
  #
1394
- # Date.new(2001,2,3).to_s #=> "2001-02-03"
1459
+ # Date.new(2001, 2, 3).to_s # => "2001-02-03"
1395
1460
  #
1396
1461
  def to_s: () -> String
1397
1462
 
1398
1463
  # <!--
1399
1464
  # rdoc-file=ext/date/date_core.c
1400
- # - d.to_time -> time
1465
+ # - to_time -> time
1401
1466
  # -->
1402
- # Returns a Time object which denotes self. If self is a julian date, convert it
1403
- # to a gregorian date before converting it to Time.
1467
+ # Returns a new Time object with the same value as `self`; if `self` is a Julian
1468
+ # date, derives its Gregorian date for conversion to the Time object:
1469
+ #
1470
+ # Date.new(2001, 2, 3).to_time # => 2001-02-03 00:00:00 -0600
1471
+ # Date.new(2001, 2, 3, Date::JULIAN).to_time # => 2001-02-16 00:00:00 -0600
1404
1472
  #
1405
1473
  def to_time: () -> Time
1406
1474
 
1407
1475
  # <!--
1408
1476
  # rdoc-file=ext/date/date_core.c
1409
- # - d.tuesday? -> bool
1477
+ # - tuesday? -> true or false
1410
1478
  # -->
1411
- # Returns true if the date is Tuesday.
1479
+ # Returns `true` if `self` is a Tuesday, `false` otherwise.
1412
1480
  #
1413
1481
  def tuesday?: () -> bool
1414
1482
 
1415
1483
  # <!--
1416
1484
  # rdoc-file=ext/date/date_core.c
1417
- # - d.upto(max) -> enumerator
1418
- # - d.upto(max){|date| ...} -> self
1485
+ # - upto(max){|date| ... } -> self
1419
1486
  # -->
1420
- # This method is equivalent to step(max, 1){|date| ...}.
1487
+ # Equivalent to #step with arguments `max` and `1`.
1421
1488
  #
1422
1489
  def upto: (Date max) { (Date) -> untyped } -> Date
1423
1490
  | (Date max) -> ::Enumerator[Date, Date]
1424
1491
 
1425
1492
  # <!--
1426
1493
  # rdoc-file=ext/date/date_core.c
1427
- # - d.wday -> fixnum
1494
+ # - wday -> integer
1428
1495
  # -->
1429
- # Returns the day of week (0-6, Sunday is zero).
1496
+ # Returns the day of week in range (0..6); Sunday is 0:
1430
1497
  #
1431
- # Date.new(2001,2,3).wday #=> 6
1498
+ # Date.new(2001, 2, 3).wday # => 6
1432
1499
  #
1433
1500
  def wday: () -> Integer
1434
1501
 
1435
1502
  # <!--
1436
1503
  # rdoc-file=ext/date/date_core.c
1437
- # - d.wednesday? -> bool
1504
+ # - wednesday? -> true or false
1438
1505
  # -->
1439
- # Returns true if the date is Wednesday.
1506
+ # Returns `true` if `self` is a Wednesday, `false` otherwise.
1440
1507
  #
1441
1508
  def wednesday?: () -> bool
1442
1509
 
1443
1510
  # <!-- rdoc-file=ext/date/date_core.c -->
1444
- # This method is equivalent to strftime('%F').
1511
+ # Equivalent to #strftime with argument `'%Y-%m-%d'` (or its [shorthand
1512
+ # form](rdoc-ref:strftime_formatting.rdoc@Shorthand+Conversion+Specifiers)
1513
+ # `'%F'`);
1514
+ #
1515
+ # Date.new(2001, 2, 3).iso8601 # => "2001-02-03"
1445
1516
  #
1446
1517
  def xmlschema: () -> String
1447
1518
 
1448
1519
  # <!--
1449
1520
  # rdoc-file=ext/date/date_core.c
1450
- # - d.yday -> fixnum
1521
+ # - yday -> integer
1451
1522
  # -->
1452
- # Returns the day of the year (1-366).
1523
+ # Returns the day of the year, in range (1..366):
1453
1524
  #
1454
- # Date.new(2001,2,3).yday #=> 34
1525
+ # Date.new(2001, 2, 3).yday # => 34
1455
1526
  #
1456
1527
  def yday: () -> Integer
1457
1528
 
1458
1529
  # <!--
1459
1530
  # rdoc-file=ext/date/date_core.c
1460
- # - d.year -> integer
1531
+ # - year -> integer
1461
1532
  # -->
1462
- # Returns the year.
1533
+ # Returns the year:
1463
1534
  #
1464
- # Date.new(2001,2,3).year #=> 2001
1465
- # (Date.new(1,1,1) - 1).year #=> 0
1535
+ # Date.new(2001, 2, 3).year # => 2001
1536
+ # (Date.new(1, 1, 1) - 1).year # => 0
1466
1537
  #
1467
1538
  def year: () -> Integer
1468
1539
  end