rbs 3.0.0.dev.2 → 3.0.0.dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -1
  3. data/.github/workflows/ruby.yml +4 -0
  4. data/Gemfile.lock +11 -11
  5. data/Rakefile +2 -2
  6. data/Steepfile +1 -1
  7. data/core/array.rbs +573 -423
  8. data/core/basic_object.rbs +11 -39
  9. data/core/binding.rbs +1 -1
  10. data/core/builtin.rbs +8 -0
  11. data/core/class.rbs +37 -0
  12. data/core/comparable.rbs +7 -18
  13. data/core/complex.rbs +2 -2
  14. data/core/data.rbs +419 -0
  15. data/core/dir.rbs +52 -104
  16. data/core/encoding.rbs +22 -181
  17. data/core/enumerable.rbs +212 -175
  18. data/core/enumerator/product.rbs +96 -0
  19. data/core/enumerator.rbs +57 -8
  20. data/core/errors.rbs +8 -2
  21. data/core/exception.rbs +41 -0
  22. data/core/fiber.rbs +95 -12
  23. data/core/file.rbs +840 -275
  24. data/core/file_test.rbs +34 -19
  25. data/core/float.rbs +40 -96
  26. data/core/gc.rbs +15 -3
  27. data/core/hash.rbs +113 -175
  28. data/core/integer.rbs +85 -145
  29. data/core/io/buffer.rbs +187 -60
  30. data/core/io/wait.rbs +28 -16
  31. data/core/io.rbs +1859 -1389
  32. data/core/kernel.rbs +525 -961
  33. data/core/match_data.rbs +306 -142
  34. data/core/math.rbs +506 -234
  35. data/core/method.rbs +0 -24
  36. data/core/module.rbs +110 -17
  37. data/core/nil_class.rbs +2 -0
  38. data/core/numeric.rbs +76 -144
  39. data/core/object.rbs +88 -212
  40. data/core/proc.rbs +17 -5
  41. data/core/process.rbs +22 -5
  42. data/core/ractor.rbs +1 -1
  43. data/core/random.rbs +20 -3
  44. data/core/range.rbs +91 -89
  45. data/core/rational.rbs +2 -3
  46. data/core/rbs/unnamed/argf.rbs +177 -120
  47. data/core/rbs/unnamed/env_class.rbs +89 -163
  48. data/core/rbs/unnamed/random.rbs +36 -12
  49. data/core/refinement.rbs +8 -0
  50. data/core/regexp.rbs +462 -272
  51. data/core/ruby_vm.rbs +210 -0
  52. data/{stdlib/set/0 → core}/set.rbs +43 -47
  53. data/core/string.rbs +1403 -1332
  54. data/core/string_io.rbs +191 -107
  55. data/core/struct.rbs +67 -63
  56. data/core/symbol.rbs +187 -201
  57. data/core/thread.rbs +40 -35
  58. data/core/time.rbs +902 -826
  59. data/core/trace_point.rbs +55 -6
  60. data/core/unbound_method.rbs +48 -24
  61. data/docs/collection.md +4 -0
  62. data/docs/syntax.md +55 -0
  63. data/ext/rbs_extension/parser.c +5 -6
  64. data/lib/rbs/cli.rb +6 -1
  65. data/lib/rbs/collection/cleaner.rb +8 -1
  66. data/lib/rbs/collection/config/lockfile.rb +3 -1
  67. data/lib/rbs/collection/config/lockfile_generator.rb +16 -14
  68. data/lib/rbs/collection/config.rb +1 -1
  69. data/lib/rbs/collection/sources/git.rb +9 -2
  70. data/lib/rbs/collection/sources/local.rb +79 -0
  71. data/lib/rbs/collection/sources.rb +8 -1
  72. data/lib/rbs/environment.rb +6 -5
  73. data/lib/rbs/environment_loader.rb +3 -2
  74. data/lib/rbs/errors.rb +18 -0
  75. data/lib/rbs/locator.rb +26 -7
  76. data/lib/rbs/sorter.rb +2 -2
  77. data/lib/rbs/version.rb +1 -1
  78. data/sig/collection/sources.rbs +32 -3
  79. data/sig/environment.rbs +2 -3
  80. data/sig/locator.rbs +14 -2
  81. data/sig/shims/{abstract_syntax_tree.rbs → _abstract_syntax_tree.rbs} +0 -0
  82. data/stdlib/bigdecimal/0/big_decimal.rbs +16 -13
  83. data/stdlib/cgi/0/core.rbs +16 -0
  84. data/stdlib/coverage/0/coverage.rbs +50 -8
  85. data/stdlib/csv/0/csv.rbs +1 -1
  86. data/stdlib/date/0/date.rbs +856 -726
  87. data/stdlib/date/0/date_time.rbs +83 -210
  88. data/stdlib/erb/0/erb.rbs +13 -36
  89. data/stdlib/etc/0/etc.rbs +127 -20
  90. data/stdlib/fileutils/0/fileutils.rbs +1290 -381
  91. data/stdlib/logger/0/logger.rbs +466 -316
  92. data/stdlib/net-http/0/net-http.rbs +2211 -534
  93. data/stdlib/nkf/0/nkf.rbs +5 -5
  94. data/stdlib/objspace/0/objspace.rbs +31 -14
  95. data/stdlib/openssl/0/openssl.rbs +11 -7
  96. data/stdlib/optparse/0/optparse.rbs +20 -17
  97. data/stdlib/pathname/0/pathname.rbs +21 -4
  98. data/stdlib/pstore/0/pstore.rbs +378 -154
  99. data/stdlib/pty/0/pty.rbs +24 -8
  100. data/stdlib/ripper/0/ripper.rbs +1650 -0
  101. data/stdlib/socket/0/addrinfo.rbs +9 -15
  102. data/stdlib/socket/0/socket.rbs +36 -3
  103. data/stdlib/strscan/0/string_scanner.rbs +7 -5
  104. data/stdlib/tempfile/0/tempfile.rbs +104 -44
  105. data/stdlib/time/0/time.rbs +2 -2
  106. data/stdlib/uri/0/file.rbs +5 -0
  107. data/stdlib/uri/0/generic.rbs +2 -2
  108. data/stdlib/yaml/0/yaml.rbs +2 -2
  109. data/stdlib/zlib/0/zlib.rbs +1 -1
  110. metadata +8 -6
  111. data/core/deprecated.rbs +0 -9
  112. data/sig/shims/ripper.rbs +0 -8
data/core/time.rbs CHANGED
@@ -1,17 +1,49 @@
1
1
  # <!-- rdoc-file=timev.rb -->
2
- # Time is an abstraction of dates and times. Time is stored internally as the
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
- # The Time class treats GMT (Greenwich Mean Time) and UTC (Coordinated Universal
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
- # Note: A Time object uses the resolution available on your system clock.
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
- # All times may have subsecond. Be aware of this fact when comparing times with
12
- # each other -- times that are apparently equal when displayed may be different
13
- # when compared. (Since Ruby 2.7.0, Time#inspect shows subsecond but Time#to_s
14
- # still doesn't show subsecond.)
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 Time.now)
46
+ # has the resolution supported by the system.
15
47
  #
16
48
  # ## Examples
17
49
  #
@@ -92,20 +124,18 @@
92
124
  #
93
125
  # First, what's elsewhere. Class Time:
94
126
  #
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).
127
+ # * Inherits from [class Object](rdoc-ref:Object@What-27s+Here).
128
+ # * Includes [module Comparable](rdoc-ref:Comparable@What-27s+Here).
99
129
  #
100
130
  #
101
131
  # Here, class Time provides methods that are useful for:
102
132
  #
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).
133
+ # * [Creating \Time objects](rdoc-ref:Time@Methods+for+Creating).
134
+ # * [Fetching \Time values](rdoc-ref:Time@Methods+for+Fetching).
135
+ # * [Querying a \Time object](rdoc-ref:Time@Methods+for+Querying).
136
+ # * [Comparing \Time objects](rdoc-ref:Time@Methods+for+Comparing).
137
+ # * [Converting a \Time object](rdoc-ref:Time@Methods+for+Converting).
138
+ # * [Rounding a \Time](rdoc-ref:Time@Methods+for+Rounding).
109
139
  #
110
140
  #
111
141
  # ### Methods for Creating
@@ -118,8 +148,7 @@
118
148
  # * ::at: Returns a new time based on seconds since epoch.
119
149
  # * ::now: Returns a new time based on the current system time.
120
150
  # * #+ (plus): Returns a new time increased by the given number of seconds.
121
- # * [-](#method-i-2D) (minus): Returns a new time
122
- # decreased by the given number of seconds.
151
+ # * #- (minus): Returns a new time decreased by the given number of seconds.
123
152
  #
124
153
  #
125
154
  # ### Methods for Fetching
@@ -163,7 +192,7 @@
163
192
  #
164
193
  # ### Methods for Comparing
165
194
  #
166
- # * [#<=>](#method-i-3C-3D-3E): Compares `self` to another time.
195
+ # * #<=>: Compares `self` to another time.
167
196
  # * #eql?: Returns whether the time is equal to another time.
168
197
  #
169
198
  #
@@ -178,6 +207,8 @@
178
207
  # * #getlocal: Returns a new time converted to local time.
179
208
  # * #utc (aliased as #gmtime): Converts time to UTC in place.
180
209
  # * #localtime: Converts time to local time in place.
210
+ # * #deconstruct_keys: Returns a hash of time components used in
211
+ # pattern-matching.
181
212
  #
182
213
  #
183
214
  # ### Methods for Rounding
@@ -187,37 +218,8 @@
187
218
  # * #floor: Returns a new time with subseconds lowered to a floor.
188
219
  #
189
220
  #
190
- # ## Timezone Argument
191
- #
192
- # A timezone argument must have `local_to_utc` and `utc_to_local` methods, and
193
- # may have `name`, `abbr`, and `dst?` methods.
194
- #
195
- # The `local_to_utc` method should convert a Time-like object from the timezone
196
- # to UTC, and `utc_to_local` is the opposite. The result also should be a Time
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.
204
- #
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
- #
209
- # The `abbr` method is used by '%Z' in #strftime.
210
- #
211
- # The `dst?` method is called with a `Time` value and should return whether the
212
- # `Time` value is in daylight savings time in the zone.
213
- #
214
- # ### Auto Conversion to Timezone
215
- #
216
- # At loading marshaled data, a timezone name will be converted to a timezone
217
- # object by `find_timezone` class method, if the method is defined.
218
- #
219
- # Similarly, that class method will be called when a timezone argument does not
220
- # have the necessary methods mentioned above.
221
+ # For the forms of argument `zone`, see [Timezone
222
+ # Specifiers](rdoc-ref:timezones.rdoc).
221
223
  #
222
224
  class Time < Object
223
225
  include Comparable
@@ -226,55 +228,60 @@ class Time < Object
226
228
  # rdoc-file=timev.rb
227
229
  # - at(time, subsec = false, unit = :microsecond, in: nil)
228
230
  # -->
229
- # *Time*
230
- #
231
- # This form accepts a Time object `time` and optional keyword argument `in`:
232
- #
233
- # Time.at(Time.new) # => 2021-04-26 08:52:31.6023486 -0500
234
- # Time.at(Time.new, in: '+09:00') # => 2021-04-26 22:52:31.6023486 +0900
235
- #
236
- # *Seconds*
237
- #
238
- # This form accepts a numeric number of seconds `sec` and optional keyword
239
- # argument `in`:
240
- #
241
- # Time.at(946702800) # => 1999-12-31 23:00:00 -0600
242
- # Time.at(946702800, in: '+09:00') # => 2000-01-01 14:00:00 +0900
243
- #
244
- # *Seconds with Subseconds and Units*
245
- #
246
- # This form accepts an integer number of seconds `sec_i`, a numeric number of
247
- # milliseconds `msec`, a symbol argument for the subsecond unit type (defaulting
248
- # to :usec), and an optional keyword argument `in`:
249
- #
250
- # Time.at(946702800, 500, :millisecond) # => 1999-12-31 23:00:00.5 -0600
251
- # Time.at(946702800, 500, :millisecond, in: '+09:00') # => 2000-01-01 14:00:00.5 +0900
252
- # Time.at(946702800, 500000) # => 1999-12-31 23:00:00.5 -0600
253
- # Time.at(946702800, 500000, :usec) # => 1999-12-31 23:00:00.5 -0600
254
- # Time.at(946702800, 500000, :microsecond) # => 1999-12-31 23:00:00.5 -0600
255
- # Time.at(946702800, 500000, in: '+09:00') # => 2000-01-01 14:00:00.5 +0900
256
- # Time.at(946702800, 500000, :usec, in: '+09:00') # => 2000-01-01 14:00:00.5 +0900
257
- # Time.at(946702800, 500000, :microsecond, in: '+09:00') # => 2000-01-01 14:00:00.5 +0900
258
- # Time.at(946702800, 500000000, :nsec) # => 1999-12-31 23:00:00.5 -0600
259
- # Time.at(946702800, 500000000, :nanosecond) # => 1999-12-31 23:00:00.5 -0600
260
- # Time.at(946702800, 500000000, :nsec, in: '+09:00') # => 2000-01-01 14:00:00.5 +0900
261
- # Time.at(946702800, 500000000, :nanosecond, in: '+09:00') # => 2000-01-01 14:00:00.5 +0900
262
- #
263
- # Parameters:
264
- # * `isec_i` is the integer number of seconds in the range `0..60`.
265
- # * `msec` is the number of milliseconds (Integer, Float, or Rational) in the
266
- # range `0..1000`.
267
- # * `usec` is the number of microseconds (Integer, Float, or Rational) in the
268
- # range `0..1000000`.
269
- # * `nsec` is the number of nanoseconds (Integer, Float, or Rational) in the
270
- # range `0..1000000000`.
271
- # * `in: zone`: a timezone *zone*, which may be:
272
- # * A string offset from UTC.
273
- # * A single letter offset from UTC, in the range `'A'..'Z'`, `'J'` (the
274
- # so-called military timezone) excluded.
275
- # * An integer number of seconds.
276
- # * A timezone object; see [Timezone
277
- # Argument](#class-Time-label-Timezone+Argument) for details.
231
+ # Returns a new Time object based on the given arguments.
232
+ #
233
+ # Required argument `time` may be either of:
234
+ #
235
+ # * A Time object, whose value is the basis for the returned time; also
236
+ # influenced by optional keyword argument `in:` (see below).
237
+ # * A numeric number of [Epoch seconds](rdoc-ref:Time@Epoch+Seconds) for the
238
+ # returned time.
239
+ #
240
+ #
241
+ # Examples:
242
+ #
243
+ # t = Time.new(2000, 12, 31, 23, 59, 59) # => 2000-12-31 23:59:59 -0600
244
+ # secs = t.to_i # => 978328799
245
+ # Time.at(secs) # => 2000-12-31 23:59:59 -0600
246
+ # Time.at(secs + 0.5) # => 2000-12-31 23:59:59.5 -0600
247
+ # Time.at(1000000000) # => 2001-09-08 20:46:40 -0500
248
+ # Time.at(0) # => 1969-12-31 18:00:00 -0600
249
+ # Time.at(-1000000000) # => 1938-04-24 17:13:20 -0500
250
+ #
251
+ # Optional numeric argument `subsec` and optional symbol argument `units` work
252
+ # together to specify subseconds for the returned time; argument `units`
253
+ # specifies the units for `subsec`:
254
+ #
255
+ # * `:millisecond`: `subsec` in milliseconds:
256
+ #
257
+ # Time.at(secs, 0, :millisecond) # => 2000-12-31 23:59:59 -0600
258
+ # Time.at(secs, 500, :millisecond) # => 2000-12-31 23:59:59.5 -0600
259
+ # Time.at(secs, 1000, :millisecond) # => 2001-01-01 00:00:00 -0600
260
+ # Time.at(secs, -1000, :millisecond) # => 2000-12-31 23:59:58 -0600
261
+ #
262
+ # * `:microsecond` or `:usec`: `subsec` in microseconds:
263
+ #
264
+ # Time.at(secs, 0, :microsecond) # => 2000-12-31 23:59:59 -0600
265
+ # Time.at(secs, 500000, :microsecond) # => 2000-12-31 23:59:59.5 -0600
266
+ # Time.at(secs, 1000000, :microsecond) # => 2001-01-01 00:00:00 -0600
267
+ # Time.at(secs, -1000000, :microsecond) # => 2000-12-31 23:59:58 -0600
268
+ #
269
+ # * `:nanosecond` or `:nsec`: `subsec` in nanoseconds:
270
+ #
271
+ # Time.at(secs, 0, :nanosecond) # => 2000-12-31 23:59:59 -0600
272
+ # Time.at(secs, 500000000, :nanosecond) # => 2000-12-31 23:59:59.5 -0600
273
+ # Time.at(secs, 1000000000, :nanosecond) # => 2001-01-01 00:00:00 -0600
274
+ # Time.at(secs, -1000000000, :nanosecond) # => 2000-12-31 23:59:58 -0600
275
+ #
276
+ #
277
+ # Optional keyword argument `+in: zone` specifies the timezone for the returned
278
+ # time:
279
+ #
280
+ # Time.at(secs, in: '+12:00') # => 2001-01-01 17:59:59 +1200
281
+ # Time.at(secs, in: '-12:00') # => 2000-12-31 17:59:59 -1200
282
+ #
283
+ # For the forms of argument `zone`, see [Timezone
284
+ # Specifiers](rdoc-ref:timezones.rdoc).
278
285
  #
279
286
  def self.at: (Time, ?in: String | Integer | nil) -> Time
280
287
  | (Numeric, ?in: String | Integer | nil) -> Time
@@ -282,60 +289,118 @@ class Time < Object
282
289
 
283
290
  type subsec_unit = :msec | :millisecond | :usec | :microsecond | :nsec | :nanosecond
284
291
 
285
- # Creates a Time object based on given values, interpreted as UTC (GMT). The
286
- # year must be specified. Other values default to the minimum value for that
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.
292
+ # <!-- rdoc-file=time.c -->
293
+ # Returns a new Time object based the on given arguments, in the UTC timezone.
291
294
  #
292
- # `sec_with_frac` and `usec_with_frac` can have a fractional part.
295
+ # With one to seven arguments given, the arguments are interpreted as in the
296
+ # first calling sequence above:
293
297
  #
294
- # Time.utc(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC
295
- # Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC
298
+ # Time.utc(year, month = 1, mday = 1, hour = 0, min = 0, sec = 0, usec = 0)
296
299
  #
297
- def self.gm: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
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.
300
+ # Examples:
306
301
  #
307
- # In the first form (up to seven arguments), argument `year` is required.
302
+ # Time.utc(2000) # => 2000-01-01 00:00:00 UTC
303
+ # Time.utc(-2000) # => -2000-01-01 00:00:00 UTC
308
304
  #
309
- # Time.local(2000) # => 2000-01-01 00:00:00 -0600
310
- # Time.local(0, 1, 2, 3, 4, 5, 6.5) # => 0000-01-02 03:04:05.0000065 -0600
305
+ # There are no minimum and maximum values for the required argument `year`.
311
306
  #
312
- # In the second form, all ten arguments are required, though the last four are
313
- # ignored. This form is useful for creating a time from a 10-element array such
314
- # as those returned by #to_a.
307
+ # For the optional arguments:
315
308
  #
316
- # array = Time.now.to_a
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
309
+ # * `month`: Month in range (1..12), or case-insensitive 3-letter month name:
320
310
  #
321
- # Parameters:
322
- # * `year`: an integer year.
323
- # * `month`: a month value, which may be:
324
- # * An integer month in the range `1..12`.
325
- # * A 3-character string that matches regular expression
326
- # `/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/i`.
311
+ # Time.utc(2000, 1) # => 2000-01-01 00:00:00 UTC
312
+ # Time.utc(2000, 12) # => 2000-12-01 00:00:00 UTC
313
+ # Time.utc(2000, 'jan') # => 2000-01-01 00:00:00 UTC
314
+ # Time.utc(2000, 'JAN') # => 2000-01-01 00:00:00 UTC
327
315
  #
328
- # * `day`: an integer day in the range `1..31` (less than 31 for some months).
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`.
316
+ # * `mday`: Month day in range(1..31):
334
317
  #
318
+ # Time.utc(2000, 1, 1) # => 2000-01-01 00:00:00 UTC
319
+ # Time.utc(2000, 1, 31) # => 2000-01-31 00:00:00 UTC
335
320
  #
336
- # Alias: Time.mktime.
321
+ # * `hour`: Hour in range (0..23), or 24 if `min`, `sec`, and `usec` are zero:
337
322
  #
338
- # Related: Time.utc.
323
+ # Time.utc(2000, 1, 1, 0) # => 2000-01-01 00:00:00 UTC
324
+ # Time.utc(2000, 1, 1, 23) # => 2000-01-01 23:00:00 UTC
325
+ # Time.utc(2000, 1, 1, 24) # => 2000-01-02 00:00:00 UTC
326
+ #
327
+ # * `min`: Minute in range (0..59):
328
+ #
329
+ # Time.utc(2000, 1, 1, 0, 0) # => 2000-01-01 00:00:00 UTC
330
+ # Time.utc(2000, 1, 1, 0, 59) # => 2000-01-01 00:59:00 UTC
331
+ #
332
+ # * `sec`: Second in range (0..59), or 60 if `usec` is zero:
333
+ #
334
+ # Time.utc(2000, 1, 1, 0, 0, 0) # => 2000-01-01 00:00:00 UTC
335
+ # Time.utc(2000, 1, 1, 0, 0, 59) # => 2000-01-01 00:00:59 UTC
336
+ # Time.utc(2000, 1, 1, 0, 0, 60) # => 2000-01-01 00:01:00 UTC
337
+ #
338
+ # * `usec`: Microsecond in range (0..999999):
339
+ #
340
+ # Time.utc(2000, 1, 1, 0, 0, 0, 0) # => 2000-01-01 00:00:00 UTC
341
+ # Time.utc(2000, 1, 1, 0, 0, 0, 999999) # => 2000-01-01 00:00:00.999999 UTC
342
+ #
343
+ #
344
+ # The values may be:
345
+ #
346
+ # * Integers, as above.
347
+ # * Numerics convertible to integers:
348
+ #
349
+ # Time.utc(Float(0.0), Rational(1, 1), 1.0, 0.0, 0.0, 0.0, 0.0)
350
+ # # => 0000-01-01 00:00:00 UTC
351
+ #
352
+ # * String integers:
353
+ #
354
+ # a = %w[0 1 1 0 0 0 0 0]
355
+ # # => ["0", "1", "1", "0", "0", "0", "0", "0"]
356
+ # Time.utc(*a) # => 0000-01-01 00:00:00 UTC
357
+ #
358
+ #
359
+ # When exactly ten arguments are given, the arguments are interpreted as in the
360
+ # second calling sequence above:
361
+ #
362
+ # Time.utc(sec, min, hour, mday, month, year, dummy, dummy, dummy, dummy)
363
+ #
364
+ # where the `dummy` arguments are ignored:
365
+ #
366
+ # a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
367
+ # # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
368
+ # Time.utc(*a) # => 0005-04-03 02:01:00 UTC
369
+ #
370
+ # This form is useful for creating a Time object from a 10-element array
371
+ # returned by Time.to_a:
372
+ #
373
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6) # => 2000-01-02 03:04:05 +000006
374
+ # a = t.to_a # => [5, 4, 3, 2, 1, 2000, 0, 2, false, nil]
375
+ # Time.utc(*a) # => 2000-01-02 03:04:05 UTC
376
+ #
377
+ # The two forms have their first six arguments in common, though in different
378
+ # orders; the ranges of these common arguments are the same for both forms; see
379
+ # above.
380
+ #
381
+ # Raises an exception if the number of arguments is eight, nine, or greater than
382
+ # ten.
383
+ #
384
+ # Time.gm is an alias for Time.utc.
385
+ #
386
+ # Related: Time.local.
387
+ #
388
+ def self.gm: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
389
+
390
+ # <!--
391
+ # rdoc-file=time.c
392
+ # - Time.local(year, month = 1, mday = 1, hour = 0, min = 0, sec = 0, usec = 0) -> new_time
393
+ # - Time.local(sec, min, hour, mday, month, year, dummy, dummy, dummy, dummy) -> new_time
394
+ # -->
395
+ # Like Time.utc, except that the returned Time object has the local timezone,
396
+ # not the UTC timezone:
397
+ #
398
+ # # With seven arguments.
399
+ # Time.local(0, 1, 2, 3, 4, 5, 6)
400
+ # # => 0000-01-02 03:04:05.000006 -0600
401
+ # # With exactly ten arguments.
402
+ # Time.local(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
403
+ # # => 0005-04-03 02:01:00 -0600
339
404
  #
340
405
  def self.local: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
341
406
 
@@ -349,54 +414,108 @@ class Time < Object
349
414
  # Time.now # => 2009-06-24 12:39:54 +0900
350
415
  # Time.now(in: '+04:00') # => 2009-06-24 07:39:54 +0400
351
416
  #
352
- # Parameter:
353
- # * `in: zone`: a timezone *zone*, which may be:
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.
417
+ # For forms of argument `zone`, see [Timezone
418
+ # Specifiers](rdoc-ref:timezones.rdoc).
360
419
  #
361
420
  def self.now: (?in: String | Integer | nil) -> Time
362
421
 
363
422
  # <!--
364
423
  # rdoc-file=time.c
365
- # - Time.utc(year, month=1, day=1, hour=0, min=0, sec_i=0, usec=0) -> new_time
366
- # - Time.utc(sec_i, min, hour, day, month, year, dummy, dummy, dummy, dummy) -> new_time
424
+ # - Time.utc(year, month = 1, mday = 1, hour = 0, min = 0, sec = 0, usec = 0) -> new_time
425
+ # - Time.utc(sec, min, hour, mday, month, year, dummy, dummy, dummy, dummy) -> new_time
367
426
  # -->
368
- # Returns a new Time object based the on given arguments; its timezone is UTC.
427
+ # Returns a new Time object based the on given arguments, in the UTC timezone.
428
+ #
429
+ # With one to seven arguments given, the arguments are interpreted as in the
430
+ # first calling sequence above:
431
+ #
432
+ # Time.utc(year, month = 1, mday = 1, hour = 0, min = 0, sec = 0, usec = 0)
433
+ #
434
+ # Examples:
369
435
  #
370
- # In the first form (up to seven arguments), argument `year` is required.
436
+ # Time.utc(2000) # => 2000-01-01 00:00:00 UTC
437
+ # Time.utc(-2000) # => -2000-01-01 00:00:00 UTC
371
438
  #
372
- # Time.utc(2000) # => 2000-01-01 00:00:00 UTC
373
- # Time.utc(0, 1, 2, 3, 4, 5, 6.5) # => 0000-01-02 03:04:05.0000065 UTC
439
+ # There are no minimum and maximum values for the required argument `year`.
374
440
  #
375
- # In the second form, all ten arguments are required, though the last four are
376
- # ignored. This form is useful for creating a time from a 10-element array such
377
- # as is returned by #to_a.
441
+ # For the optional arguments:
378
442
  #
379
- # array = Time.now.to_a
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
443
+ # * `month`: Month in range (1..12), or case-insensitive 3-letter month name:
383
444
  #
384
- # Parameters:
385
- # * `year`: an integer year.
386
- # * `month`: a month value, which may be:
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`.
445
+ # Time.utc(2000, 1) # => 2000-01-01 00:00:00 UTC
446
+ # Time.utc(2000, 12) # => 2000-12-01 00:00:00 UTC
447
+ # Time.utc(2000, 'jan') # => 2000-01-01 00:00:00 UTC
448
+ # Time.utc(2000, 'JAN') # => 2000-01-01 00:00:00 UTC
390
449
  #
391
- # * `day`: an integer day in the range `1..31` (less than 31 for some months).
392
- # * `hour`: an integer hour in the range `0..23`.
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`.
450
+ # * `mday`: Month day in range(1..31):
397
451
  #
452
+ # Time.utc(2000, 1, 1) # => 2000-01-01 00:00:00 UTC
453
+ # Time.utc(2000, 1, 31) # => 2000-01-31 00:00:00 UTC
398
454
  #
399
- # Alias: Time.gm.
455
+ # * `hour`: Hour in range (0..23), or 24 if `min`, `sec`, and `usec` are zero:
456
+ #
457
+ # Time.utc(2000, 1, 1, 0) # => 2000-01-01 00:00:00 UTC
458
+ # Time.utc(2000, 1, 1, 23) # => 2000-01-01 23:00:00 UTC
459
+ # Time.utc(2000, 1, 1, 24) # => 2000-01-02 00:00:00 UTC
460
+ #
461
+ # * `min`: Minute in range (0..59):
462
+ #
463
+ # Time.utc(2000, 1, 1, 0, 0) # => 2000-01-01 00:00:00 UTC
464
+ # Time.utc(2000, 1, 1, 0, 59) # => 2000-01-01 00:59:00 UTC
465
+ #
466
+ # * `sec`: Second in range (0..59), or 60 if `usec` is zero:
467
+ #
468
+ # Time.utc(2000, 1, 1, 0, 0, 0) # => 2000-01-01 00:00:00 UTC
469
+ # Time.utc(2000, 1, 1, 0, 0, 59) # => 2000-01-01 00:00:59 UTC
470
+ # Time.utc(2000, 1, 1, 0, 0, 60) # => 2000-01-01 00:01:00 UTC
471
+ #
472
+ # * `usec`: Microsecond in range (0..999999):
473
+ #
474
+ # Time.utc(2000, 1, 1, 0, 0, 0, 0) # => 2000-01-01 00:00:00 UTC
475
+ # Time.utc(2000, 1, 1, 0, 0, 0, 999999) # => 2000-01-01 00:00:00.999999 UTC
476
+ #
477
+ #
478
+ # The values may be:
479
+ #
480
+ # * Integers, as above.
481
+ # * Numerics convertible to integers:
482
+ #
483
+ # Time.utc(Float(0.0), Rational(1, 1), 1.0, 0.0, 0.0, 0.0, 0.0)
484
+ # # => 0000-01-01 00:00:00 UTC
485
+ #
486
+ # * String integers:
487
+ #
488
+ # a = %w[0 1 1 0 0 0 0 0]
489
+ # # => ["0", "1", "1", "0", "0", "0", "0", "0"]
490
+ # Time.utc(*a) # => 0000-01-01 00:00:00 UTC
491
+ #
492
+ #
493
+ # When exactly ten arguments are given, the arguments are interpreted as in the
494
+ # second calling sequence above:
495
+ #
496
+ # Time.utc(sec, min, hour, mday, month, year, dummy, dummy, dummy, dummy)
497
+ #
498
+ # where the `dummy` arguments are ignored:
499
+ #
500
+ # a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
501
+ # # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
502
+ # Time.utc(*a) # => 0005-04-03 02:01:00 UTC
503
+ #
504
+ # This form is useful for creating a Time object from a 10-element array
505
+ # returned by Time.to_a:
506
+ #
507
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6) # => 2000-01-02 03:04:05 +000006
508
+ # a = t.to_a # => [5, 4, 3, 2, 1, 2000, 0, 2, false, nil]
509
+ # Time.utc(*a) # => 2000-01-02 03:04:05 UTC
510
+ #
511
+ # The two forms have their first six arguments in common, though in different
512
+ # orders; the ranges of these common arguments are the same for both forms; see
513
+ # above.
514
+ #
515
+ # Raises an exception if the number of arguments is eight, nine, or greater than
516
+ # ten.
517
+ #
518
+ # Time.gm is an alias for Time.utc.
400
519
  #
401
520
  # Related: Time.local.
402
521
  #
@@ -404,28 +523,37 @@ class Time < Object
404
523
 
405
524
  # <!--
406
525
  # rdoc-file=time.c
407
- # - time + numeric -> time
526
+ # - self + numeric -> new_time
408
527
  # -->
409
- # Adds some number of seconds (possibly including subsecond) to *time* and
410
- # returns that value as a new Time object.
528
+ # Returns a new Time object whose value is the sum of the numeric value of
529
+ # `self` and the given `numeric`:
530
+ #
531
+ # t = Time.new(2000) # => 2000-01-01 00:00:00 -0600
532
+ # t + (60 * 60 * 24) # => 2000-01-02 00:00:00 -0600
533
+ # t + 0.5 # => 2000-01-01 00:00:00.5 -0600
411
534
  #
412
- # t = Time.now #=> 2020-07-20 22:14:43.170490982 +0900
413
- # t + (60 * 60 * 24) #=> 2020-07-21 22:14:43.170490982 +0900
535
+ # Related: Time#-.
414
536
  #
415
537
  def +: (Numeric arg0) -> Time
416
538
 
417
539
  # <!--
418
540
  # rdoc-file=time.c
419
- # - time - other_time -> float
420
- # - time - numeric -> time
541
+ # - self - numeric -> new_time
542
+ # - self - other_time -> float
421
543
  # -->
422
- # Returns a difference in seconds as a Float between *time* and `other_time`, or
423
- # subtracts the given number of seconds in `numeric` from *time*.
544
+ # When `numeric` is given, returns a new Time object whose value is the
545
+ # difference of the numeric value of `self` and `numeric`:
546
+ #
547
+ # t = Time.new(2000) # => 2000-01-01 00:00:00 -0600
548
+ # t - (60 * 60 * 24) # => 1999-12-31 00:00:00 -0600
549
+ # t - 0.5 # => 1999-12-31 23:59:59.5 -0600
424
550
  #
425
- # t = Time.now #=> 2020-07-20 22:15:49.302766336 +0900
426
- # t2 = t + 2592000 #=> 2020-08-19 22:15:49.302766336 +0900
427
- # t2 - t #=> 2592000.0
428
- # t2 - 2592000 #=> 2020-07-20 22:15:49.302766336 +0900
551
+ # When `other_time` is given, returns a Float whose value is the difference of
552
+ # the numeric values of `self` and `other_time`:
553
+ #
554
+ # t - t # => 0.0
555
+ #
556
+ # Related: Time#+.
429
557
  #
430
558
  def -: (Time arg0) -> Float
431
559
  | (Numeric arg0) -> Time
@@ -436,27 +564,30 @@ class Time < Object
436
564
 
437
565
  # <!--
438
566
  # rdoc-file=time.c
439
- # - time <=> other_time -> -1, 0, +1, or nil
567
+ # - self <=> other_time -> -1, 0, +1, or nil
440
568
  # -->
441
- # Compares `time` with `other_time`.
569
+ # Compares `self` with `other_time`; returns:
442
570
  #
443
- # -1, 0, +1 or nil depending on whether `time` is less than, equal to, or
444
- # greater than `other_time`.
571
+ # * `-1`, if `self` is less than `other_time`.
572
+ # * `0`, if `self` is equal to `other_time`.
573
+ # * `1`, if `self` is greater then `other_time`.
574
+ # * `nil`, if `self` and `other_time` are incomparable.
445
575
  #
446
- # `nil` is returned if the two values are incomparable.
447
576
  #
448
- # t = Time.now #=> 2007-11-19 08:12:12 -0600
449
- # t2 = t + 2592000 #=> 2007-12-19 08:12:12 -0600
450
- # t <=> t2 #=> -1
451
- # t2 <=> t #=> 1
577
+ # Examples:
578
+ #
579
+ # t = Time.now # => 2007-11-19 08:12:12 -0600
580
+ # t2 = t + 2592000 # => 2007-12-19 08:12:12 -0600
581
+ # t <=> t2 # => -1
582
+ # t2 <=> t # => 1
452
583
  #
453
- # t = Time.now #=> 2007-11-19 08:13:38 -0600
454
- # t2 = t + 0.1 #=> 2007-11-19 08:13:38 -0600
455
- # t.nsec #=> 98222999
456
- # t2.nsec #=> 198222999
457
- # t <=> t2 #=> -1
458
- # t2 <=> t #=> 1
459
- # t <=> t #=> 0
584
+ # t = Time.now # => 2007-11-19 08:13:38 -0600
585
+ # t2 = t + 0.1 # => 2007-11-19 08:13:38 -0600
586
+ # t.nsec # => 98222999
587
+ # t2.nsec # => 198222999
588
+ # t <=> t2 # => -1
589
+ # t2 <=> t # => 1
590
+ # t <=> t # => 0
460
591
  #
461
592
  def <=>: (Time other) -> Integer
462
593
  | (untyped other) -> Integer?
@@ -466,895 +597,834 @@ class Time < Object
466
597
  def >=: (Time arg0) -> bool
467
598
 
468
599
  # <!-- rdoc-file=time.c -->
469
- # Returns a canonical string representation of *time*.
600
+ # Returns a string representation of `self`, formatted by `strftime('%a %b %e %T
601
+ # %Y')` or its shorthand version `strftime('%c')`; see [Formats for Dates and
602
+ # Times](rdoc-ref:strftime_formatting.rdoc):
603
+ #
604
+ # t = Time.new(2000, 12, 31, 23, 59, 59, 0.5)
605
+ # t.ctime # => "Sun Dec 31 23:59:59 2000"
606
+ # t.strftime('%a %b %e %T %Y') # => "Sun Dec 31 23:59:59 2000"
607
+ # t.strftime('%c') # => "Sun Dec 31 23:59:59 2000"
608
+ #
609
+ # Time#asctime is an alias for Time#ctime.
610
+ #
611
+ # Related: Time#to_s, Time#inspect:
470
612
  #
471
- # Time.now.asctime #=> "Wed Apr 9 08:56:03 2003"
472
- # Time.now.ctime #=> "Wed Apr 9 08:56:03 2003"
613
+ # t.inspect # => "2000-12-31 23:59:59.5 +000001"
614
+ # t.to_s # => "2000-12-31 23:59:59 +0000"
473
615
  #
474
616
  def asctime: () -> String
475
617
 
476
618
  # <!--
477
619
  # rdoc-file=time.c
478
- # - time.asctime -> string
479
- # - time.ctime -> string
620
+ # - ctime -> string
480
621
  # -->
481
- # Returns a canonical string representation of *time*.
622
+ # Returns a string representation of `self`, formatted by `strftime('%a %b %e %T
623
+ # %Y')` or its shorthand version `strftime('%c')`; see [Formats for Dates and
624
+ # Times](rdoc-ref:strftime_formatting.rdoc):
482
625
  #
483
- # Time.now.asctime #=> "Wed Apr 9 08:56:03 2003"
484
- # Time.now.ctime #=> "Wed Apr 9 08:56:03 2003"
626
+ # t = Time.new(2000, 12, 31, 23, 59, 59, 0.5)
627
+ # t.ctime # => "Sun Dec 31 23:59:59 2000"
628
+ # t.strftime('%a %b %e %T %Y') # => "Sun Dec 31 23:59:59 2000"
629
+ # t.strftime('%c') # => "Sun Dec 31 23:59:59 2000"
630
+ #
631
+ # Time#asctime is an alias for Time#ctime.
632
+ #
633
+ # Related: Time#to_s, Time#inspect:
634
+ #
635
+ # t.inspect # => "2000-12-31 23:59:59.5 +000001"
636
+ # t.to_s # => "2000-12-31 23:59:59 +0000"
485
637
  #
486
638
  def ctime: () -> String
487
639
 
488
640
  # <!-- rdoc-file=time.c -->
489
- # Returns the day of the month (1..31) for *time*.
641
+ # Returns the integer day of the month for `self`, in range (1..31):
490
642
  #
491
- # t = Time.now #=> 2007-11-19 08:27:03 -0600
492
- # t.day #=> 19
493
- # t.mday #=> 19
643
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
644
+ # # => 2000-01-02 03:04:05 +000006
645
+ # t.mday # => 2
646
+ #
647
+ # Time#day is an alias for Time#mday.
648
+ #
649
+ # Related: Time#year, Time#hour, Time#min.
494
650
  #
495
651
  def day: () -> Integer
496
652
 
653
+ # <!--
654
+ # rdoc-file=time.c
655
+ # - deconstruct_keys(array_of_names_or_nil) -> hash
656
+ # -->
657
+ # Returns a hash of the name/value pairs, to use in pattern matching. Possible
658
+ # keys are: `:year`, `:month`, `:day`, `:yday`, `:wday`, `:hour`, `:min`,
659
+ # `:sec`, `:subsec`, `:dst`, `:zone`.
660
+ #
661
+ # Possible usages:
662
+ #
663
+ # t = Time.utc(2022, 10, 5, 21, 25, 30)
664
+ #
665
+ # if t in wday: 3, day: ..7 # uses deconstruct_keys underneath
666
+ # puts "first Wednesday of the month"
667
+ # end
668
+ # #=> prints "first Wednesday of the month"
669
+ #
670
+ # case t
671
+ # in year: ...2022
672
+ # puts "too old"
673
+ # in month: ..9
674
+ # puts "quarter 1-3"
675
+ # in wday: 1..5, month:
676
+ # puts "working day in month #{month}"
677
+ # end
678
+ # #=> prints "working day in month 10"
679
+ #
680
+ # Note that deconstruction by pattern can also be combined with class check:
681
+ #
682
+ # if t in Time(wday: 3, day: ..7)
683
+ # puts "first Wednesday of the month"
684
+ # end
685
+ #
686
+ def deconstruct_keys: (Array[Symbol]?) -> Hash[Symbol, Integer]
687
+
497
688
  # <!-- rdoc-file=time.c -->
498
- # Returns `true` if *time* occurs during Daylight Saving Time in its time zone.
499
- #
500
- # # CST6CDT:
501
- # Time.local(2000, 1, 1).zone #=> "CST"
502
- # Time.local(2000, 1, 1).isdst #=> false
503
- # Time.local(2000, 1, 1).dst? #=> false
504
- # Time.local(2000, 7, 1).zone #=> "CDT"
505
- # Time.local(2000, 7, 1).isdst #=> true
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
689
+ # Returns `true` if `self` is in daylight saving time, `false` otherwise:
690
+ #
691
+ # t = Time.local(2000, 1, 1) # => 2000-01-01 00:00:00 -0600
692
+ # t.zone # => "Central Standard Time"
693
+ # t.dst? # => false
694
+ # t = Time.local(2000, 7, 1) # => 2000-07-01 00:00:00 -0500
695
+ # t.zone # => "Central Daylight Time"
696
+ # t.dst? # => true
697
+ #
698
+ # Time#isdst is an alias for Time#dst?.
515
699
  #
516
700
  def dst?: () -> bool
517
701
 
518
702
  # <!--
519
703
  # rdoc-file=time.c
520
- # - time.eql?(other_time)
704
+ # - eql?(other_time)
521
705
  # -->
522
- # Returns `true` if *time* and `other_time` are both Time objects with the same
523
- # seconds (including subsecond) from the Epoch.
706
+ # Returns `true` if `self` and `other_time` are both Time objects with the exact
707
+ # same time value.
524
708
  #
525
709
  def eql?: (untyped arg0) -> bool
526
710
 
527
711
  # <!--
528
712
  # rdoc-file=time.c
529
- # - time.friday? -> true or false
713
+ # - friday? -> true or false
530
714
  # -->
531
- # Returns `true` if *time* represents Friday.
715
+ # Returns `true` if `self` represents a Friday, `false` otherwise:
716
+ #
717
+ # t = Time.utc(2000, 1, 7) # => 2000-01-07 00:00:00 UTC
718
+ # t.friday? # => true
532
719
  #
533
- # t = Time.local(1987, 12, 18) #=> 1987-12-18 00:00:00 -0600
534
- # t.friday? #=> true
720
+ # Related: Time#saturday?, Time#sunday?, Time#monday?.
535
721
  #
536
722
  def friday?: () -> bool
537
723
 
538
724
  # <!--
539
725
  # rdoc-file=time.c
540
- # - time.getgm -> new_time
541
- # - time.getutc -> new_time
726
+ # - getutc -> new_time
542
727
  # -->
543
- # Returns a new Time object representing *time* in UTC.
728
+ # Returns a new Time object representing the value of `self` converted to the
729
+ # UTC timezone:
544
730
  #
545
- # t = Time.local(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 -0600
546
- # t.gmt? #=> false
547
- # y = t.getgm #=> 2000-01-02 02:15:01 UTC
548
- # y.gmt? #=> true
549
- # t == y #=> true
731
+ # local = Time.local(2000) # => 2000-01-01 00:00:00 -0600
732
+ # local.utc? # => false
733
+ # utc = local.getutc # => 2000-01-01 06:00:00 UTC
734
+ # utc.utc? # => true
735
+ # utc == local # => true
736
+ #
737
+ # Time#getgm is an alias for Time#getutc.
550
738
  #
551
739
  def getgm: () -> Time
552
740
 
553
741
  # <!--
554
742
  # rdoc-file=time.c
555
- # - time.getlocal -> new_time
556
- # - time.getlocal(utc_offset) -> new_time
557
- # - time.getlocal(timezone) -> new_time
743
+ # - getlocal(zone = nil) -> new_time
558
744
  # -->
559
- # Returns a new Time object representing *time* in local time (using the local
560
- # time zone in effect for this process).
561
- #
562
- # If `utc_offset` is given, it is used instead of the local time. `utc_offset`
563
- # can be given as a human-readable string (eg. `"+09:00"`) or as a number of
564
- # seconds (eg. `32400`).
565
- #
566
- # t = Time.utc(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
567
- # t.utc? #=> true
568
- #
569
- # l = t.getlocal #=> 2000-01-01 14:15:01 -0600
570
- # l.utc? #=> false
571
- # t == l #=> true
745
+ # Returns a new Time object representing the value of `self` converted to a
746
+ # given timezone; if `zone` is `nil`, the local timezone is used:
572
747
  #
573
- # j = t.getlocal("+09:00") #=> 2000-01-02 05:15:01 +0900
574
- # j.utc? #=> false
575
- # t == j #=> true
748
+ # t = Time.utc(2000) # => 2000-01-01 00:00:00 UTC
749
+ # t.getlocal # => 1999-12-31 18:00:00 -0600
750
+ # t.getlocal('+12:00') # => 2000-01-01 12:00:00 +1200
576
751
  #
577
- # k = t.getlocal(9*60*60) #=> 2000-01-02 05:15:01 +0900
578
- # k.utc? #=> false
579
- # t == k #=> true
752
+ # For forms of argument `zone`, see [Timezone
753
+ # Specifiers](rdoc-ref:timezones.rdoc).
580
754
  #
581
755
  def getlocal: (?Integer utc_offset) -> Time
582
756
 
583
757
  # <!-- rdoc-file=time.c -->
584
- # Returns a new Time object representing *time* in UTC.
758
+ # Returns a new Time object representing the value of `self` converted to the
759
+ # UTC timezone:
585
760
  #
586
- # t = Time.local(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 -0600
587
- # t.gmt? #=> false
588
- # y = t.getgm #=> 2000-01-02 02:15:01 UTC
589
- # y.gmt? #=> true
590
- # t == y #=> true
761
+ # local = Time.local(2000) # => 2000-01-01 00:00:00 -0600
762
+ # local.utc? # => false
763
+ # utc = local.getutc # => 2000-01-01 06:00:00 UTC
764
+ # utc.utc? # => true
765
+ # utc == local # => true
766
+ #
767
+ # Time#getgm is an alias for Time#getutc.
591
768
  #
592
769
  def getutc: () -> Time
593
770
 
594
771
  # <!-- rdoc-file=time.c -->
595
- # Returns `true` if *time* represents a time in UTC (GMT).
772
+ # Returns `true` if `self` represents a time in UTC (GMT):
773
+ #
774
+ # now = Time.now
775
+ # # => 2022-08-18 10:24:13.5398485 -0500
776
+ # now.utc? # => false
777
+ # utc = Time.utc(2000, 1, 1, 20, 15, 1)
778
+ # # => 2000-01-01 20:15:01 UTC
779
+ # utc.utc? # => true
596
780
  #
597
- # t = Time.now #=> 2007-11-19 08:15:23 -0600
598
- # t.utc? #=> false
599
- # t = Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC
600
- # t.utc? #=> true
781
+ # Time#gmt? is an alias for Time#utc?.
601
782
  #
602
- # t = Time.now #=> 2007-11-19 08:16:03 -0600
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
783
+ # Related: Time.utc.
606
784
  #
607
785
  def gmt?: () -> bool
608
786
 
609
787
  # <!-- rdoc-file=time.c -->
610
- # Returns the offset in seconds between the timezone of *time* and UTC.
788
+ # Returns the offset in seconds between the timezones of UTC and `self`:
611
789
  #
612
- # t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
613
- # t.gmt_offset #=> 0
614
- # l = t.getlocal #=> 2000-01-01 14:15:01 -0600
615
- # l.gmt_offset #=> -21600
790
+ # Time.utc(2000, 1, 1).utc_offset # => 0
791
+ # Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours.
792
+ #
793
+ # Time#gmt_offset and Time#gmtoff are aliases for Time#utc_offset.
616
794
  #
617
795
  def gmt_offset: () -> Integer
618
796
 
619
797
  # <!--
620
798
  # rdoc-file=time.c
621
- # - time.gmtime -> time
622
- # - time.utc -> time
799
+ # - utc -> self
623
800
  # -->
624
- # Converts *time* to UTC (GMT), modifying the receiver.
801
+ # Returns `self`, converted to the UTC timezone:
802
+ #
803
+ # t = Time.new(2000) # => 2000-01-01 00:00:00 -0600
804
+ # t.utc? # => false
805
+ # t.utc # => 2000-01-01 06:00:00 UTC
806
+ # t.utc? # => true
625
807
  #
626
- # t = Time.now #=> 2007-11-19 08:18:31 -0600
627
- # t.gmt? #=> false
628
- # t.gmtime #=> 2007-11-19 14:18:31 UTC
629
- # t.gmt? #=> true
808
+ # Time#gmtime is an alias for Time#utc.
630
809
  #
631
- # t = Time.now #=> 2007-11-19 08:18:51 -0600
632
- # t.utc? #=> false
633
- # t.utc #=> 2007-11-19 14:18:51 UTC
634
- # t.utc? #=> true
810
+ # Related: Time#getutc (returns a new converted Time object).
635
811
  #
636
812
  def gmtime: () -> Time
637
813
 
638
814
  # <!--
639
815
  # rdoc-file=time.c
640
- # - time.hash -> integer
816
+ # - hash -> integer
641
817
  # -->
642
- # Returns a hash code for this Time object.
818
+ # Returns the integer hash code for `self`.
643
819
  #
644
- # See also Object#hash.
820
+ # Related: Object#hash.
645
821
  #
646
822
  def hash: () -> Integer
647
823
 
648
824
  # <!--
649
825
  # rdoc-file=time.c
650
- # - time.hour -> integer
826
+ # - hour -> integer
651
827
  # -->
652
- # Returns the hour of the day (0..23) for *time*.
828
+ # Returns the integer hour of the day for `self`, in range (0..23):
829
+ #
830
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
831
+ # # => 2000-01-02 03:04:05 +000006
832
+ # t.hour # => 3
653
833
  #
654
- # t = Time.now #=> 2007-11-19 08:26:20 -0600
655
- # t.hour #=> 8
834
+ # Related: Time#year, Time#mon, Time#min.
656
835
  #
657
836
  def hour: () -> Integer
658
837
 
659
838
  # <!--
660
839
  # rdoc-file=timev.rb
661
- # - new(year = (now = true), mon = nil, mday = nil, hour = nil, min = nil, sec = nil, zone = nil, in: nil)
840
+ # - new(year = (now = true), mon = (str = year; nil), mday = nil, hour = nil, min = nil, sec = nil, zone = nil, in: nil, precision: 9)
662
841
  # -->
663
- # Returns a new Time object based on the given arguments.
842
+ # Returns a new Time object based on the given arguments, by default in the
843
+ # local timezone.
664
844
  #
665
845
  # With no positional arguments, returns the value of Time.now:
666
846
  #
667
- # Time.new # => 2021-04-24 17:27:46.0512465 -0500
847
+ # Time.new # => 2021-04-24 17:27:46.0512465 -0500
848
+ #
849
+ # With one string argument that represents a time, returns a new Time object
850
+ # based on the given argument, in the local timezone.
851
+ #
852
+ # Time.new('2000-12-31 23:59:59.5') # => 2000-12-31 23:59:59.5 -0600
853
+ # Time.new('2000-12-31 23:59:59.5 +0900') # => 2000-12-31 23:59:59.5 +0900
854
+ # Time.new('2000-12-31 23:59:59.5', in: '+0900') # => 2000-12-31 23:59:59.5 +0900
855
+ # Time.new('2000-12-31 23:59:59.5') # => 2000-12-31 23:59:59.5 -0600
856
+ # Time.new('2000-12-31 23:59:59.56789', precision: 3) # => 2000-12-31 23:59:59.567 -0600
857
+ #
858
+ # With one to six arguments, returns a new Time object based on the given
859
+ # arguments, in the local timezone.
860
+ #
861
+ # Time.new(2000, 1, 2, 3, 4, 5) # => 2000-01-02 03:04:05 -0600
862
+ #
863
+ # For the positional arguments (other than `zone`):
864
+ #
865
+ # * `year`: Year, with no range limits:
866
+ #
867
+ # Time.new(999999999) # => 999999999-01-01 00:00:00 -0600
868
+ # Time.new(-999999999) # => -999999999-01-01 00:00:00 -0600
869
+ #
870
+ # * `month`: Month in range (1..12), or case-insensitive 3-letter month name:
871
+ #
872
+ # Time.new(2000, 1) # => 2000-01-01 00:00:00 -0600
873
+ # Time.new(2000, 12) # => 2000-12-01 00:00:00 -0600
874
+ # Time.new(2000, 'jan') # => 2000-01-01 00:00:00 -0600
875
+ # Time.new(2000, 'JAN') # => 2000-01-01 00:00:00 -0600
876
+ #
877
+ # * `mday`: Month day in range(1..31):
878
+ #
879
+ # Time.new(2000, 1, 1) # => 2000-01-01 00:00:00 -0600
880
+ # Time.new(2000, 1, 31) # => 2000-01-31 00:00:00 -0600
881
+ #
882
+ # * `hour`: Hour in range (0..23), or 24 if `min`, `sec`, and `usec` are zero:
883
+ #
884
+ # Time.new(2000, 1, 1, 0) # => 2000-01-01 00:00:00 -0600
885
+ # Time.new(2000, 1, 1, 23) # => 2000-01-01 23:00:00 -0600
886
+ # Time.new(2000, 1, 1, 24) # => 2000-01-02 00:00:00 -0600
668
887
  #
669
- # Otherwise, returns a new Time object based on the given parameters:
888
+ # * `min`: Minute in range (0..59):
670
889
  #
671
- # Time.new(2000) # => 2000-01-01 00:00:00 -0600
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
890
+ # Time.new(2000, 1, 1, 0, 0) # => 2000-01-01 00:00:00 -0600
891
+ # Time.new(2000, 1, 1, 0, 59) # => 2000-01-01 00:59:00 -0600
674
892
  #
675
- # Parameters:
893
+ # * `sec`: Second in range (0...61):
676
894
  #
677
- # * `year`: an integer year.
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`.
895
+ # Time.new(2000, 1, 1, 0, 0, 0) # => 2000-01-01 00:00:00 -0600
896
+ # Time.new(2000, 1, 1, 0, 0, 59) # => 2000-01-01 00:00:59 -0600
897
+ # Time.new(2000, 1, 1, 0, 0, 60) # => 2000-01-01 00:01:00 -0600
682
898
  #
683
- # * `day`: an integer day in the range `1..31` (less than 31 for some months).
684
- # * `hour`: an integer hour in the range `0..23`.
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.
899
+ # `sec` may be Float or Rational.
695
900
  #
696
- # * `in: zone`: a timezone *zone*, which may be as above.
901
+ # Time.new(2000, 1, 1, 0, 0, 59.5) # => 2000-12-31 23:59:59.5 +0900
902
+ # Time.new(2000, 1, 1, 0, 0, 59.7r) # => 2000-12-31 23:59:59.7 +0900
903
+ #
904
+ #
905
+ # These values may be:
906
+ #
907
+ # * Integers, as above.
908
+ # * Numerics convertible to integers:
909
+ #
910
+ # Time.new(Float(0.0), Rational(1, 1), 1.0, 0.0, 0.0, 0.0)
911
+ # # => 0000-01-01 00:00:00 -0600
912
+ #
913
+ # * String integers:
914
+ #
915
+ # a = %w[0 1 1 0 0 0]
916
+ # # => ["0", "1", "1", "0", "0", "0"]
917
+ # Time.new(*a) # => 0000-01-01 00:00:00 -0600
918
+ #
919
+ #
920
+ # When positional argument `zone` or keyword argument `in:` is given, the new
921
+ # Time object is in the specified timezone. For the forms of argument `zone`,
922
+ # see [Timezone Specifiers](rdoc-ref:timezones.rdoc):
923
+ #
924
+ # Time.new(2000, 1, 1, 0, 0, 0, '+12:00')
925
+ # # => 2000-01-01 00:00:00 +1200
926
+ # Time.new(2000, 1, 1, 0, 0, 0, in: '-12:00')
927
+ # # => 2000-01-01 00:00:00 -1200
928
+ # Time.new(in: '-12:00')
929
+ # # => 2022-08-23 08:49:26.1941467 -1200
930
+ #
931
+ # * `precision`: maximum effective digits in sub-second part, default is 9.
932
+ # More digits will be truncated, as other operations of Time. Ignored unless
933
+ # the first argument is a string.
697
934
  #
698
935
  def initialize: (?Integer? year, ?Integer? month, ?Integer? day, ?Integer? hour, ?Integer? min, ?Numeric? sec, ?String | Integer | nil) -> void
699
936
  | (?Integer? year, ?Integer? month, ?Integer? day, ?Integer? hour, ?Integer? min, ?Numeric? sec, in: String | Integer | nil) -> void
937
+ | (String, ?in: string | int | nil, ?precision: int) -> void
700
938
 
701
939
  # <!--
702
940
  # rdoc-file=time.c
703
- # - time.inspect -> string
941
+ # - inspect -> string
704
942
  # -->
705
- # Returns a detailed string representing *time*. Unlike to_s, preserves
706
- # subsecond in the representation for easier debugging.
943
+ # Returns a string representation of `self` with subseconds:
707
944
  #
708
- # t = Time.now
709
- # t.inspect #=> "2012-11-10 18:16:12.261257655 +0100"
710
- # t.strftime "%Y-%m-%d %H:%M:%S.%N %z" #=> "2012-11-10 18:16:12.261257655 +0100"
945
+ # t = Time.new(2000, 12, 31, 23, 59, 59, 0.5)
946
+ # t.inspect # => "2000-12-31 23:59:59.5 +000001"
711
947
  #
712
- # t.utc.inspect #=> "2012-11-10 17:16:12.261257655 UTC"
713
- # t.strftime "%Y-%m-%d %H:%M:%S.%N UTC" #=> "2012-11-10 17:16:12.261257655 UTC"
948
+ # Related: Time#ctime, Time#to_s:
949
+ #
950
+ # t.ctime # => "Sun Dec 31 23:59:59 2000"
951
+ # t.to_s # => "2000-12-31 23:59:59 +0000"
714
952
  #
715
953
  def inspect: () -> String
716
954
 
717
955
  # <!--
718
956
  # rdoc-file=time.c
719
- # - time.isdst -> true or false
720
- # - time.dst? -> true or false
957
+ # - dst? -> true or false
721
958
  # -->
722
- # Returns `true` if *time* occurs during Daylight Saving Time in its time zone.
723
- #
724
- # # CST6CDT:
725
- # Time.local(2000, 1, 1).zone #=> "CST"
726
- # Time.local(2000, 1, 1).isdst #=> false
727
- # Time.local(2000, 1, 1).dst? #=> false
728
- # Time.local(2000, 7, 1).zone #=> "CDT"
729
- # Time.local(2000, 7, 1).isdst #=> true
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
959
+ # Returns `true` if `self` is in daylight saving time, `false` otherwise:
960
+ #
961
+ # t = Time.local(2000, 1, 1) # => 2000-01-01 00:00:00 -0600
962
+ # t.zone # => "Central Standard Time"
963
+ # t.dst? # => false
964
+ # t = Time.local(2000, 7, 1) # => 2000-07-01 00:00:00 -0500
965
+ # t.zone # => "Central Daylight Time"
966
+ # t.dst? # => true
967
+ #
968
+ # Time#isdst is an alias for Time#dst?.
739
969
  #
740
970
  def isdst: () -> bool
741
971
 
742
972
  # <!--
743
973
  # rdoc-file=time.c
744
- # - time.localtime -> time
745
- # - time.localtime(utc_offset) -> time
974
+ # - localtime -> self or new_time
975
+ # - localtime(zone) -> new_time
746
976
  # -->
747
- # Converts *time* to local time (using the local time zone in effect at the
748
- # creation time of *time*) modifying the receiver.
977
+ # With no argument given:
749
978
  #
750
- # If `utc_offset` is given, it is used instead of the local time.
979
+ # * Returns `self` if `self` is a local time.
980
+ # * Otherwise returns a new Time in the user's local timezone:
751
981
  #
752
- # t = Time.utc(2000, "jan", 1, 20, 15, 1) #=> 2000-01-01 20:15:01 UTC
753
- # t.utc? #=> true
982
+ # t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
983
+ # t.localtime # => 2000-01-01 14:15:01 -0600
754
984
  #
755
- # t.localtime #=> 2000-01-01 14:15:01 -0600
756
- # t.utc? #=> false
757
985
  #
758
- # t.localtime("+09:00") #=> 2000-01-02 05:15:01 +0900
759
- # t.utc? #=> false
986
+ # With argument `zone` given, returns the new Time object created by converting
987
+ # `self` to the given time zone:
760
988
  #
761
- # If `utc_offset` is not given and *time* is local time, just returns the
762
- # receiver.
989
+ # t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
990
+ # t.localtime("-09:00") # => 2000-01-01 11:15:01 -0900
991
+ #
992
+ # For forms of argument `zone`, see [Timezone
993
+ # Specifiers](rdoc-ref:timezones.rdoc).
763
994
  #
764
995
  def localtime: (?String utc_offset) -> Time
765
996
 
766
997
  # <!--
767
998
  # rdoc-file=time.c
768
- # - time.day -> integer
769
- # - time.mday -> integer
999
+ # - mday -> integer
770
1000
  # -->
771
- # Returns the day of the month (1..31) for *time*.
1001
+ # Returns the integer day of the month for `self`, in range (1..31):
1002
+ #
1003
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
1004
+ # # => 2000-01-02 03:04:05 +000006
1005
+ # t.mday # => 2
772
1006
  #
773
- # t = Time.now #=> 2007-11-19 08:27:03 -0600
774
- # t.day #=> 19
775
- # t.mday #=> 19
1007
+ # Time#day is an alias for Time#mday.
1008
+ #
1009
+ # Related: Time#year, Time#hour, Time#min.
776
1010
  #
777
1011
  def mday: () -> Integer
778
1012
 
779
1013
  # <!--
780
1014
  # rdoc-file=time.c
781
- # - time.min -> integer
1015
+ # - min -> integer
782
1016
  # -->
783
- # Returns the minute of the hour (0..59) for *time*.
1017
+ # Returns the integer minute of the hour for `self`, in range (0..59):
1018
+ #
1019
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
1020
+ # # => 2000-01-02 03:04:05 +000006
1021
+ # t.min # => 4
784
1022
  #
785
- # t = Time.now #=> 2007-11-19 08:25:51 -0600
786
- # t.min #=> 25
1023
+ # Related: Time#year, Time#mon, Time#sec.
787
1024
  #
788
1025
  def min: () -> Integer
789
1026
 
790
1027
  # <!--
791
1028
  # rdoc-file=time.c
792
- # - time.mon -> integer
793
- # - time.month -> integer
1029
+ # - mon -> integer
794
1030
  # -->
795
- # Returns the month of the year (1..12) for *time*.
1031
+ # Returns the integer month of the year for `self`, in range (1..12):
796
1032
  #
797
- # t = Time.now #=> 2007-11-19 08:27:30 -0600
798
- # t.mon #=> 11
799
- # t.month #=> 11
1033
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
1034
+ # # => 2000-01-02 03:04:05 +000006
1035
+ # t.mon # => 1
1036
+ #
1037
+ # Time#month is an alias for Time#mday.
1038
+ #
1039
+ # Related: Time#year, Time#hour, Time#min.
800
1040
  #
801
1041
  def mon: () -> Integer
802
1042
 
803
1043
  # <!--
804
1044
  # rdoc-file=time.c
805
- # - time.monday? -> true or false
1045
+ # - monday? -> true or false
806
1046
  # -->
807
- # Returns `true` if *time* represents Monday.
1047
+ # Returns `true` if `self` represents a Monday, `false` otherwise:
1048
+ #
1049
+ # t = Time.utc(2000, 1, 3) # => 2000-01-03 00:00:00 UTC
1050
+ # t.monday? # => true
808
1051
  #
809
- # t = Time.local(2003, 8, 4) #=> 2003-08-04 00:00:00 -0500
810
- # t.monday? #=> true
1052
+ # Related: Time#tuesday?, Time#wednesday?, Time#thursday?.
811
1053
  #
812
1054
  def monday?: () -> bool
813
1055
 
814
1056
  # <!-- rdoc-file=time.c -->
815
- # Returns the number of nanoseconds for the subsecond part of *time*. The result
816
- # is a non-negative integer less than 10**9.
1057
+ # Returns the number of nanoseconds in the subseconds part of `self` in the
1058
+ # range (0..999_999_999); lower-order digits are truncated, not rounded:
817
1059
  #
818
- # t = Time.now #=> 2020-07-20 22:07:10.963933942 +0900
819
- # t.nsec #=> 963933942
1060
+ # t = Time.now # => 2022-07-11 15:04:53.3219637 -0500
1061
+ # t.nsec # => 321963700
820
1062
  #
821
- # If *time* has fraction of nanosecond (such as picoseconds), it is truncated.
1063
+ # Related: Time#subsec (returns exact subseconds).
822
1064
  #
823
- # t = Time.new(2000,1,1,0,0,0.666_777_888_999r)
824
- # t.nsec #=> 666777888
825
- #
826
- # Time#subsec can be used to obtain the subsecond part exactly.
1065
+ # Time#tv_nsec is an alias for Time#usec.
827
1066
  #
828
1067
  def nsec: () -> Integer
829
1068
 
830
1069
  # <!--
831
1070
  # rdoc-file=time.c
832
- # - time.round([ndigits]) -> new_time
1071
+ # - round(ndigits = 0) -> new_time
833
1072
  # -->
834
- # Rounds subsecond to a given precision in decimal digits (0 digits by default).
835
- # It returns a new Time object. `ndigits` should be zero or a positive integer.
836
- #
837
- # t = Time.utc(2010,3,30, 5,43,25.123456789r)
838
- # t #=> 2010-03-30 05:43:25.123456789 UTC
839
- # t.round #=> 2010-03-30 05:43:25 UTC
840
- # t.round(0) #=> 2010-03-30 05:43:25 UTC
841
- # t.round(1) #=> 2010-03-30 05:43:25.1 UTC
842
- # t.round(2) #=> 2010-03-30 05:43:25.12 UTC
843
- # t.round(3) #=> 2010-03-30 05:43:25.123 UTC
844
- # t.round(4) #=> 2010-03-30 05:43:25.1235 UTC
845
- #
846
- # t = Time.utc(1999,12,31, 23,59,59)
847
- # (t + 0.4).round #=> 1999-12-31 23:59:59 UTC
848
- # (t + 0.49).round #=> 1999-12-31 23:59:59 UTC
849
- # (t + 0.5).round #=> 2000-01-01 00:00:00 UTC
850
- # (t + 1.4).round #=> 2000-01-01 00:00:00 UTC
851
- # (t + 1.49).round #=> 2000-01-01 00:00:00 UTC
852
- # (t + 1.5).round #=> 2000-01-01 00:00:01 UTC
853
- #
854
- # t = Time.utc(1999,12,31, 23,59,59) #=> 1999-12-31 23:59:59 UTC
855
- # (t + 0.123456789).round(4).iso8601(6) #=> 1999-12-31 23:59:59.1235 UTC
1073
+ # Returns a new Time object whose numeric value is that of `self`, with its
1074
+ # seconds value rounded to precision `ndigits`:
1075
+ #
1076
+ # t = Time.utc(2010, 3, 30, 5, 43, 25.123456789r)
1077
+ # t # => 2010-03-30 05:43:25.123456789 UTC
1078
+ # t.round # => 2010-03-30 05:43:25 UTC
1079
+ # t.round(0) # => 2010-03-30 05:43:25 UTC
1080
+ # t.round(1) # => 2010-03-30 05:43:25.1 UTC
1081
+ # t.round(2) # => 2010-03-30 05:43:25.12 UTC
1082
+ # t.round(3) # => 2010-03-30 05:43:25.123 UTC
1083
+ # t.round(4) # => 2010-03-30 05:43:25.1235 UTC
1084
+ #
1085
+ # t = Time.utc(1999, 12,31, 23, 59, 59)
1086
+ # t # => 1999-12-31 23:59:59 UTC
1087
+ # (t + 0.4).round # => 1999-12-31 23:59:59 UTC
1088
+ # (t + 0.49).round # => 1999-12-31 23:59:59 UTC
1089
+ # (t + 0.5).round # => 2000-01-01 00:00:00 UTC
1090
+ # (t + 1.4).round # => 2000-01-01 00:00:00 UTC
1091
+ # (t + 1.49).round # => 2000-01-01 00:00:00 UTC
1092
+ # (t + 1.5).round # => 2000-01-01 00:00:01 UTC
1093
+ #
1094
+ # Related: Time#ceil, Time#floor.
856
1095
  #
857
1096
  def round: (?Integer arg0) -> Time
858
1097
 
859
1098
  # <!--
860
1099
  # rdoc-file=time.c
861
- # - time.saturday? -> true or false
1100
+ # - saturday? -> true or false
862
1101
  # -->
863
- # Returns `true` if *time* represents Saturday.
1102
+ # Returns `true` if `self` represents a Saturday, `false` otherwise:
1103
+ #
1104
+ # t = Time.utc(2000, 1, 1) # => 2000-01-01 00:00:00 UTC
1105
+ # t.saturday? # => true
864
1106
  #
865
- # t = Time.local(2006, 6, 10) #=> 2006-06-10 00:00:00 -0500
866
- # t.saturday? #=> true
1107
+ # Related: Time#sunday?, Time#monday?, Time#tuesday?.
867
1108
  #
868
1109
  def saturday?: () -> bool
869
1110
 
870
1111
  # <!--
871
1112
  # rdoc-file=time.c
872
- # - time.sec -> integer
1113
+ # - sec -> integer
873
1114
  # -->
874
- # Returns the second of the minute (0..60) for *time*.
1115
+ # Returns the integer second of the minute for `self`, in range (0..60):
1116
+ #
1117
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
1118
+ # # => 2000-01-02 03:04:05 +000006
1119
+ # t.sec # => 5
875
1120
  #
876
- # **Note:** Seconds range from zero to 60 to allow the system to inject leap
877
- # seconds. See https://en.wikipedia.org/wiki/Leap_second for further details.
1121
+ # Note: the second value may be 60 when there is a [leap
1122
+ # second](https://en.wikipedia.org/wiki/Leap_second).
878
1123
  #
879
- # t = Time.now #=> 2007-11-19 08:25:02 -0600
880
- # t.sec #=> 2
1124
+ # Related: Time#year, Time#mon, Time#min.
881
1125
  #
882
1126
  def sec: () -> Integer
883
1127
 
884
1128
  # <!--
885
1129
  # rdoc-file=time.c
886
- # - time.strftime( string ) -> string
1130
+ # - strftime(format_string) -> string
887
1131
  # -->
888
- # Formats *time* according to the directives in the given format string.
889
- #
890
- # The directives begin with a percent (%) character. Any text not listed as a
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)
1132
+ # Returns a string representation of `self`, formatted according to the given
1133
+ # string `format`. See [Formats for Dates and
1134
+ # Times](rdoc-ref:strftime_formatting.rdoc).
1061
1135
  #
1062
1136
  def strftime: (String arg0) -> String
1063
1137
 
1064
1138
  # <!--
1065
1139
  # rdoc-file=time.c
1066
- # - time.subsec -> number
1140
+ # - subsec -> numeric
1067
1141
  # -->
1068
- # Returns the subsecond for *time*.
1142
+ # Returns the exact subseconds for `self` as a Numeric (Integer or Rational):
1069
1143
  #
1070
- # The return value can be a rational number.
1144
+ # t = Time.now # => 2022-07-11 15:11:36.8490302 -0500
1145
+ # t.subsec # => (4245151/5000000)
1071
1146
  #
1072
- # t = Time.now #=> 2020-07-20 15:40:26.867462289 +0900
1073
- # t.subsec #=> (867462289/1000000000)
1147
+ # If the subseconds is zero, returns integer zero:
1074
1148
  #
1075
- # t = Time.now #=> 2020-07-20 15:40:50.313828595 +0900
1076
- # t.subsec #=> (62765719/200000000)
1077
- #
1078
- # t = Time.new(2000,1,1,2,3,4) #=> 2000-01-01 02:03:04 +0900
1079
- # t.subsec #=> 0
1080
- #
1081
- # Time.new(2000,1,1,0,0,1/3r,"UTC").subsec #=> (1/3)
1149
+ # t = Time.new(2000, 1, 1, 2, 3, 4) # => 2000-01-01 02:03:04 -0600
1150
+ # t.subsec # => 0
1082
1151
  #
1083
1152
  def subsec: () -> (0 | Rational)
1084
1153
 
1085
1154
  # <!--
1086
1155
  # rdoc-file=time.c
1087
- # - time.sunday? -> true or false
1156
+ # - sunday? -> true or false
1088
1157
  # -->
1089
- # Returns `true` if *time* represents Sunday.
1158
+ # Returns `true` if `self` represents a Sunday, `false` otherwise:
1090
1159
  #
1091
- # t = Time.local(1990, 4, 1) #=> 1990-04-01 00:00:00 -0600
1092
- # t.sunday? #=> true
1160
+ # t = Time.utc(2000, 1, 2) # => 2000-01-02 00:00:00 UTC
1161
+ # t.sunday? # => true
1162
+ #
1163
+ # Related: Time#monday?, Time#tuesday?, Time#wednesday?.
1093
1164
  #
1094
1165
  def sunday?: () -> bool
1095
1166
 
1096
1167
  # <!--
1097
1168
  # rdoc-file=time.c
1098
- # - time.thursday? -> true or false
1169
+ # - thursday? -> true or false
1099
1170
  # -->
1100
- # Returns `true` if *time* represents Thursday.
1171
+ # Returns `true` if `self` represents a Thursday, `false` otherwise:
1172
+ #
1173
+ # t = Time.utc(2000, 1, 6) # => 2000-01-06 00:00:00 UTC
1174
+ # t.thursday? # => true
1101
1175
  #
1102
- # t = Time.local(1995, 12, 21) #=> 1995-12-21 00:00:00 -0600
1103
- # t.thursday? #=> true
1176
+ # Related: Time#friday?, Time#saturday?, Time#sunday?.
1104
1177
  #
1105
1178
  def thursday?: () -> bool
1106
1179
 
1107
1180
  # <!--
1108
1181
  # rdoc-file=time.c
1109
- # - time.to_a -> array
1182
+ # - to_a -> array
1110
1183
  # -->
1111
- # Returns a ten-element *array* of values for *time*:
1184
+ # Returns a 10-element array of values representing `self`:
1112
1185
  #
1113
- # [sec, min, hour, day, month, year, wday, yday, isdst, zone]
1186
+ # Time.utc(2000, 1, 1).to_a
1187
+ # # => [0, 0, 0, 1, 1, 2000, 6, 1, false, "UTC"]
1188
+ # # [sec, min, hour, day, mon, year, wday, yday, dst?, zone]
1114
1189
  #
1115
- # See the individual methods for an explanation of the valid ranges of each
1116
- # value. The ten elements can be passed directly to Time.utc or Time.local to
1117
- # create a new Time object.
1118
- #
1119
- # t = Time.now #=> 2007-11-19 08:36:01 -0600
1120
- # now = t.to_a #=> [1, 36, 8, 19, 11, 2007, 1, 323, false, "CST"]
1190
+ # The returned array is suitable for use as an argument to Time.utc or
1191
+ # Time.local to create a new Time object.
1121
1192
  #
1122
1193
  def to_a: () -> [ Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, bool, String ]
1123
1194
 
1124
1195
  # <!--
1125
1196
  # rdoc-file=time.c
1126
- # - time.to_f -> float
1197
+ # - to_f -> float
1127
1198
  # -->
1128
- # Returns the value of *time* as a floating point number of seconds since the
1129
- # Epoch. The return value approximate the exact value in the Time object because
1130
- # floating point numbers cannot represent all rational numbers exactly.
1199
+ # Returns the value of `self` as a Float number [Epoch
1200
+ # seconds](rdoc-ref:Time@Epoch+Seconds); subseconds are included.
1201
+ #
1202
+ # The stored value of `self` is a [Rational](rdoc-ref:Rational@#method-i-to_f),
1203
+ # which means that the returned value may be approximate:
1131
1204
  #
1132
- # t = Time.now #=> 2020-07-20 22:00:29.38740268 +0900
1133
- # t.to_f #=> 1595250029.3874028
1134
- # t.to_i #=> 1595250029
1205
+ # Time.utc(1970, 1, 1, 0, 0, 0).to_f # => 0.0
1206
+ # Time.utc(1970, 1, 1, 0, 0, 0, 999999).to_f # => 0.999999
1207
+ # Time.utc(1950, 1, 1, 0, 0, 0).to_f # => -631152000.0
1208
+ # Time.utc(1990, 1, 1, 0, 0, 0).to_f # => 631152000.0
1135
1209
  #
1136
- # Note that IEEE 754 double is not accurate enough to represent the exact number
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`.
1210
+ # Related: Time#to_i, Time#to_r.
1142
1211
  #
1143
1212
  def to_f: () -> Float
1144
1213
 
1145
1214
  # <!--
1146
1215
  # rdoc-file=time.c
1147
- # - time.to_i -> int
1148
- # - time.tv_sec -> int
1216
+ # - to_i -> integer
1149
1217
  # -->
1150
- # Returns the value of *time* as an integer number of seconds since the Epoch.
1218
+ # Returns the value of `self` as integer [Epoch
1219
+ # seconds](rdoc-ref:Time@Epoch+Seconds); subseconds are truncated (not rounded):
1220
+ #
1221
+ # Time.utc(1970, 1, 1, 0, 0, 0).to_i # => 0
1222
+ # Time.utc(1970, 1, 1, 0, 0, 0, 999999).to_i # => 0
1223
+ # Time.utc(1950, 1, 1, 0, 0, 0).to_i # => -631152000
1224
+ # Time.utc(1990, 1, 1, 0, 0, 0).to_i # => 631152000
1151
1225
  #
1152
- # If *time* contains subsecond, they are truncated.
1226
+ # Time#tv_sec is an alias for Time#to_i.
1153
1227
  #
1154
- # t = Time.now #=> 2020-07-21 01:41:29.746012609 +0900
1155
- # t.to_i #=> 1595263289
1228
+ # Related: Time#to_f Time#to_r.
1156
1229
  #
1157
1230
  def to_i: () -> Integer
1158
1231
 
1159
1232
  # <!--
1160
1233
  # rdoc-file=time.c
1161
- # - time.to_r -> a_rational
1234
+ # - to_r -> rational
1162
1235
  # -->
1163
- # Returns the value of *time* as a rational number of seconds since the Epoch.
1236
+ # Returns the value of `self` as a Rational exact number of [Epoch
1237
+ # seconds](rdoc-ref:Time@Epoch+Seconds);
1164
1238
  #
1165
- # t = Time.now #=> 2020-07-20 22:03:45.212167333 +0900
1166
- # t.to_r #=> (1595250225212167333/1000000000)
1239
+ # Time.now.to_r # => (16571402750320203/10000000)
1167
1240
  #
1168
- # This method is intended to be used to get an accurate value representing the
1169
- # seconds (including subsecond) since the Epoch.
1241
+ # Related: Time#to_f, Time#to_i.
1170
1242
  #
1171
1243
  def to_r: () -> Rational
1172
1244
 
1173
1245
  # <!--
1174
1246
  # rdoc-file=time.c
1175
- # - time.to_s -> string
1247
+ # - to_s -> string
1176
1248
  # -->
1177
- # Returns a string representing *time*. Equivalent to calling #strftime with the
1178
- # appropriate format string.
1249
+ # Returns a string representation of `self`, without subseconds:
1179
1250
  #
1180
- # t = Time.now
1181
- # t.to_s #=> "2012-11-10 18:16:12 +0100"
1182
- # t.strftime "%Y-%m-%d %H:%M:%S %z" #=> "2012-11-10 18:16:12 +0100"
1251
+ # t = Time.new(2000, 12, 31, 23, 59, 59, 0.5)
1252
+ # t.to_s # => "2000-12-31 23:59:59 +0000"
1183
1253
  #
1184
- # t.utc.to_s #=> "2012-11-10 17:16:12 UTC"
1185
- # t.strftime "%Y-%m-%d %H:%M:%S UTC" #=> "2012-11-10 17:16:12 UTC"
1254
+ # Related: Time#ctime, Time#inspect:
1255
+ #
1256
+ # t.ctime # => "Sun Dec 31 23:59:59 2000"
1257
+ # t.inspect # => "2000-12-31 23:59:59.5 +000001"
1186
1258
  #
1187
1259
  def to_s: () -> String
1188
1260
 
1189
1261
  # <!--
1190
1262
  # rdoc-file=time.c
1191
- # - time.tuesday? -> true or false
1263
+ # - tuesday? -> true or false
1192
1264
  # -->
1193
- # Returns `true` if *time* represents Tuesday.
1265
+ # Returns `true` if `self` represents a Tuesday, `false` otherwise:
1266
+ #
1267
+ # t = Time.utc(2000, 1, 4) # => 2000-01-04 00:00:00 UTC
1268
+ # t.tuesday? # => true
1194
1269
  #
1195
- # t = Time.local(1991, 2, 19) #=> 1991-02-19 00:00:00 -0600
1196
- # t.tuesday? #=> true
1270
+ # Related: Time#wednesday?, Time#thursday?, Time#friday?.
1197
1271
  #
1198
1272
  def tuesday?: () -> bool
1199
1273
 
1200
1274
  # <!--
1201
1275
  # rdoc-file=time.c
1202
- # - time.nsec -> int
1203
- # - time.tv_nsec -> int
1276
+ # - nsec -> integer
1204
1277
  # -->
1205
- # Returns the number of nanoseconds for the subsecond part of *time*. The result
1206
- # is a non-negative integer less than 10**9.
1207
- #
1208
- # t = Time.now #=> 2020-07-20 22:07:10.963933942 +0900
1209
- # t.nsec #=> 963933942
1278
+ # Returns the number of nanoseconds in the subseconds part of `self` in the
1279
+ # range (0..999_999_999); lower-order digits are truncated, not rounded:
1210
1280
  #
1211
- # If *time* has fraction of nanosecond (such as picoseconds), it is truncated.
1281
+ # t = Time.now # => 2022-07-11 15:04:53.3219637 -0500
1282
+ # t.nsec # => 321963700
1212
1283
  #
1213
- # t = Time.new(2000,1,1,0,0,0.666_777_888_999r)
1214
- # t.nsec #=> 666777888
1284
+ # Related: Time#subsec (returns exact subseconds).
1215
1285
  #
1216
- # Time#subsec can be used to obtain the subsecond part exactly.
1286
+ # Time#tv_nsec is an alias for Time#usec.
1217
1287
  #
1218
1288
  def tv_nsec: () -> Integer
1219
1289
 
1220
1290
  # <!-- rdoc-file=time.c -->
1221
- # Returns the value of *time* as an integer number of seconds since the Epoch.
1291
+ # Returns the value of `self` as integer [Epoch
1292
+ # seconds](rdoc-ref:Time@Epoch+Seconds); subseconds are truncated (not rounded):
1222
1293
  #
1223
- # If *time* contains subsecond, they are truncated.
1294
+ # Time.utc(1970, 1, 1, 0, 0, 0).to_i # => 0
1295
+ # Time.utc(1970, 1, 1, 0, 0, 0, 999999).to_i # => 0
1296
+ # Time.utc(1950, 1, 1, 0, 0, 0).to_i # => -631152000
1297
+ # Time.utc(1990, 1, 1, 0, 0, 0).to_i # => 631152000
1224
1298
  #
1225
- # t = Time.now #=> 2020-07-21 01:41:29.746012609 +0900
1226
- # t.to_i #=> 1595263289
1299
+ # Time#tv_sec is an alias for Time#to_i.
1300
+ #
1301
+ # Related: Time#to_f Time#to_r.
1227
1302
  #
1228
1303
  def tv_sec: () -> Integer
1229
1304
 
1230
1305
  # <!--
1231
1306
  # rdoc-file=time.c
1232
- # - time.usec -> int
1233
- # - time.tv_usec -> int
1307
+ # - usec -> integer
1234
1308
  # -->
1235
- # Returns the number of microseconds for the subsecond part of *time*. The
1236
- # result is a non-negative integer less than 10**6.
1237
- #
1238
- # t = Time.now #=> 2020-07-20 22:05:58.459785953 +0900
1239
- # t.usec #=> 459785
1309
+ # Returns the number of microseconds in the subseconds part of `self` in the
1310
+ # range (0..999_999); lower-order digits are truncated, not rounded:
1240
1311
  #
1241
- # If *time* has fraction of microsecond (such as nanoseconds), it is truncated.
1312
+ # t = Time.now # => 2022-07-11 14:59:47.5484697 -0500
1313
+ # t.usec # => 548469
1242
1314
  #
1243
- # t = Time.new(2000,1,1,0,0,0.666_777_888_999r)
1244
- # t.usec #=> 666777
1315
+ # Related: Time#subsec (returns exact subseconds).
1245
1316
  #
1246
- # Time#subsec can be used to obtain the subsecond part exactly.
1317
+ # Time#tv_usec is an alias for Time#usec.
1247
1318
  #
1248
1319
  def tv_usec: () -> Integer
1249
1320
 
1250
1321
  # <!-- rdoc-file=time.c -->
1251
- # Returns the number of microseconds for the subsecond part of *time*. The
1252
- # result is a non-negative integer less than 10**6.
1253
- #
1254
- # t = Time.now #=> 2020-07-20 22:05:58.459785953 +0900
1255
- # t.usec #=> 459785
1322
+ # Returns the number of microseconds in the subseconds part of `self` in the
1323
+ # range (0..999_999); lower-order digits are truncated, not rounded:
1256
1324
  #
1257
- # If *time* has fraction of microsecond (such as nanoseconds), it is truncated.
1325
+ # t = Time.now # => 2022-07-11 14:59:47.5484697 -0500
1326
+ # t.usec # => 548469
1258
1327
  #
1259
- # t = Time.new(2000,1,1,0,0,0.666_777_888_999r)
1260
- # t.usec #=> 666777
1328
+ # Related: Time#subsec (returns exact subseconds).
1261
1329
  #
1262
- # Time#subsec can be used to obtain the subsecond part exactly.
1330
+ # Time#tv_usec is an alias for Time#usec.
1263
1331
  #
1264
1332
  def usec: () -> Integer
1265
1333
 
1266
1334
  # <!-- rdoc-file=time.c -->
1267
- # Converts *time* to UTC (GMT), modifying the receiver.
1335
+ # Returns `self`, converted to the UTC timezone:
1268
1336
  #
1269
- # t = Time.now #=> 2007-11-19 08:18:31 -0600
1270
- # t.gmt? #=> false
1271
- # t.gmtime #=> 2007-11-19 14:18:31 UTC
1272
- # t.gmt? #=> true
1337
+ # t = Time.new(2000) # => 2000-01-01 00:00:00 -0600
1338
+ # t.utc? # => false
1339
+ # t.utc # => 2000-01-01 06:00:00 UTC
1340
+ # t.utc? # => true
1273
1341
  #
1274
- # t = Time.now #=> 2007-11-19 08:18:51 -0600
1275
- # t.utc? #=> false
1276
- # t.utc #=> 2007-11-19 14:18:51 UTC
1277
- # t.utc? #=> true
1342
+ # Time#gmtime is an alias for Time#utc.
1343
+ #
1344
+ # Related: Time#getutc (returns a new converted Time object).
1278
1345
  #
1279
1346
  def utc: () -> Time
1280
1347
 
1281
1348
  # <!--
1282
1349
  # rdoc-file=time.c
1283
- # - time.utc? -> true or false
1284
- # - time.gmt? -> true or false
1350
+ # - utc? -> true or false
1285
1351
  # -->
1286
- # Returns `true` if *time* represents a time in UTC (GMT).
1352
+ # Returns `true` if `self` represents a time in UTC (GMT):
1353
+ #
1354
+ # now = Time.now
1355
+ # # => 2022-08-18 10:24:13.5398485 -0500
1356
+ # now.utc? # => false
1357
+ # utc = Time.utc(2000, 1, 1, 20, 15, 1)
1358
+ # # => 2000-01-01 20:15:01 UTC
1359
+ # utc.utc? # => true
1287
1360
  #
1288
- # t = Time.now #=> 2007-11-19 08:15:23 -0600
1289
- # t.utc? #=> false
1290
- # t = Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC
1291
- # t.utc? #=> true
1361
+ # Time#gmt? is an alias for Time#utc?.
1292
1362
  #
1293
- # t = Time.now #=> 2007-11-19 08:16:03 -0600
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
1363
+ # Related: Time.utc.
1297
1364
  #
1298
1365
  def utc?: () -> bool
1299
1366
 
1300
1367
  # <!-- rdoc-file=time.c -->
1301
- # Returns the offset in seconds between the timezone of *time* and UTC.
1368
+ # Returns the offset in seconds between the timezones of UTC and `self`:
1302
1369
  #
1303
- # t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
1304
- # t.gmt_offset #=> 0
1305
- # l = t.getlocal #=> 2000-01-01 14:15:01 -0600
1306
- # l.gmt_offset #=> -21600
1370
+ # Time.utc(2000, 1, 1).utc_offset # => 0
1371
+ # Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours.
1372
+ #
1373
+ # Time#gmt_offset and Time#gmtoff are aliases for Time#utc_offset.
1307
1374
  #
1308
1375
  def utc_offset: () -> Integer
1309
1376
 
1310
1377
  # <!--
1311
1378
  # rdoc-file=time.c
1312
- # - time.wday -> integer
1379
+ # - wday -> integer
1313
1380
  # -->
1314
- # Returns an integer representing the day of the week, 0..6, with Sunday == 0.
1315
- #
1316
- # t = Time.now #=> 2007-11-20 02:35:35 -0600
1317
- # t.wday #=> 2
1318
- # t.sunday? #=> false
1319
- # t.monday? #=> false
1320
- # t.tuesday? #=> true
1321
- # t.wednesday? #=> false
1322
- # t.thursday? #=> false
1323
- # t.friday? #=> false
1324
- # t.saturday? #=> false
1381
+ # Returns the integer day of the week for `self`, in range (0..6), with Sunday
1382
+ # as zero.
1383
+ #
1384
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
1385
+ # # => 2000-01-02 03:04:05 +000006
1386
+ # t.wday # => 0
1387
+ # t.sunday? # => true
1388
+ #
1389
+ # Related: Time#year, Time#hour, Time#min.
1325
1390
  #
1326
1391
  def wday: () -> Integer
1327
1392
 
1328
1393
  # <!--
1329
1394
  # rdoc-file=time.c
1330
- # - time.wednesday? -> true or false
1395
+ # - wednesday? -> true or false
1331
1396
  # -->
1332
- # Returns `true` if *time* represents Wednesday.
1397
+ # Returns `true` if `self` represents a Wednesday, `false` otherwise:
1333
1398
  #
1334
- # t = Time.local(1993, 2, 24) #=> 1993-02-24 00:00:00 -0600
1335
- # t.wednesday? #=> true
1399
+ # t = Time.utc(2000, 1, 5) # => 2000-01-05 00:00:00 UTC
1400
+ # t.wednesday? # => true
1401
+ #
1402
+ # Related: Time#thursday?, Time#friday?, Time#saturday?.
1336
1403
  #
1337
1404
  def wednesday?: () -> bool
1338
1405
 
1339
1406
  # <!--
1340
1407
  # rdoc-file=time.c
1341
- # - time.yday -> integer
1408
+ # - yday -> integer
1342
1409
  # -->
1343
- # Returns an integer representing the day of the year, 1..366.
1410
+ # Returns the integer day of the year of `self`, in range (1..366).
1344
1411
  #
1345
- # t = Time.now #=> 2007-11-19 08:32:31 -0600
1346
- # t.yday #=> 323
1412
+ # Time.new(2000, 1, 1).yday # => 1
1413
+ # Time.new(2000, 12, 31).yday # => 366
1347
1414
  #
1348
1415
  def yday: () -> Integer
1349
1416
 
1350
1417
  # <!--
1351
1418
  # rdoc-file=time.c
1352
- # - time.year -> integer
1419
+ # - year -> integer
1353
1420
  # -->
1354
- # Returns the year for *time* (including the century).
1421
+ # Returns the integer year for `self`:
1422
+ #
1423
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
1424
+ # # => 2000-01-02 03:04:05 +000006
1425
+ # t.year # => 2000
1355
1426
  #
1356
- # t = Time.now #=> 2007-11-19 08:27:51 -0600
1357
- # t.year #=> 2007
1427
+ # Related: Time#mon, Time#hour, Time#min.
1358
1428
  #
1359
1429
  def year: () -> Integer
1360
1430
 
@@ -1362,97 +1432,103 @@ class Time < Object
1362
1432
  # rdoc-file=time.c
1363
1433
  # - time.zone -> string or timezone
1364
1434
  # -->
1365
- # Returns the name of the time zone used for *time*. As of Ruby 1.8, returns
1366
- # ``UTC'' rather than ``GMT'' for UTC times.
1435
+ # Returns the string name of the time zone for `self`:
1367
1436
  #
1368
- # t = Time.gm(2000, "jan", 1, 20, 15, 1)
1369
- # t.zone #=> "UTC"
1370
- # t = Time.local(2000, "jan", 1, 20, 15, 1)
1371
- # t.zone #=> "CST"
1437
+ # Time.utc(2000, 1, 1).zone # => "UTC"
1438
+ # Time.new(2000, 1, 1).zone # => "Central Standard Time"
1372
1439
  #
1373
1440
  def zone: () -> String
1374
1441
 
1375
- # Same as Time::gm, but interprets the values in the local time zone.
1442
+ # <!-- rdoc-file=time.c -->
1443
+ # Like Time.utc, except that the returned Time object has the local timezone,
1444
+ # not the UTC timezone:
1376
1445
  #
1377
- # Time.local(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 -0600
1446
+ # # With seven arguments.
1447
+ # Time.local(0, 1, 2, 3, 4, 5, 6)
1448
+ # # => 0000-01-02 03:04:05.000006 -0600
1449
+ # # With exactly ten arguments.
1450
+ # Time.local(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
1451
+ # # => 0005-04-03 02:01:00 -0600
1378
1452
  #
1379
1453
  def self.mktime: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
1380
1454
 
1381
1455
  # <!--
1382
1456
  # rdoc-file=time.c
1383
- # - time.gmt_offset -> integer
1384
- # - time.gmtoff -> integer
1385
- # - time.utc_offset -> integer
1457
+ # - utc_offset -> integer
1386
1458
  # -->
1387
- # Returns the offset in seconds between the timezone of *time* and UTC.
1459
+ # Returns the offset in seconds between the timezones of UTC and `self`:
1388
1460
  #
1389
- # t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
1390
- # t.gmt_offset #=> 0
1391
- # l = t.getlocal #=> 2000-01-01 14:15:01 -0600
1392
- # l.gmt_offset #=> -21600
1461
+ # Time.utc(2000, 1, 1).utc_offset # => 0
1462
+ # Time.local(2000, 1, 1).utc_offset # => -21600 # -6*3600, or minus six hours.
1463
+ #
1464
+ # Time#gmt_offset and Time#gmtoff are aliases for Time#utc_offset.
1393
1465
  #
1394
1466
  def gmtoff: () -> Integer
1395
1467
 
1396
1468
  # <!-- rdoc-file=time.c -->
1397
- # Returns the month of the year (1..12) for *time*.
1469
+ # Returns the integer month of the year for `self`, in range (1..12):
1470
+ #
1471
+ # t = Time.new(2000, 1, 2, 3, 4, 5, 6)
1472
+ # # => 2000-01-02 03:04:05 +000006
1473
+ # t.mon # => 1
1474
+ #
1475
+ # Time#month is an alias for Time#mday.
1398
1476
  #
1399
- # t = Time.now #=> 2007-11-19 08:27:30 -0600
1400
- # t.mon #=> 11
1401
- # t.month #=> 11
1477
+ # Related: Time#year, Time#hour, Time#min.
1402
1478
  #
1403
1479
  def month: () -> Integer
1404
1480
 
1405
1481
  # <!--
1406
1482
  # rdoc-file=time.c
1407
- # - time.floor([ndigits]) -> new_time
1483
+ # - floor(ndigits = 0) -> new_time
1408
1484
  # -->
1409
- # Floors subsecond to a given precision in decimal digits (0 digits by default).
1410
- # It returns a new Time object. `ndigits` should be zero or a positive integer.
1411
- #
1412
- # t = Time.utc(2010,3,30, 5,43,25.123456789r)
1413
- # t #=> 2010-03-30 05:43:25.123456789 UTC
1414
- # t.floor #=> 2010-03-30 05:43:25 UTC
1415
- # t.floor(0) #=> 2010-03-30 05:43:25 UTC
1416
- # t.floor(1) #=> 2010-03-30 05:43:25.1 UTC
1417
- # t.floor(2) #=> 2010-03-30 05:43:25.12 UTC
1418
- # t.floor(3) #=> 2010-03-30 05:43:25.123 UTC
1419
- # t.floor(4) #=> 2010-03-30 05:43:25.1234 UTC
1420
- #
1421
- # t = Time.utc(1999,12,31, 23,59,59)
1422
- # (t + 0.4).floor #=> 1999-12-31 23:59:59 UTC
1423
- # (t + 0.9).floor #=> 1999-12-31 23:59:59 UTC
1424
- # (t + 1.4).floor #=> 2000-01-01 00:00:00 UTC
1425
- # (t + 1.9).floor #=> 2000-01-01 00:00:00 UTC
1426
- #
1427
- # t = Time.utc(1999,12,31, 23,59,59)
1428
- # (t + 0.123456789).floor(4) #=> 1999-12-31 23:59:59.1234 UTC
1485
+ # Returns a new Time object whose numerical value is less than or equal to
1486
+ # `self` with its seconds truncated to precision `ndigits`:
1487
+ #
1488
+ # t = Time.utc(2010, 3, 30, 5, 43, 25.123456789r)
1489
+ # t # => 2010-03-30 05:43:25.123456789 UTC
1490
+ # t.floor # => 2010-03-30 05:43:25 UTC
1491
+ # t.floor(2) # => 2010-03-30 05:43:25.12 UTC
1492
+ # t.floor(4) # => 2010-03-30 05:43:25.1234 UTC
1493
+ # t.floor(6) # => 2010-03-30 05:43:25.123456 UTC
1494
+ # t.floor(8) # => 2010-03-30 05:43:25.12345678 UTC
1495
+ # t.floor(10) # => 2010-03-30 05:43:25.123456789 UTC
1496
+ #
1497
+ # t = Time.utc(1999, 12, 31, 23, 59, 59)
1498
+ # t # => 1999-12-31 23:59:59 UTC
1499
+ # (t + 0.4).floor # => 1999-12-31 23:59:59 UTC
1500
+ # (t + 0.9).floor # => 1999-12-31 23:59:59 UTC
1501
+ # (t + 1.4).floor # => 2000-01-01 00:00:00 UTC
1502
+ # (t + 1.9).floor # => 2000-01-01 00:00:00 UTC
1503
+ #
1504
+ # Related: Time#ceil, Time#round.
1429
1505
  #
1430
1506
  def floor: (?Integer ndigits) -> Time
1431
1507
 
1432
1508
  # <!--
1433
1509
  # rdoc-file=time.c
1434
- # - time.ceil([ndigits]) -> new_time
1510
+ # - ceil(ndigits = 0) -> new_time
1435
1511
  # -->
1436
- # Ceils subsecond to a given precision in decimal digits (0 digits by default).
1437
- # It returns a new Time object. `ndigits` should be zero or a positive integer.
1438
- #
1439
- # t = Time.utc(2010,3,30, 5,43,25.0123456789r)
1440
- # t #=> 2010-03-30 05:43:25 123456789/10000000000 UTC
1441
- # t.ceil #=> 2010-03-30 05:43:26 UTC
1442
- # t.ceil(0) #=> 2010-03-30 05:43:26 UTC
1443
- # t.ceil(1) #=> 2010-03-30 05:43:25.1 UTC
1444
- # t.ceil(2) #=> 2010-03-30 05:43:25.02 UTC
1445
- # t.ceil(3) #=> 2010-03-30 05:43:25.013 UTC
1446
- # t.ceil(4) #=> 2010-03-30 05:43:25.0124 UTC
1447
- #
1448
- # t = Time.utc(1999,12,31, 23,59,59)
1449
- # (t + 0.4).ceil #=> 2000-01-01 00:00:00 UTC
1450
- # (t + 0.9).ceil #=> 2000-01-01 00:00:00 UTC
1451
- # (t + 1.4).ceil #=> 2000-01-01 00:00:01 UTC
1452
- # (t + 1.9).ceil #=> 2000-01-01 00:00:01 UTC
1453
- #
1454
- # t = Time.utc(1999,12,31, 23,59,59)
1455
- # (t + 0.123456789).ceil(4) #=> 1999-12-31 23:59:59.1235 UTC
1512
+ # Returns a new Time object whose numerical value is greater than or equal to
1513
+ # `self` with its seconds truncated to precision `ndigits`:
1514
+ #
1515
+ # t = Time.utc(2010, 3, 30, 5, 43, 25.123456789r)
1516
+ # t # => 2010-03-30 05:43:25.123456789 UTC
1517
+ # t.ceil # => 2010-03-30 05:43:26 UTC
1518
+ # t.ceil(2) # => 2010-03-30 05:43:25.13 UTC
1519
+ # t.ceil(4) # => 2010-03-30 05:43:25.1235 UTC
1520
+ # t.ceil(6) # => 2010-03-30 05:43:25.123457 UTC
1521
+ # t.ceil(8) # => 2010-03-30 05:43:25.12345679 UTC
1522
+ # t.ceil(10) # => 2010-03-30 05:43:25.123456789 UTC
1523
+ #
1524
+ # t = Time.utc(1999, 12, 31, 23, 59, 59)
1525
+ # t # => 1999-12-31 23:59:59 UTC
1526
+ # (t + 0.4).ceil # => 2000-01-01 00:00:00 UTC
1527
+ # (t + 0.9).ceil # => 2000-01-01 00:00:00 UTC
1528
+ # (t + 1.4).ceil # => 2000-01-01 00:00:01 UTC
1529
+ # (t + 1.9).ceil # => 2000-01-01 00:00:01 UTC
1530
+ #
1531
+ # Related: Time#floor, Time#round.
1456
1532
  #
1457
1533
  def ceil: (?Integer ndigits) -> Time
1458
1534
  end