rbs 2.8.4 → 3.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +12 -4
- data/.github/workflows/comments.yml +11 -11
- data/.github/workflows/dependabot.yml +30 -0
- data/.github/workflows/ruby.yml +40 -49
- data/.github/workflows/typecheck.yml +36 -0
- data/.github/workflows/windows.yml +28 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +42 -2
- data/CHANGELOG.md +845 -1
- data/README.md +64 -4
- data/Rakefile +198 -18
- data/Steepfile +11 -11
- data/config.yml +311 -0
- data/core/array.rbs +2189 -1914
- data/core/basic_object.rbs +59 -84
- data/core/binding.rbs +7 -69
- data/core/builtin.rbs +210 -11
- data/core/class.rbs +37 -0
- data/core/comparable.rbs +23 -25
- data/core/complex.rbs +449 -227
- data/core/constants.rbs +29 -21
- data/core/data.rbs +415 -0
- data/core/dir.rbs +698 -415
- data/core/encoding.rbs +468 -843
- data/core/enumerable.rbs +495 -455
- data/core/enumerator/product.rbs +92 -0
- data/core/enumerator.rbs +106 -9
- data/core/env.rbs +1 -1
- data/core/errno.rbs +506 -605
- data/core/errors.rbs +15 -17
- data/core/exception.rbs +361 -145
- data/core/false_class.rbs +39 -26
- data/core/fiber.rbs +121 -14
- data/core/file.rbs +1262 -320
- data/core/file_test.rbs +62 -45
- data/core/float.rbs +187 -208
- data/core/gc.rbs +446 -196
- data/core/global_variables.rbs +29 -29
- data/core/hash.rbs +242 -349
- data/core/integer.rbs +246 -308
- data/core/io/buffer.rbs +373 -122
- data/core/io/wait.rbs +29 -17
- data/core/io.rbs +1881 -1518
- data/core/kernel.rbs +2116 -1538
- data/core/marshal.rbs +24 -14
- data/core/match_data.rbs +413 -166
- data/core/math.rbs +531 -291
- data/core/method.rbs +101 -32
- data/core/module.rbs +228 -64
- data/core/nil_class.rbs +106 -47
- data/core/numeric.rbs +206 -292
- data/core/object.rbs +73 -1168
- data/core/object_space/weak_key_map.rbs +166 -0
- data/core/object_space.rbs +5 -3
- data/core/proc.rbs +280 -39
- data/core/process.rbs +1318 -658
- data/core/ractor.rbs +200 -134
- data/core/random.rbs +21 -4
- data/core/range.rbs +309 -153
- data/core/rational.rbs +4 -12
- data/core/rb_config.rbs +64 -43
- data/core/rbs/unnamed/argf.rbs +411 -147
- data/core/rbs/unnamed/env_class.rbs +137 -253
- data/core/rbs/unnamed/random.rbs +49 -26
- data/core/refinement.rbs +16 -1
- data/core/regexp.rbs +1568 -862
- data/core/ruby_vm.rbs +719 -7
- data/core/rubygems/config_file.rbs +3 -0
- data/core/rubygems/errors.rbs +69 -6
- data/core/rubygems/rubygems.rbs +71 -17
- data/core/rubygems/version.rbs +11 -7
- data/{stdlib/set/0 → core}/set.rbs +80 -91
- data/core/signal.rbs +14 -8
- data/core/string.rbs +1732 -1607
- data/core/struct.rbs +467 -95
- data/core/symbol.rbs +215 -245
- data/core/thread.rbs +133 -89
- data/core/thread_group.rbs +9 -9
- data/core/time.rbs +1141 -841
- data/core/trace_point.rbs +181 -121
- data/core/true_class.rbs +58 -32
- data/core/unbound_method.rbs +103 -30
- data/core/warning.rbs +50 -5
- data/docs/CONTRIBUTING.md +1 -1
- data/docs/architecture.md +110 -0
- data/docs/collection.md +59 -5
- data/docs/data_and_struct.md +86 -0
- data/docs/gem.md +57 -0
- data/docs/rbs_by_example.md +16 -35
- data/docs/repo.md +1 -1
- data/docs/sigs.md +7 -7
- data/docs/stdlib.md +63 -5
- data/docs/syntax.md +255 -61
- data/docs/tools.md +1 -0
- data/ext/rbs_extension/extconf.rb +10 -0
- data/ext/rbs_extension/lexer.c +1741 -1548
- data/ext/rbs_extension/lexer.h +11 -1
- data/ext/rbs_extension/lexer.re +12 -6
- data/ext/rbs_extension/lexstate.c +26 -3
- data/ext/rbs_extension/location.c +119 -111
- data/ext/rbs_extension/location.h +32 -7
- data/ext/rbs_extension/main.c +3 -0
- data/ext/rbs_extension/parser.c +883 -481
- data/ext/rbs_extension/parserstate.c +65 -25
- data/ext/rbs_extension/parserstate.h +13 -3
- data/ext/rbs_extension/rbs_extension.h +1 -10
- data/ext/rbs_extension/unescape.c +7 -47
- data/goodcheck.yml +2 -2
- data/{ext/rbs_extension → include/rbs}/constants.h +26 -15
- data/include/rbs/ruby_objs.h +72 -0
- data/include/rbs.h +7 -0
- data/lib/rbs/annotate/annotations.rb +3 -3
- data/lib/rbs/annotate/formatter.rb +13 -3
- data/lib/rbs/annotate/rdoc_annotator.rb +1 -1
- data/lib/rbs/annotate/rdoc_source.rb +12 -3
- data/lib/rbs/ast/declarations.rb +85 -2
- data/lib/rbs/ast/directives.rb +39 -0
- data/lib/rbs/ast/members.rb +49 -15
- data/lib/rbs/ast/type_param.rb +104 -15
- data/lib/rbs/ast/visitor.rb +137 -0
- data/lib/rbs/buffer.rb +5 -0
- data/lib/rbs/cli/colored_io.rb +48 -0
- data/lib/rbs/cli/diff.rb +83 -0
- data/lib/rbs/cli/validate.rb +356 -0
- data/lib/rbs/cli.rb +253 -143
- data/lib/rbs/collection/cleaner.rb +8 -1
- data/lib/rbs/collection/config/lockfile.rb +92 -0
- data/lib/rbs/collection/config/lockfile_generator.rb +154 -65
- data/lib/rbs/collection/config.rb +19 -46
- data/lib/rbs/collection/installer.rb +12 -13
- data/lib/rbs/collection/sources/base.rb +2 -2
- data/lib/rbs/collection/sources/git.rb +146 -69
- data/lib/rbs/collection/sources/local.rb +81 -0
- data/lib/rbs/collection/sources/rubygems.rb +10 -12
- data/lib/rbs/collection/sources/stdlib.rb +14 -13
- data/lib/rbs/collection/sources.rb +15 -2
- data/lib/rbs/collection.rb +2 -1
- data/lib/rbs/definition.rb +13 -16
- data/lib/rbs/definition_builder/ancestor_builder.rb +100 -24
- data/lib/rbs/definition_builder/method_builder.rb +4 -4
- data/lib/rbs/definition_builder.rb +489 -584
- data/lib/rbs/diff.rb +125 -0
- data/lib/rbs/environment/use_map.rb +77 -0
- data/lib/rbs/environment.rb +406 -105
- data/lib/rbs/environment_loader.rb +48 -44
- data/lib/rbs/environment_walker.rb +1 -1
- data/lib/rbs/errors.rb +175 -56
- data/lib/rbs/file_finder.rb +28 -0
- data/lib/rbs/location_aux.rb +8 -7
- data/lib/rbs/locator.rb +37 -15
- data/lib/rbs/method_type.rb +23 -0
- data/lib/rbs/namespace.rb +1 -0
- data/lib/rbs/parser/lex_result.rb +15 -0
- data/lib/rbs/parser/token.rb +23 -0
- data/lib/rbs/parser_aux.rb +22 -13
- data/lib/rbs/prototype/helpers.rb +48 -22
- data/lib/rbs/prototype/node_usage.rb +99 -0
- data/lib/rbs/prototype/rb.rb +125 -31
- data/lib/rbs/prototype/rbi.rb +49 -36
- data/lib/rbs/prototype/runtime/helpers.rb +59 -0
- data/lib/rbs/prototype/runtime/reflection.rb +19 -0
- data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
- data/lib/rbs/prototype/runtime.rb +273 -159
- data/lib/rbs/resolver/constant_resolver.rb +24 -8
- data/lib/rbs/resolver/type_name_resolver.rb +41 -7
- data/lib/rbs/sorter.rb +153 -123
- data/lib/rbs/substitution.rb +19 -0
- data/lib/rbs/subtractor.rb +201 -0
- data/lib/rbs/test/errors.rb +24 -11
- data/lib/rbs/test/guaranteed.rb +30 -0
- data/lib/rbs/test/hook.rb +45 -40
- data/lib/rbs/test/setup.rb +1 -1
- data/lib/rbs/test/tester.rb +1 -1
- data/lib/rbs/test/type_check.rb +120 -23
- data/lib/rbs/test.rb +6 -3
- data/lib/rbs/type_alias_dependency.rb +13 -3
- data/lib/rbs/type_alias_regularity.rb +21 -14
- data/lib/rbs/type_name.rb +18 -13
- data/lib/rbs/types.rb +352 -18
- data/lib/rbs/unit_test/convertibles.rb +176 -0
- data/lib/rbs/unit_test/spy.rb +136 -0
- data/lib/rbs/unit_test/type_assertions.rb +341 -0
- data/lib/rbs/unit_test/with_aliases.rb +143 -0
- data/lib/rbs/unit_test.rb +6 -0
- data/lib/rbs/validator.rb +55 -30
- data/lib/rbs/variance_calculator.rb +26 -23
- data/lib/rbs/vendorer.rb +3 -3
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +69 -22
- data/lib/rbs.rb +7 -2
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +5 -5
- data/rbs.gemspec +12 -2
- data/schema/decls.json +1 -1
- data/schema/members.json +15 -10
- data/sig/ancestor_builder.rbs +4 -0
- data/sig/ancestor_graph.rbs +22 -2
- data/sig/annotate/formatter.rbs +2 -2
- data/sig/annotate/rdoc_annotater.rbs +1 -1
- data/sig/cli/colored_io.rbs +15 -0
- data/sig/cli/diff.rbs +21 -0
- data/sig/cli/validate.rbs +43 -0
- data/sig/cli.rbs +4 -0
- data/sig/collection/config/lockfile.rbs +74 -0
- data/sig/collection/config/lockfile_generator.rbs +66 -0
- data/sig/collection/config.rbs +5 -48
- data/sig/collection/installer.rbs +1 -1
- data/sig/collection/sources.rbs +105 -33
- data/sig/constant.rbs +1 -1
- data/sig/declarations.rbs +42 -3
- data/sig/definition.rbs +26 -10
- data/sig/definition_builder.rbs +103 -81
- data/sig/diff.rbs +28 -0
- data/sig/directives.rbs +61 -0
- data/sig/environment.rbs +175 -29
- data/sig/environment_loader.rbs +20 -18
- data/sig/errors.rbs +123 -2
- data/sig/file_finder.rbs +28 -0
- data/sig/location.rbs +0 -3
- data/sig/locator.rbs +14 -2
- data/sig/manifest.yaml +0 -1
- data/sig/members.rbs +32 -9
- data/sig/method_types.rbs +10 -4
- data/sig/namespace.rbs +2 -3
- data/sig/parser.rbs +55 -16
- data/sig/prototype/helpers.rbs +4 -0
- data/sig/prototype/node_usage.rbs +20 -0
- data/sig/prototype/rb.rbs +10 -2
- data/sig/prototype/rbi.rbs +2 -0
- data/sig/prototype/runtime.rbs +182 -0
- data/sig/rbs.rbs +1 -1
- data/sig/rdoc/rbs.rbs +4 -0
- data/sig/repository.rbs +7 -5
- data/sig/resolver/constant_resolver.rbs +3 -4
- data/sig/resolver/context.rbs +1 -1
- data/sig/resolver/type_name_resolver.rbs +5 -1
- data/sig/shims/bundler.rbs +38 -0
- data/sig/shims/rubygems.rbs +19 -0
- data/sig/sorter.rbs +23 -5
- data/sig/substitution.rbs +6 -0
- data/sig/subtractor.rbs +37 -0
- data/sig/test/errors.rbs +52 -0
- data/sig/test/guranteed.rbs +9 -0
- data/sig/test/type_check.rbs +19 -0
- data/sig/test.rbs +82 -0
- data/sig/type_alias_dependency.rbs +31 -0
- data/sig/type_alias_regularity.rbs +12 -6
- data/sig/type_param.rbs +45 -9
- data/sig/typename.rbs +8 -5
- data/sig/types.rbs +119 -12
- data/sig/unit_test/convertibles.rbs +154 -0
- data/sig/unit_test/spy.rbs +28 -0
- data/sig/unit_test/type_assertions.rbs +194 -0
- data/sig/unit_test/with_aliases.rbs +136 -0
- data/sig/use_map.rbs +35 -0
- data/sig/validator.rbs +12 -5
- data/sig/variance_calculator.rbs +3 -1
- data/sig/vendorer.rbs +1 -1
- data/sig/visitor.rbs +47 -0
- data/sig/writer.rbs +6 -2
- data/src/constants.c +153 -0
- data/src/ruby_objs.c +793 -0
- data/stdlib/base64/0/base64.rbs +298 -45
- data/stdlib/benchmark/0/benchmark.rbs +12 -3
- data/stdlib/bigdecimal/0/big_decimal.rbs +62 -198
- data/stdlib/cgi/0/core.rbs +68 -15
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/coverage/0/coverage.rbs +50 -11
- data/stdlib/csv/0/csv.rbs +90 -119
- data/stdlib/csv/0/manifest.yaml +1 -0
- data/stdlib/date/0/date.rbs +806 -735
- data/stdlib/date/0/date_time.rbs +70 -211
- data/stdlib/dbm/0/dbm.rbs +0 -2
- data/stdlib/delegate/0/delegator.rbs +184 -0
- data/stdlib/delegate/0/kernel.rbs +47 -0
- data/stdlib/delegate/0/simple_delegator.rbs +96 -0
- data/stdlib/did_you_mean/0/did_you_mean.rbs +3 -8
- data/stdlib/digest/0/digest.rbs +48 -35
- data/stdlib/erb/0/erb.rbs +15 -39
- data/stdlib/etc/0/etc.rbs +174 -54
- data/stdlib/fileutils/0/fileutils.rbs +1234 -385
- data/stdlib/forwardable/0/forwardable.rbs +4 -4
- data/stdlib/io-console/0/io-console.rbs +82 -17
- data/stdlib/ipaddr/0/ipaddr.rbs +11 -6
- data/stdlib/json/0/json.rbs +434 -151
- data/stdlib/kconv/0/kconv.rbs +166 -0
- data/stdlib/logger/0/formatter.rbs +0 -2
- data/stdlib/logger/0/log_device.rbs +1 -3
- data/stdlib/logger/0/logger.rbs +465 -328
- data/stdlib/minitest/0/kernel.rbs +2 -2
- data/stdlib/minitest/0/minitest/abstract_reporter.rbs +4 -1
- data/stdlib/minitest/0/minitest/assertion.rbs +1 -0
- data/stdlib/minitest/0/minitest/assertions.rbs +58 -13
- data/stdlib/minitest/0/minitest/backtrace_filter.rbs +7 -0
- data/stdlib/minitest/0/minitest/bench_spec.rbs +8 -8
- data/stdlib/minitest/0/minitest/benchmark.rbs +17 -16
- data/stdlib/minitest/0/minitest/compress.rbs +13 -0
- data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
- data/stdlib/minitest/0/minitest/mock.rbs +9 -5
- data/stdlib/minitest/0/minitest/parallel/executor.rbs +4 -0
- data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +0 -1
- data/stdlib/minitest/0/minitest/pride_io.rbs +8 -0
- data/stdlib/minitest/0/minitest/pride_lol.rbs +2 -0
- data/stdlib/minitest/0/minitest/progress_reporter.rbs +1 -1
- data/stdlib/minitest/0/minitest/reportable.rbs +2 -0
- data/stdlib/minitest/0/minitest/runnable.rbs +33 -1
- data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +1 -1
- data/stdlib/minitest/0/minitest/spec/dsl.rbs +10 -6
- data/stdlib/minitest/0/minitest/spec.rbs +1 -1
- data/stdlib/minitest/0/minitest/statistics_reporter.rbs +5 -0
- data/stdlib/minitest/0/minitest/summary_reporter.rbs +0 -7
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +7 -7
- data/stdlib/minitest/0/minitest/test.rbs +7 -14
- data/stdlib/minitest/0/minitest/unexpected_error.rbs +2 -0
- data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
- data/stdlib/minitest/0/minitest/unit.rbs +1 -2
- data/stdlib/minitest/0/minitest.rbs +41 -892
- data/stdlib/monitor/0/monitor.rbs +91 -10
- data/stdlib/mutex_m/0/mutex_m.rbs +0 -2
- data/stdlib/net-http/0/manifest.yaml +1 -1
- data/stdlib/net-http/0/net-http.rbs +3858 -964
- data/stdlib/net-protocol/0/manifest.yaml +2 -0
- data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
- data/stdlib/net-smtp/0/manifest.yaml +2 -0
- data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
- data/stdlib/nkf/0/nkf.rbs +35 -5
- data/stdlib/objspace/0/objspace.rbs +40 -18
- data/stdlib/observable/0/observable.rbs +217 -0
- data/stdlib/open-uri/0/manifest.yaml +4 -0
- data/stdlib/open-uri/0/open-uri.rbs +393 -0
- data/stdlib/open3/0/open3.rbs +147 -0
- data/stdlib/openssl/0/manifest.yaml +1 -0
- data/stdlib/openssl/0/openssl.rbs +681 -316
- data/stdlib/optparse/0/optparse.rbs +100 -65
- data/stdlib/pathname/0/pathname.rbs +24 -15
- data/stdlib/pp/0/manifest.yaml +2 -0
- data/stdlib/pp/0/pp.rbs +300 -0
- data/stdlib/prettyprint/0/prettyprint.rbs +2 -6
- data/stdlib/pstore/0/pstore.rbs +370 -156
- data/stdlib/psych/0/core_ext.rbs +12 -0
- data/stdlib/{yaml → psych}/0/dbm.rbs +3 -3
- data/stdlib/psych/0/manifest.yaml +3 -0
- data/stdlib/psych/0/psych.rbs +402 -0
- data/stdlib/{yaml → psych}/0/store.rbs +2 -2
- data/stdlib/pty/0/pty.rbs +63 -11
- data/stdlib/rdoc/0/code_object.rbs +51 -0
- data/stdlib/rdoc/0/comment.rbs +59 -0
- data/stdlib/rdoc/0/context.rbs +153 -0
- data/stdlib/rdoc/0/markup.rbs +117 -0
- data/stdlib/rdoc/0/parser.rbs +56 -0
- data/stdlib/rdoc/0/rdoc.rbs +13 -380
- data/stdlib/rdoc/0/ri.rbs +17 -0
- data/stdlib/rdoc/0/store.rbs +48 -0
- data/stdlib/rdoc/0/top_level.rbs +97 -0
- data/stdlib/resolv/0/resolv.rbs +16 -79
- data/stdlib/ripper/0/ripper.rbs +1648 -0
- data/stdlib/securerandom/0/securerandom.rbs +7 -2
- data/stdlib/shellwords/0/shellwords.rbs +11 -12
- data/stdlib/singleton/0/singleton.rbs +0 -3
- data/stdlib/socket/0/addrinfo.rbs +13 -18
- data/stdlib/socket/0/basic_socket.rbs +5 -10
- data/stdlib/socket/0/ip_socket.rbs +0 -2
- data/stdlib/socket/0/socket.rbs +77 -46
- data/stdlib/socket/0/tcp_server.rbs +0 -5
- data/stdlib/socket/0/tcp_socket.rbs +36 -3
- data/stdlib/socket/0/udp_socket.rbs +4 -5
- data/stdlib/socket/0/unix_server.rbs +0 -5
- data/stdlib/socket/0/unix_socket.rbs +2 -4
- data/{core/string_io.rbs → stdlib/stringio/0/stringio.rbs} +188 -107
- data/stdlib/strscan/0/string_scanner.rbs +1269 -425
- data/stdlib/tempfile/0/tempfile.rbs +224 -61
- data/stdlib/time/0/time.rbs +48 -35
- data/stdlib/timeout/0/timeout.rbs +17 -8
- data/stdlib/tmpdir/0/tmpdir.rbs +10 -3
- data/stdlib/tsort/0/tsort.rbs +0 -4
- data/stdlib/uri/0/common.rbs +271 -144
- data/stdlib/uri/0/file.rbs +5 -0
- data/stdlib/uri/0/ftp.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +26 -22
- data/stdlib/uri/0/http.rbs +4 -4
- data/stdlib/uri/0/ldap.rbs +1 -1
- data/stdlib/uri/0/mailto.rbs +84 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
- data/stdlib/yaml/0/manifest.yaml +1 -2
- data/stdlib/yaml/0/yaml.rbs +1 -199
- data/stdlib/zlib/0/buf_error.rbs +10 -0
- data/stdlib/zlib/0/data_error.rbs +10 -0
- data/stdlib/zlib/0/deflate.rbs +210 -0
- data/stdlib/zlib/0/error.rbs +20 -0
- data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
- data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
- data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
- data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
- data/stdlib/zlib/0/gzip_file.rbs +156 -0
- data/stdlib/zlib/0/gzip_reader.rbs +293 -0
- data/stdlib/zlib/0/gzip_writer.rbs +166 -0
- data/stdlib/zlib/0/inflate.rbs +180 -0
- data/stdlib/zlib/0/mem_error.rbs +10 -0
- data/stdlib/zlib/0/need_dict.rbs +13 -0
- data/stdlib/zlib/0/stream_end.rbs +11 -0
- data/stdlib/zlib/0/stream_error.rbs +11 -0
- data/stdlib/zlib/0/version_error.rbs +11 -0
- data/stdlib/zlib/0/zlib.rbs +1 -3
- data/stdlib/zlib/0/zstream.rbs +200 -0
- data/templates/include/rbs/constants.h.erb +20 -0
- data/templates/include/rbs/ruby_objs.h.erb +10 -0
- data/templates/src/constants.c.erb +36 -0
- data/templates/src/ruby_objs.c.erb +27 -0
- data/templates/template.rb +122 -0
- metadata +136 -36
- data/Gemfile +0 -33
- data/Gemfile.lock +0 -118
- data/core/deprecated.rbs +0 -9
- data/ext/rbs_extension/constants.c +0 -135
- data/ext/rbs_extension/ruby_objs.c +0 -525
- data/ext/rbs_extension/ruby_objs.h +0 -43
- data/lib/rbs/constant_table.rb +0 -167
- data/lib/rbs/parser_compat/lexer_error.rb +0 -6
- data/lib/rbs/parser_compat/located_value.rb +0 -7
- data/lib/rbs/parser_compat/semantics_error.rb +0 -6
- data/lib/rbs/parser_compat/syntax_error.rb +0 -6
- data/lib/rbs/test/spy.rb +0 -6
- data/lib/rbs/type_name_resolver.rb +0 -67
- data/sig/constant_table.rbs +0 -30
- data/sig/shims/abstract_syntax_tree.rbs +0 -25
- data/sig/shims/pp.rbs +0 -3
- data/sig/shims/ripper.rbs +0 -8
- data/sig/shims.rbs +0 -69
- data/sig/type_name_resolver.rbs +0 -26
- data/stdlib/minitest/0/manifest.yaml +0 -2
- data/stdlib/prime/0/integer-extension.rbs +0 -41
- data/stdlib/prime/0/manifest.yaml +0 -2
- data/stdlib/prime/0/prime.rbs +0 -372
data/stdlib/date/0/date.rbs
CHANGED
@@ -1,144 +1,96 @@
|
|
1
1
|
# <!-- rdoc-file=ext/date/date_core.c -->
|
2
|
-
#
|
2
|
+
# Class Date provides methods for storing and manipulating calendar dates.
|
3
3
|
#
|
4
|
-
#
|
4
|
+
# Consider using [class Time](rdoc-ref:Time) instead of class Date if:
|
5
5
|
#
|
6
|
-
#
|
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
|
-
#
|
10
|
+
# A Date object, once created, is immutable, and cannot be modified.
|
9
11
|
#
|
10
|
-
#
|
12
|
+
# ## Creating a Date
|
11
13
|
#
|
12
|
-
#
|
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
|
-
#
|
16
|
+
# Date.today # => #<Date: 1999-12-31>
|
16
17
|
#
|
17
|
-
#
|
18
|
+
# You can create a specific date from various combinations of arguments:
|
18
19
|
#
|
19
|
-
#
|
20
|
-
# ordinal number within the year.
|
20
|
+
# * Date.new takes integer year, month, and day-of-month:
|
21
21
|
#
|
22
|
-
#
|
22
|
+
# Date.new(1999, 12, 31) # => #<Date: 1999-12-31>
|
23
23
|
#
|
24
|
-
#
|
24
|
+
# * Date.ordinal takes integer year and day-of-year:
|
25
25
|
#
|
26
|
-
#
|
26
|
+
# Date.ordinal(1999, 365) # => #<Date: 1999-12-31>
|
27
27
|
#
|
28
|
-
#
|
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
|
-
#
|
30
|
+
# Date.jd(2451544) # => #<Date: 1999-12-31>
|
35
31
|
#
|
36
|
-
#
|
32
|
+
# * Date.commercial takes integer commercial data (year, week, day-of-week):
|
37
33
|
#
|
38
|
-
#
|
39
|
-
# January 1, 4713 BCE (in the Julian calendar).
|
34
|
+
# Date.commercial(1999, 52, 5) # => #<Date: 1999-12-31>
|
40
35
|
#
|
41
|
-
#
|
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
|
-
#
|
46
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
53
|
-
#
|
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
|
-
#
|
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
|
-
#
|
61
|
-
#
|
62
|
-
#
|
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
|
-
#
|
64
|
+
# When `limit` is:
|
65
65
|
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
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(
|
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)
|
101
|
+
# - Date._httpdate(string, limit: 128) -> hash
|
150
102
|
# -->
|
151
|
-
# Returns a hash of parsed
|
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
|
-
#
|
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)
|
117
|
+
# - Date._iso8601(string, limit: 128) -> hash
|
162
118
|
# -->
|
163
|
-
# Returns a hash of parsed
|
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
|
-
#
|
166
|
-
#
|
167
|
-
#
|
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)
|
135
|
+
# - Date._jisx0301(string, limit: 128) -> hash
|
174
136
|
# -->
|
175
|
-
# Returns a hash of parsed
|
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
|
-
#
|
178
|
-
#
|
179
|
-
#
|
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
|
152
|
+
# - Date._parse(string, comp = true, limit: 128) -> hash
|
186
153
|
# -->
|
187
|
-
#
|
188
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
201
|
-
#
|
202
|
-
#
|
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)
|
209
|
-
# - Date._rfc822(string, limit: 128) -> hash
|
179
|
+
# - Date._rfc2822(string, limit: 128) -> hash
|
210
180
|
# -->
|
211
|
-
# Returns a hash of parsed
|
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
|
-
#
|
214
|
-
#
|
215
|
-
#
|
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)
|
197
|
+
# - Date._rfc3339(string, limit: 128) -> hash
|
222
198
|
# -->
|
223
|
-
# Returns a hash of parsed
|
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
|
-
#
|
226
|
-
#
|
227
|
-
#
|
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)
|
234
|
-
# - Date._rfc822(string, limit: 128) -> hash
|
215
|
+
# - Date._rfc2822(string, limit: 128) -> hash
|
235
216
|
# -->
|
236
|
-
# Returns a hash of parsed
|
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
|
-
#
|
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
|
233
|
+
# - Date._strptime(string, format = '%F') -> hash
|
247
234
|
# -->
|
248
|
-
#
|
249
|
-
#
|
250
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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)
|
251
|
+
# - Date._xmlschema(string, limit: 128) -> hash
|
262
252
|
# -->
|
263
|
-
# Returns a hash of parsed
|
253
|
+
# Returns a hash of values parsed from `string`, which should be a valid XML
|
254
|
+
# date format:
|
264
255
|
#
|
265
|
-
#
|
266
|
-
#
|
267
|
-
#
|
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
|
-
# -
|
274
|
-
# - Date.new([year=-4712[, month=1[, mday=1[, start=Date::ITALY]]]]) -> date
|
268
|
+
# - civil(*args)
|
275
269
|
# -->
|
276
|
-
#
|
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(
|
276
|
+
# - Date.commercial(cwyear = -4712, cweek = 1, cwday = 1, start = Date::ITALY) -> date
|
301
277
|
# -->
|
302
|
-
#
|
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
|
-
#
|
305
|
-
#
|
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
|
-
#
|
309
|
-
#
|
310
|
-
#
|
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
|
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)
|
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
|
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
|
-
#
|
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'
|
335
|
+
# - Date.httpdate(string = 'Mon, 01 Jan -4712 00:00:00 GMT', start = Date::ITALY, limit: 128) -> date
|
332
336
|
# -->
|
333
|
-
#
|
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
|
-
#
|
337
|
-
# #=> #<Date: 2001-02-03 ...>
|
344
|
+
# See:
|
338
345
|
#
|
339
|
-
#
|
340
|
-
#
|
341
|
-
#
|
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'
|
355
|
+
# - Date.iso8601(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
|
348
356
|
# -->
|
349
|
-
#
|
350
|
-
# ISO 8601
|
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
|
-
#
|
353
|
-
# Date.iso8601('20010203') #=> #<Date: 2001-02-03 ...>
|
354
|
-
# Date.iso8601('2001-W05-6') #=> #<Date: 2001-02-03 ...>
|
365
|
+
# See:
|
355
366
|
#
|
356
|
-
#
|
357
|
-
#
|
358
|
-
#
|
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(
|
376
|
+
# - Date.jd(jd = 0, start = Date::ITALY) -> date
|
365
377
|
# -->
|
366
|
-
#
|
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
|
-
#
|
369
|
-
#
|
370
|
-
#
|
388
|
+
# Date::ITALY # => 2299161
|
389
|
+
# Date.jd(Date::ITALY).gregorian? # => true
|
390
|
+
# Date.jd(Date::ITALY + 1).gregorian? # => true
|
371
391
|
#
|
372
|
-
#
|
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'
|
404
|
+
# - Date.jisx0301(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
|
379
405
|
# -->
|
380
|
-
#
|
381
|
-
# JIS X 0301
|
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.
|
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')
|
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
|
-
#
|
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)
|
429
|
+
# - Date.julian_leap?(year) -> true or false
|
398
430
|
# -->
|
399
|
-
# Returns true if the given year is a leap year
|
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)
|
403
|
-
# Date.julian_leap?(1901)
|
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)
|
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
|
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
|
-
#
|
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(
|
459
|
+
# - Date.ordinal(year = -4712, yday = 1, start = Date::ITALY) -> date
|
423
460
|
# -->
|
424
|
-
#
|
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
|
-
#
|
427
|
-
#
|
469
|
+
# Date.ordinal(2001).to_s # => "2001-01-01"
|
470
|
+
# Date.ordinal(-2001).to_s # => "-2001-01-01"
|
428
471
|
#
|
429
|
-
#
|
430
|
-
#
|
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
|
-
#
|
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'
|
491
|
+
# - Date.parse(string = '-4712-01-01', comp = true, start = Date::ITALY, limit: 128) -> date
|
440
492
|
# -->
|
441
|
-
#
|
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
|
-
#
|
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
|
-
#
|
448
|
-
#
|
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
|
-
#
|
451
|
-
#
|
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
|
-
#
|
455
|
-
#
|
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
|
-
|
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'
|
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
|
-
#
|
466
|
-
# RFC 2822
|
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
|
-
#
|
469
|
-
# #=> #<Date: 2001-02-03 ...>
|
532
|
+
# See:
|
470
533
|
#
|
471
|
-
#
|
472
|
-
#
|
473
|
-
#
|
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'
|
543
|
+
# - Date.rfc3339(string = '-4712-01-01T00:00:00+00:00', start = Date::ITALY, limit: 128) -> date
|
480
544
|
# -->
|
481
|
-
#
|
482
|
-
# RFC 3339
|
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
|
-
#
|
554
|
+
# * Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
|
555
|
+
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
485
556
|
#
|
486
|
-
#
|
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'
|
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
|
-
#
|
498
|
-
# RFC 2822
|
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
|
-
#
|
501
|
-
#
|
575
|
+
# * Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
|
576
|
+
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
502
577
|
#
|
503
|
-
#
|
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(
|
584
|
+
# - Date.strptime(string = '-4712-01-01', format = '%F', start = Date::ITALY) -> date
|
512
585
|
# -->
|
513
|
-
#
|
514
|
-
#
|
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')
|
518
|
-
# Date.strptime('03-02-2001', '%d-%m-%Y')
|
519
|
-
# Date.strptime('2001-034', '%Y-%j')
|
520
|
-
# Date.strptime('2001-W05-6', '%G-W%V-%u')
|
521
|
-
# Date.strptime('2001 04 6', '%Y %U %w')
|
522
|
-
# Date.strptime('2001 05 6', '%Y %W %u')
|
523
|
-
# Date.strptime('sat3feb01', '%a%d%b%y')
|
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
|
-
#
|
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(
|
611
|
+
# - Date.today(start = Date::ITALY) -> date
|
532
612
|
# -->
|
533
|
-
#
|
613
|
+
# Returns a new Date object constructed from the present date:
|
534
614
|
#
|
535
|
-
# Date.today
|
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
|
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
|
545
|
-
#
|
546
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
640
|
+
# - Date.valid_commercial?(cwyear, cweek, cwday, start = Date::ITALY) -> true or false
|
559
641
|
# -->
|
560
|
-
# Returns true if the
|
642
|
+
# Returns `true` if the arguments define a valid commercial date, `false`
|
643
|
+
# otherwise:
|
561
644
|
#
|
562
|
-
# Date.valid_commercial?(2001,5,6)
|
563
|
-
# Date.valid_commercial?(2001,5,8)
|
645
|
+
# Date.valid_commercial?(2001, 5, 6) # => true
|
646
|
+
# Date.valid_commercial?(2001, 5, 8) # => false
|
564
647
|
#
|
565
|
-
# See
|
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
|
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
|
575
|
-
#
|
576
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
675
|
+
# - Date.valid_jd?(jd, start = Date::ITALY) -> true
|
589
676
|
# -->
|
590
|
-
#
|
677
|
+
# Implemented for compatibility; returns `true` unless `jd` is invalid (i.e.,
|
678
|
+
# not a Numeric).
|
591
679
|
#
|
592
|
-
# Date.valid_jd?(2451944)
|
680
|
+
# Date.valid_jd?(2451944) # => true
|
593
681
|
#
|
594
|
-
# See
|
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
|
690
|
+
# - Date.valid_ordinal?(year, yday, start = Date::ITALY) -> true or false
|
601
691
|
# -->
|
602
|
-
# Returns true if the
|
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
|
-
#
|
605
|
-
# Date.valid_ordinal?(2001,366) #=> false
|
698
|
+
# See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
|
606
699
|
#
|
607
|
-
#
|
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'
|
706
|
+
# - Date.xmlschema(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
|
614
707
|
# -->
|
615
|
-
#
|
616
|
-
# XML
|
708
|
+
# Returns a new Date object with values parsed from `string`, which should be a
|
709
|
+
# valid XML date format:
|
617
710
|
#
|
618
|
-
# Date.
|
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
|
-
#
|
621
|
-
#
|
622
|
-
#
|
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
|
-
#
|
651
|
-
# If the other is a numeric value,
|
652
|
-
# before self.
|
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
|
671
|
-
# be a numeric
|
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)
|
674
|
-
# Date.new(2001,2,3)
|
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
|
677
|
-
#
|
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,
|
680
|
-
# Date.new(2001,3,31) <<
|
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
|
778
|
+
# This results in the following, possibly unexpected, behaviors:
|
683
779
|
#
|
684
|
-
# Date.new(2001,3,31)
|
685
|
-
#
|
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)
|
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
|
-
# -
|
792
|
+
# - self <=> other -> -1, 0, 1 or nil
|
694
793
|
# -->
|
695
|
-
# Compares
|
696
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
# -
|
833
|
+
# - self === other -> true, false, or nil.
|
711
834
|
# -->
|
712
|
-
# Returns true if
|
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
|
-
#
|
715
|
-
#
|
716
|
-
#
|
717
|
-
#
|
718
|
-
#
|
719
|
-
#
|
720
|
-
#
|
721
|
-
#
|
722
|
-
#
|
723
|
-
#
|
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
|
870
|
+
# - d >> n -> new_date
|
730
871
|
# -->
|
731
|
-
# Returns a
|
732
|
-
# be a numeric
|
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)
|
735
|
-
# Date.new(2001,2,3)
|
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
|
738
|
-
#
|
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,
|
741
|
-
# Date.new(2001,1,31) >>
|
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
|
884
|
+
# This results in the following, possibly unexpected, behaviors:
|
744
885
|
#
|
745
|
-
# Date.new(2001,1,31)
|
746
|
-
#
|
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)
|
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
|
-
# -
|
779
|
-
# - d.ctime -> string
|
922
|
+
# - asctime -> string
|
780
923
|
# -->
|
781
|
-
#
|
782
|
-
#
|
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
|
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
|
-
#
|
790
|
-
#
|
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
|
-
#
|
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
|
-
# -
|
947
|
+
# - cwday -> integer
|
799
948
|
# -->
|
800
|
-
# Returns the
|
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
|
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
|
-
# -
|
958
|
+
# - cweek -> integer
|
809
959
|
# -->
|
810
|
-
# Returns
|
960
|
+
# Returns commercial-date week index for `self` (see Date.commercial):
|
811
961
|
#
|
812
|
-
# Date.new(2001,2,3).cweek
|
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
|
-
# -
|
968
|
+
# - cwyear -> integer
|
819
969
|
# -->
|
820
|
-
# Returns
|
970
|
+
# Returns commercial-date year for `self` (see Date.commercial):
|
821
971
|
#
|
822
|
-
# Date.new(2001,2,3).cwyear
|
823
|
-
# Date.new(2000,1,1).cwyear
|
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
|
978
|
+
# Returns the day of the month in range (1..31):
|
829
979
|
#
|
830
|
-
# Date.new(2001,2,3).mday
|
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
|
-
# -
|
837
|
-
# - d.downto(min){|date| ...} -> self
|
986
|
+
# - deconstruct_keys(array_of_names_or_nil) -> hash
|
838
987
|
# -->
|
839
|
-
#
|
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
|
-
# -
|
1029
|
+
# - england -> new_date
|
847
1030
|
# -->
|
848
|
-
#
|
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
|
-
# -
|
1037
|
+
# - friday? -> true or false
|
855
1038
|
# -->
|
856
|
-
# Returns true if
|
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
|
-
# -
|
1045
|
+
# - gregorian -> new_date
|
863
1046
|
# -->
|
864
|
-
#
|
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
|
-
# -
|
1053
|
+
# - gregorian? -> true or false
|
871
1054
|
# -->
|
872
|
-
# Returns true if the date is on or after the
|
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?
|
875
|
-
# (Date.new(1582,10,15) - 1).gregorian?
|
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
|
-
# -
|
1065
|
+
# - httpdate -> string
|
882
1066
|
# -->
|
883
|
-
#
|
884
|
-
#
|
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
|
-
# -
|
1076
|
+
# - inspect -> string
|
891
1077
|
# -->
|
892
|
-
# Returns
|
1078
|
+
# Returns a string representation of `self`:
|
893
1079
|
#
|
894
|
-
# Date.new(2001,2,3).inspect
|
895
|
-
#
|
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
|
-
# -
|
904
|
-
# - d.xmlschema -> string
|
1087
|
+
# - iso8601 -> string
|
905
1088
|
# -->
|
906
|
-
#
|
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
|
-
# -
|
1099
|
+
# - italy -> new_date
|
913
1100
|
# -->
|
914
|
-
#
|
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
|
-
# -
|
1119
|
+
# - jisx0301 -> string
|
933
1120
|
# -->
|
934
|
-
# Returns a string in
|
1121
|
+
# Returns a string representation of the date in `self` in JIS X 0301 format.
|
935
1122
|
#
|
936
|
-
# Date.new(2001,2,3).jisx0301
|
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
|
-
# -
|
1129
|
+
# - julian -> new_date
|
943
1130
|
# -->
|
944
|
-
#
|
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?
|
1137
|
+
# - d.julian? -> true or false
|
951
1138
|
# -->
|
952
|
-
# Returns true if the date is before the
|
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?
|
955
|
-
#
|
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
|
-
# -
|
1149
|
+
# - ld -> integer
|
962
1150
|
# -->
|
963
|
-
# Returns the Lilian day number.
|
964
|
-
# the
|
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
|
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
|
-
# -
|
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?
|
977
|
-
# Date.new(2001).leap?
|
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
|
-
# -
|
984
|
-
# - d.day -> fixnum
|
1172
|
+
# - mday -> integer
|
985
1173
|
# -->
|
986
|
-
# Returns the day of the month (1
|
1174
|
+
# Returns the day of the month in range (1..31):
|
987
1175
|
#
|
988
|
-
# Date.new(2001,2,3).mday
|
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
|
-
# -
|
1007
|
-
# - d.month -> fixnum
|
1194
|
+
# - mon -> integer
|
1008
1195
|
# -->
|
1009
|
-
# Returns the month (1
|
1196
|
+
# Returns the month in range (1..12):
|
1010
1197
|
#
|
1011
|
-
# Date.new(2001,2,3).mon
|
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
|
-
# -
|
1204
|
+
# - monday? -> true or false
|
1018
1205
|
# -->
|
1019
|
-
# Returns true if
|
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
|
1211
|
+
# Returns the month in range (1..12):
|
1025
1212
|
#
|
1026
|
-
# Date.new(2001,2,3).mon
|
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
|
-
# -
|
1219
|
+
# - new_start(start = Date::ITALY]) -> new_date
|
1033
1220
|
# -->
|
1034
|
-
#
|
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
|
-
#
|
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.
|
1044
|
-
# - d.next -> date
|
1234
|
+
# - d.next -> new_date
|
1045
1235
|
# -->
|
1046
|
-
# Returns a
|
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
|
-
# -
|
1246
|
+
# - next_day(n = 1) -> new_date
|
1053
1247
|
# -->
|
1054
|
-
#
|
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
|
-
# -
|
1254
|
+
# - next_month(n = 1) -> new_date
|
1061
1255
|
# -->
|
1062
|
-
#
|
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
|
-
# -
|
1262
|
+
# - next_year(n = 1) -> new_date
|
1071
1263
|
# -->
|
1072
|
-
#
|
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
|
-
# -
|
1270
|
+
# - prev_day(n = 1) -> new_date
|
1085
1271
|
# -->
|
1086
|
-
#
|
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
|
-
# -
|
1278
|
+
# - prev_month(n = 1) -> new_date
|
1093
1279
|
# -->
|
1094
|
-
#
|
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
|
-
# -
|
1286
|
+
# - prev_year(n = 1) -> new_date
|
1103
1287
|
# -->
|
1104
|
-
#
|
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
|
-
# -
|
1117
|
-
# - d.rfc822 -> string
|
1294
|
+
# - rfc2822 -> string
|
1118
1295
|
# -->
|
1119
|
-
#
|
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
|
-
# -
|
1305
|
+
# - rfc3339 -> string
|
1126
1306
|
# -->
|
1127
|
-
#
|
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
|
-
#
|
1133
|
-
# RFC 2822
|
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
|
-
#
|
1136
|
-
# #=> #<Date: 2001-02-03 ...>
|
1323
|
+
# See:
|
1137
1324
|
#
|
1138
|
-
#
|
1139
|
-
#
|
1140
|
-
#
|
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
|
-
# -
|
1334
|
+
# - saturday? -> true or false
|
1147
1335
|
# -->
|
1148
|
-
# Returns true if
|
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
|
-
# -
|
1342
|
+
# - start -> float
|
1155
1343
|
# -->
|
1156
|
-
# Returns the Julian
|
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)
|
1159
|
-
#
|
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
|
-
# -
|
1166
|
-
# - d.step(limit[, step=1]){|date| ...} -> self
|
1364
|
+
# - step(limit, step = 1){|date| ... } -> self
|
1167
1365
|
# -->
|
1168
|
-
#
|
1169
|
-
#
|
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
|
-
#
|
1172
|
-
#
|
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
|
-
# -
|
1180
|
-
# -->
|
1181
|
-
#
|
1182
|
-
#
|
1183
|
-
#
|
1184
|
-
#
|
1185
|
-
#
|
1186
|
-
#
|
1187
|
-
#
|
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
|
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
|
-
# -
|
1419
|
+
# - sunday? -> true or false
|
1358
1420
|
# -->
|
1359
|
-
# Returns true if
|
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
|
-
# -
|
1427
|
+
# - thursday? -> true or false
|
1366
1428
|
# -->
|
1367
|
-
# Returns true if
|
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
|
-
# -
|
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
|
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
|
-
# -
|
1453
|
+
# - to_s -> string
|
1390
1454
|
# -->
|
1391
|
-
# Returns a string
|
1392
|
-
#
|
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
|
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
|
-
# -
|
1465
|
+
# - to_time -> time
|
1401
1466
|
# -->
|
1402
|
-
# Returns a Time object
|
1403
|
-
#
|
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
|
-
# -
|
1477
|
+
# - tuesday? -> true or false
|
1410
1478
|
# -->
|
1411
|
-
# Returns true if
|
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
|
-
# -
|
1418
|
-
# - d.upto(max){|date| ...} -> self
|
1485
|
+
# - upto(max){|date| ... } -> self
|
1419
1486
|
# -->
|
1420
|
-
#
|
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
|
-
# -
|
1494
|
+
# - wday -> integer
|
1428
1495
|
# -->
|
1429
|
-
# Returns the day of week (0
|
1496
|
+
# Returns the day of week in range (0..6); Sunday is 0:
|
1430
1497
|
#
|
1431
|
-
# Date.new(2001,2,3).wday
|
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
|
-
# -
|
1504
|
+
# - wednesday? -> true or false
|
1438
1505
|
# -->
|
1439
|
-
# Returns true if
|
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
|
-
#
|
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
|
-
# -
|
1521
|
+
# - yday -> integer
|
1451
1522
|
# -->
|
1452
|
-
# Returns the day of the year (1
|
1523
|
+
# Returns the day of the year, in range (1..366):
|
1453
1524
|
#
|
1454
|
-
# Date.new(2001,2,3).yday
|
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
|
-
# -
|
1531
|
+
# - year -> integer
|
1461
1532
|
# -->
|
1462
|
-
# Returns the year
|
1533
|
+
# Returns the year:
|
1463
1534
|
#
|
1464
|
-
# Date.new(2001,2,3).year
|
1465
|
-
# (Date.new(1,1,1) - 1).year
|
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
|