rbs 2.8.4 → 3.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +12 -4
- data/.github/workflows/comments.yml +11 -11
- data/.github/workflows/dependabot.yml +30 -0
- data/.github/workflows/ruby.yml +40 -49
- data/.github/workflows/typecheck.yml +36 -0
- data/.github/workflows/windows.yml +28 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +42 -2
- data/CHANGELOG.md +845 -1
- data/README.md +64 -4
- data/Rakefile +198 -18
- data/Steepfile +11 -11
- data/config.yml +311 -0
- data/core/array.rbs +2189 -1914
- data/core/basic_object.rbs +59 -84
- data/core/binding.rbs +7 -69
- data/core/builtin.rbs +210 -11
- data/core/class.rbs +37 -0
- data/core/comparable.rbs +23 -25
- data/core/complex.rbs +449 -227
- data/core/constants.rbs +29 -21
- data/core/data.rbs +415 -0
- data/core/dir.rbs +698 -415
- data/core/encoding.rbs +468 -843
- data/core/enumerable.rbs +495 -455
- data/core/enumerator/product.rbs +92 -0
- data/core/enumerator.rbs +106 -9
- data/core/env.rbs +1 -1
- data/core/errno.rbs +506 -605
- data/core/errors.rbs +15 -17
- data/core/exception.rbs +361 -145
- data/core/false_class.rbs +39 -26
- data/core/fiber.rbs +121 -14
- data/core/file.rbs +1262 -320
- data/core/file_test.rbs +62 -45
- data/core/float.rbs +187 -208
- data/core/gc.rbs +446 -196
- data/core/global_variables.rbs +29 -29
- data/core/hash.rbs +242 -349
- data/core/integer.rbs +246 -308
- data/core/io/buffer.rbs +373 -122
- data/core/io/wait.rbs +29 -17
- data/core/io.rbs +1881 -1518
- data/core/kernel.rbs +2116 -1538
- data/core/marshal.rbs +24 -14
- data/core/match_data.rbs +413 -166
- data/core/math.rbs +531 -291
- data/core/method.rbs +101 -32
- data/core/module.rbs +228 -64
- data/core/nil_class.rbs +106 -47
- data/core/numeric.rbs +206 -292
- data/core/object.rbs +73 -1168
- data/core/object_space/weak_key_map.rbs +166 -0
- data/core/object_space.rbs +5 -3
- data/core/proc.rbs +280 -39
- data/core/process.rbs +1318 -658
- data/core/ractor.rbs +200 -134
- data/core/random.rbs +21 -4
- data/core/range.rbs +309 -153
- data/core/rational.rbs +4 -12
- data/core/rb_config.rbs +64 -43
- data/core/rbs/unnamed/argf.rbs +411 -147
- data/core/rbs/unnamed/env_class.rbs +137 -253
- data/core/rbs/unnamed/random.rbs +49 -26
- data/core/refinement.rbs +16 -1
- data/core/regexp.rbs +1568 -862
- data/core/ruby_vm.rbs +719 -7
- data/core/rubygems/config_file.rbs +3 -0
- data/core/rubygems/errors.rbs +69 -6
- data/core/rubygems/rubygems.rbs +71 -17
- data/core/rubygems/version.rbs +11 -7
- data/{stdlib/set/0 → core}/set.rbs +80 -91
- data/core/signal.rbs +14 -8
- data/core/string.rbs +1732 -1607
- data/core/struct.rbs +467 -95
- data/core/symbol.rbs +215 -245
- data/core/thread.rbs +133 -89
- data/core/thread_group.rbs +9 -9
- data/core/time.rbs +1141 -841
- data/core/trace_point.rbs +181 -121
- data/core/true_class.rbs +58 -32
- data/core/unbound_method.rbs +103 -30
- data/core/warning.rbs +50 -5
- data/docs/CONTRIBUTING.md +1 -1
- data/docs/architecture.md +110 -0
- data/docs/collection.md +59 -5
- data/docs/data_and_struct.md +86 -0
- data/docs/gem.md +57 -0
- data/docs/rbs_by_example.md +16 -35
- data/docs/repo.md +1 -1
- data/docs/sigs.md +7 -7
- data/docs/stdlib.md +63 -5
- data/docs/syntax.md +255 -61
- data/docs/tools.md +1 -0
- data/ext/rbs_extension/extconf.rb +10 -0
- data/ext/rbs_extension/lexer.c +1741 -1548
- data/ext/rbs_extension/lexer.h +11 -1
- data/ext/rbs_extension/lexer.re +12 -6
- data/ext/rbs_extension/lexstate.c +26 -3
- data/ext/rbs_extension/location.c +119 -111
- data/ext/rbs_extension/location.h +32 -7
- data/ext/rbs_extension/main.c +3 -0
- data/ext/rbs_extension/parser.c +883 -481
- data/ext/rbs_extension/parserstate.c +65 -25
- data/ext/rbs_extension/parserstate.h +13 -3
- data/ext/rbs_extension/rbs_extension.h +1 -10
- data/ext/rbs_extension/unescape.c +7 -47
- data/goodcheck.yml +2 -2
- data/{ext/rbs_extension → include/rbs}/constants.h +26 -15
- data/include/rbs/ruby_objs.h +72 -0
- data/include/rbs.h +7 -0
- data/lib/rbs/annotate/annotations.rb +3 -3
- data/lib/rbs/annotate/formatter.rb +13 -3
- data/lib/rbs/annotate/rdoc_annotator.rb +1 -1
- data/lib/rbs/annotate/rdoc_source.rb +12 -3
- data/lib/rbs/ast/declarations.rb +85 -2
- data/lib/rbs/ast/directives.rb +39 -0
- data/lib/rbs/ast/members.rb +49 -15
- data/lib/rbs/ast/type_param.rb +104 -15
- data/lib/rbs/ast/visitor.rb +137 -0
- data/lib/rbs/buffer.rb +5 -0
- data/lib/rbs/cli/colored_io.rb +48 -0
- data/lib/rbs/cli/diff.rb +83 -0
- data/lib/rbs/cli/validate.rb +356 -0
- data/lib/rbs/cli.rb +253 -143
- data/lib/rbs/collection/cleaner.rb +8 -1
- data/lib/rbs/collection/config/lockfile.rb +92 -0
- data/lib/rbs/collection/config/lockfile_generator.rb +154 -65
- data/lib/rbs/collection/config.rb +19 -46
- data/lib/rbs/collection/installer.rb +12 -13
- data/lib/rbs/collection/sources/base.rb +2 -2
- data/lib/rbs/collection/sources/git.rb +146 -69
- data/lib/rbs/collection/sources/local.rb +81 -0
- data/lib/rbs/collection/sources/rubygems.rb +10 -12
- data/lib/rbs/collection/sources/stdlib.rb +14 -13
- data/lib/rbs/collection/sources.rb +15 -2
- data/lib/rbs/collection.rb +2 -1
- data/lib/rbs/definition.rb +13 -16
- data/lib/rbs/definition_builder/ancestor_builder.rb +100 -24
- data/lib/rbs/definition_builder/method_builder.rb +4 -4
- data/lib/rbs/definition_builder.rb +489 -584
- data/lib/rbs/diff.rb +125 -0
- data/lib/rbs/environment/use_map.rb +77 -0
- data/lib/rbs/environment.rb +406 -105
- data/lib/rbs/environment_loader.rb +48 -44
- data/lib/rbs/environment_walker.rb +1 -1
- data/lib/rbs/errors.rb +175 -56
- data/lib/rbs/file_finder.rb +28 -0
- data/lib/rbs/location_aux.rb +8 -7
- data/lib/rbs/locator.rb +37 -15
- data/lib/rbs/method_type.rb +23 -0
- data/lib/rbs/namespace.rb +1 -0
- data/lib/rbs/parser/lex_result.rb +15 -0
- data/lib/rbs/parser/token.rb +23 -0
- data/lib/rbs/parser_aux.rb +22 -13
- data/lib/rbs/prototype/helpers.rb +48 -22
- data/lib/rbs/prototype/node_usage.rb +99 -0
- data/lib/rbs/prototype/rb.rb +125 -31
- data/lib/rbs/prototype/rbi.rb +49 -36
- data/lib/rbs/prototype/runtime/helpers.rb +59 -0
- data/lib/rbs/prototype/runtime/reflection.rb +19 -0
- data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
- data/lib/rbs/prototype/runtime.rb +273 -159
- data/lib/rbs/resolver/constant_resolver.rb +24 -8
- data/lib/rbs/resolver/type_name_resolver.rb +41 -7
- data/lib/rbs/sorter.rb +153 -123
- data/lib/rbs/substitution.rb +19 -0
- data/lib/rbs/subtractor.rb +201 -0
- data/lib/rbs/test/errors.rb +24 -11
- data/lib/rbs/test/guaranteed.rb +30 -0
- data/lib/rbs/test/hook.rb +45 -40
- data/lib/rbs/test/setup.rb +1 -1
- data/lib/rbs/test/tester.rb +1 -1
- data/lib/rbs/test/type_check.rb +120 -23
- data/lib/rbs/test.rb +6 -3
- data/lib/rbs/type_alias_dependency.rb +13 -3
- data/lib/rbs/type_alias_regularity.rb +21 -14
- data/lib/rbs/type_name.rb +18 -13
- data/lib/rbs/types.rb +352 -18
- data/lib/rbs/unit_test/convertibles.rb +176 -0
- data/lib/rbs/unit_test/spy.rb +136 -0
- data/lib/rbs/unit_test/type_assertions.rb +341 -0
- data/lib/rbs/unit_test/with_aliases.rb +143 -0
- data/lib/rbs/unit_test.rb +6 -0
- data/lib/rbs/validator.rb +55 -30
- data/lib/rbs/variance_calculator.rb +26 -23
- data/lib/rbs/vendorer.rb +3 -3
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +69 -22
- data/lib/rbs.rb +7 -2
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +5 -5
- data/rbs.gemspec +12 -2
- data/schema/decls.json +1 -1
- data/schema/members.json +15 -10
- data/sig/ancestor_builder.rbs +4 -0
- data/sig/ancestor_graph.rbs +22 -2
- data/sig/annotate/formatter.rbs +2 -2
- data/sig/annotate/rdoc_annotater.rbs +1 -1
- data/sig/cli/colored_io.rbs +15 -0
- data/sig/cli/diff.rbs +21 -0
- data/sig/cli/validate.rbs +43 -0
- data/sig/cli.rbs +4 -0
- data/sig/collection/config/lockfile.rbs +74 -0
- data/sig/collection/config/lockfile_generator.rbs +66 -0
- data/sig/collection/config.rbs +5 -48
- data/sig/collection/installer.rbs +1 -1
- data/sig/collection/sources.rbs +105 -33
- data/sig/constant.rbs +1 -1
- data/sig/declarations.rbs +42 -3
- data/sig/definition.rbs +26 -10
- data/sig/definition_builder.rbs +103 -81
- data/sig/diff.rbs +28 -0
- data/sig/directives.rbs +61 -0
- data/sig/environment.rbs +175 -29
- data/sig/environment_loader.rbs +20 -18
- data/sig/errors.rbs +123 -2
- data/sig/file_finder.rbs +28 -0
- data/sig/location.rbs +0 -3
- data/sig/locator.rbs +14 -2
- data/sig/manifest.yaml +0 -1
- data/sig/members.rbs +32 -9
- data/sig/method_types.rbs +10 -4
- data/sig/namespace.rbs +2 -3
- data/sig/parser.rbs +55 -16
- data/sig/prototype/helpers.rbs +4 -0
- data/sig/prototype/node_usage.rbs +20 -0
- data/sig/prototype/rb.rbs +10 -2
- data/sig/prototype/rbi.rbs +2 -0
- data/sig/prototype/runtime.rbs +182 -0
- data/sig/rbs.rbs +1 -1
- data/sig/rdoc/rbs.rbs +4 -0
- data/sig/repository.rbs +7 -5
- data/sig/resolver/constant_resolver.rbs +3 -4
- data/sig/resolver/context.rbs +1 -1
- data/sig/resolver/type_name_resolver.rbs +5 -1
- data/sig/shims/bundler.rbs +38 -0
- data/sig/shims/rubygems.rbs +19 -0
- data/sig/sorter.rbs +23 -5
- data/sig/substitution.rbs +6 -0
- data/sig/subtractor.rbs +37 -0
- data/sig/test/errors.rbs +52 -0
- data/sig/test/guranteed.rbs +9 -0
- data/sig/test/type_check.rbs +19 -0
- data/sig/test.rbs +82 -0
- data/sig/type_alias_dependency.rbs +31 -0
- data/sig/type_alias_regularity.rbs +12 -6
- data/sig/type_param.rbs +45 -9
- data/sig/typename.rbs +8 -5
- data/sig/types.rbs +119 -12
- data/sig/unit_test/convertibles.rbs +154 -0
- data/sig/unit_test/spy.rbs +28 -0
- data/sig/unit_test/type_assertions.rbs +194 -0
- data/sig/unit_test/with_aliases.rbs +136 -0
- data/sig/use_map.rbs +35 -0
- data/sig/validator.rbs +12 -5
- data/sig/variance_calculator.rbs +3 -1
- data/sig/vendorer.rbs +1 -1
- data/sig/visitor.rbs +47 -0
- data/sig/writer.rbs +6 -2
- data/src/constants.c +153 -0
- data/src/ruby_objs.c +793 -0
- data/stdlib/base64/0/base64.rbs +298 -45
- data/stdlib/benchmark/0/benchmark.rbs +12 -3
- data/stdlib/bigdecimal/0/big_decimal.rbs +62 -198
- data/stdlib/cgi/0/core.rbs +68 -15
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/coverage/0/coverage.rbs +50 -11
- data/stdlib/csv/0/csv.rbs +90 -119
- data/stdlib/csv/0/manifest.yaml +1 -0
- data/stdlib/date/0/date.rbs +806 -735
- data/stdlib/date/0/date_time.rbs +70 -211
- data/stdlib/dbm/0/dbm.rbs +0 -2
- data/stdlib/delegate/0/delegator.rbs +184 -0
- data/stdlib/delegate/0/kernel.rbs +47 -0
- data/stdlib/delegate/0/simple_delegator.rbs +96 -0
- data/stdlib/did_you_mean/0/did_you_mean.rbs +3 -8
- data/stdlib/digest/0/digest.rbs +48 -35
- data/stdlib/erb/0/erb.rbs +15 -39
- data/stdlib/etc/0/etc.rbs +174 -54
- data/stdlib/fileutils/0/fileutils.rbs +1234 -385
- data/stdlib/forwardable/0/forwardable.rbs +4 -4
- data/stdlib/io-console/0/io-console.rbs +82 -17
- data/stdlib/ipaddr/0/ipaddr.rbs +11 -6
- data/stdlib/json/0/json.rbs +434 -151
- data/stdlib/kconv/0/kconv.rbs +166 -0
- data/stdlib/logger/0/formatter.rbs +0 -2
- data/stdlib/logger/0/log_device.rbs +1 -3
- data/stdlib/logger/0/logger.rbs +465 -328
- data/stdlib/minitest/0/kernel.rbs +2 -2
- data/stdlib/minitest/0/minitest/abstract_reporter.rbs +4 -1
- data/stdlib/minitest/0/minitest/assertion.rbs +1 -0
- data/stdlib/minitest/0/minitest/assertions.rbs +58 -13
- data/stdlib/minitest/0/minitest/backtrace_filter.rbs +7 -0
- data/stdlib/minitest/0/minitest/bench_spec.rbs +8 -8
- data/stdlib/minitest/0/minitest/benchmark.rbs +17 -16
- data/stdlib/minitest/0/minitest/compress.rbs +13 -0
- data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
- data/stdlib/minitest/0/minitest/mock.rbs +9 -5
- data/stdlib/minitest/0/minitest/parallel/executor.rbs +4 -0
- data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +0 -1
- data/stdlib/minitest/0/minitest/pride_io.rbs +8 -0
- data/stdlib/minitest/0/minitest/pride_lol.rbs +2 -0
- data/stdlib/minitest/0/minitest/progress_reporter.rbs +1 -1
- data/stdlib/minitest/0/minitest/reportable.rbs +2 -0
- data/stdlib/minitest/0/minitest/runnable.rbs +33 -1
- data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +1 -1
- data/stdlib/minitest/0/minitest/spec/dsl.rbs +10 -6
- data/stdlib/minitest/0/minitest/spec.rbs +1 -1
- data/stdlib/minitest/0/minitest/statistics_reporter.rbs +5 -0
- data/stdlib/minitest/0/minitest/summary_reporter.rbs +0 -7
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +7 -7
- data/stdlib/minitest/0/minitest/test.rbs +7 -14
- data/stdlib/minitest/0/minitest/unexpected_error.rbs +2 -0
- data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
- data/stdlib/minitest/0/minitest/unit.rbs +1 -2
- data/stdlib/minitest/0/minitest.rbs +41 -892
- data/stdlib/monitor/0/monitor.rbs +91 -10
- data/stdlib/mutex_m/0/mutex_m.rbs +0 -2
- data/stdlib/net-http/0/manifest.yaml +1 -1
- data/stdlib/net-http/0/net-http.rbs +3858 -964
- data/stdlib/net-protocol/0/manifest.yaml +2 -0
- data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
- data/stdlib/net-smtp/0/manifest.yaml +2 -0
- data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
- data/stdlib/nkf/0/nkf.rbs +35 -5
- data/stdlib/objspace/0/objspace.rbs +40 -18
- data/stdlib/observable/0/observable.rbs +217 -0
- data/stdlib/open-uri/0/manifest.yaml +4 -0
- data/stdlib/open-uri/0/open-uri.rbs +393 -0
- data/stdlib/open3/0/open3.rbs +147 -0
- data/stdlib/openssl/0/manifest.yaml +1 -0
- data/stdlib/openssl/0/openssl.rbs +681 -316
- data/stdlib/optparse/0/optparse.rbs +100 -65
- data/stdlib/pathname/0/pathname.rbs +24 -15
- data/stdlib/pp/0/manifest.yaml +2 -0
- data/stdlib/pp/0/pp.rbs +300 -0
- data/stdlib/prettyprint/0/prettyprint.rbs +2 -6
- data/stdlib/pstore/0/pstore.rbs +370 -156
- data/stdlib/psych/0/core_ext.rbs +12 -0
- data/stdlib/{yaml → psych}/0/dbm.rbs +3 -3
- data/stdlib/psych/0/manifest.yaml +3 -0
- data/stdlib/psych/0/psych.rbs +402 -0
- data/stdlib/{yaml → psych}/0/store.rbs +2 -2
- data/stdlib/pty/0/pty.rbs +63 -11
- data/stdlib/rdoc/0/code_object.rbs +51 -0
- data/stdlib/rdoc/0/comment.rbs +59 -0
- data/stdlib/rdoc/0/context.rbs +153 -0
- data/stdlib/rdoc/0/markup.rbs +117 -0
- data/stdlib/rdoc/0/parser.rbs +56 -0
- data/stdlib/rdoc/0/rdoc.rbs +13 -380
- data/stdlib/rdoc/0/ri.rbs +17 -0
- data/stdlib/rdoc/0/store.rbs +48 -0
- data/stdlib/rdoc/0/top_level.rbs +97 -0
- data/stdlib/resolv/0/resolv.rbs +16 -79
- data/stdlib/ripper/0/ripper.rbs +1648 -0
- data/stdlib/securerandom/0/securerandom.rbs +7 -2
- data/stdlib/shellwords/0/shellwords.rbs +11 -12
- data/stdlib/singleton/0/singleton.rbs +0 -3
- data/stdlib/socket/0/addrinfo.rbs +13 -18
- data/stdlib/socket/0/basic_socket.rbs +5 -10
- data/stdlib/socket/0/ip_socket.rbs +0 -2
- data/stdlib/socket/0/socket.rbs +77 -46
- data/stdlib/socket/0/tcp_server.rbs +0 -5
- data/stdlib/socket/0/tcp_socket.rbs +36 -3
- data/stdlib/socket/0/udp_socket.rbs +4 -5
- data/stdlib/socket/0/unix_server.rbs +0 -5
- data/stdlib/socket/0/unix_socket.rbs +2 -4
- data/{core/string_io.rbs → stdlib/stringio/0/stringio.rbs} +188 -107
- data/stdlib/strscan/0/string_scanner.rbs +1269 -425
- data/stdlib/tempfile/0/tempfile.rbs +224 -61
- data/stdlib/time/0/time.rbs +48 -35
- data/stdlib/timeout/0/timeout.rbs +17 -8
- data/stdlib/tmpdir/0/tmpdir.rbs +10 -3
- data/stdlib/tsort/0/tsort.rbs +0 -4
- data/stdlib/uri/0/common.rbs +271 -144
- data/stdlib/uri/0/file.rbs +5 -0
- data/stdlib/uri/0/ftp.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +26 -22
- data/stdlib/uri/0/http.rbs +4 -4
- data/stdlib/uri/0/ldap.rbs +1 -1
- data/stdlib/uri/0/mailto.rbs +84 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
- data/stdlib/yaml/0/manifest.yaml +1 -2
- data/stdlib/yaml/0/yaml.rbs +1 -199
- data/stdlib/zlib/0/buf_error.rbs +10 -0
- data/stdlib/zlib/0/data_error.rbs +10 -0
- data/stdlib/zlib/0/deflate.rbs +210 -0
- data/stdlib/zlib/0/error.rbs +20 -0
- data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
- data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
- data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
- data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
- data/stdlib/zlib/0/gzip_file.rbs +156 -0
- data/stdlib/zlib/0/gzip_reader.rbs +293 -0
- data/stdlib/zlib/0/gzip_writer.rbs +166 -0
- data/stdlib/zlib/0/inflate.rbs +180 -0
- data/stdlib/zlib/0/mem_error.rbs +10 -0
- data/stdlib/zlib/0/need_dict.rbs +13 -0
- data/stdlib/zlib/0/stream_end.rbs +11 -0
- data/stdlib/zlib/0/stream_error.rbs +11 -0
- data/stdlib/zlib/0/version_error.rbs +11 -0
- data/stdlib/zlib/0/zlib.rbs +1 -3
- data/stdlib/zlib/0/zstream.rbs +200 -0
- data/templates/include/rbs/constants.h.erb +20 -0
- data/templates/include/rbs/ruby_objs.h.erb +10 -0
- data/templates/src/constants.c.erb +36 -0
- data/templates/src/ruby_objs.c.erb +27 -0
- data/templates/template.rb +122 -0
- metadata +136 -36
- data/Gemfile +0 -33
- data/Gemfile.lock +0 -118
- data/core/deprecated.rbs +0 -9
- data/ext/rbs_extension/constants.c +0 -135
- data/ext/rbs_extension/ruby_objs.c +0 -525
- data/ext/rbs_extension/ruby_objs.h +0 -43
- data/lib/rbs/constant_table.rb +0 -167
- data/lib/rbs/parser_compat/lexer_error.rb +0 -6
- data/lib/rbs/parser_compat/located_value.rb +0 -7
- data/lib/rbs/parser_compat/semantics_error.rb +0 -6
- data/lib/rbs/parser_compat/syntax_error.rb +0 -6
- data/lib/rbs/test/spy.rb +0 -6
- data/lib/rbs/type_name_resolver.rb +0 -67
- data/sig/constant_table.rbs +0 -30
- data/sig/shims/abstract_syntax_tree.rbs +0 -25
- data/sig/shims/pp.rbs +0 -3
- data/sig/shims/ripper.rbs +0 -8
- data/sig/shims.rbs +0 -69
- data/sig/type_name_resolver.rbs +0 -26
- data/stdlib/minitest/0/manifest.yaml +0 -2
- data/stdlib/prime/0/integer-extension.rbs +0 -41
- data/stdlib/prime/0/manifest.yaml +0 -2
- data/stdlib/prime/0/prime.rbs +0 -372
data/core/time.rbs
CHANGED
@@ -1,23 +1,91 @@
|
|
1
1
|
# <!-- rdoc-file=timev.rb -->
|
2
|
-
# Time
|
3
|
-
# number of seconds with subsecond since the *Epoch*, 1970-01-01 00:00:00 UTC.
|
2
|
+
# A `Time` object represents a date and time:
|
4
3
|
#
|
5
|
-
#
|
6
|
-
# Time) as equivalent. GMT is the older way of referring to these baseline times
|
7
|
-
# but persists in the names of calls on POSIX systems.
|
4
|
+
# Time.new(2000, 1, 1, 0, 0, 0) # => 2000-01-01 00:00:00 -0600
|
8
5
|
#
|
9
|
-
#
|
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:
|
10
9
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
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.
|
15
83
|
#
|
16
84
|
# ## Examples
|
17
85
|
#
|
18
86
|
# All of these examples were done using the EST timezone which is GMT-5.
|
19
87
|
#
|
20
|
-
# ### Creating a New Time Instance
|
88
|
+
# ### Creating a New `Time` Instance
|
21
89
|
#
|
22
90
|
# You can create a new instance of Time with Time.new. This will use the current
|
23
91
|
# system time. Time.now is an alias for this. You can also pass parts of the
|
@@ -34,7 +102,7 @@
|
|
34
102
|
#
|
35
103
|
# Time.new(2002, 10, 31, 2, 2, 2, "+02:00") #=> 2002-10-31 02:02:02 +0200
|
36
104
|
#
|
37
|
-
# Or a timezone object:
|
105
|
+
# Or [a timezone object](rdoc-ref:Time@Timezone+Objects):
|
38
106
|
#
|
39
107
|
# zone = timezone("Europe/Athens") # Eastern European Time, UTC+2
|
40
108
|
# Time.new(2002, 10, 31, 2, 2, 2, zone) #=> 2002-10-31 02:02:02 +0200
|
@@ -48,7 +116,7 @@
|
|
48
116
|
#
|
49
117
|
# Time.at(628232400) #=> 1989-11-28 00:00:00 -0500
|
50
118
|
#
|
51
|
-
# ### Working with an Instance of Time
|
119
|
+
# ### Working with an Instance of `Time`
|
52
120
|
#
|
53
121
|
# Once you have an instance of Time there is a multitude of things you can do
|
54
122
|
# with it. Below are some examples. For all of the following examples, we will
|
@@ -90,23 +158,19 @@
|
|
90
158
|
#
|
91
159
|
# ## What's Here
|
92
160
|
#
|
93
|
-
# First, what's elsewhere. Class Time
|
94
|
-
#
|
95
|
-
# * Inherits from [class
|
96
|
-
# Object](Object.html#class-Object-label-What-27s+Here).
|
97
|
-
# * Includes [module
|
98
|
-
# Comparable](Comparable.html#module-Comparable-label-What-27s+Here).
|
161
|
+
# First, what's elsewhere. Class `Time`:
|
99
162
|
#
|
163
|
+
# * Inherits from [class Object](rdoc-ref:Object@What-27s+Here).
|
164
|
+
# * Includes [module Comparable](rdoc-ref:Comparable@What-27s+Here).
|
100
165
|
#
|
101
|
-
# Here, class Time provides methods that are useful for:
|
102
|
-
#
|
103
|
-
# * [Creating \Time objects](#class-Time-label-Methods+for+Creating).
|
104
|
-
# * [Fetching \Time values](#class-Time-label-Methods+for+Fetching).
|
105
|
-
# * [Querying a \Time object](#class-Time-label-Methods+for+Querying).
|
106
|
-
# * [Comparing \Time objects](#class-Time-label-Methods+for+Comparing).
|
107
|
-
# * [Converting a \Time object](#class-Time-label-Methods+for+Converting).
|
108
|
-
# * [Rounding a \Time](#class-Time-label-Methods+for+Rounding).
|
166
|
+
# Here, class `Time` provides methods that are useful for:
|
109
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).
|
110
174
|
#
|
111
175
|
# ### Methods for Creating
|
112
176
|
#
|
@@ -118,9 +182,7 @@
|
|
118
182
|
# * ::at: Returns a new time based on seconds since epoch.
|
119
183
|
# * ::now: Returns a new time based on the current system time.
|
120
184
|
# * #+ (plus): Returns a new time increased by the given number of seconds.
|
121
|
-
# *
|
122
|
-
# decreased by the given number of seconds.
|
123
|
-
#
|
185
|
+
# * #- (minus): Returns a new time decreased by the given number of seconds.
|
124
186
|
#
|
125
187
|
# ### Methods for Fetching
|
126
188
|
#
|
@@ -146,7 +208,6 @@
|
|
146
208
|
# * #to_r: Returns the Rational number of seconds since epoch for the time.
|
147
209
|
# * #zone: Returns a string representation of the timezone of the time.
|
148
210
|
#
|
149
|
-
#
|
150
211
|
# ### Methods for Querying
|
151
212
|
#
|
152
213
|
# * #utc? (aliased as #gmt?): Returns whether the time is UTC.
|
@@ -160,13 +221,11 @@
|
|
160
221
|
# * #friday?: Returns whether time is a Friday.
|
161
222
|
# * #saturday?: Returns whether the time is a Saturday.
|
162
223
|
#
|
163
|
-
#
|
164
224
|
# ### Methods for Comparing
|
165
225
|
#
|
166
|
-
# *
|
226
|
+
# * #<=>: Compares `self` to another time.
|
167
227
|
# * #eql?: Returns whether the time is equal to another time.
|
168
228
|
#
|
169
|
-
#
|
170
229
|
# ### Methods for Converting
|
171
230
|
#
|
172
231
|
# * #asctime (aliased as #ctime): Returns the time as a string.
|
@@ -178,7 +237,8 @@
|
|
178
237
|
# * #getlocal: Returns a new time converted to local time.
|
179
238
|
# * #utc (aliased as #gmtime): Converts time to UTC in place.
|
180
239
|
# * #localtime: Converts time to local time in place.
|
181
|
-
#
|
240
|
+
# * #deconstruct_keys: Returns a hash of time components used in
|
241
|
+
# pattern-matching.
|
182
242
|
#
|
183
243
|
# ### Methods for Rounding
|
184
244
|
#
|
@@ -186,95 +246,273 @@
|
|
186
246
|
# * #ceil: Returns a new time with subseconds raised to a ceiling.
|
187
247
|
# * #floor: Returns a new time with subseconds lowered to a floor.
|
188
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`:
|
189
374
|
#
|
190
|
-
#
|
375
|
+
# Called when `Marshal.dump(t)` is invoked
|
191
376
|
#
|
192
|
-
#
|
193
|
-
#
|
377
|
+
# Argument
|
378
|
+
# : none.
|
194
379
|
#
|
195
|
-
#
|
196
|
-
#
|
197
|
-
# or Time-like object (not necessary to be the same class). The #zone of the
|
198
|
-
# result is just ignored. Time-like argument to these methods is similar to a
|
199
|
-
# Time object in UTC without subsecond; it has attribute readers for the parts,
|
200
|
-
# e.g. #year, #month, and so on, and epoch time readers, #to_i. The subsecond
|
201
|
-
# attributes are fixed as 0, and #utc_offset, #zone, #isdst, and their aliases
|
202
|
-
# are same as a Time object in UTC. Also #to_time, #+, and #- methods are
|
203
|
-
# defined.
|
380
|
+
# Returns
|
381
|
+
# : the string name of the timezone.
|
204
382
|
#
|
205
|
-
# The `name` method is used for marshaling. If this method is not defined on a
|
206
|
-
# timezone object, Time objects using that timezone object can not be dumped by
|
207
|
-
# Marshal.
|
208
383
|
#
|
209
|
-
#
|
384
|
+
# #### `Time`-Like Objects
|
210
385
|
#
|
211
|
-
#
|
212
|
-
#
|
386
|
+
# A `Time`-like object is a container object capable of interfacing with
|
387
|
+
# timezone libraries for timezone conversion.
|
213
388
|
#
|
214
|
-
#
|
389
|
+
# The argument to the timezone conversion methods above will have attributes
|
390
|
+
# similar to Time, except that timezone related attributes are meaningless.
|
215
391
|
#
|
216
|
-
#
|
217
|
-
# object
|
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.
|
218
395
|
#
|
219
|
-
#
|
220
|
-
#
|
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.
|
221
436
|
#
|
222
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
|
+
|
223
458
|
include Comparable
|
224
459
|
|
225
460
|
# <!--
|
226
461
|
# rdoc-file=timev.rb
|
227
462
|
# - at(time, subsec = false, unit = :microsecond, in: nil)
|
228
463
|
# -->
|
229
|
-
#
|
230
|
-
#
|
231
|
-
#
|
232
|
-
#
|
233
|
-
#
|
234
|
-
#
|
235
|
-
#
|
236
|
-
#
|
237
|
-
#
|
238
|
-
#
|
239
|
-
#
|
240
|
-
#
|
241
|
-
#
|
242
|
-
# Time.at(
|
243
|
-
#
|
244
|
-
#
|
245
|
-
#
|
246
|
-
#
|
247
|
-
#
|
248
|
-
#
|
249
|
-
#
|
250
|
-
#
|
251
|
-
#
|
252
|
-
#
|
253
|
-
#
|
254
|
-
#
|
255
|
-
#
|
256
|
-
#
|
257
|
-
#
|
258
|
-
#
|
259
|
-
#
|
260
|
-
#
|
261
|
-
#
|
262
|
-
#
|
263
|
-
#
|
264
|
-
#
|
265
|
-
#
|
266
|
-
#
|
267
|
-
#
|
268
|
-
#
|
269
|
-
#
|
270
|
-
#
|
271
|
-
#
|
272
|
-
#
|
273
|
-
#
|
274
|
-
#
|
275
|
-
#
|
276
|
-
#
|
277
|
-
#
|
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).
|
278
516
|
#
|
279
517
|
def self.at: (Time, ?in: String | Integer | nil) -> Time
|
280
518
|
| (Numeric, ?in: String | Integer | nil) -> Time
|
@@ -282,60 +520,114 @@ class Time < Object
|
|
282
520
|
|
283
521
|
type subsec_unit = :msec | :millisecond | :usec | :microsecond | :nsec | :nanosecond
|
284
522
|
|
285
|
-
#
|
286
|
-
#
|
287
|
-
# field (and may be `nil` or omitted). Months may be specified by numbers from 1
|
288
|
-
# to 12, or by the three-letter English month names. Hours are specified on a
|
289
|
-
# 24-hour clock (0..23). Raises an ArgumentError if any values are out of range.
|
290
|
-
# Will also accept ten arguments in the order output by Time#to_a.
|
523
|
+
# <!-- rdoc-file=time.c -->
|
524
|
+
# Returns a new `Time` object based the on given arguments, in the UTC timezone.
|
291
525
|
#
|
292
|
-
#
|
526
|
+
# With one to seven arguments given, the arguments are interpreted as in the
|
527
|
+
# first calling sequence above:
|
293
528
|
#
|
294
|
-
# Time.utc(
|
295
|
-
# Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC
|
529
|
+
# Time.utc(year, month = 1, mday = 1, hour = 0, min = 0, sec = 0, usec = 0)
|
296
530
|
#
|
297
|
-
|
298
|
-
|
299
|
-
# <!--
|
300
|
-
# rdoc-file=time.c
|
301
|
-
# - Time.local(year, month=1, day=1, hour=0, min=0, sec_i=0, usec=0) -> new_time
|
302
|
-
# - Time.local(sec, min, hour, day, month, year, dummy, dummy, dummy, dummy) -> new_time
|
303
|
-
# -->
|
304
|
-
# Returns a new Time object based the on given arguments; its timezone is the
|
305
|
-
# local timezone.
|
531
|
+
# Examples:
|
306
532
|
#
|
307
|
-
#
|
533
|
+
# Time.utc(2000) # => 2000-01-01 00:00:00 UTC
|
534
|
+
# Time.utc(-2000) # => -2000-01-01 00:00:00 UTC
|
308
535
|
#
|
309
|
-
#
|
310
|
-
# Time.local(0, 1, 2, 3, 4, 5, 6.5) # => 0000-01-02 03:04:05.0000065 -0600
|
536
|
+
# There are no minimum and maximum values for the required argument `year`.
|
311
537
|
#
|
312
|
-
#
|
313
|
-
# ignored. This form is useful for creating a time from a 10-element array such
|
314
|
-
# as those returned by #to_a.
|
538
|
+
# For the optional arguments:
|
315
539
|
#
|
316
|
-
#
|
317
|
-
# p array # => [57, 26, 13, 24, 4, 2021, 6, 114, true, "Central Daylight Time"]
|
318
|
-
# array[5] = 2000
|
319
|
-
# Time.local(*array) # => 2000-04-24 13:26:57 -0500
|
540
|
+
# * `month`: Month in range (1..12), or case-insensitive 3-letter month name:
|
320
541
|
#
|
321
|
-
#
|
322
|
-
#
|
323
|
-
#
|
324
|
-
#
|
325
|
-
# * A 3-character string that matches regular expression
|
326
|
-
# `/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/i`.
|
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
|
327
546
|
#
|
328
|
-
# * `
|
329
|
-
# * `hour`: an integer hour in the range `0..23`.
|
330
|
-
# * `min`: an integer minute in the range `0..59`.
|
331
|
-
# * `isec_i` is the integer number of seconds in the range `0..60`.
|
332
|
-
# * `usec` is the number of microseconds (Integer, Float, or Rational) in the
|
333
|
-
# range `0..1000000`.
|
547
|
+
# * `mday`: Month day in range(1..31):
|
334
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
|
335
551
|
#
|
336
|
-
#
|
552
|
+
# * `hour`: Hour in range (0..23), or 24 if `min`, `sec`, and `usec` are zero:
|
337
553
|
#
|
338
|
-
#
|
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
|
339
631
|
#
|
340
632
|
def self.local: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
|
341
633
|
|
@@ -343,60 +635,110 @@ class Time < Object
|
|
343
635
|
# rdoc-file=timev.rb
|
344
636
|
# - now(in: nil)
|
345
637
|
# -->
|
346
|
-
# Creates a new Time object from the current system time. This is the same as
|
638
|
+
# Creates a new `Time` object from the current system time. This is the same as
|
347
639
|
# Time.new without arguments.
|
348
640
|
#
|
349
641
|
# Time.now # => 2009-06-24 12:39:54 +0900
|
350
642
|
# Time.now(in: '+04:00') # => 2009-06-24 07:39:54 +0400
|
351
643
|
#
|
352
|
-
#
|
353
|
-
#
|
354
|
-
# * A string offset from UTC.
|
355
|
-
# * A single letter offset from UTC, in the range `'A'..'Z'`, `'J'` (the
|
356
|
-
# so-called military timezone) excluded.
|
357
|
-
# * An integer number of seconds.
|
358
|
-
# * A timezone object; see [Timezone
|
359
|
-
# Argument](#class-Time-label-Timezone+Argument) for details.
|
644
|
+
# For forms of argument `zone`, see [Timezone
|
645
|
+
# Specifiers](rdoc-ref:Time@Timezone+Specifiers).
|
360
646
|
#
|
361
647
|
def self.now: (?in: String | Integer | nil) -> Time
|
362
648
|
|
363
649
|
# <!--
|
364
650
|
# rdoc-file=time.c
|
365
|
-
# - Time.utc(year, month=1,
|
366
|
-
# - Time.utc(
|
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
|
367
653
|
# -->
|
368
|
-
# Returns a new Time object based the on given arguments
|
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)
|
369
660
|
#
|
370
|
-
#
|
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:
|
371
705
|
#
|
372
|
-
#
|
373
|
-
#
|
706
|
+
# * Integers, as above.
|
707
|
+
# * Numerics convertible to integers:
|
374
708
|
#
|
375
|
-
#
|
376
|
-
#
|
377
|
-
# as is returned by #to_a.
|
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
|
378
711
|
#
|
379
|
-
#
|
380
|
-
# p array # => [57, 26, 13, 24, 4, 2021, 6, 114, true, "Central Daylight Time"]
|
381
|
-
# array[5] = 2000
|
382
|
-
# Time.utc(*array) # => 2000-04-24 13:26:57 UTC
|
712
|
+
# * String integers:
|
383
713
|
#
|
384
|
-
#
|
385
|
-
#
|
386
|
-
#
|
387
|
-
# * An integer month in the range `1..12`.
|
388
|
-
# * A 3-character string that matches regular expression
|
389
|
-
# `/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/i`.
|
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
|
390
717
|
#
|
391
|
-
#
|
392
|
-
#
|
393
|
-
# * `min`: an integer minute in the range `0..59`.
|
394
|
-
# * `isec_i` is the integer number of seconds in the range `0..60`.
|
395
|
-
# * `usec` is the number of microseconds (Integer, Float, or Rational) in the
|
396
|
-
# range `0..1000000`.
|
718
|
+
# When exactly ten arguments are given, the arguments are interpreted as in the
|
719
|
+
# second calling sequence above:
|
397
720
|
#
|
721
|
+
# Time.utc(sec, min, hour, mday, month, year, dummy, dummy, dummy, dummy)
|
398
722
|
#
|
399
|
-
#
|
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.
|
400
742
|
#
|
401
743
|
# Related: Time.local.
|
402
744
|
#
|
@@ -404,28 +746,37 @@ class Time < Object
|
|
404
746
|
|
405
747
|
# <!--
|
406
748
|
# rdoc-file=time.c
|
407
|
-
# -
|
749
|
+
# - self + numeric -> new_time
|
408
750
|
# -->
|
409
|
-
#
|
410
|
-
#
|
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
|
411
757
|
#
|
412
|
-
#
|
413
|
-
# t + (60 * 60 * 24) #=> 2020-07-21 22:14:43.170490982 +0900
|
758
|
+
# Related: Time#-.
|
414
759
|
#
|
415
760
|
def +: (Numeric arg0) -> Time
|
416
761
|
|
417
762
|
# <!--
|
418
763
|
# rdoc-file=time.c
|
419
|
-
# -
|
420
|
-
# -
|
764
|
+
# - self - numeric -> new_time
|
765
|
+
# - self - other_time -> float
|
421
766
|
# -->
|
422
|
-
#
|
423
|
-
#
|
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:
|
424
776
|
#
|
425
|
-
# t
|
426
|
-
#
|
427
|
-
#
|
428
|
-
# t2 - 2592000 #=> 2020-07-20 22:15:49.302766336 +0900
|
777
|
+
# t - t # => 0.0
|
778
|
+
#
|
779
|
+
# Related: Time#+.
|
429
780
|
#
|
430
781
|
def -: (Time arg0) -> Float
|
431
782
|
| (Numeric arg0) -> Time
|
@@ -436,27 +787,29 @@ class Time < Object
|
|
436
787
|
|
437
788
|
# <!--
|
438
789
|
# rdoc-file=time.c
|
439
|
-
# -
|
790
|
+
# - self <=> other_time -> -1, 0, +1, or nil
|
440
791
|
# -->
|
441
|
-
# Compares `
|
792
|
+
# Compares `self` with `other_time`; returns:
|
442
793
|
#
|
443
|
-
#
|
444
|
-
#
|
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.
|
445
798
|
#
|
446
|
-
#
|
799
|
+
# Examples:
|
447
800
|
#
|
448
|
-
# t = Time.now
|
449
|
-
# t2 = t + 2592000
|
450
|
-
# t <=> t2
|
451
|
-
# t2 <=> t
|
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
|
452
805
|
#
|
453
|
-
# t = Time.now
|
454
|
-
# t2 = t + 0.1
|
455
|
-
# t.nsec
|
456
|
-
# t2.nsec
|
457
|
-
# t <=> t2
|
458
|
-
# t2 <=> t
|
459
|
-
# t <=> t
|
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
|
460
813
|
#
|
461
814
|
def <=>: (Time other) -> Integer
|
462
815
|
| (untyped other) -> Integer?
|
@@ -466,895 +819,840 @@ class Time < Object
|
|
466
819
|
def >=: (Time arg0) -> bool
|
467
820
|
|
468
821
|
# <!-- rdoc-file=time.c -->
|
469
|
-
# Returns a
|
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:
|
470
832
|
#
|
471
|
-
#
|
472
|
-
#
|
833
|
+
# t.inspect # => "2000-12-31 23:59:59.5 +000001"
|
834
|
+
# t.to_s # => "2000-12-31 23:59:59 +0000"
|
473
835
|
#
|
474
836
|
def asctime: () -> String
|
475
837
|
|
476
838
|
# <!--
|
477
839
|
# rdoc-file=time.c
|
478
|
-
# -
|
479
|
-
# - time.ctime -> string
|
840
|
+
# - ctime -> string
|
480
841
|
# -->
|
481
|
-
# Returns a
|
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):
|
482
845
|
#
|
483
|
-
# Time.
|
484
|
-
#
|
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"
|
485
855
|
#
|
486
856
|
def ctime: () -> String
|
487
857
|
|
488
858
|
# <!-- rdoc-file=time.c -->
|
489
|
-
# Returns the day of the month (1..31)
|
859
|
+
# Returns the integer day of the month for `self`, in range (1..31):
|
490
860
|
#
|
491
|
-
# t = Time.
|
492
|
-
#
|
493
|
-
# t.mday
|
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.
|
494
866
|
#
|
495
867
|
def day: () -> Integer
|
496
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
|
+
|
497
904
|
# <!-- rdoc-file=time.c -->
|
498
|
-
# Returns `true` if
|
499
|
-
#
|
500
|
-
# #
|
501
|
-
#
|
502
|
-
#
|
503
|
-
#
|
504
|
-
#
|
505
|
-
#
|
506
|
-
# Time.local(2000, 7, 1).dst? #=> true
|
507
|
-
#
|
508
|
-
# # Asia/Tokyo:
|
509
|
-
# Time.local(2000, 1, 1).zone #=> "JST"
|
510
|
-
# Time.local(2000, 1, 1).isdst #=> false
|
511
|
-
# Time.local(2000, 1, 1).dst? #=> false
|
512
|
-
# Time.local(2000, 7, 1).zone #=> "JST"
|
513
|
-
# Time.local(2000, 7, 1).isdst #=> false
|
514
|
-
# Time.local(2000, 7, 1).dst? #=> false
|
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
|
515
913
|
#
|
516
914
|
def dst?: () -> bool
|
517
915
|
|
518
916
|
# <!--
|
519
917
|
# rdoc-file=time.c
|
520
|
-
# -
|
918
|
+
# - eql?(other_time)
|
521
919
|
# -->
|
522
|
-
# Returns `true` if
|
523
|
-
#
|
920
|
+
# Returns `true` if `self` and `other_time` are both `Time` objects with the
|
921
|
+
# exact same time value.
|
524
922
|
#
|
525
923
|
def eql?: (untyped arg0) -> bool
|
526
924
|
|
527
925
|
# <!--
|
528
926
|
# rdoc-file=time.c
|
529
|
-
# -
|
927
|
+
# - friday? -> true or false
|
530
928
|
# -->
|
531
|
-
# Returns `true` if
|
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
|
532
933
|
#
|
533
|
-
#
|
534
|
-
# t.friday? #=> true
|
934
|
+
# Related: Time#saturday?, Time#sunday?, Time#monday?.
|
535
935
|
#
|
536
936
|
def friday?: () -> bool
|
537
937
|
|
538
938
|
# <!--
|
539
939
|
# rdoc-file=time.c
|
540
|
-
# -
|
541
|
-
# - time.getutc -> new_time
|
940
|
+
# - getutc -> new_time
|
542
941
|
# -->
|
543
|
-
# Returns a new Time object representing
|
942
|
+
# Returns a new `Time` object representing the value of `self` converted to the
|
943
|
+
# UTC timezone:
|
544
944
|
#
|
545
|
-
#
|
546
|
-
#
|
547
|
-
#
|
548
|
-
#
|
549
|
-
#
|
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
|
550
950
|
#
|
551
951
|
def getgm: () -> Time
|
552
952
|
|
553
953
|
# <!--
|
554
954
|
# rdoc-file=time.c
|
555
|
-
# -
|
556
|
-
# - time.getlocal(utc_offset) -> new_time
|
557
|
-
# - time.getlocal(timezone) -> new_time
|
955
|
+
# - getlocal(zone = nil) -> new_time
|
558
956
|
# -->
|
559
|
-
# Returns a new Time object representing
|
560
|
-
#
|
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:
|
561
959
|
#
|
562
|
-
#
|
563
|
-
#
|
564
|
-
#
|
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
|
565
963
|
#
|
566
|
-
#
|
567
|
-
#
|
568
|
-
#
|
569
|
-
# l = t.getlocal #=> 2000-01-01 14:15:01 -0600
|
570
|
-
# l.utc? #=> false
|
571
|
-
# t == l #=> true
|
572
|
-
#
|
573
|
-
# j = t.getlocal("+09:00") #=> 2000-01-02 05:15:01 +0900
|
574
|
-
# j.utc? #=> false
|
575
|
-
# t == j #=> true
|
576
|
-
#
|
577
|
-
# k = t.getlocal(9*60*60) #=> 2000-01-02 05:15:01 +0900
|
578
|
-
# k.utc? #=> false
|
579
|
-
# t == k #=> true
|
964
|
+
# For forms of argument `zone`, see [Timezone
|
965
|
+
# Specifiers](rdoc-ref:Time@Timezone+Specifiers).
|
580
966
|
#
|
581
967
|
def getlocal: (?Integer utc_offset) -> Time
|
582
968
|
|
583
969
|
# <!-- rdoc-file=time.c -->
|
584
|
-
# Returns a new Time object representing
|
970
|
+
# Returns a new `Time` object representing the value of `self` converted to the
|
971
|
+
# UTC timezone:
|
585
972
|
#
|
586
|
-
#
|
587
|
-
#
|
588
|
-
#
|
589
|
-
#
|
590
|
-
#
|
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
|
591
978
|
#
|
592
979
|
def getutc: () -> Time
|
593
980
|
|
594
981
|
# <!-- rdoc-file=time.c -->
|
595
|
-
# Returns `true` if
|
982
|
+
# Returns `true` if `self` represents a time in UTC (GMT):
|
596
983
|
#
|
597
|
-
#
|
598
|
-
#
|
599
|
-
#
|
600
|
-
#
|
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
|
601
990
|
#
|
602
|
-
#
|
603
|
-
# t.gmt? #=> false
|
604
|
-
# t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
|
605
|
-
# t.gmt? #=> true
|
991
|
+
# Related: Time.utc.
|
606
992
|
#
|
607
993
|
def gmt?: () -> bool
|
608
994
|
|
609
995
|
# <!-- rdoc-file=time.c -->
|
610
|
-
# Returns the offset in seconds between the
|
996
|
+
# Returns the offset in seconds between the timezones of UTC and `self`:
|
611
997
|
#
|
612
|
-
#
|
613
|
-
#
|
614
|
-
# l = t.getlocal #=> 2000-01-01 14:15:01 -0600
|
615
|
-
# l.gmt_offset #=> -21600
|
998
|
+
# Time.utc(2000, 1, 1).utc_offset # => 0
|
999
|
+
# Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours.
|
616
1000
|
#
|
617
1001
|
def gmt_offset: () -> Integer
|
618
1002
|
|
619
1003
|
# <!--
|
620
1004
|
# rdoc-file=time.c
|
621
|
-
# -
|
622
|
-
# - time.utc -> time
|
1005
|
+
# - utc -> self
|
623
1006
|
# -->
|
624
|
-
#
|
1007
|
+
# Returns `self`, converted to the UTC timezone:
|
625
1008
|
#
|
626
|
-
# t = Time.
|
627
|
-
# t.
|
628
|
-
# t.
|
629
|
-
# t.
|
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
|
630
1013
|
#
|
631
|
-
#
|
632
|
-
# t.utc? #=> false
|
633
|
-
# t.utc #=> 2007-11-19 14:18:51 UTC
|
634
|
-
# t.utc? #=> true
|
1014
|
+
# Related: Time#getutc (returns a new converted `Time` object).
|
635
1015
|
#
|
636
1016
|
def gmtime: () -> Time
|
637
1017
|
|
638
1018
|
# <!--
|
639
1019
|
# rdoc-file=time.c
|
640
|
-
# -
|
1020
|
+
# - hash -> integer
|
641
1021
|
# -->
|
642
|
-
# Returns
|
1022
|
+
# Returns the integer hash code for `self`.
|
643
1023
|
#
|
644
|
-
#
|
1024
|
+
# Related: Object#hash.
|
645
1025
|
#
|
646
1026
|
def hash: () -> Integer
|
647
1027
|
|
648
1028
|
# <!--
|
649
1029
|
# rdoc-file=time.c
|
650
|
-
# -
|
1030
|
+
# - hour -> integer
|
651
1031
|
# -->
|
652
|
-
# Returns the hour of the day (0..23)
|
1032
|
+
# Returns the integer hour of the day for `self`, in range (0..23):
|
653
1033
|
#
|
654
|
-
# t = Time.
|
655
|
-
#
|
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.
|
656
1039
|
#
|
657
1040
|
def hour: () -> Integer
|
658
1041
|
|
659
1042
|
# <!--
|
660
1043
|
# rdoc-file=timev.rb
|
661
|
-
# - new(year =
|
1044
|
+
# - Time.new(year = nil, mon = nil, mday = nil, hour = nil, min = nil, sec = nil, zone = nil, in: nil, precision: 9)
|
662
1045
|
# -->
|
663
|
-
# Returns a new Time object based on the given arguments
|
1046
|
+
# Returns a new `Time` object based on the given arguments, by default in the
|
1047
|
+
# local timezone.
|
664
1048
|
#
|
665
1049
|
# With no positional arguments, returns the value of Time.now:
|
666
1050
|
#
|
667
|
-
# Time.new
|
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):
|
668
1093
|
#
|
669
|
-
#
|
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
|
670
1096
|
#
|
671
|
-
#
|
672
|
-
# Time.new(2000, 12, 31, 23, 59, 59.5) # => 2000-12-31 23:59:59.5 -0600
|
673
|
-
# Time.new(2000, 12, 31, 23, 59, 59.5, '+09:00') # => 2000-12-31 23:59:59.5 +0900
|
1097
|
+
# * `sec`: Second in range (0...61):
|
674
1098
|
#
|
675
|
-
#
|
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
|
676
1102
|
#
|
677
|
-
#
|
678
|
-
# * `month`: a month value, which may be:
|
679
|
-
# * An integer month in the range `1..12`.
|
680
|
-
# * A 3-character string that matches regular expression
|
681
|
-
# `/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/i`.
|
1103
|
+
# `sec` may be Float or Rational.
|
682
1104
|
#
|
683
|
-
#
|
684
|
-
#
|
685
|
-
# * `min`: an integer minute in the range `0..59`.
|
686
|
-
# * `sec` is the number of seconds (Integer, Float, or Rational) in the range
|
687
|
-
# `0..60`.
|
688
|
-
# * `zone`: a timezone, which may be:
|
689
|
-
# * A string offset from UTC.
|
690
|
-
# * A single letter offset from UTC, in the range `'A'..'Z'`, `'J'` (the
|
691
|
-
# so-called military timezone) excluded.
|
692
|
-
# * An integer number of seconds.
|
693
|
-
# * A timezone object; see [Timezone
|
694
|
-
# Argument](#class-Time-label-Timezone+Argument) for details.
|
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
|
695
1107
|
#
|
696
|
-
#
|
1108
|
+
# These values may be:
|
697
1109
|
#
|
698
|
-
|
699
|
-
|
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
|
700
1146
|
|
701
1147
|
# <!--
|
702
1148
|
# rdoc-file=time.c
|
703
|
-
# -
|
1149
|
+
# - inspect -> string
|
704
1150
|
# -->
|
705
|
-
# Returns a
|
706
|
-
# subsecond in the representation for easier debugging.
|
1151
|
+
# Returns a string representation of `self` with subseconds:
|
707
1152
|
#
|
708
|
-
# t = Time.
|
709
|
-
# t.inspect
|
710
|
-
# t.strftime "%Y-%m-%d %H:%M:%S.%N %z" #=> "2012-11-10 18:16:12.261257655 +0100"
|
1153
|
+
# t = Time.new(2000, 12, 31, 23, 59, 59, 0.5)
|
1154
|
+
# t.inspect # => "2000-12-31 23:59:59.5 +000001"
|
711
1155
|
#
|
712
|
-
#
|
713
|
-
#
|
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"
|
714
1160
|
#
|
715
1161
|
def inspect: () -> String
|
716
1162
|
|
717
1163
|
# <!--
|
718
1164
|
# rdoc-file=time.c
|
719
|
-
# -
|
720
|
-
# - time.dst? -> true or false
|
1165
|
+
# - dst? -> true or false
|
721
1166
|
# -->
|
722
|
-
# Returns `true` if
|
723
|
-
#
|
724
|
-
# #
|
725
|
-
#
|
726
|
-
#
|
727
|
-
#
|
728
|
-
#
|
729
|
-
#
|
730
|
-
# Time.local(2000, 7, 1).dst? #=> true
|
731
|
-
#
|
732
|
-
# # Asia/Tokyo:
|
733
|
-
# Time.local(2000, 1, 1).zone #=> "JST"
|
734
|
-
# Time.local(2000, 1, 1).isdst #=> false
|
735
|
-
# Time.local(2000, 1, 1).dst? #=> false
|
736
|
-
# Time.local(2000, 7, 1).zone #=> "JST"
|
737
|
-
# Time.local(2000, 7, 1).isdst #=> false
|
738
|
-
# Time.local(2000, 7, 1).dst? #=> false
|
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
|
739
1175
|
#
|
740
1176
|
def isdst: () -> bool
|
741
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
|
+
|
742
1197
|
# <!--
|
743
1198
|
# rdoc-file=time.c
|
744
|
-
# -
|
745
|
-
# -
|
1199
|
+
# - localtime -> self or new_time
|
1200
|
+
# - localtime(zone) -> new_time
|
746
1201
|
# -->
|
747
|
-
#
|
748
|
-
# creation time of *time*) modifying the receiver.
|
1202
|
+
# With no argument given:
|
749
1203
|
#
|
750
|
-
#
|
1204
|
+
# * Returns `self` if `self` is a local time.
|
1205
|
+
# * Otherwise returns a new `Time` in the user's local timezone:
|
751
1206
|
#
|
752
|
-
#
|
753
|
-
#
|
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
|
754
1209
|
#
|
755
|
-
#
|
756
|
-
#
|
1210
|
+
# With argument `zone` given, returns the new `Time` object created by
|
1211
|
+
# converting `self` to the given time zone:
|
757
1212
|
#
|
758
|
-
# t.
|
759
|
-
# t.
|
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
|
760
1215
|
#
|
761
|
-
#
|
762
|
-
#
|
1216
|
+
# For forms of argument `zone`, see [Timezone
|
1217
|
+
# Specifiers](rdoc-ref:Time@Timezone+Specifiers).
|
763
1218
|
#
|
764
1219
|
def localtime: (?String utc_offset) -> Time
|
765
1220
|
|
766
1221
|
# <!--
|
767
1222
|
# rdoc-file=time.c
|
768
|
-
# -
|
769
|
-
# - time.mday -> integer
|
1223
|
+
# - mday -> integer
|
770
1224
|
# -->
|
771
|
-
# Returns the day of the month (1..31)
|
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
|
772
1230
|
#
|
773
|
-
#
|
774
|
-
# t.day #=> 19
|
775
|
-
# t.mday #=> 19
|
1231
|
+
# Related: Time#year, Time#hour, Time#min.
|
776
1232
|
#
|
777
1233
|
def mday: () -> Integer
|
778
1234
|
|
779
1235
|
# <!--
|
780
1236
|
# rdoc-file=time.c
|
781
|
-
# -
|
1237
|
+
# - min -> integer
|
782
1238
|
# -->
|
783
|
-
# Returns the minute of the hour (0..59)
|
1239
|
+
# Returns the integer minute of the hour for `self`, in range (0..59):
|
784
1240
|
#
|
785
|
-
# t = Time.
|
786
|
-
#
|
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.
|
787
1246
|
#
|
788
1247
|
def min: () -> Integer
|
789
1248
|
|
790
1249
|
# <!--
|
791
1250
|
# rdoc-file=time.c
|
792
|
-
# -
|
793
|
-
# - time.month -> integer
|
1251
|
+
# - mon -> integer
|
794
1252
|
# -->
|
795
|
-
# Returns the month of the year (1..12)
|
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
|
796
1258
|
#
|
797
|
-
#
|
798
|
-
# t.mon #=> 11
|
799
|
-
# t.month #=> 11
|
1259
|
+
# Related: Time#year, Time#hour, Time#min.
|
800
1260
|
#
|
801
1261
|
def mon: () -> Integer
|
802
1262
|
|
803
1263
|
# <!--
|
804
1264
|
# rdoc-file=time.c
|
805
|
-
# -
|
1265
|
+
# - monday? -> true or false
|
806
1266
|
# -->
|
807
|
-
# Returns `true` if
|
1267
|
+
# Returns `true` if `self` represents a Monday, `false` otherwise:
|
808
1268
|
#
|
809
|
-
# t = Time.
|
810
|
-
# t.monday?
|
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?.
|
811
1273
|
#
|
812
1274
|
def monday?: () -> bool
|
813
1275
|
|
814
1276
|
# <!-- rdoc-file=time.c -->
|
815
|
-
# Returns the number of nanoseconds
|
816
|
-
#
|
817
|
-
#
|
818
|
-
# t = Time.now #=> 2020-07-20 22:07:10.963933942 +0900
|
819
|
-
# t.nsec #=> 963933942
|
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:
|
820
1279
|
#
|
821
|
-
#
|
1280
|
+
# t = Time.now # => 2022-07-11 15:04:53.3219637 -0500
|
1281
|
+
# t.nsec # => 321963700
|
822
1282
|
#
|
823
|
-
#
|
824
|
-
# t.nsec #=> 666777888
|
825
|
-
#
|
826
|
-
# Time#subsec can be used to obtain the subsecond part exactly.
|
1283
|
+
# Related: Time#subsec (returns exact subseconds).
|
827
1284
|
#
|
828
1285
|
def nsec: () -> Integer
|
829
1286
|
|
830
1287
|
# <!--
|
831
1288
|
# rdoc-file=time.c
|
832
|
-
# -
|
1289
|
+
# - round(ndigits = 0) -> new_time
|
833
1290
|
# -->
|
834
|
-
#
|
835
|
-
#
|
836
|
-
#
|
837
|
-
# t = Time.utc(2010,3,30, 5,43,25.123456789r)
|
838
|
-
# t
|
839
|
-
# t.round
|
840
|
-
# t.round(0)
|
841
|
-
# t.round(1)
|
842
|
-
# t.round(2)
|
843
|
-
# t.round(3)
|
844
|
-
# t.round(4)
|
845
|
-
#
|
846
|
-
# t = Time.utc(1999,12,31, 23,59,59)
|
847
|
-
#
|
848
|
-
# (t + 0.
|
849
|
-
# (t + 0.
|
850
|
-
# (t +
|
851
|
-
# (t + 1.
|
852
|
-
# (t + 1.
|
853
|
-
#
|
854
|
-
#
|
855
|
-
#
|
856
|
-
#
|
857
|
-
def round: (?
|
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
|
858
1315
|
|
859
1316
|
# <!--
|
860
1317
|
# rdoc-file=time.c
|
861
|
-
# -
|
1318
|
+
# - saturday? -> true or false
|
862
1319
|
# -->
|
863
|
-
# Returns `true` if
|
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
|
864
1324
|
#
|
865
|
-
#
|
866
|
-
# t.saturday? #=> true
|
1325
|
+
# Related: Time#sunday?, Time#monday?, Time#tuesday?.
|
867
1326
|
#
|
868
1327
|
def saturday?: () -> bool
|
869
1328
|
|
870
1329
|
# <!--
|
871
1330
|
# rdoc-file=time.c
|
872
|
-
# -
|
1331
|
+
# - sec -> integer
|
873
1332
|
# -->
|
874
|
-
# Returns the second of the minute (0..60)
|
1333
|
+
# Returns the integer second of the minute for `self`, in range (0..60):
|
875
1334
|
#
|
876
|
-
#
|
877
|
-
#
|
1335
|
+
# t = Time.new(2000, 1, 2, 3, 4, 5, 6)
|
1336
|
+
# # => 2000-01-02 03:04:05 +000006
|
1337
|
+
# t.sec # => 5
|
878
1338
|
#
|
879
|
-
#
|
880
|
-
#
|
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.
|
881
1343
|
#
|
882
1344
|
def sec: () -> Integer
|
883
1345
|
|
884
1346
|
# <!--
|
885
1347
|
# rdoc-file=time.c
|
886
|
-
# -
|
1348
|
+
# - strftime(format_string) -> string
|
887
1349
|
# -->
|
888
|
-
#
|
889
|
-
#
|
890
|
-
#
|
891
|
-
# directive will be passed through to the output string.
|
892
|
-
#
|
893
|
-
# The directive consists of a percent (%) character, zero or more flags,
|
894
|
-
# optional minimum field width, optional modifier and a conversion specifier as
|
895
|
-
# follows:
|
896
|
-
#
|
897
|
-
# %<flags><width><modifier><conversion>
|
898
|
-
#
|
899
|
-
# Flags:
|
900
|
-
# - don't pad a numerical output
|
901
|
-
# _ use spaces for padding
|
902
|
-
# 0 use zeros for padding
|
903
|
-
# ^ upcase the result string
|
904
|
-
# # change case
|
905
|
-
# : use colons for %z
|
906
|
-
#
|
907
|
-
# The minimum field width specifies the minimum width.
|
908
|
-
#
|
909
|
-
# The modifiers are "E" and "O". They are ignored.
|
910
|
-
#
|
911
|
-
# Format directives:
|
912
|
-
#
|
913
|
-
# Date (Year, Month, Day):
|
914
|
-
# %Y - Year with century if provided, will pad result at least 4 digits.
|
915
|
-
# -0001, 0000, 1995, 2009, 14292, etc.
|
916
|
-
# %C - year / 100 (rounded down such as 20 in 2009)
|
917
|
-
# %y - year % 100 (00..99)
|
918
|
-
#
|
919
|
-
# %m - Month of the year, zero-padded (01..12)
|
920
|
-
# %_m blank-padded ( 1..12)
|
921
|
-
# %-m no-padded (1..12)
|
922
|
-
# %B - The full month name (``January'')
|
923
|
-
# %^B uppercased (``JANUARY'')
|
924
|
-
# %b - The abbreviated month name (``Jan'')
|
925
|
-
# %^b uppercased (``JAN'')
|
926
|
-
# %h - Equivalent to %b
|
927
|
-
#
|
928
|
-
# %d - Day of the month, zero-padded (01..31)
|
929
|
-
# %-d no-padded (1..31)
|
930
|
-
# %e - Day of the month, blank-padded ( 1..31)
|
931
|
-
#
|
932
|
-
# %j - Day of the year (001..366)
|
933
|
-
#
|
934
|
-
# Time (Hour, Minute, Second, Subsecond):
|
935
|
-
# %H - Hour of the day, 24-hour clock, zero-padded (00..23)
|
936
|
-
# %k - Hour of the day, 24-hour clock, blank-padded ( 0..23)
|
937
|
-
# %I - Hour of the day, 12-hour clock, zero-padded (01..12)
|
938
|
-
# %l - Hour of the day, 12-hour clock, blank-padded ( 1..12)
|
939
|
-
# %P - Meridian indicator, lowercase (``am'' or ``pm'')
|
940
|
-
# %p - Meridian indicator, uppercase (``AM'' or ``PM'')
|
941
|
-
#
|
942
|
-
# %M - Minute of the hour (00..59)
|
943
|
-
#
|
944
|
-
# %S - Second of the minute (00..60)
|
945
|
-
#
|
946
|
-
# %L - Millisecond of the second (000..999)
|
947
|
-
# The digits under millisecond are truncated to not produce 1000.
|
948
|
-
# %N - Fractional seconds digits, default is 9 digits (nanosecond)
|
949
|
-
# %3N millisecond (3 digits)
|
950
|
-
# %6N microsecond (6 digits)
|
951
|
-
# %9N nanosecond (9 digits)
|
952
|
-
# %12N picosecond (12 digits)
|
953
|
-
# %15N femtosecond (15 digits)
|
954
|
-
# %18N attosecond (18 digits)
|
955
|
-
# %21N zeptosecond (21 digits)
|
956
|
-
# %24N yoctosecond (24 digits)
|
957
|
-
# The digits under the specified length are truncated to avoid
|
958
|
-
# carry up.
|
959
|
-
#
|
960
|
-
# Time zone:
|
961
|
-
# %z - Time zone as hour and minute offset from UTC (e.g. +0900)
|
962
|
-
# %:z - hour and minute offset from UTC with a colon (e.g. +09:00)
|
963
|
-
# %::z - hour, minute and second offset from UTC (e.g. +09:00:00)
|
964
|
-
# %Z - Abbreviated time zone name or similar information. (OS dependent)
|
965
|
-
#
|
966
|
-
# Weekday:
|
967
|
-
# %A - The full weekday name (``Sunday'')
|
968
|
-
# %^A uppercased (``SUNDAY'')
|
969
|
-
# %a - The abbreviated name (``Sun'')
|
970
|
-
# %^a uppercased (``SUN'')
|
971
|
-
# %u - Day of the week (Monday is 1, 1..7)
|
972
|
-
# %w - Day of the week (Sunday is 0, 0..6)
|
973
|
-
#
|
974
|
-
# ISO 8601 week-based year and week number:
|
975
|
-
# The first week of YYYY starts with a Monday and includes YYYY-01-04.
|
976
|
-
# The days in the year before the first week are in the last week of
|
977
|
-
# the previous year.
|
978
|
-
# %G - The week-based year
|
979
|
-
# %g - The last 2 digits of the week-based year (00..99)
|
980
|
-
# %V - Week number of the week-based year (01..53)
|
981
|
-
#
|
982
|
-
# Week number:
|
983
|
-
# The first week of YYYY that starts with a Sunday or Monday (according to %U
|
984
|
-
# or %W). The days in the year before the first week are in week 0.
|
985
|
-
# %U - Week number of the year. The week starts with Sunday. (00..53)
|
986
|
-
# %W - Week number of the year. The week starts with Monday. (00..53)
|
987
|
-
#
|
988
|
-
# Seconds since the Epoch:
|
989
|
-
# %s - Number of seconds since 1970-01-01 00:00:00 UTC.
|
990
|
-
#
|
991
|
-
# Literal string:
|
992
|
-
# %n - Newline character (\n)
|
993
|
-
# %t - Tab character (\t)
|
994
|
-
# %% - Literal ``%'' character
|
995
|
-
#
|
996
|
-
# Combination:
|
997
|
-
# %c - date and time (%a %b %e %T %Y)
|
998
|
-
# %D - Date (%m/%d/%y)
|
999
|
-
# %F - The ISO 8601 date format (%Y-%m-%d)
|
1000
|
-
# %v - VMS date (%e-%^b-%4Y)
|
1001
|
-
# %x - Same as %D
|
1002
|
-
# %X - Same as %T
|
1003
|
-
# %r - 12-hour time (%I:%M:%S %p)
|
1004
|
-
# %R - 24-hour time (%H:%M)
|
1005
|
-
# %T - 24-hour time (%H:%M:%S)
|
1006
|
-
#
|
1007
|
-
# This method is similar to strftime() function defined in ISO C and POSIX.
|
1008
|
-
#
|
1009
|
-
# While all directives are locale independent since Ruby 1.9, %Z is platform
|
1010
|
-
# dependent. So, the result may differ even if the same format string is used in
|
1011
|
-
# other systems such as C.
|
1012
|
-
#
|
1013
|
-
# %z is recommended over %Z. %Z doesn't identify the timezone. For example,
|
1014
|
-
# "CST" is used at America/Chicago (-06:00), America/Havana (-05:00),
|
1015
|
-
# Asia/Harbin (+08:00), Australia/Darwin (+09:30) and Australia/Adelaide
|
1016
|
-
# (+10:30). Also, %Z is highly dependent on the operating system. For example,
|
1017
|
-
# it may generate a non ASCII string on Japanese Windows, i.e. the result can be
|
1018
|
-
# different to "JST". So the numeric time zone offset, %z, is recommended.
|
1019
|
-
#
|
1020
|
-
# Examples:
|
1021
|
-
#
|
1022
|
-
# t = Time.new(2007,11,19,8,37,48,"-06:00") #=> 2007-11-19 08:37:48 -0600
|
1023
|
-
# t.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007"
|
1024
|
-
# t.strftime("at %I:%M %p") #=> "at 08:37 AM"
|
1025
|
-
#
|
1026
|
-
# Various ISO 8601 formats:
|
1027
|
-
# %Y%m%d => 20071119 Calendar date (basic)
|
1028
|
-
# %F => 2007-11-19 Calendar date (extended)
|
1029
|
-
# %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month
|
1030
|
-
# %Y => 2007 Calendar date, reduced accuracy, specific year
|
1031
|
-
# %C => 20 Calendar date, reduced accuracy, specific century
|
1032
|
-
# %Y%j => 2007323 Ordinal date (basic)
|
1033
|
-
# %Y-%j => 2007-323 Ordinal date (extended)
|
1034
|
-
# %GW%V%u => 2007W471 Week date (basic)
|
1035
|
-
# %G-W%V-%u => 2007-W47-1 Week date (extended)
|
1036
|
-
# %GW%V => 2007W47 Week date, reduced accuracy, specific week (basic)
|
1037
|
-
# %G-W%V => 2007-W47 Week date, reduced accuracy, specific week (extended)
|
1038
|
-
# %H%M%S => 083748 Local time (basic)
|
1039
|
-
# %T => 08:37:48 Local time (extended)
|
1040
|
-
# %H%M => 0837 Local time, reduced accuracy, specific minute (basic)
|
1041
|
-
# %H:%M => 08:37 Local time, reduced accuracy, specific minute (extended)
|
1042
|
-
# %H => 08 Local time, reduced accuracy, specific hour
|
1043
|
-
# %H%M%S,%L => 083748,000 Local time with decimal fraction, comma as decimal sign (basic)
|
1044
|
-
# %T,%L => 08:37:48,000 Local time with decimal fraction, comma as decimal sign (extended)
|
1045
|
-
# %H%M%S.%L => 083748.000 Local time with decimal fraction, full stop as decimal sign (basic)
|
1046
|
-
# %T.%L => 08:37:48.000 Local time with decimal fraction, full stop as decimal sign (extended)
|
1047
|
-
# %H%M%S%z => 083748-0600 Local time and the difference from UTC (basic)
|
1048
|
-
# %T%:z => 08:37:48-06:00 Local time and the difference from UTC (extended)
|
1049
|
-
# %Y%m%dT%H%M%S%z => 20071119T083748-0600 Date and time of day for calendar date (basic)
|
1050
|
-
# %FT%T%:z => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended)
|
1051
|
-
# %Y%jT%H%M%S%z => 2007323T083748-0600 Date and time of day for ordinal date (basic)
|
1052
|
-
# %Y-%jT%T%:z => 2007-323T08:37:48-06:00 Date and time of day for ordinal date (extended)
|
1053
|
-
# %GW%V%uT%H%M%S%z => 2007W471T083748-0600 Date and time of day for week date (basic)
|
1054
|
-
# %G-W%V-%uT%T%:z => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended)
|
1055
|
-
# %Y%m%dT%H%M => 20071119T0837 Calendar date and local time (basic)
|
1056
|
-
# %FT%R => 2007-11-19T08:37 Calendar date and local time (extended)
|
1057
|
-
# %Y%jT%H%MZ => 2007323T0837Z Ordinal date and UTC of day (basic)
|
1058
|
-
# %Y-%jT%RZ => 2007-323T08:37Z Ordinal date and UTC of day (extended)
|
1059
|
-
# %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic)
|
1060
|
-
# %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended)
|
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).
|
1061
1353
|
#
|
1062
1354
|
def strftime: (String arg0) -> String
|
1063
1355
|
|
1064
1356
|
# <!--
|
1065
1357
|
# rdoc-file=time.c
|
1066
|
-
# -
|
1358
|
+
# - subsec -> numeric
|
1067
1359
|
# -->
|
1068
|
-
# Returns the
|
1069
|
-
#
|
1070
|
-
# The return value can be a rational number.
|
1071
|
-
#
|
1072
|
-
# t = Time.now #=> 2020-07-20 15:40:26.867462289 +0900
|
1073
|
-
# t.subsec #=> (867462289/1000000000)
|
1360
|
+
# Returns the exact subseconds for `self` as a Numeric (Integer or Rational):
|
1074
1361
|
#
|
1075
|
-
# t = Time.now
|
1076
|
-
# t.subsec
|
1362
|
+
# t = Time.now # => 2022-07-11 15:11:36.8490302 -0500
|
1363
|
+
# t.subsec # => (4245151/5000000)
|
1077
1364
|
#
|
1078
|
-
#
|
1079
|
-
# t.subsec #=> 0
|
1365
|
+
# If the subseconds is zero, returns integer zero:
|
1080
1366
|
#
|
1081
|
-
# Time.new(2000,1,1,
|
1367
|
+
# t = Time.new(2000, 1, 1, 2, 3, 4) # => 2000-01-01 02:03:04 -0600
|
1368
|
+
# t.subsec # => 0
|
1082
1369
|
#
|
1083
1370
|
def subsec: () -> (0 | Rational)
|
1084
1371
|
|
1085
1372
|
# <!--
|
1086
1373
|
# rdoc-file=time.c
|
1087
|
-
# -
|
1374
|
+
# - sunday? -> true or false
|
1088
1375
|
# -->
|
1089
|
-
# Returns `true` if
|
1376
|
+
# Returns `true` if `self` represents a Sunday, `false` otherwise:
|
1090
1377
|
#
|
1091
|
-
# t = Time.
|
1092
|
-
# t.sunday?
|
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?.
|
1093
1382
|
#
|
1094
1383
|
def sunday?: () -> bool
|
1095
1384
|
|
1096
1385
|
# <!--
|
1097
1386
|
# rdoc-file=time.c
|
1098
|
-
# -
|
1387
|
+
# - thursday? -> true or false
|
1099
1388
|
# -->
|
1100
|
-
# Returns `true` if
|
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
|
1101
1393
|
#
|
1102
|
-
#
|
1103
|
-
# t.thursday? #=> true
|
1394
|
+
# Related: Time#friday?, Time#saturday?, Time#sunday?.
|
1104
1395
|
#
|
1105
1396
|
def thursday?: () -> bool
|
1106
1397
|
|
1107
1398
|
# <!--
|
1108
1399
|
# rdoc-file=time.c
|
1109
|
-
# -
|
1400
|
+
# - to_a -> array
|
1110
1401
|
# -->
|
1111
|
-
# Returns a
|
1402
|
+
# Returns a 10-element array of values representing `self`:
|
1112
1403
|
#
|
1113
|
-
#
|
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]
|
1114
1407
|
#
|
1115
|
-
#
|
1116
|
-
#
|
1117
|
-
# create a new Time object.
|
1408
|
+
# The returned array is suitable for use as an argument to Time.utc or
|
1409
|
+
# Time.local to create a new `Time` object.
|
1118
1410
|
#
|
1119
|
-
|
1120
|
-
# now = t.to_a #=> [1, 36, 8, 19, 11, 2007, 1, 323, false, "CST"]
|
1121
|
-
#
|
1122
|
-
def to_a: () -> [ Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, bool, String ]
|
1411
|
+
def to_a: () -> [ Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, bool, String? ]
|
1123
1412
|
|
1124
1413
|
# <!--
|
1125
1414
|
# rdoc-file=time.c
|
1126
|
-
# -
|
1415
|
+
# - to_f -> float
|
1127
1416
|
# -->
|
1128
|
-
# Returns the value of
|
1129
|
-
# Epoch
|
1130
|
-
#
|
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:
|
1131
1422
|
#
|
1132
|
-
#
|
1133
|
-
#
|
1134
|
-
#
|
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
|
1135
1427
|
#
|
1136
|
-
#
|
1137
|
-
# of nanoseconds since the Epoch. (IEEE 754 double has 53bit mantissa. So it can
|
1138
|
-
# represent exact number of nanoseconds only in `2 ** 53 / 1_000_000_000 / 60 /
|
1139
|
-
# 60 / 24 = 104.2` days.) When Ruby uses a nanosecond-resolution clock function,
|
1140
|
-
# such as `clock_gettime` of POSIX, to obtain the current time, Time#to_f can
|
1141
|
-
# lose information of a Time object created with `Time.now`.
|
1428
|
+
# Related: Time#to_i, Time#to_r.
|
1142
1429
|
#
|
1143
1430
|
def to_f: () -> Float
|
1144
1431
|
|
1145
1432
|
# <!--
|
1146
1433
|
# rdoc-file=time.c
|
1147
|
-
# -
|
1148
|
-
# - time.tv_sec -> int
|
1434
|
+
# - to_i -> integer
|
1149
1435
|
# -->
|
1150
|
-
# Returns the value of
|
1436
|
+
# Returns the value of `self` as integer [Epoch
|
1437
|
+
# seconds](rdoc-ref:Time@Epoch+Seconds); subseconds are truncated (not rounded):
|
1151
1438
|
#
|
1152
|
-
#
|
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
|
1153
1443
|
#
|
1154
|
-
#
|
1155
|
-
# t.to_i #=> 1595263289
|
1444
|
+
# Related: Time#to_f Time#to_r.
|
1156
1445
|
#
|
1157
1446
|
def to_i: () -> Integer
|
1158
1447
|
|
1159
1448
|
# <!--
|
1160
1449
|
# rdoc-file=time.c
|
1161
|
-
# -
|
1450
|
+
# - to_r -> rational
|
1162
1451
|
# -->
|
1163
|
-
# Returns the value of
|
1452
|
+
# Returns the value of `self` as a Rational exact number of [Epoch
|
1453
|
+
# seconds](rdoc-ref:Time@Epoch+Seconds);
|
1164
1454
|
#
|
1165
|
-
#
|
1166
|
-
# t.to_r #=> (1595250225212167333/1000000000)
|
1455
|
+
# Time.now.to_r # => (16571402750320203/10000000)
|
1167
1456
|
#
|
1168
|
-
#
|
1169
|
-
# seconds (including subsecond) since the Epoch.
|
1457
|
+
# Related: Time#to_f, Time#to_i.
|
1170
1458
|
#
|
1171
1459
|
def to_r: () -> Rational
|
1172
1460
|
|
1173
1461
|
# <!--
|
1174
1462
|
# rdoc-file=time.c
|
1175
|
-
# -
|
1463
|
+
# - to_s -> string
|
1176
1464
|
# -->
|
1177
|
-
# Returns a string
|
1178
|
-
# appropriate format string.
|
1465
|
+
# Returns a string representation of `self`, without subseconds:
|
1179
1466
|
#
|
1180
|
-
# t = Time.
|
1181
|
-
# t.to_s
|
1182
|
-
#
|
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:
|
1183
1471
|
#
|
1184
|
-
# t.
|
1185
|
-
# t.
|
1472
|
+
# t.ctime # => "Sun Dec 31 23:59:59 2000"
|
1473
|
+
# t.inspect # => "2000-12-31 23:59:59.5 +000001"
|
1186
1474
|
#
|
1187
1475
|
def to_s: () -> String
|
1188
1476
|
|
1189
1477
|
# <!--
|
1190
1478
|
# rdoc-file=time.c
|
1191
|
-
# -
|
1479
|
+
# - tuesday? -> true or false
|
1192
1480
|
# -->
|
1193
|
-
# Returns `true` if
|
1481
|
+
# Returns `true` if `self` represents a Tuesday, `false` otherwise:
|
1194
1482
|
#
|
1195
|
-
# t = Time.
|
1196
|
-
# t.tuesday?
|
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?.
|
1197
1487
|
#
|
1198
1488
|
def tuesday?: () -> bool
|
1199
1489
|
|
1200
1490
|
# <!--
|
1201
1491
|
# rdoc-file=time.c
|
1202
|
-
# -
|
1203
|
-
# - time.tv_nsec -> int
|
1492
|
+
# - nsec -> integer
|
1204
1493
|
# -->
|
1205
|
-
# Returns the number of nanoseconds
|
1206
|
-
#
|
1207
|
-
#
|
1208
|
-
# t = Time.now #=> 2020-07-20 22:07:10.963933942 +0900
|
1209
|
-
# t.nsec #=> 963933942
|
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:
|
1210
1496
|
#
|
1211
|
-
#
|
1497
|
+
# t = Time.now # => 2022-07-11 15:04:53.3219637 -0500
|
1498
|
+
# t.nsec # => 321963700
|
1212
1499
|
#
|
1213
|
-
#
|
1214
|
-
# t.nsec #=> 666777888
|
1215
|
-
#
|
1216
|
-
# Time#subsec can be used to obtain the subsecond part exactly.
|
1500
|
+
# Related: Time#subsec (returns exact subseconds).
|
1217
1501
|
#
|
1218
1502
|
def tv_nsec: () -> Integer
|
1219
1503
|
|
1220
1504
|
# <!-- rdoc-file=time.c -->
|
1221
|
-
# Returns the value of
|
1505
|
+
# Returns the value of `self` as integer [Epoch
|
1506
|
+
# seconds](rdoc-ref:Time@Epoch+Seconds); subseconds are truncated (not rounded):
|
1222
1507
|
#
|
1223
|
-
#
|
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
|
1224
1512
|
#
|
1225
|
-
#
|
1226
|
-
# t.to_i #=> 1595263289
|
1513
|
+
# Related: Time#to_f Time#to_r.
|
1227
1514
|
#
|
1228
1515
|
def tv_sec: () -> Integer
|
1229
1516
|
|
1230
1517
|
# <!--
|
1231
1518
|
# rdoc-file=time.c
|
1232
|
-
# -
|
1233
|
-
# - time.tv_usec -> int
|
1519
|
+
# - usec -> integer
|
1234
1520
|
# -->
|
1235
|
-
# Returns the number of microseconds
|
1236
|
-
#
|
1237
|
-
#
|
1238
|
-
# t = Time.now #=> 2020-07-20 22:05:58.459785953 +0900
|
1239
|
-
# t.usec #=> 459785
|
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:
|
1240
1523
|
#
|
1241
|
-
#
|
1524
|
+
# t = Time.now # => 2022-07-11 14:59:47.5484697 -0500
|
1525
|
+
# t.usec # => 548469
|
1242
1526
|
#
|
1243
|
-
#
|
1244
|
-
# t.usec #=> 666777
|
1245
|
-
#
|
1246
|
-
# Time#subsec can be used to obtain the subsecond part exactly.
|
1527
|
+
# Related: Time#subsec (returns exact subseconds).
|
1247
1528
|
#
|
1248
1529
|
def tv_usec: () -> Integer
|
1249
1530
|
|
1250
1531
|
# <!-- rdoc-file=time.c -->
|
1251
|
-
# Returns the number of microseconds
|
1252
|
-
#
|
1253
|
-
#
|
1254
|
-
# t = Time.now #=> 2020-07-20 22:05:58.459785953 +0900
|
1255
|
-
# t.usec #=> 459785
|
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:
|
1256
1534
|
#
|
1257
|
-
#
|
1535
|
+
# t = Time.now # => 2022-07-11 14:59:47.5484697 -0500
|
1536
|
+
# t.usec # => 548469
|
1258
1537
|
#
|
1259
|
-
#
|
1260
|
-
# t.usec #=> 666777
|
1261
|
-
#
|
1262
|
-
# Time#subsec can be used to obtain the subsecond part exactly.
|
1538
|
+
# Related: Time#subsec (returns exact subseconds).
|
1263
1539
|
#
|
1264
1540
|
def usec: () -> Integer
|
1265
1541
|
|
1266
1542
|
# <!-- rdoc-file=time.c -->
|
1267
|
-
#
|
1543
|
+
# Returns `self`, converted to the UTC timezone:
|
1268
1544
|
#
|
1269
|
-
# t = Time.
|
1270
|
-
# t.
|
1271
|
-
# t.
|
1272
|
-
# t.
|
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
|
1273
1549
|
#
|
1274
|
-
#
|
1275
|
-
# t.utc? #=> false
|
1276
|
-
# t.utc #=> 2007-11-19 14:18:51 UTC
|
1277
|
-
# t.utc? #=> true
|
1550
|
+
# Related: Time#getutc (returns a new converted `Time` object).
|
1278
1551
|
#
|
1279
1552
|
def utc: () -> Time
|
1280
1553
|
|
1281
1554
|
# <!--
|
1282
1555
|
# rdoc-file=time.c
|
1283
|
-
# -
|
1284
|
-
# - time.gmt? -> true or false
|
1556
|
+
# - utc? -> true or false
|
1285
1557
|
# -->
|
1286
|
-
# Returns `true` if
|
1558
|
+
# Returns `true` if `self` represents a time in UTC (GMT):
|
1287
1559
|
#
|
1288
|
-
#
|
1289
|
-
#
|
1290
|
-
#
|
1291
|
-
#
|
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
|
1292
1566
|
#
|
1293
|
-
#
|
1294
|
-
# t.gmt? #=> false
|
1295
|
-
# t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
|
1296
|
-
# t.gmt? #=> true
|
1567
|
+
# Related: Time.utc.
|
1297
1568
|
#
|
1298
1569
|
def utc?: () -> bool
|
1299
1570
|
|
1300
1571
|
# <!-- rdoc-file=time.c -->
|
1301
|
-
# Returns the offset in seconds between the
|
1572
|
+
# Returns the offset in seconds between the timezones of UTC and `self`:
|
1302
1573
|
#
|
1303
|
-
#
|
1304
|
-
#
|
1305
|
-
# l = t.getlocal #=> 2000-01-01 14:15:01 -0600
|
1306
|
-
# l.gmt_offset #=> -21600
|
1574
|
+
# Time.utc(2000, 1, 1).utc_offset # => 0
|
1575
|
+
# Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours.
|
1307
1576
|
#
|
1308
1577
|
def utc_offset: () -> Integer
|
1309
1578
|
|
1310
1579
|
# <!--
|
1311
1580
|
# rdoc-file=time.c
|
1312
|
-
# -
|
1581
|
+
# - wday -> integer
|
1313
1582
|
# -->
|
1314
|
-
# Returns
|
1315
|
-
#
|
1316
|
-
#
|
1317
|
-
# t.
|
1318
|
-
#
|
1319
|
-
# t.
|
1320
|
-
# t.
|
1321
|
-
#
|
1322
|
-
#
|
1323
|
-
# t.friday? #=> false
|
1324
|
-
# t.saturday? #=> false
|
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.
|
1325
1592
|
#
|
1326
1593
|
def wday: () -> Integer
|
1327
1594
|
|
1328
1595
|
# <!--
|
1329
1596
|
# rdoc-file=time.c
|
1330
|
-
# -
|
1597
|
+
# - wednesday? -> true or false
|
1331
1598
|
# -->
|
1332
|
-
# Returns `true` if
|
1599
|
+
# Returns `true` if `self` represents a Wednesday, `false` otherwise:
|
1333
1600
|
#
|
1334
|
-
# t = Time.
|
1335
|
-
# t.wednesday?
|
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?.
|
1336
1605
|
#
|
1337
1606
|
def wednesday?: () -> bool
|
1338
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
|
+
|
1339
1634
|
# <!--
|
1340
1635
|
# rdoc-file=time.c
|
1341
|
-
# -
|
1636
|
+
# - yday -> integer
|
1342
1637
|
# -->
|
1343
|
-
# Returns
|
1638
|
+
# Returns the integer day of the year of `self`, in range (1..366).
|
1344
1639
|
#
|
1345
|
-
#
|
1346
|
-
#
|
1640
|
+
# Time.new(2000, 1, 1).yday # => 1
|
1641
|
+
# Time.new(2000, 12, 31).yday # => 366
|
1347
1642
|
#
|
1348
1643
|
def yday: () -> Integer
|
1349
1644
|
|
1350
1645
|
# <!--
|
1351
1646
|
# rdoc-file=time.c
|
1352
|
-
# -
|
1647
|
+
# - year -> integer
|
1353
1648
|
# -->
|
1354
|
-
# Returns the year for
|
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
|
1355
1654
|
#
|
1356
|
-
#
|
1357
|
-
# t.year #=> 2007
|
1655
|
+
# Related: Time#mon, Time#hour, Time#min.
|
1358
1656
|
#
|
1359
1657
|
def year: () -> Integer
|
1360
1658
|
|
@@ -1362,99 +1660,101 @@ class Time < Object
|
|
1362
1660
|
# rdoc-file=time.c
|
1363
1661
|
# - time.zone -> string or timezone
|
1364
1662
|
# -->
|
1365
|
-
# Returns the name of the time zone
|
1366
|
-
# ``UTC'' rather than ``GMT'' for UTC times.
|
1663
|
+
# Returns the string name of the time zone for `self`:
|
1367
1664
|
#
|
1368
|
-
#
|
1369
|
-
#
|
1370
|
-
# t = Time.local(2000, "jan", 1, 20, 15, 1)
|
1371
|
-
# t.zone #=> "CST"
|
1665
|
+
# Time.utc(2000, 1, 1).zone # => "UTC"
|
1666
|
+
# Time.new(2000, 1, 1).zone # => "Central Standard Time"
|
1372
1667
|
#
|
1373
|
-
def zone: () -> String
|
1668
|
+
def zone: () -> String?
|
1374
1669
|
|
1375
|
-
#
|
1670
|
+
# <!-- rdoc-file=time.c -->
|
1671
|
+
# Like Time.utc, except that the returned `Time` object has the local timezone,
|
1672
|
+
# not the UTC timezone:
|
1376
1673
|
#
|
1377
|
-
#
|
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
|
1378
1680
|
#
|
1379
1681
|
def self.mktime: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
|
1380
1682
|
|
1381
1683
|
# <!--
|
1382
1684
|
# rdoc-file=time.c
|
1383
|
-
# -
|
1384
|
-
# - time.gmtoff -> integer
|
1385
|
-
# - time.utc_offset -> integer
|
1685
|
+
# - utc_offset -> integer
|
1386
1686
|
# -->
|
1387
|
-
# Returns the offset in seconds between the
|
1687
|
+
# Returns the offset in seconds between the timezones of UTC and `self`:
|
1388
1688
|
#
|
1389
|
-
#
|
1390
|
-
#
|
1391
|
-
# l = t.getlocal #=> 2000-01-01 14:15:01 -0600
|
1392
|
-
# l.gmt_offset #=> -21600
|
1689
|
+
# Time.utc(2000, 1, 1).utc_offset # => 0
|
1690
|
+
# Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours.
|
1393
1691
|
#
|
1394
1692
|
def gmtoff: () -> Integer
|
1395
1693
|
|
1396
1694
|
# <!-- rdoc-file=time.c -->
|
1397
|
-
# Returns the month of the year (1..12)
|
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
|
1398
1700
|
#
|
1399
|
-
#
|
1400
|
-
# t.mon #=> 11
|
1401
|
-
# t.month #=> 11
|
1701
|
+
# Related: Time#year, Time#hour, Time#min.
|
1402
1702
|
#
|
1403
1703
|
def month: () -> Integer
|
1404
1704
|
|
1405
1705
|
# <!--
|
1406
1706
|
# rdoc-file=time.c
|
1407
|
-
# -
|
1707
|
+
# - floor(ndigits = 0) -> new_time
|
1408
1708
|
# -->
|
1409
|
-
#
|
1410
|
-
#
|
1709
|
+
# Returns a new `Time` object whose numerical value is less than or equal to
|
1710
|
+
# `self` with its seconds truncated to precision `ndigits`:
|
1411
1711
|
#
|
1412
|
-
# t = Time.utc(2010,3,30, 5,43,25.123456789r)
|
1413
|
-
# t
|
1414
|
-
# t.floor
|
1415
|
-
# t.floor(
|
1416
|
-
# t.floor(
|
1417
|
-
# t.floor(
|
1418
|
-
# t.floor(
|
1419
|
-
# t.floor(
|
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
|
1420
1720
|
#
|
1421
|
-
# t = Time.utc(1999,12,31, 23,59,59)
|
1422
|
-
#
|
1423
|
-
# (t + 0.
|
1424
|
-
# (t +
|
1425
|
-
# (t + 1.
|
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
|
1426
1727
|
#
|
1427
|
-
#
|
1428
|
-
# (t + 0.123456789).floor(4) #=> 1999-12-31 23:59:59.1234 UTC
|
1728
|
+
# Related: Time#ceil, Time#round.
|
1429
1729
|
#
|
1430
|
-
def floor: (?
|
1730
|
+
def floor: (?int ndigits) -> Time
|
1431
1731
|
|
1432
1732
|
# <!--
|
1433
1733
|
# rdoc-file=time.c
|
1434
|
-
# -
|
1734
|
+
# - ceil(ndigits = 0) -> new_time
|
1435
1735
|
# -->
|
1436
|
-
#
|
1437
|
-
#
|
1438
|
-
#
|
1439
|
-
# t = Time.utc(2010,3,30, 5,43,25.
|
1440
|
-
# t
|
1441
|
-
# t.ceil
|
1442
|
-
# t.ceil(
|
1443
|
-
# t.ceil(
|
1444
|
-
# t.ceil(
|
1445
|
-
# t.ceil(
|
1446
|
-
# t.ceil(
|
1447
|
-
#
|
1448
|
-
# t = Time.utc(1999,12,31, 23,59,59)
|
1449
|
-
#
|
1450
|
-
# (t + 0.
|
1451
|
-
# (t +
|
1452
|
-
# (t + 1.
|
1453
|
-
#
|
1454
|
-
#
|
1455
|
-
#
|
1456
|
-
#
|
1457
|
-
def ceil: (?
|
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
|
1458
1758
|
end
|
1459
1759
|
|
1460
1760
|
Time::RFC2822_DAY_NAME: Array[String]
|