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