rbs-relaxed 3.9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/dependabot.yml +22 -0
- data/.github/workflows/comments.yml +35 -0
- data/.github/workflows/dependabot.yml +30 -0
- data/.github/workflows/ruby.yml +82 -0
- data/.github/workflows/typecheck.yml +38 -0
- data/.github/workflows/windows.yml +43 -0
- data/.gitignore +23 -0
- data/.rubocop.yml +68 -0
- data/BSDL +22 -0
- data/CHANGELOG.md +1868 -0
- data/COPYING +56 -0
- data/README.md +203 -0
- data/Rakefile +417 -0
- data/Steepfile +44 -0
- data/config.yml +313 -0
- data/core/array.rbs +4062 -0
- data/core/basic_object.rbs +375 -0
- data/core/binding.rbs +150 -0
- data/core/builtin.rbs +277 -0
- data/core/class.rbs +220 -0
- data/core/comparable.rbs +171 -0
- data/core/complex.rbs +786 -0
- data/core/constants.rbs +96 -0
- data/core/data.rbs +415 -0
- data/core/dir.rbs +981 -0
- data/core/encoding.rbs +1371 -0
- data/core/enumerable.rbs +2405 -0
- data/core/enumerator/product.rbs +92 -0
- data/core/enumerator.rbs +630 -0
- data/core/env.rbs +6 -0
- data/core/errno.rbs +673 -0
- data/core/errors.rbs +760 -0
- data/core/exception.rbs +485 -0
- data/core/false_class.rbs +82 -0
- data/core/fiber.rbs +550 -0
- data/core/fiber_error.rbs +11 -0
- data/core/file.rbs +2936 -0
- data/core/file_test.rbs +331 -0
- data/core/float.rbs +1151 -0
- data/core/gc.rbs +644 -0
- data/core/global_variables.rbs +184 -0
- data/core/hash.rbs +1861 -0
- data/core/integer.rbs +1413 -0
- data/core/io/buffer.rbs +984 -0
- data/core/io/wait.rbs +70 -0
- data/core/io.rbs +3406 -0
- data/core/kernel.rbs +3096 -0
- data/core/marshal.rbs +207 -0
- data/core/match_data.rbs +635 -0
- data/core/math.rbs +729 -0
- data/core/method.rbs +386 -0
- data/core/module.rbs +1704 -0
- data/core/nil_class.rbs +209 -0
- data/core/numeric.rbs +818 -0
- data/core/object.rbs +110 -0
- data/core/object_space/weak_key_map.rbs +166 -0
- data/core/object_space.rbs +190 -0
- data/core/proc.rbs +868 -0
- data/core/process.rbs +2296 -0
- data/core/ractor.rbs +1068 -0
- data/core/random.rbs +237 -0
- data/core/range.rbs +1107 -0
- data/core/rational.rbs +531 -0
- data/core/rb_config.rbs +88 -0
- data/core/rbs/unnamed/argf.rbs +1229 -0
- data/core/rbs/unnamed/env_class.rbs +1209 -0
- data/core/rbs/unnamed/random.rbs +293 -0
- data/core/refinement.rbs +59 -0
- data/core/regexp.rbs +1930 -0
- data/core/ruby_vm.rbs +765 -0
- data/core/rubygems/basic_specification.rbs +6 -0
- data/core/rubygems/config_file.rbs +38 -0
- data/core/rubygems/dependency_installer.rbs +6 -0
- data/core/rubygems/errors.rbs +176 -0
- data/core/rubygems/installer.rbs +15 -0
- data/core/rubygems/path_support.rbs +6 -0
- data/core/rubygems/platform.rbs +7 -0
- data/core/rubygems/request_set.rbs +49 -0
- data/core/rubygems/requirement.rbs +148 -0
- data/core/rubygems/rubygems.rbs +1171 -0
- data/core/rubygems/source_list.rbs +15 -0
- data/core/rubygems/specification.rbs +23 -0
- data/core/rubygems/stream_ui.rbs +5 -0
- data/core/rubygems/uninstaller.rbs +10 -0
- data/core/rubygems/version.rbs +294 -0
- data/core/set.rbs +621 -0
- data/core/signal.rbs +100 -0
- data/core/string.rbs +3583 -0
- data/core/struct.rbs +667 -0
- data/core/symbol.rbs +475 -0
- data/core/thread.rbs +1765 -0
- data/core/thread_group.rbs +79 -0
- data/core/time.rbs +1762 -0
- data/core/trace_point.rbs +477 -0
- data/core/true_class.rbs +98 -0
- data/core/unbound_method.rbs +329 -0
- data/core/warning.rbs +87 -0
- data/docs/CONTRIBUTING.md +106 -0
- data/docs/architecture.md +110 -0
- data/docs/collection.md +192 -0
- data/docs/data_and_struct.md +86 -0
- data/docs/gem.md +57 -0
- data/docs/rbs_by_example.md +309 -0
- data/docs/repo.md +125 -0
- data/docs/sigs.md +167 -0
- data/docs/stdlib.md +147 -0
- data/docs/syntax.md +910 -0
- data/docs/tools.md +17 -0
- data/exe/rbs +7 -0
- data/ext/rbs_extension/extconf.rb +15 -0
- data/ext/rbs_extension/lexer.c +2728 -0
- data/ext/rbs_extension/lexer.h +179 -0
- data/ext/rbs_extension/lexer.re +147 -0
- data/ext/rbs_extension/lexstate.c +175 -0
- data/ext/rbs_extension/location.c +325 -0
- data/ext/rbs_extension/location.h +85 -0
- data/ext/rbs_extension/main.c +33 -0
- data/ext/rbs_extension/parser.c +2973 -0
- data/ext/rbs_extension/parser.h +18 -0
- data/ext/rbs_extension/parserstate.c +397 -0
- data/ext/rbs_extension/parserstate.h +163 -0
- data/ext/rbs_extension/rbs_extension.h +31 -0
- data/ext/rbs_extension/unescape.c +32 -0
- data/goodcheck.yml +91 -0
- data/include/rbs/constants.h +82 -0
- data/include/rbs/ruby_objs.h +72 -0
- data/include/rbs/util/rbs_constant_pool.h +219 -0
- data/include/rbs.h +7 -0
- data/lib/rbs/ancestor_graph.rb +92 -0
- data/lib/rbs/annotate/annotations.rb +199 -0
- data/lib/rbs/annotate/formatter.rb +92 -0
- data/lib/rbs/annotate/rdoc_annotator.rb +400 -0
- data/lib/rbs/annotate/rdoc_source.rb +131 -0
- data/lib/rbs/annotate.rb +8 -0
- data/lib/rbs/ast/annotation.rb +29 -0
- data/lib/rbs/ast/comment.rb +29 -0
- data/lib/rbs/ast/declarations.rb +467 -0
- data/lib/rbs/ast/directives.rb +49 -0
- data/lib/rbs/ast/members.rb +451 -0
- data/lib/rbs/ast/type_param.rb +225 -0
- data/lib/rbs/ast/visitor.rb +137 -0
- data/lib/rbs/buffer.rb +67 -0
- data/lib/rbs/builtin_names.rb +58 -0
- data/lib/rbs/cli/colored_io.rb +48 -0
- data/lib/rbs/cli/diff.rb +83 -0
- data/lib/rbs/cli/validate.rb +357 -0
- data/lib/rbs/cli.rb +1223 -0
- data/lib/rbs/collection/cleaner.rb +38 -0
- data/lib/rbs/collection/config/lockfile.rb +92 -0
- data/lib/rbs/collection/config/lockfile_generator.rb +218 -0
- data/lib/rbs/collection/config.rb +81 -0
- data/lib/rbs/collection/installer.rb +32 -0
- data/lib/rbs/collection/sources/base.rb +14 -0
- data/lib/rbs/collection/sources/git.rb +258 -0
- data/lib/rbs/collection/sources/local.rb +81 -0
- data/lib/rbs/collection/sources/rubygems.rb +48 -0
- data/lib/rbs/collection/sources/stdlib.rb +50 -0
- data/lib/rbs/collection/sources.rb +38 -0
- data/lib/rbs/collection.rb +16 -0
- data/lib/rbs/constant.rb +28 -0
- data/lib/rbs/definition.rb +401 -0
- data/lib/rbs/definition_builder/ancestor_builder.rb +620 -0
- data/lib/rbs/definition_builder/method_builder.rb +254 -0
- data/lib/rbs/definition_builder.rb +845 -0
- data/lib/rbs/diff.rb +125 -0
- data/lib/rbs/environment/use_map.rb +77 -0
- data/lib/rbs/environment.rb +829 -0
- data/lib/rbs/environment_loader.rb +173 -0
- data/lib/rbs/environment_walker.rb +155 -0
- data/lib/rbs/errors.rb +645 -0
- data/lib/rbs/factory.rb +18 -0
- data/lib/rbs/file_finder.rb +28 -0
- data/lib/rbs/location_aux.rb +138 -0
- data/lib/rbs/locator.rb +243 -0
- data/lib/rbs/method_type.rb +143 -0
- data/lib/rbs/namespace.rb +125 -0
- data/lib/rbs/parser/lex_result.rb +15 -0
- data/lib/rbs/parser/token.rb +23 -0
- data/lib/rbs/parser_aux.rb +114 -0
- data/lib/rbs/prototype/helpers.rb +140 -0
- data/lib/rbs/prototype/node_usage.rb +99 -0
- data/lib/rbs/prototype/rb.rb +840 -0
- data/lib/rbs/prototype/rbi.rb +641 -0
- 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 +667 -0
- data/lib/rbs/repository.rb +127 -0
- data/lib/rbs/resolver/constant_resolver.rb +219 -0
- data/lib/rbs/resolver/type_name_resolver.rb +91 -0
- data/lib/rbs/sorter.rb +198 -0
- data/lib/rbs/substitution.rb +83 -0
- data/lib/rbs/subtractor.rb +201 -0
- data/lib/rbs/test/errors.rb +80 -0
- data/lib/rbs/test/guaranteed.rb +30 -0
- data/lib/rbs/test/hook.rb +212 -0
- data/lib/rbs/test/observer.rb +19 -0
- data/lib/rbs/test/setup.rb +84 -0
- data/lib/rbs/test/setup_helper.rb +50 -0
- data/lib/rbs/test/tester.rb +167 -0
- data/lib/rbs/test/type_check.rb +435 -0
- data/lib/rbs/test.rb +112 -0
- data/lib/rbs/type_alias_dependency.rb +100 -0
- data/lib/rbs/type_alias_regularity.rb +126 -0
- data/lib/rbs/type_name.rb +109 -0
- data/lib/rbs/types.rb +1596 -0
- data/lib/rbs/unit_test/convertibles.rb +176 -0
- data/lib/rbs/unit_test/spy.rb +138 -0
- data/lib/rbs/unit_test/type_assertions.rb +347 -0
- data/lib/rbs/unit_test/with_aliases.rb +143 -0
- data/lib/rbs/unit_test.rb +6 -0
- data/lib/rbs/validator.rb +186 -0
- data/lib/rbs/variance_calculator.rb +189 -0
- data/lib/rbs/vendorer.rb +71 -0
- data/lib/rbs/version.rb +5 -0
- data/lib/rbs/writer.rb +424 -0
- data/lib/rbs.rb +94 -0
- data/lib/rdoc/discover.rb +20 -0
- data/lib/rdoc_plugin/parser.rb +163 -0
- data/rbs-relaxed.gemspec +48 -0
- data/schema/annotation.json +14 -0
- data/schema/comment.json +26 -0
- data/schema/decls.json +326 -0
- data/schema/function.json +87 -0
- data/schema/location.json +56 -0
- data/schema/members.json +266 -0
- data/schema/methodType.json +50 -0
- data/schema/typeParam.json +36 -0
- data/schema/types.json +317 -0
- data/sig/ancestor_builder.rbs +163 -0
- data/sig/ancestor_graph.rbs +60 -0
- data/sig/annotate/annotations.rbs +102 -0
- data/sig/annotate/formatter.rbs +24 -0
- data/sig/annotate/rdoc_annotater.rbs +82 -0
- data/sig/annotate/rdoc_source.rbs +30 -0
- data/sig/annotation.rbs +27 -0
- data/sig/buffer.rbs +32 -0
- data/sig/builtin_names.rbs +44 -0
- 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 +87 -0
- data/sig/collection/cleaner.rbs +13 -0
- data/sig/collection/config/lockfile.rbs +74 -0
- data/sig/collection/config/lockfile_generator.rbs +66 -0
- data/sig/collection/config.rbs +46 -0
- data/sig/collection/installer.rbs +17 -0
- data/sig/collection/sources.rbs +214 -0
- data/sig/collection.rbs +4 -0
- data/sig/comment.rbs +26 -0
- data/sig/constant.rbs +21 -0
- data/sig/declarations.rbs +267 -0
- data/sig/definition.rbs +173 -0
- data/sig/definition_builder.rbs +165 -0
- data/sig/diff.rbs +28 -0
- data/sig/directives.rbs +77 -0
- data/sig/environment.rbs +279 -0
- data/sig/environment_loader.rbs +111 -0
- data/sig/environment_walker.rbs +65 -0
- data/sig/errors.rbs +405 -0
- data/sig/factory.rbs +5 -0
- data/sig/file_finder.rbs +28 -0
- data/sig/location.rbs +110 -0
- data/sig/locator.rbs +58 -0
- data/sig/manifest.yaml +7 -0
- data/sig/members.rbs +258 -0
- data/sig/method_builder.rbs +84 -0
- data/sig/method_types.rbs +58 -0
- data/sig/namespace.rbs +146 -0
- data/sig/parser.rbs +100 -0
- data/sig/prototype/helpers.rbs +27 -0
- data/sig/prototype/node_usage.rbs +20 -0
- data/sig/prototype/rb.rbs +96 -0
- data/sig/prototype/rbi.rbs +75 -0
- data/sig/prototype/runtime.rbs +182 -0
- data/sig/rbs.rbs +21 -0
- data/sig/rdoc/rbs.rbs +67 -0
- data/sig/repository.rbs +85 -0
- data/sig/resolver/constant_resolver.rbs +92 -0
- data/sig/resolver/context.rbs +34 -0
- data/sig/resolver/type_name_resolver.rbs +35 -0
- data/sig/shims/bundler.rbs +38 -0
- data/sig/shims/enumerable.rbs +5 -0
- data/sig/shims/rubygems.rbs +19 -0
- data/sig/sorter.rbs +41 -0
- data/sig/substitution.rbs +48 -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 +53 -0
- data/sig/type_alias_regularity.rbs +98 -0
- data/sig/type_param.rbs +110 -0
- data/sig/typename.rbs +79 -0
- data/sig/types.rbs +579 -0
- data/sig/unit_test/convertibles.rbs +154 -0
- data/sig/unit_test/spy.rbs +30 -0
- data/sig/unit_test/type_assertions.rbs +196 -0
- data/sig/unit_test/with_aliases.rbs +136 -0
- data/sig/use_map.rbs +35 -0
- data/sig/util.rbs +9 -0
- data/sig/validator.rbs +63 -0
- data/sig/variance_calculator.rbs +87 -0
- data/sig/vendorer.rbs +51 -0
- data/sig/version.rbs +3 -0
- data/sig/visitor.rbs +47 -0
- data/sig/writer.rbs +127 -0
- data/src/constants.c +153 -0
- data/src/ruby_objs.c +795 -0
- data/src/util/rbs_constant_pool.c +342 -0
- data/stdlib/abbrev/0/abbrev.rbs +66 -0
- data/stdlib/abbrev/0/array.rbs +26 -0
- data/stdlib/base64/0/base64.rbs +355 -0
- data/stdlib/benchmark/0/benchmark.rbs +452 -0
- data/stdlib/bigdecimal/0/big_decimal.rbs +1629 -0
- data/stdlib/bigdecimal-math/0/big_math.rbs +119 -0
- data/stdlib/bigdecimal-math/0/manifest.yaml +2 -0
- data/stdlib/cgi/0/core.rbs +1285 -0
- data/stdlib/cgi/0/manifest.yaml +3 -0
- data/stdlib/coverage/0/coverage.rbs +263 -0
- data/stdlib/csv/0/csv.rbs +3776 -0
- data/stdlib/csv/0/manifest.yaml +3 -0
- data/stdlib/date/0/date.rbs +1585 -0
- data/stdlib/date/0/date_time.rbs +616 -0
- data/stdlib/date/0/time.rbs +26 -0
- data/stdlib/dbm/0/dbm.rbs +421 -0
- 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 +343 -0
- data/stdlib/digest/0/digest.rbs +577 -0
- data/stdlib/erb/0/erb.rbs +532 -0
- data/stdlib/etc/0/etc.rbs +865 -0
- data/stdlib/fileutils/0/fileutils.rbs +1734 -0
- data/stdlib/find/0/find.rbs +49 -0
- data/stdlib/forwardable/0/forwardable.rbs +268 -0
- data/stdlib/io-console/0/io-console.rbs +414 -0
- data/stdlib/ipaddr/0/ipaddr.rbs +428 -0
- data/stdlib/json/0/json.rbs +1916 -0
- data/stdlib/kconv/0/kconv.rbs +166 -0
- data/stdlib/logger/0/formatter.rbs +45 -0
- data/stdlib/logger/0/log_device.rbs +100 -0
- data/stdlib/logger/0/logger.rbs +796 -0
- data/stdlib/logger/0/manifest.yaml +2 -0
- data/stdlib/logger/0/period.rbs +17 -0
- data/stdlib/logger/0/severity.rbs +34 -0
- data/stdlib/minitest/0/kernel.rbs +42 -0
- data/stdlib/minitest/0/minitest/abstract_reporter.rbs +52 -0
- data/stdlib/minitest/0/minitest/assertion.rbs +17 -0
- data/stdlib/minitest/0/minitest/assertions.rbs +590 -0
- data/stdlib/minitest/0/minitest/backtrace_filter.rbs +23 -0
- data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
- data/stdlib/minitest/0/minitest/benchmark.rbs +259 -0
- data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
- 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/expectation.rbs +2 -0
- data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
- data/stdlib/minitest/0/minitest/guard.rbs +64 -0
- data/stdlib/minitest/0/minitest/mock.rbs +64 -0
- data/stdlib/minitest/0/minitest/parallel/executor.rbs +46 -0
- data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +5 -0
- data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
- data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
- data/stdlib/minitest/0/minitest/pride_io.rbs +62 -0
- data/stdlib/minitest/0/minitest/pride_lol.rbs +19 -0
- data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
- data/stdlib/minitest/0/minitest/reportable.rbs +53 -0
- data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
- data/stdlib/minitest/0/minitest/result.rbs +28 -0
- data/stdlib/minitest/0/minitest/runnable.rbs +163 -0
- data/stdlib/minitest/0/minitest/skip.rbs +6 -0
- data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
- data/stdlib/minitest/0/minitest/spec/dsl.rbs +129 -0
- data/stdlib/minitest/0/minitest/spec.rbs +11 -0
- data/stdlib/minitest/0/minitest/statistics_reporter.rbs +81 -0
- data/stdlib/minitest/0/minitest/summary_reporter.rbs +18 -0
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
- data/stdlib/minitest/0/minitest/test.rbs +69 -0
- data/stdlib/minitest/0/minitest/unexpected_error.rbs +12 -0
- data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
- data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
- data/stdlib/minitest/0/minitest/unit.rbs +4 -0
- data/stdlib/minitest/0/minitest.rbs +115 -0
- data/stdlib/monitor/0/monitor.rbs +363 -0
- data/stdlib/mutex_m/0/mutex_m.rbs +104 -0
- data/stdlib/net-http/0/manifest.yaml +3 -0
- data/stdlib/net-http/0/net-http.rbs +5552 -0
- 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 +402 -0
- data/stdlib/objspace/0/objspace.rbs +487 -0
- 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 +3 -0
- data/stdlib/openssl/0/openssl.rbs +12113 -0
- data/stdlib/optparse/0/optparse.rbs +1725 -0
- data/stdlib/pathname/0/pathname.rbs +1406 -0
- data/stdlib/pp/0/manifest.yaml +2 -0
- data/stdlib/pp/0/pp.rbs +300 -0
- data/stdlib/prettyprint/0/prettyprint.rbs +383 -0
- data/stdlib/pstore/0/pstore.rbs +603 -0
- data/stdlib/psych/0/core_ext.rbs +12 -0
- data/stdlib/psych/0/dbm.rbs +237 -0
- data/stdlib/psych/0/manifest.yaml +3 -0
- data/stdlib/psych/0/psych.rbs +402 -0
- data/stdlib/psych/0/store.rbs +59 -0
- data/stdlib/pty/0/pty.rbs +237 -0
- 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 +391 -0
- 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/manifest.yaml +3 -0
- data/stdlib/resolv/0/resolv.rbs +1830 -0
- data/stdlib/ripper/0/ripper.rbs +1648 -0
- data/stdlib/securerandom/0/securerandom.rbs +62 -0
- data/stdlib/shellwords/0/shellwords.rbs +229 -0
- data/stdlib/singleton/0/singleton.rbs +131 -0
- data/stdlib/socket/0/addrinfo.rbs +666 -0
- data/stdlib/socket/0/basic_socket.rbs +590 -0
- data/stdlib/socket/0/constants.rbs +2295 -0
- data/stdlib/socket/0/ip_socket.rbs +92 -0
- data/stdlib/socket/0/socket.rbs +4157 -0
- data/stdlib/socket/0/socket_error.rbs +5 -0
- data/stdlib/socket/0/tcp_server.rbs +192 -0
- data/stdlib/socket/0/tcp_socket.rbs +79 -0
- data/stdlib/socket/0/udp_socket.rbs +133 -0
- data/stdlib/socket/0/unix_server.rbs +169 -0
- data/stdlib/socket/0/unix_socket.rbs +172 -0
- data/stdlib/stringio/0/stringio.rbs +567 -0
- data/stdlib/strscan/0/string_scanner.rbs +1627 -0
- data/stdlib/tempfile/0/tempfile.rbs +479 -0
- data/stdlib/time/0/time.rbs +432 -0
- data/stdlib/timeout/0/timeout.rbs +81 -0
- data/stdlib/tmpdir/0/tmpdir.rbs +69 -0
- data/stdlib/tsort/0/cyclic.rbs +5 -0
- data/stdlib/tsort/0/interfaces.rbs +20 -0
- data/stdlib/tsort/0/tsort.rbs +409 -0
- data/stdlib/uri/0/common.rbs +582 -0
- data/stdlib/uri/0/file.rbs +118 -0
- data/stdlib/uri/0/ftp.rbs +13 -0
- data/stdlib/uri/0/generic.rbs +1108 -0
- data/stdlib/uri/0/http.rbs +104 -0
- data/stdlib/uri/0/https.rbs +14 -0
- data/stdlib/uri/0/ldap.rbs +230 -0
- data/stdlib/uri/0/ldaps.rbs +14 -0
- data/stdlib/uri/0/mailto.rbs +92 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +189 -0
- data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
- data/stdlib/uri/0/ws.rbs +13 -0
- data/stdlib/uri/0/wss.rbs +9 -0
- data/stdlib/yaml/0/manifest.yaml +2 -0
- data/stdlib/yaml/0/yaml.rbs +1 -0
- 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 +449 -0
- data/stdlib/zlib/0/zstream.rbs +200 -0
- metadata +532 -0
@@ -0,0 +1,1585 @@
|
|
1
|
+
# <!-- rdoc-file=ext/date/date_core.c -->
|
2
|
+
# Class Date provides methods for storing and manipulating calendar dates.
|
3
|
+
#
|
4
|
+
# Consider using [class Time](rdoc-ref:Time) instead of class Date if:
|
5
|
+
#
|
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).
|
9
|
+
#
|
10
|
+
# A Date object, once created, is immutable, and cannot be modified.
|
11
|
+
#
|
12
|
+
# ## Creating a Date
|
13
|
+
#
|
14
|
+
# You can create a date for the current date, using Date.today:
|
15
|
+
#
|
16
|
+
# Date.today # => #<Date: 1999-12-31>
|
17
|
+
#
|
18
|
+
# You can create a specific date from various combinations of arguments:
|
19
|
+
#
|
20
|
+
# * Date.new takes integer year, month, and day-of-month:
|
21
|
+
#
|
22
|
+
# Date.new(1999, 12, 31) # => #<Date: 1999-12-31>
|
23
|
+
#
|
24
|
+
# * Date.ordinal takes integer year and day-of-year:
|
25
|
+
#
|
26
|
+
# Date.ordinal(1999, 365) # => #<Date: 1999-12-31>
|
27
|
+
#
|
28
|
+
# * Date.jd takes integer Julian day:
|
29
|
+
#
|
30
|
+
# Date.jd(2451544) # => #<Date: 1999-12-31>
|
31
|
+
#
|
32
|
+
# * Date.commercial takes integer commercial data (year, week, day-of-week):
|
33
|
+
#
|
34
|
+
# Date.commercial(1999, 52, 5) # => #<Date: 1999-12-31>
|
35
|
+
#
|
36
|
+
# * Date.parse takes a string, which it parses heuristically:
|
37
|
+
#
|
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>
|
42
|
+
#
|
43
|
+
# * Date.strptime takes a date string and a format string, then parses the
|
44
|
+
# date string according to the format string:
|
45
|
+
#
|
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>
|
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)
|
57
|
+
#
|
58
|
+
# ## Argument `limit`
|
59
|
+
#
|
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
|
+
#
|
64
|
+
# When `limit` is:
|
65
|
+
#
|
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.
|
70
|
+
#
|
71
|
+
class Date
|
72
|
+
# <!--
|
73
|
+
# rdoc-file=ext/date/date_core.c
|
74
|
+
# - Date.new(year = -4712, month = 1, mday = 1, start = Date::ITALY) -> date
|
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.
|
94
|
+
#
|
95
|
+
def initialize: (?Integer year, ?Integer month, ?Integer mday, ?Integer start) -> void
|
96
|
+
|
97
|
+
include Comparable
|
98
|
+
|
99
|
+
# <!--
|
100
|
+
# rdoc-file=ext/date/date_core.c
|
101
|
+
# - Date._httpdate(string, limit: 128) -> hash
|
102
|
+
# -->
|
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}
|
110
|
+
#
|
111
|
+
# Related: Date.httpdate (returns a Date object).
|
112
|
+
#
|
113
|
+
def self._httpdate: (String str) -> Hash[Symbol, Integer]
|
114
|
+
|
115
|
+
# <!--
|
116
|
+
# rdoc-file=ext/date/date_core.c
|
117
|
+
# - Date._iso8601(string, limit: 128) -> hash
|
118
|
+
# -->
|
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):
|
122
|
+
#
|
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).
|
130
|
+
#
|
131
|
+
def self._iso8601: (String str) -> Hash[Symbol, Integer]
|
132
|
+
|
133
|
+
# <!--
|
134
|
+
# rdoc-file=ext/date/date_core.c
|
135
|
+
# - Date._jisx0301(string, limit: 128) -> hash
|
136
|
+
# -->
|
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}
|
143
|
+
#
|
144
|
+
# See argument [limit](rdoc-ref:Date@Argument+limit).
|
145
|
+
#
|
146
|
+
# Related: Date.jisx0301 (returns a Date object).
|
147
|
+
#
|
148
|
+
def self._jisx0301: (String str) -> Hash[Symbol, Integer]
|
149
|
+
|
150
|
+
# <!--
|
151
|
+
# rdoc-file=ext/date/date_core.c
|
152
|
+
# - Date._parse(string, comp = true, limit: 128) -> hash
|
153
|
+
# -->
|
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.
|
160
|
+
#
|
161
|
+
# Returns a hash of values parsed from `string`:
|
162
|
+
#
|
163
|
+
# Date._parse('2001-02-03') # => {:year=>2001, :mon=>2, :mday=>3}
|
164
|
+
#
|
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:
|
167
|
+
#
|
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).
|
174
|
+
#
|
175
|
+
def self._parse: (String str, ?boolish complete) -> Hash[Symbol, Integer]
|
176
|
+
|
177
|
+
# <!--
|
178
|
+
# rdoc-file=ext/date/date_core.c
|
179
|
+
# - Date._rfc2822(string, limit: 128) -> hash
|
180
|
+
# -->
|
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}
|
188
|
+
#
|
189
|
+
# See argument [limit](rdoc-ref:Date@Argument+limit).
|
190
|
+
#
|
191
|
+
# Related: Date.rfc2822 (returns a Date object).
|
192
|
+
#
|
193
|
+
def self._rfc2822: (String str) -> Hash[Symbol, Integer | String]
|
194
|
+
|
195
|
+
# <!--
|
196
|
+
# rdoc-file=ext/date/date_core.c
|
197
|
+
# - Date._rfc3339(string, limit: 128) -> hash
|
198
|
+
# -->
|
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}
|
206
|
+
#
|
207
|
+
# See argument [limit](rdoc-ref:Date@Argument+limit).
|
208
|
+
#
|
209
|
+
# Related: Date.rfc3339 (returns a Date object).
|
210
|
+
#
|
211
|
+
def self._rfc3339: (String str) -> Hash[Symbol, Integer | String]
|
212
|
+
|
213
|
+
# <!--
|
214
|
+
# rdoc-file=ext/date/date_core.c
|
215
|
+
# - Date._rfc2822(string, limit: 128) -> hash
|
216
|
+
# -->
|
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).
|
226
|
+
#
|
227
|
+
# Related: Date.rfc2822 (returns a Date object).
|
228
|
+
#
|
229
|
+
def self._rfc822: (String str) -> Hash[Symbol, Integer | String]
|
230
|
+
|
231
|
+
# <!--
|
232
|
+
# rdoc-file=ext/date/date_core.c
|
233
|
+
# - Date._strptime(string, format = '%F') -> hash
|
234
|
+
# -->
|
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.)
|
242
|
+
#
|
243
|
+
# See also [strptime(3)](https://man7.org/linux/man-pages/man3/strptime.3.html).
|
244
|
+
#
|
245
|
+
# Related: Date.strptime (returns a Date object).
|
246
|
+
#
|
247
|
+
def self._strptime: (String str, ?String format) -> Hash[Symbol, Integer]
|
248
|
+
|
249
|
+
# <!--
|
250
|
+
# rdoc-file=ext/date/date_core.c
|
251
|
+
# - Date._xmlschema(string, limit: 128) -> hash
|
252
|
+
# -->
|
253
|
+
# Returns a hash of values parsed from `string`, which should be a valid XML
|
254
|
+
# date format:
|
255
|
+
#
|
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).
|
263
|
+
#
|
264
|
+
def self._xmlschema: (String str) -> Hash[Symbol, Integer]
|
265
|
+
|
266
|
+
# <!--
|
267
|
+
# rdoc-file=ext/date/date_core.c
|
268
|
+
# - civil(*args)
|
269
|
+
# -->
|
270
|
+
# Same as Date.new.
|
271
|
+
#
|
272
|
+
def self.civil: (?Integer year, ?Integer month, ?Integer mday, ?Integer start) -> Date
|
273
|
+
|
274
|
+
# <!--
|
275
|
+
# rdoc-file=ext/date/date_core.c
|
276
|
+
# - Date.commercial(cwyear = -4712, cweek = 1, cwday = 1, start = Date::ITALY) -> date
|
277
|
+
# -->
|
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"
|
304
|
+
#
|
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
|
+
#
|
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
|
+
#
|
312
|
+
# See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
|
313
|
+
#
|
314
|
+
# Related: Date.jd, Date.new, Date.ordinal.
|
315
|
+
#
|
316
|
+
def self.commercial: (?Integer cwyear, ?Integer cweek, ?Integer cwday, ?Integer start) -> Date
|
317
|
+
|
318
|
+
# <!--
|
319
|
+
# rdoc-file=ext/date/date_core.c
|
320
|
+
# - Date.gregorian_leap?(year) -> true or false
|
321
|
+
# -->
|
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
|
328
|
+
#
|
329
|
+
# Related: Date.julian_leap?.
|
330
|
+
#
|
331
|
+
def self.gregorian_leap?: (Integer year) -> bool
|
332
|
+
|
333
|
+
# <!--
|
334
|
+
# rdoc-file=ext/date/date_core.c
|
335
|
+
# - Date.httpdate(string = 'Mon, 01 Jan -4712 00:00:00 GMT', start = Date::ITALY, limit: 128) -> date
|
336
|
+
# -->
|
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>
|
343
|
+
#
|
344
|
+
# See:
|
345
|
+
#
|
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).
|
350
|
+
#
|
351
|
+
def self.httpdate: (String str, ?Integer start) -> Date
|
352
|
+
|
353
|
+
# <!--
|
354
|
+
# rdoc-file=ext/date/date_core.c
|
355
|
+
# - Date.iso8601(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
|
356
|
+
# -->
|
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>
|
364
|
+
#
|
365
|
+
# See:
|
366
|
+
#
|
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).
|
371
|
+
#
|
372
|
+
def self.iso8601: (String str, ?Integer start) -> Date
|
373
|
+
|
374
|
+
# <!--
|
375
|
+
# rdoc-file=ext/date/date_core.c
|
376
|
+
# - Date.jd(jd = 0, start = Date::ITALY) -> date
|
377
|
+
# -->
|
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`:
|
387
|
+
#
|
388
|
+
# Date::ITALY # => 2299161
|
389
|
+
# Date.jd(Date::ITALY).gregorian? # => true
|
390
|
+
# Date.jd(Date::ITALY + 1).gregorian? # => true
|
391
|
+
#
|
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.
|
399
|
+
#
|
400
|
+
def self.jd: (Integer jd, ?Integer start) -> Date
|
401
|
+
|
402
|
+
# <!--
|
403
|
+
# rdoc-file=ext/date/date_core.c
|
404
|
+
# - Date.jisx0301(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
|
405
|
+
# -->
|
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):
|
409
|
+
#
|
410
|
+
# d = Date.new(2001, 2, 3)
|
411
|
+
# s = d.jisx0301 # => "H13.02.03"
|
412
|
+
# Date.jisx0301(s) # => #<Date: 2001-02-03>
|
413
|
+
#
|
414
|
+
# For no-era year, legacy format, Heisei is assumed.
|
415
|
+
#
|
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).
|
422
|
+
#
|
423
|
+
# Related: Date._jisx0301 (returns a hash).
|
424
|
+
#
|
425
|
+
def self.jisx0301: (String str, ?Integer start) -> Date
|
426
|
+
|
427
|
+
# <!--
|
428
|
+
# rdoc-file=ext/date/date_core.c
|
429
|
+
# - Date.julian_leap?(year) -> true or false
|
430
|
+
# -->
|
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:
|
434
|
+
#
|
435
|
+
# Date.julian_leap?(1900) # => true
|
436
|
+
# Date.julian_leap?(1901) # => false
|
437
|
+
#
|
438
|
+
# Related: Date.gregorian_leap?.
|
439
|
+
#
|
440
|
+
def self.julian_leap?: (Integer year) -> bool
|
441
|
+
|
442
|
+
# <!--
|
443
|
+
# rdoc-file=ext/date/date_core.c
|
444
|
+
# - Date.gregorian_leap?(year) -> true or false
|
445
|
+
# -->
|
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
|
452
|
+
#
|
453
|
+
# Related: Date.julian_leap?.
|
454
|
+
#
|
455
|
+
def self.leap?: (Integer year) -> bool
|
456
|
+
|
457
|
+
# <!--
|
458
|
+
# rdoc-file=ext/date/date_core.c
|
459
|
+
# - Date.ordinal(year = -4712, yday = 1, start = Date::ITALY) -> date
|
460
|
+
# -->
|
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:
|
468
|
+
#
|
469
|
+
# Date.ordinal(2001).to_s # => "2001-01-01"
|
470
|
+
# Date.ordinal(-2001).to_s # => "-2001-01-01"
|
471
|
+
#
|
472
|
+
# With positive argument `yday` == `n`, returns the date for the `nth` day of
|
473
|
+
# the given year:
|
474
|
+
#
|
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.
|
486
|
+
#
|
487
|
+
def self.ordinal: (?Integer year, ?Integer yday, ?Integer start) -> Date
|
488
|
+
|
489
|
+
# <!--
|
490
|
+
# rdoc-file=ext/date/date_core.c
|
491
|
+
# - Date.parse(string = '-4712-01-01', comp = true, start = Date::ITALY, limit: 128) -> date
|
492
|
+
# -->
|
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.
|
498
|
+
#
|
499
|
+
# Returns a new Date object with values parsed from `string`:
|
500
|
+
#
|
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>
|
504
|
+
#
|
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:
|
507
|
+
#
|
508
|
+
# Date.parse('01-02-03', true) # => #<Date: 2001-02-03>
|
509
|
+
# Date.parse('01-02-03', false) # => #<Date: 0001-02-03>
|
510
|
+
#
|
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
|
519
|
+
|
520
|
+
# <!--
|
521
|
+
# rdoc-file=ext/date/date_core.c
|
522
|
+
# - Date.rfc2822(string = 'Mon, 1 Jan -4712 00:00:00 +0000', start = Date::ITALY, limit: 128) -> date
|
523
|
+
# -->
|
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>
|
531
|
+
#
|
532
|
+
# See:
|
533
|
+
#
|
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).
|
538
|
+
#
|
539
|
+
def self.rfc2822: (String str, ?Integer start) -> Date
|
540
|
+
|
541
|
+
# <!--
|
542
|
+
# rdoc-file=ext/date/date_core.c
|
543
|
+
# - Date.rfc3339(string = '-4712-01-01T00:00:00+00:00', start = Date::ITALY, limit: 128) -> date
|
544
|
+
# -->
|
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:
|
553
|
+
#
|
554
|
+
# * Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
|
555
|
+
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
556
|
+
#
|
557
|
+
# Related: Date._rfc3339 (returns a hash).
|
558
|
+
#
|
559
|
+
def self.rfc3339: (String str, ?Integer start) -> Date
|
560
|
+
|
561
|
+
# <!--
|
562
|
+
# rdoc-file=ext/date/date_core.c
|
563
|
+
# - Date.rfc2822(string = 'Mon, 1 Jan -4712 00:00:00 +0000', start = Date::ITALY, limit: 128) -> date
|
564
|
+
# -->
|
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:
|
574
|
+
#
|
575
|
+
# * Argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
|
576
|
+
# * Argument [limit](rdoc-ref:Date@Argument+limit).
|
577
|
+
#
|
578
|
+
# Related: Date._rfc2822 (returns a hash).
|
579
|
+
#
|
580
|
+
def self.rfc822: (String str, ?Integer start) -> Date
|
581
|
+
|
582
|
+
# <!--
|
583
|
+
# rdoc-file=ext/date/date_core.c
|
584
|
+
# - Date.strptime(string = '-4712-01-01', format = '%F', start = Date::ITALY) -> date
|
585
|
+
# -->
|
586
|
+
# Returns a new Date object with values parsed from `string`, according to the
|
587
|
+
# given `format`:
|
588
|
+
#
|
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>
|
596
|
+
#
|
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).
|
606
|
+
#
|
607
|
+
def self.strptime: (String str, ?String format, ?Integer start) -> Date
|
608
|
+
|
609
|
+
# <!--
|
610
|
+
# rdoc-file=ext/date/date_core.c
|
611
|
+
# - Date.today(start = Date::ITALY) -> date
|
612
|
+
# -->
|
613
|
+
# Returns a new Date object constructed from the present date:
|
614
|
+
#
|
615
|
+
# Date.today.to_s # => "2022-07-06"
|
616
|
+
#
|
617
|
+
# See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
|
618
|
+
#
|
619
|
+
def self.today: (?Integer start) -> Date
|
620
|
+
|
621
|
+
# <!--
|
622
|
+
# rdoc-file=ext/date/date_core.c
|
623
|
+
# - Date.valid_civil?(year, month, mday, start = Date::ITALY) -> true or false
|
624
|
+
# -->
|
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
|
631
|
+
#
|
632
|
+
# See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
|
633
|
+
#
|
634
|
+
# Related: Date.jd, Date.new.
|
635
|
+
#
|
636
|
+
def self.valid_civil?: (Integer year, Integer month, Integer mday, ?Integer start) -> bool
|
637
|
+
|
638
|
+
# <!--
|
639
|
+
# rdoc-file=ext/date/date_core.c
|
640
|
+
# - Date.valid_commercial?(cwyear, cweek, cwday, start = Date::ITALY) -> true or false
|
641
|
+
# -->
|
642
|
+
# Returns `true` if the arguments define a valid commercial date, `false`
|
643
|
+
# otherwise:
|
644
|
+
#
|
645
|
+
# Date.valid_commercial?(2001, 5, 6) # => true
|
646
|
+
# Date.valid_commercial?(2001, 5, 8) # => false
|
647
|
+
#
|
648
|
+
# See Date.commercial.
|
649
|
+
#
|
650
|
+
# See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
|
651
|
+
#
|
652
|
+
# Related: Date.jd, Date.commercial.
|
653
|
+
#
|
654
|
+
def self.valid_commercial?: (Integer cwyear, Integer cweek, Integer cwday, ?Integer start) -> bool
|
655
|
+
|
656
|
+
# <!--
|
657
|
+
# rdoc-file=ext/date/date_core.c
|
658
|
+
# - Date.valid_civil?(year, month, mday, start = Date::ITALY) -> true or false
|
659
|
+
# -->
|
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
|
666
|
+
#
|
667
|
+
# See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
|
668
|
+
#
|
669
|
+
# Related: Date.jd, Date.new.
|
670
|
+
#
|
671
|
+
def self.valid_date?: (Integer year, Integer month, Integer mday, ?Integer start) -> bool
|
672
|
+
|
673
|
+
# <!--
|
674
|
+
# rdoc-file=ext/date/date_core.c
|
675
|
+
# - Date.valid_jd?(jd, start = Date::ITALY) -> true
|
676
|
+
# -->
|
677
|
+
# Implemented for compatibility; returns `true` unless `jd` is invalid (i.e.,
|
678
|
+
# not a Numeric).
|
679
|
+
#
|
680
|
+
# Date.valid_jd?(2451944) # => true
|
681
|
+
#
|
682
|
+
# See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
|
683
|
+
#
|
684
|
+
# Related: Date.jd.
|
685
|
+
#
|
686
|
+
def self.valid_jd?: (Integer jd, ?Integer start) -> bool
|
687
|
+
|
688
|
+
# <!--
|
689
|
+
# rdoc-file=ext/date/date_core.c
|
690
|
+
# - Date.valid_ordinal?(year, yday, start = Date::ITALY) -> true or false
|
691
|
+
# -->
|
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
|
697
|
+
#
|
698
|
+
# See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
|
699
|
+
#
|
700
|
+
# Related: Date.jd, Date.ordinal.
|
701
|
+
#
|
702
|
+
def self.valid_ordinal?: (Integer year, Integer yday, ?Integer start) -> bool
|
703
|
+
|
704
|
+
# <!--
|
705
|
+
# rdoc-file=ext/date/date_core.c
|
706
|
+
# - Date.xmlschema(string = '-4712-01-01', start = Date::ITALY, limit: 128) -> date
|
707
|
+
# -->
|
708
|
+
# Returns a new Date object with values parsed from `string`, which should be a
|
709
|
+
# valid XML date format:
|
710
|
+
#
|
711
|
+
# d = Date.new(2001, 2, 3)
|
712
|
+
# s = d.xmlschema # => "2001-02-03"
|
713
|
+
# Date.xmlschema(s) # => #<Date: 2001-02-03>
|
714
|
+
#
|
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).
|
721
|
+
#
|
722
|
+
def self.xmlschema: (String str, ?Integer start) -> Date
|
723
|
+
|
724
|
+
# <!--
|
725
|
+
# rdoc-file=ext/date/date_core.c
|
726
|
+
# - d + other -> date
|
727
|
+
# -->
|
728
|
+
# Returns a date object pointing `other` days after self. The other should be a
|
729
|
+
# numeric value. If the other is a fractional number, assumes its precision is
|
730
|
+
# at most nanosecond.
|
731
|
+
#
|
732
|
+
# Date.new(2001,2,3) + 1 #=> #<Date: 2001-02-04 ...>
|
733
|
+
# DateTime.new(2001,2,3) + Rational(1,2)
|
734
|
+
# #=> #<DateTime: 2001-02-03T12:00:00+00:00 ...>
|
735
|
+
# DateTime.new(2001,2,3) + Rational(-1,2)
|
736
|
+
# #=> #<DateTime: 2001-02-02T12:00:00+00:00 ...>
|
737
|
+
# DateTime.jd(0,12) + DateTime.new(2001,2,3).ajd
|
738
|
+
# #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
|
739
|
+
#
|
740
|
+
def +: (Numeric & _ToR other) -> Date
|
741
|
+
|
742
|
+
# <!--
|
743
|
+
# rdoc-file=ext/date/date_core.c
|
744
|
+
# - d - other -> date or rational
|
745
|
+
# -->
|
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.
|
750
|
+
#
|
751
|
+
# Date.new(2001,2,3) - 1 #=> #<Date: 2001-02-02 ...>
|
752
|
+
# DateTime.new(2001,2,3) - Rational(1,2)
|
753
|
+
# #=> #<DateTime: 2001-02-02T12:00:00+00:00 ...>
|
754
|
+
# Date.new(2001,2,3) - Date.new(2001)
|
755
|
+
# #=> (33/1)
|
756
|
+
# DateTime.new(2001,2,3) - DateTime.new(2001,2,2,12)
|
757
|
+
# #=> (1/2)
|
758
|
+
#
|
759
|
+
def -: (Numeric & _ToR other) -> Date
|
760
|
+
| (Date other) -> Rational
|
761
|
+
|
762
|
+
# <!--
|
763
|
+
# rdoc-file=ext/date/date_core.c
|
764
|
+
# - d << n -> date
|
765
|
+
# -->
|
766
|
+
# Returns a new Date object representing the date `n` months earlier; `n` should
|
767
|
+
# be a numeric:
|
768
|
+
#
|
769
|
+
# (Date.new(2001, 2, 3) << 1).to_s # => "2001-01-03"
|
770
|
+
# (Date.new(2001, 2, 3) << -2).to_s # => "2001-04-03"
|
771
|
+
#
|
772
|
+
# When the same day does not exist for the new month, the last day of that month
|
773
|
+
# is used instead:
|
774
|
+
#
|
775
|
+
# (Date.new(2001, 3, 31) << 1).to_s # => "2001-02-28"
|
776
|
+
# (Date.new(2001, 3, 31) << -6).to_s # => "2001-09-30"
|
777
|
+
#
|
778
|
+
# This results in the following, possibly unexpected, behaviors:
|
779
|
+
#
|
780
|
+
# d0 = Date.new(2001, 3, 31)
|
781
|
+
# d0 << 2 # => #<Date: 2001-01-31>
|
782
|
+
# d0 << 1 << 1 # => #<Date: 2001-01-28>
|
783
|
+
#
|
784
|
+
# d0 = Date.new(2001, 3, 31)
|
785
|
+
# d1 = d0 << 1 # => #<Date: 2001-02-28>
|
786
|
+
# d2 = d1 << -1 # => #<Date: 2001-03-28>
|
787
|
+
#
|
788
|
+
def <<: (Integer month) -> Date
|
789
|
+
|
790
|
+
# <!--
|
791
|
+
# rdoc-file=ext/date/date_core.c
|
792
|
+
# - self <=> other -> -1, 0, 1 or nil
|
793
|
+
# -->
|
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:
|
802
|
+
#
|
803
|
+
# * Another Date object:
|
804
|
+
#
|
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
|
828
|
+
#
|
829
|
+
def <=>: (untyped other) -> Integer?
|
830
|
+
|
831
|
+
# <!--
|
832
|
+
# rdoc-file=ext/date/date_core.c
|
833
|
+
# - self === other -> true, false, or nil.
|
834
|
+
# -->
|
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:
|
850
|
+
#
|
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
|
865
|
+
#
|
866
|
+
def ===: (Date other) -> bool
|
867
|
+
|
868
|
+
# <!--
|
869
|
+
# rdoc-file=ext/date/date_core.c
|
870
|
+
# - d >> n -> new_date
|
871
|
+
# -->
|
872
|
+
# Returns a new Date object representing the date `n` months later; `n` should
|
873
|
+
# be a numeric:
|
874
|
+
#
|
875
|
+
# (Date.new(2001, 2, 3) >> 1).to_s # => "2001-03-03"
|
876
|
+
# (Date.new(2001, 2, 3) >> -2).to_s # => "2000-12-03"
|
877
|
+
#
|
878
|
+
# When the same day does not exist for the new month, the last day of that month
|
879
|
+
# is used instead:
|
880
|
+
#
|
881
|
+
# (Date.new(2001, 1, 31) >> 1).to_s # => "2001-02-28"
|
882
|
+
# (Date.new(2001, 1, 31) >> -4).to_s # => "2000-09-30"
|
883
|
+
#
|
884
|
+
# This results in the following, possibly unexpected, behaviors:
|
885
|
+
#
|
886
|
+
# d0 = Date.new(2001, 1, 31)
|
887
|
+
# d1 = d0 >> 1 # => #<Date: 2001-02-28>
|
888
|
+
# d2 = d1 >> 1 # => #<Date: 2001-03-28>
|
889
|
+
#
|
890
|
+
# d0 = Date.new(2001, 1, 31)
|
891
|
+
# d1 = d0 >> 1 # => #<Date: 2001-02-28>
|
892
|
+
# d2 = d1 >> -1 # => #<Date: 2001-01-28>
|
893
|
+
#
|
894
|
+
def >>: (Integer month) -> Date
|
895
|
+
|
896
|
+
# <!--
|
897
|
+
# rdoc-file=ext/date/date_core.c
|
898
|
+
# - d.ajd -> rational
|
899
|
+
# -->
|
900
|
+
# Returns the astronomical Julian day number. This is a fractional number,
|
901
|
+
# which is not adjusted by the offset.
|
902
|
+
#
|
903
|
+
# DateTime.new(2001,2,3,4,5,6,'+7').ajd #=> (11769328217/4800)
|
904
|
+
# DateTime.new(2001,2,2,14,5,6,'-7').ajd #=> (11769328217/4800)
|
905
|
+
#
|
906
|
+
def ajd: () -> Rational
|
907
|
+
|
908
|
+
# <!--
|
909
|
+
# rdoc-file=ext/date/date_core.c
|
910
|
+
# - d.amjd -> rational
|
911
|
+
# -->
|
912
|
+
# Returns the astronomical modified Julian day number. This is a fractional
|
913
|
+
# number, which is not adjusted by the offset.
|
914
|
+
#
|
915
|
+
# DateTime.new(2001,2,3,4,5,6,'+7').amjd #=> (249325817/4800)
|
916
|
+
# DateTime.new(2001,2,2,14,5,6,'-7').amjd #=> (249325817/4800)
|
917
|
+
#
|
918
|
+
def amjd: () -> Rational
|
919
|
+
|
920
|
+
# <!--
|
921
|
+
# rdoc-file=ext/date/date_core.c
|
922
|
+
# - asctime -> string
|
923
|
+
# -->
|
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"
|
929
|
+
#
|
930
|
+
# See [asctime](https://linux.die.net/man/3/asctime).
|
931
|
+
#
|
932
|
+
def asctime: () -> String
|
933
|
+
|
934
|
+
# <!-- rdoc-file=ext/date/date_core.c -->
|
935
|
+
# Equivalent to #strftime with argument `'%a %b %e %T %Y'` (or its [shorthand
|
936
|
+
# form](rdoc-ref:strftime_formatting.rdoc@Shorthand+Conversion+Specifiers)
|
937
|
+
# `'%c'`):
|
938
|
+
#
|
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).
|
942
|
+
#
|
943
|
+
def ctime: () -> String
|
944
|
+
|
945
|
+
# <!--
|
946
|
+
# rdoc-file=ext/date/date_core.c
|
947
|
+
# - cwday -> integer
|
948
|
+
# -->
|
949
|
+
# Returns the commercial-date weekday index for `self` (see Date.commercial); 1
|
950
|
+
# is Monday:
|
951
|
+
#
|
952
|
+
# Date.new(2001, 2, 3).cwday # => 6
|
953
|
+
#
|
954
|
+
def cwday: () -> Integer
|
955
|
+
|
956
|
+
# <!--
|
957
|
+
# rdoc-file=ext/date/date_core.c
|
958
|
+
# - cweek -> integer
|
959
|
+
# -->
|
960
|
+
# Returns commercial-date week index for `self` (see Date.commercial):
|
961
|
+
#
|
962
|
+
# Date.new(2001, 2, 3).cweek # => 5
|
963
|
+
#
|
964
|
+
def cweek: () -> Integer
|
965
|
+
|
966
|
+
# <!--
|
967
|
+
# rdoc-file=ext/date/date_core.c
|
968
|
+
# - cwyear -> integer
|
969
|
+
# -->
|
970
|
+
# Returns commercial-date year for `self` (see Date.commercial):
|
971
|
+
#
|
972
|
+
# Date.new(2001, 2, 3).cwyear # => 2001
|
973
|
+
# Date.new(2000, 1, 1).cwyear # => 1999
|
974
|
+
#
|
975
|
+
def cwyear: () -> Integer
|
976
|
+
|
977
|
+
# <!-- rdoc-file=ext/date/date_core.c -->
|
978
|
+
# Returns the day of the month in range (1..31):
|
979
|
+
#
|
980
|
+
# Date.new(2001, 2, 3).mday # => 3
|
981
|
+
#
|
982
|
+
def day: () -> Integer
|
983
|
+
|
984
|
+
# <!--
|
985
|
+
# rdoc-file=ext/date/date_core.c
|
986
|
+
# - deconstruct_keys(array_of_names_or_nil) -> hash
|
987
|
+
# -->
|
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`.
|
1023
|
+
#
|
1024
|
+
def downto: (Date min) { (Date) -> untyped } -> Date
|
1025
|
+
| (Date min) -> Enumerator[Date, Date]
|
1026
|
+
|
1027
|
+
# <!--
|
1028
|
+
# rdoc-file=ext/date/date_core.c
|
1029
|
+
# - england -> new_date
|
1030
|
+
# -->
|
1031
|
+
# Equivalent to Date#new_start with argument Date::ENGLAND.
|
1032
|
+
#
|
1033
|
+
def england: () -> Date
|
1034
|
+
|
1035
|
+
# <!--
|
1036
|
+
# rdoc-file=ext/date/date_core.c
|
1037
|
+
# - friday? -> true or false
|
1038
|
+
# -->
|
1039
|
+
# Returns `true` if `self` is a Friday, `false` otherwise.
|
1040
|
+
#
|
1041
|
+
def friday?: () -> bool
|
1042
|
+
|
1043
|
+
# <!--
|
1044
|
+
# rdoc-file=ext/date/date_core.c
|
1045
|
+
# - gregorian -> new_date
|
1046
|
+
# -->
|
1047
|
+
# Equivalent to Date#new_start with argument Date::GREGORIAN.
|
1048
|
+
#
|
1049
|
+
def gregorian: () -> Date
|
1050
|
+
|
1051
|
+
# <!--
|
1052
|
+
# rdoc-file=ext/date/date_core.c
|
1053
|
+
# - gregorian? -> true or false
|
1054
|
+
# -->
|
1055
|
+
# Returns `true` if the date is on or after the date of calendar reform, `false`
|
1056
|
+
# otherwise:
|
1057
|
+
#
|
1058
|
+
# Date.new(1582, 10, 15).gregorian? # => true
|
1059
|
+
# (Date.new(1582, 10, 15) - 1).gregorian? # => false
|
1060
|
+
#
|
1061
|
+
def gregorian?: () -> bool
|
1062
|
+
|
1063
|
+
# <!--
|
1064
|
+
# rdoc-file=ext/date/date_core.c
|
1065
|
+
# - httpdate -> string
|
1066
|
+
# -->
|
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"
|
1071
|
+
#
|
1072
|
+
def httpdate: () -> String
|
1073
|
+
|
1074
|
+
# <!--
|
1075
|
+
# rdoc-file=ext/date/date_core.c
|
1076
|
+
# - inspect -> string
|
1077
|
+
# -->
|
1078
|
+
# Returns a string representation of `self`:
|
1079
|
+
#
|
1080
|
+
# Date.new(2001, 2, 3).inspect
|
1081
|
+
# # => "#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>"
|
1082
|
+
#
|
1083
|
+
def inspect: () -> String
|
1084
|
+
|
1085
|
+
# <!--
|
1086
|
+
# rdoc-file=ext/date/date_core.c
|
1087
|
+
# - iso8601 -> string
|
1088
|
+
# -->
|
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"
|
1094
|
+
#
|
1095
|
+
def iso8601: () -> String
|
1096
|
+
|
1097
|
+
# <!--
|
1098
|
+
# rdoc-file=ext/date/date_core.c
|
1099
|
+
# - italy -> new_date
|
1100
|
+
# -->
|
1101
|
+
# Equivalent to Date#new_start with argument Date::ITALY.
|
1102
|
+
#
|
1103
|
+
def italy: () -> Date
|
1104
|
+
|
1105
|
+
# <!--
|
1106
|
+
# rdoc-file=ext/date/date_core.c
|
1107
|
+
# - d.jd -> integer
|
1108
|
+
# -->
|
1109
|
+
# Returns the Julian day number. This is a whole number, which is adjusted by
|
1110
|
+
# the offset as the local time.
|
1111
|
+
#
|
1112
|
+
# DateTime.new(2001,2,3,4,5,6,'+7').jd #=> 2451944
|
1113
|
+
# DateTime.new(2001,2,3,4,5,6,'-7').jd #=> 2451944
|
1114
|
+
#
|
1115
|
+
def jd: () -> Integer
|
1116
|
+
|
1117
|
+
# <!--
|
1118
|
+
# rdoc-file=ext/date/date_core.c
|
1119
|
+
# - jisx0301 -> string
|
1120
|
+
# -->
|
1121
|
+
# Returns a string representation of the date in `self` in JIS X 0301 format.
|
1122
|
+
#
|
1123
|
+
# Date.new(2001, 2, 3).jisx0301 # => "H13.02.03"
|
1124
|
+
#
|
1125
|
+
def jisx0301: () -> String
|
1126
|
+
|
1127
|
+
# <!--
|
1128
|
+
# rdoc-file=ext/date/date_core.c
|
1129
|
+
# - julian -> new_date
|
1130
|
+
# -->
|
1131
|
+
# Equivalent to Date#new_start with argument Date::JULIAN.
|
1132
|
+
#
|
1133
|
+
def julian: () -> Date
|
1134
|
+
|
1135
|
+
# <!--
|
1136
|
+
# rdoc-file=ext/date/date_core.c
|
1137
|
+
# - d.julian? -> true or false
|
1138
|
+
# -->
|
1139
|
+
# Returns `true` if the date is before the date of calendar reform, `false`
|
1140
|
+
# otherwise:
|
1141
|
+
#
|
1142
|
+
# (Date.new(1582, 10, 15) - 1).julian? # => true
|
1143
|
+
# Date.new(1582, 10, 15).julian? # => false
|
1144
|
+
#
|
1145
|
+
def julian?: () -> bool
|
1146
|
+
|
1147
|
+
# <!--
|
1148
|
+
# rdoc-file=ext/date/date_core.c
|
1149
|
+
# - ld -> integer
|
1150
|
+
# -->
|
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.
|
1154
|
+
#
|
1155
|
+
# Date.new(2001, 2, 3).ld # => 152784
|
1156
|
+
#
|
1157
|
+
def ld: () -> Integer
|
1158
|
+
|
1159
|
+
# <!--
|
1160
|
+
# rdoc-file=ext/date/date_core.c
|
1161
|
+
# - leap? -> true or false
|
1162
|
+
# -->
|
1163
|
+
# Returns `true` if the year is a leap year, `false` otherwise:
|
1164
|
+
#
|
1165
|
+
# Date.new(2000).leap? # => true
|
1166
|
+
# Date.new(2001).leap? # => false
|
1167
|
+
#
|
1168
|
+
def leap?: () -> bool
|
1169
|
+
|
1170
|
+
# <!--
|
1171
|
+
# rdoc-file=ext/date/date_core.c
|
1172
|
+
# - mday -> integer
|
1173
|
+
# -->
|
1174
|
+
# Returns the day of the month in range (1..31):
|
1175
|
+
#
|
1176
|
+
# Date.new(2001, 2, 3).mday # => 3
|
1177
|
+
#
|
1178
|
+
def mday: () -> Integer
|
1179
|
+
|
1180
|
+
# <!--
|
1181
|
+
# rdoc-file=ext/date/date_core.c
|
1182
|
+
# - d.mjd -> integer
|
1183
|
+
# -->
|
1184
|
+
# Returns the modified Julian day number. This is a whole number, which is
|
1185
|
+
# adjusted by the offset as the local time.
|
1186
|
+
#
|
1187
|
+
# DateTime.new(2001,2,3,4,5,6,'+7').mjd #=> 51943
|
1188
|
+
# DateTime.new(2001,2,3,4,5,6,'-7').mjd #=> 51943
|
1189
|
+
#
|
1190
|
+
def mjd: () -> Integer
|
1191
|
+
|
1192
|
+
# <!--
|
1193
|
+
# rdoc-file=ext/date/date_core.c
|
1194
|
+
# - mon -> integer
|
1195
|
+
# -->
|
1196
|
+
# Returns the month in range (1..12):
|
1197
|
+
#
|
1198
|
+
# Date.new(2001, 2, 3).mon # => 2
|
1199
|
+
#
|
1200
|
+
def mon: () -> Integer
|
1201
|
+
|
1202
|
+
# <!--
|
1203
|
+
# rdoc-file=ext/date/date_core.c
|
1204
|
+
# - monday? -> true or false
|
1205
|
+
# -->
|
1206
|
+
# Returns `true` if `self` is a Monday, `false` otherwise.
|
1207
|
+
#
|
1208
|
+
def monday?: () -> bool
|
1209
|
+
|
1210
|
+
# <!-- rdoc-file=ext/date/date_core.c -->
|
1211
|
+
# Returns the month in range (1..12):
|
1212
|
+
#
|
1213
|
+
# Date.new(2001, 2, 3).mon # => 2
|
1214
|
+
#
|
1215
|
+
def month: () -> Integer
|
1216
|
+
|
1217
|
+
# <!--
|
1218
|
+
# rdoc-file=ext/date/date_core.c
|
1219
|
+
# - new_start(start = Date::ITALY]) -> new_date
|
1220
|
+
# -->
|
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
|
1227
|
+
#
|
1228
|
+
# See argument [start](rdoc-ref:date/calendars.rdoc@Argument+start).
|
1229
|
+
#
|
1230
|
+
def new_start: (?Integer start) -> Date
|
1231
|
+
|
1232
|
+
# <!--
|
1233
|
+
# rdoc-file=ext/date/date_core.c
|
1234
|
+
# - d.next -> new_date
|
1235
|
+
# -->
|
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"
|
1241
|
+
#
|
1242
|
+
def next: () -> Date
|
1243
|
+
|
1244
|
+
# <!--
|
1245
|
+
# rdoc-file=ext/date/date_core.c
|
1246
|
+
# - next_day(n = 1) -> new_date
|
1247
|
+
# -->
|
1248
|
+
# Equivalent to Date#+ with argument `n`.
|
1249
|
+
#
|
1250
|
+
def next_day: (?Integer day) -> Date
|
1251
|
+
|
1252
|
+
# <!--
|
1253
|
+
# rdoc-file=ext/date/date_core.c
|
1254
|
+
# - next_month(n = 1) -> new_date
|
1255
|
+
# -->
|
1256
|
+
# Equivalent to #>> with argument `n`.
|
1257
|
+
#
|
1258
|
+
def next_month: (?Integer month) -> Date
|
1259
|
+
|
1260
|
+
# <!--
|
1261
|
+
# rdoc-file=ext/date/date_core.c
|
1262
|
+
# - next_year(n = 1) -> new_date
|
1263
|
+
# -->
|
1264
|
+
# Equivalent to #>> with argument `n * 12`.
|
1265
|
+
#
|
1266
|
+
def next_year: (?Integer year) -> Date
|
1267
|
+
|
1268
|
+
# <!--
|
1269
|
+
# rdoc-file=ext/date/date_core.c
|
1270
|
+
# - prev_day(n = 1) -> new_date
|
1271
|
+
# -->
|
1272
|
+
# Equivalent to Date#- with argument `n`.
|
1273
|
+
#
|
1274
|
+
def prev_day: (?Integer day) -> Date
|
1275
|
+
|
1276
|
+
# <!--
|
1277
|
+
# rdoc-file=ext/date/date_core.c
|
1278
|
+
# - prev_month(n = 1) -> new_date
|
1279
|
+
# -->
|
1280
|
+
# Equivalent to #<< with argument `n`.
|
1281
|
+
#
|
1282
|
+
def prev_month: (?Integer month) -> Date
|
1283
|
+
|
1284
|
+
# <!--
|
1285
|
+
# rdoc-file=ext/date/date_core.c
|
1286
|
+
# - prev_year(n = 1) -> new_date
|
1287
|
+
# -->
|
1288
|
+
# Equivalent to #<< with argument `n * 12`.
|
1289
|
+
#
|
1290
|
+
def prev_year: (?Integer year) -> Date
|
1291
|
+
|
1292
|
+
# <!--
|
1293
|
+
# rdoc-file=ext/date/date_core.c
|
1294
|
+
# - rfc2822 -> string
|
1295
|
+
# -->
|
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"
|
1300
|
+
#
|
1301
|
+
def rfc2822: () -> String
|
1302
|
+
|
1303
|
+
# <!--
|
1304
|
+
# rdoc-file=ext/date/date_core.c
|
1305
|
+
# - rfc3339 -> string
|
1306
|
+
# -->
|
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"
|
1311
|
+
#
|
1312
|
+
def rfc3339: () -> String
|
1313
|
+
|
1314
|
+
# <!-- rdoc-file=ext/date/date_core.c -->
|
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>
|
1322
|
+
#
|
1323
|
+
# See:
|
1324
|
+
#
|
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).
|
1329
|
+
#
|
1330
|
+
def rfc822: () -> String
|
1331
|
+
|
1332
|
+
# <!--
|
1333
|
+
# rdoc-file=ext/date/date_core.c
|
1334
|
+
# - saturday? -> true or false
|
1335
|
+
# -->
|
1336
|
+
# Returns `true` if `self` is a Saturday, `false` otherwise.
|
1337
|
+
#
|
1338
|
+
def saturday?: () -> bool
|
1339
|
+
|
1340
|
+
# <!--
|
1341
|
+
# rdoc-file=ext/date/date_core.c
|
1342
|
+
# - start -> float
|
1343
|
+
# -->
|
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"
|
1350
|
+
#
|
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).
|
1359
|
+
#
|
1360
|
+
def start: () -> Float
|
1361
|
+
|
1362
|
+
# <!--
|
1363
|
+
# rdoc-file=ext/date/date_core.c
|
1364
|
+
# - step(limit, step = 1){|date| ... } -> self
|
1365
|
+
# -->
|
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 }
|
1378
|
+
#
|
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.
|
1390
|
+
#
|
1391
|
+
def step: (Date limit, ?Integer step) { (Date) -> untyped } -> Date
|
1392
|
+
| (Date limit, ?Integer step) -> ::Enumerator[Date, Date]
|
1393
|
+
|
1394
|
+
# <!--
|
1395
|
+
# rdoc-file=ext/date/date_core.c
|
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).
|
1405
|
+
#
|
1406
|
+
def strftime: (?String format) -> String
|
1407
|
+
|
1408
|
+
# <!-- rdoc-file=ext/date/date_core.c -->
|
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"
|
1414
|
+
#
|
1415
|
+
def succ: () -> Date
|
1416
|
+
|
1417
|
+
# <!--
|
1418
|
+
# rdoc-file=ext/date/date_core.c
|
1419
|
+
# - sunday? -> true or false
|
1420
|
+
# -->
|
1421
|
+
# Returns `true` if `self` is a Sunday, `false` otherwise.
|
1422
|
+
#
|
1423
|
+
def sunday?: () -> bool
|
1424
|
+
|
1425
|
+
# <!--
|
1426
|
+
# rdoc-file=ext/date/date_core.c
|
1427
|
+
# - thursday? -> true or false
|
1428
|
+
# -->
|
1429
|
+
# Returns `true` if `self` is a Thursday, `false` otherwise.
|
1430
|
+
#
|
1431
|
+
def thursday?: () -> bool
|
1432
|
+
|
1433
|
+
# <!--
|
1434
|
+
# rdoc-file=ext/date/date_core.c
|
1435
|
+
# - to_date -> self
|
1436
|
+
# -->
|
1437
|
+
# Returns `self`.
|
1438
|
+
#
|
1439
|
+
def to_date: () -> Date
|
1440
|
+
|
1441
|
+
# <!--
|
1442
|
+
# rdoc-file=ext/date/date_core.c
|
1443
|
+
# - d.to_datetime -> datetime
|
1444
|
+
# -->
|
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>
|
1448
|
+
#
|
1449
|
+
def to_datetime: () -> DateTime
|
1450
|
+
|
1451
|
+
# <!--
|
1452
|
+
# rdoc-file=ext/date/date_core.c
|
1453
|
+
# - to_s -> string
|
1454
|
+
# -->
|
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'`):
|
1458
|
+
#
|
1459
|
+
# Date.new(2001, 2, 3).to_s # => "2001-02-03"
|
1460
|
+
#
|
1461
|
+
def to_s: () -> String
|
1462
|
+
|
1463
|
+
# <!--
|
1464
|
+
# rdoc-file=ext/date/date_core.c
|
1465
|
+
# - to_time -> time
|
1466
|
+
# -->
|
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
|
1472
|
+
#
|
1473
|
+
def to_time: () -> Time
|
1474
|
+
|
1475
|
+
# <!--
|
1476
|
+
# rdoc-file=ext/date/date_core.c
|
1477
|
+
# - tuesday? -> true or false
|
1478
|
+
# -->
|
1479
|
+
# Returns `true` if `self` is a Tuesday, `false` otherwise.
|
1480
|
+
#
|
1481
|
+
def tuesday?: () -> bool
|
1482
|
+
|
1483
|
+
# <!--
|
1484
|
+
# rdoc-file=ext/date/date_core.c
|
1485
|
+
# - upto(max){|date| ... } -> self
|
1486
|
+
# -->
|
1487
|
+
# Equivalent to #step with arguments `max` and `1`.
|
1488
|
+
#
|
1489
|
+
def upto: (Date max) { (Date) -> untyped } -> Date
|
1490
|
+
| (Date max) -> ::Enumerator[Date, Date]
|
1491
|
+
|
1492
|
+
# <!--
|
1493
|
+
# rdoc-file=ext/date/date_core.c
|
1494
|
+
# - wday -> integer
|
1495
|
+
# -->
|
1496
|
+
# Returns the day of week in range (0..6); Sunday is 0:
|
1497
|
+
#
|
1498
|
+
# Date.new(2001, 2, 3).wday # => 6
|
1499
|
+
#
|
1500
|
+
def wday: () -> Integer
|
1501
|
+
|
1502
|
+
# <!--
|
1503
|
+
# rdoc-file=ext/date/date_core.c
|
1504
|
+
# - wednesday? -> true or false
|
1505
|
+
# -->
|
1506
|
+
# Returns `true` if `self` is a Wednesday, `false` otherwise.
|
1507
|
+
#
|
1508
|
+
def wednesday?: () -> bool
|
1509
|
+
|
1510
|
+
# <!-- rdoc-file=ext/date/date_core.c -->
|
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"
|
1516
|
+
#
|
1517
|
+
def xmlschema: () -> String
|
1518
|
+
|
1519
|
+
# <!--
|
1520
|
+
# rdoc-file=ext/date/date_core.c
|
1521
|
+
# - yday -> integer
|
1522
|
+
# -->
|
1523
|
+
# Returns the day of the year, in range (1..366):
|
1524
|
+
#
|
1525
|
+
# Date.new(2001, 2, 3).yday # => 34
|
1526
|
+
#
|
1527
|
+
def yday: () -> Integer
|
1528
|
+
|
1529
|
+
# <!--
|
1530
|
+
# rdoc-file=ext/date/date_core.c
|
1531
|
+
# - year -> integer
|
1532
|
+
# -->
|
1533
|
+
# Returns the year:
|
1534
|
+
#
|
1535
|
+
# Date.new(2001, 2, 3).year # => 2001
|
1536
|
+
# (Date.new(1, 1, 1) - 1).year # => 0
|
1537
|
+
#
|
1538
|
+
def year: () -> Integer
|
1539
|
+
end
|
1540
|
+
|
1541
|
+
# <!-- rdoc-file=ext/date/date_core.c -->
|
1542
|
+
# An array of strings of abbreviated day names in English. The first is "Sun".
|
1543
|
+
#
|
1544
|
+
Date::ABBR_DAYNAMES: Array[String]
|
1545
|
+
|
1546
|
+
# <!-- rdoc-file=ext/date/date_core.c -->
|
1547
|
+
# An array of strings of abbreviated month names in English. The first element
|
1548
|
+
# is nil.
|
1549
|
+
#
|
1550
|
+
Date::ABBR_MONTHNAMES: Array[String?]
|
1551
|
+
|
1552
|
+
# <!-- rdoc-file=ext/date/date_core.c -->
|
1553
|
+
# An array of strings of the full names of days of the week in English. The
|
1554
|
+
# first is "Sunday".
|
1555
|
+
#
|
1556
|
+
Date::DAYNAMES: Array[String]
|
1557
|
+
|
1558
|
+
# <!-- rdoc-file=ext/date/date_core.c -->
|
1559
|
+
# The Julian day number of the day of calendar reform for England and her
|
1560
|
+
# colonies.
|
1561
|
+
#
|
1562
|
+
Date::ENGLAND: Integer
|
1563
|
+
|
1564
|
+
# <!-- rdoc-file=ext/date/date_core.c -->
|
1565
|
+
# The Julian day number of the day of calendar reform for the proleptic
|
1566
|
+
# Gregorian calendar.
|
1567
|
+
#
|
1568
|
+
Date::GREGORIAN: Integer
|
1569
|
+
|
1570
|
+
# <!-- rdoc-file=ext/date/date_core.c -->
|
1571
|
+
# The Julian day number of the day of calendar reform for Italy and some
|
1572
|
+
# catholic countries.
|
1573
|
+
#
|
1574
|
+
Date::ITALY: Integer
|
1575
|
+
|
1576
|
+
# <!-- rdoc-file=ext/date/date_core.c -->
|
1577
|
+
# The Julian day number of the day of calendar reform for the proleptic Julian
|
1578
|
+
# calendar.
|
1579
|
+
#
|
1580
|
+
Date::JULIAN: Integer
|
1581
|
+
|
1582
|
+
# <!-- rdoc-file=ext/date/date_core.c -->
|
1583
|
+
# An array of strings of full month names in English. The first element is nil.
|
1584
|
+
#
|
1585
|
+
Date::MONTHNAMES: Array[String?]
|