rbs 3.0.0.dev.2 → 3.0.0.dev.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +2 -1
- data/.github/workflows/ruby.yml +4 -0
- data/Gemfile.lock +11 -11
- data/Rakefile +2 -2
- data/Steepfile +1 -1
- data/core/array.rbs +573 -423
- data/core/basic_object.rbs +11 -39
- data/core/binding.rbs +1 -1
- data/core/builtin.rbs +8 -0
- data/core/class.rbs +37 -0
- data/core/comparable.rbs +7 -18
- data/core/complex.rbs +2 -2
- data/core/data.rbs +419 -0
- data/core/dir.rbs +52 -104
- data/core/encoding.rbs +22 -181
- data/core/enumerable.rbs +212 -175
- data/core/enumerator/product.rbs +96 -0
- data/core/enumerator.rbs +57 -8
- data/core/errors.rbs +8 -2
- data/core/exception.rbs +41 -0
- data/core/fiber.rbs +95 -12
- data/core/file.rbs +840 -275
- data/core/file_test.rbs +34 -19
- data/core/float.rbs +40 -96
- data/core/gc.rbs +15 -3
- data/core/hash.rbs +113 -175
- data/core/integer.rbs +85 -145
- data/core/io/buffer.rbs +187 -60
- data/core/io/wait.rbs +28 -16
- data/core/io.rbs +1859 -1389
- data/core/kernel.rbs +525 -961
- data/core/match_data.rbs +306 -142
- data/core/math.rbs +506 -234
- data/core/method.rbs +0 -24
- data/core/module.rbs +110 -17
- data/core/nil_class.rbs +2 -0
- data/core/numeric.rbs +76 -144
- data/core/object.rbs +88 -212
- data/core/proc.rbs +17 -5
- data/core/process.rbs +22 -5
- data/core/ractor.rbs +1 -1
- data/core/random.rbs +20 -3
- data/core/range.rbs +91 -89
- data/core/rational.rbs +2 -3
- data/core/rbs/unnamed/argf.rbs +177 -120
- data/core/rbs/unnamed/env_class.rbs +89 -163
- data/core/rbs/unnamed/random.rbs +36 -12
- data/core/refinement.rbs +8 -0
- data/core/regexp.rbs +462 -272
- data/core/ruby_vm.rbs +210 -0
- data/{stdlib/set/0 → core}/set.rbs +43 -47
- data/core/string.rbs +1403 -1332
- data/core/string_io.rbs +191 -107
- data/core/struct.rbs +67 -63
- data/core/symbol.rbs +187 -201
- data/core/thread.rbs +40 -35
- data/core/time.rbs +902 -826
- data/core/trace_point.rbs +55 -6
- data/core/unbound_method.rbs +48 -24
- data/docs/collection.md +4 -0
- data/docs/syntax.md +55 -0
- data/ext/rbs_extension/parser.c +5 -6
- data/lib/rbs/cli.rb +6 -1
- data/lib/rbs/collection/cleaner.rb +8 -1
- data/lib/rbs/collection/config/lockfile.rb +3 -1
- data/lib/rbs/collection/config/lockfile_generator.rb +16 -14
- data/lib/rbs/collection/config.rb +1 -1
- data/lib/rbs/collection/sources/git.rb +9 -2
- data/lib/rbs/collection/sources/local.rb +79 -0
- data/lib/rbs/collection/sources.rb +8 -1
- data/lib/rbs/environment.rb +6 -5
- data/lib/rbs/environment_loader.rb +3 -2
- data/lib/rbs/errors.rb +18 -0
- data/lib/rbs/locator.rb +26 -7
- data/lib/rbs/sorter.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/sig/collection/sources.rbs +32 -3
- data/sig/environment.rbs +2 -3
- data/sig/locator.rbs +14 -2
- data/sig/shims/{abstract_syntax_tree.rbs → _abstract_syntax_tree.rbs} +0 -0
- data/stdlib/bigdecimal/0/big_decimal.rbs +16 -13
- data/stdlib/cgi/0/core.rbs +16 -0
- data/stdlib/coverage/0/coverage.rbs +50 -8
- data/stdlib/csv/0/csv.rbs +1 -1
- data/stdlib/date/0/date.rbs +856 -726
- data/stdlib/date/0/date_time.rbs +83 -210
- data/stdlib/erb/0/erb.rbs +13 -36
- data/stdlib/etc/0/etc.rbs +127 -20
- data/stdlib/fileutils/0/fileutils.rbs +1290 -381
- data/stdlib/logger/0/logger.rbs +466 -316
- data/stdlib/net-http/0/net-http.rbs +2211 -534
- data/stdlib/nkf/0/nkf.rbs +5 -5
- data/stdlib/objspace/0/objspace.rbs +31 -14
- data/stdlib/openssl/0/openssl.rbs +11 -7
- data/stdlib/optparse/0/optparse.rbs +20 -17
- data/stdlib/pathname/0/pathname.rbs +21 -4
- data/stdlib/pstore/0/pstore.rbs +378 -154
- data/stdlib/pty/0/pty.rbs +24 -8
- data/stdlib/ripper/0/ripper.rbs +1650 -0
- data/stdlib/socket/0/addrinfo.rbs +9 -15
- data/stdlib/socket/0/socket.rbs +36 -3
- data/stdlib/strscan/0/string_scanner.rbs +7 -5
- data/stdlib/tempfile/0/tempfile.rbs +104 -44
- data/stdlib/time/0/time.rbs +2 -2
- data/stdlib/uri/0/file.rbs +5 -0
- data/stdlib/uri/0/generic.rbs +2 -2
- data/stdlib/yaml/0/yaml.rbs +2 -2
- data/stdlib/zlib/0/zlib.rbs +1 -1
- metadata +8 -6
- data/core/deprecated.rbs +0 -9
- data/sig/shims/ripper.rbs +0 -8
data/core/time.rbs
CHANGED
@@ -1,17 +1,49 @@
|
|
1
1
|
# <!-- rdoc-file=timev.rb -->
|
2
|
-
# Time
|
3
|
-
# number of seconds with subsecond since the *Epoch*, 1970-01-01 00:00:00 UTC.
|
2
|
+
# A Time object represents a date and time:
|
4
3
|
#
|
5
|
-
#
|
6
|
-
# Time) as equivalent. GMT is the older way of referring to these baseline times
|
7
|
-
# but persists in the names of calls on POSIX systems.
|
4
|
+
# Time.new(2000, 1, 1, 0, 0, 0) # => 2000-01-01 00:00:00 -0600
|
8
5
|
#
|
9
|
-
#
|
6
|
+
# Although its value can be expressed as a single numeric (see [Epoch
|
7
|
+
# Seconds](rdoc-ref:Time@Epoch+Seconds) below), it can be convenient to deal
|
8
|
+
# with the value by parts:
|
10
9
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# t = Time.new(-2000, 1, 1, 0, 0, 0.0)
|
11
|
+
# # => -2000-01-01 00:00:00 -0600
|
12
|
+
# t.year # => -2000
|
13
|
+
# t.month # => 1
|
14
|
+
# t.mday # => 1
|
15
|
+
# t.hour # => 0
|
16
|
+
# t.min # => 0
|
17
|
+
# t.sec # => 0
|
18
|
+
# t.subsec # => 0
|
19
|
+
#
|
20
|
+
# t = Time.new(2000, 12, 31, 23, 59, 59.5)
|
21
|
+
# # => 2000-12-31 23:59:59.5 -0600
|
22
|
+
# t.year # => 2000
|
23
|
+
# t.month # => 12
|
24
|
+
# t.mday # => 31
|
25
|
+
# t.hour # => 23
|
26
|
+
# t.min # => 59
|
27
|
+
# t.sec # => 59
|
28
|
+
# t.subsec # => (1/2)
|
29
|
+
#
|
30
|
+
# ## Epoch Seconds
|
31
|
+
#
|
32
|
+
# *Epoch seconds* is the exact number of seconds (including fractional
|
33
|
+
# subseconds) since the Unix Epoch, January 1, 1970.
|
34
|
+
#
|
35
|
+
# You can retrieve that value exactly using method Time.to_r:
|
36
|
+
#
|
37
|
+
# Time.at(0).to_r # => (0/1)
|
38
|
+
# Time.at(0.999999).to_r # => (9007190247541737/9007199254740992)
|
39
|
+
#
|
40
|
+
# Other retrieval methods such as Time#to_i and Time#to_f may return a value
|
41
|
+
# that rounds or truncates subseconds.
|
42
|
+
#
|
43
|
+
# ## Time Resolution
|
44
|
+
#
|
45
|
+
# A Time object derived from the system clock (for example, by method 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
|
-
#
|
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](
|
104
|
-
# * [Fetching \Time values](
|
105
|
-
# * [Querying a \Time object](
|
106
|
-
# * [Comparing \Time objects](
|
107
|
-
# * [Converting a \Time object](
|
108
|
-
# * [Rounding a \Time](
|
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
|
-
# *
|
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
|
-
# *
|
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
|
-
#
|
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
|
-
#
|
230
|
-
#
|
231
|
-
#
|
232
|
-
#
|
233
|
-
#
|
234
|
-
#
|
235
|
-
#
|
236
|
-
#
|
237
|
-
#
|
238
|
-
#
|
239
|
-
#
|
240
|
-
#
|
241
|
-
# Time.
|
242
|
-
#
|
243
|
-
#
|
244
|
-
#
|
245
|
-
#
|
246
|
-
#
|
247
|
-
#
|
248
|
-
#
|
249
|
-
#
|
250
|
-
#
|
251
|
-
#
|
252
|
-
#
|
253
|
-
#
|
254
|
-
#
|
255
|
-
#
|
256
|
-
#
|
257
|
-
#
|
258
|
-
#
|
259
|
-
#
|
260
|
-
#
|
261
|
-
#
|
262
|
-
#
|
263
|
-
#
|
264
|
-
#
|
265
|
-
#
|
266
|
-
#
|
267
|
-
# * `
|
268
|
-
#
|
269
|
-
#
|
270
|
-
#
|
271
|
-
#
|
272
|
-
#
|
273
|
-
#
|
274
|
-
#
|
275
|
-
#
|
276
|
-
#
|
277
|
-
#
|
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
|
-
#
|
286
|
-
#
|
287
|
-
# field (and may be `nil` or omitted). Months may be specified by numbers from 1
|
288
|
-
# to 12, or by the three-letter English month names. Hours are specified on a
|
289
|
-
# 24-hour clock (0..23). Raises an ArgumentError if any values are out of range.
|
290
|
-
# Will also accept ten arguments in the order output by Time#to_a.
|
292
|
+
# <!-- rdoc-file=time.c -->
|
293
|
+
# Returns a new Time object based the on given arguments, in the UTC timezone.
|
291
294
|
#
|
292
|
-
#
|
295
|
+
# With one to seven arguments given, the arguments are interpreted as in the
|
296
|
+
# first calling sequence above:
|
293
297
|
#
|
294
|
-
# Time.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
|
-
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
322
|
-
#
|
323
|
-
#
|
324
|
-
#
|
325
|
-
# * A 3-character string that matches regular expression
|
326
|
-
# `/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/i`.
|
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
|
-
# * `
|
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
|
-
#
|
321
|
+
# * `hour`: Hour in range (0..23), or 24 if `min`, `sec`, and `usec` are zero:
|
337
322
|
#
|
338
|
-
#
|
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
|
-
#
|
353
|
-
#
|
354
|
-
# * A string offset from UTC.
|
355
|
-
# * A single letter offset from UTC, in the range `'A'..'Z'`, `'J'` (the
|
356
|
-
# so-called military timezone) excluded.
|
357
|
-
# * An integer number of seconds.
|
358
|
-
# * A timezone object; see [Timezone
|
359
|
-
# Argument](#class-Time-label-Timezone+Argument) for details.
|
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,
|
366
|
-
# - Time.utc(
|
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
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
385
|
-
#
|
386
|
-
#
|
387
|
-
#
|
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
|
-
# * `
|
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
|
-
#
|
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
|
-
# -
|
526
|
+
# - self + numeric -> new_time
|
408
527
|
# -->
|
409
|
-
#
|
410
|
-
#
|
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
|
-
#
|
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
|
-
# -
|
420
|
-
# -
|
541
|
+
# - self - numeric -> new_time
|
542
|
+
# - self - other_time -> float
|
421
543
|
# -->
|
422
|
-
#
|
423
|
-
#
|
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
|
-
#
|
426
|
-
#
|
427
|
-
#
|
428
|
-
#
|
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
|
-
# -
|
567
|
+
# - self <=> other_time -> -1, 0, +1, or nil
|
440
568
|
# -->
|
441
|
-
# Compares `
|
569
|
+
# Compares `self` with `other_time`; returns:
|
442
570
|
#
|
443
|
-
#
|
444
|
-
#
|
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
|
-
#
|
449
|
-
#
|
450
|
-
# t
|
451
|
-
# t2
|
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
|
454
|
-
# t2 = t + 0.1
|
455
|
-
# t.nsec
|
456
|
-
# t2.nsec
|
457
|
-
# t <=> t2
|
458
|
-
# t2 <=> t
|
459
|
-
# t <=> t
|
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
|
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
|
-
#
|
472
|
-
#
|
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
|
-
# -
|
479
|
-
# - time.ctime -> string
|
620
|
+
# - ctime -> string
|
480
621
|
# -->
|
481
|
-
# Returns a
|
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.
|
484
|
-
#
|
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)
|
641
|
+
# Returns the integer day of the month for `self`, in range (1..31):
|
490
642
|
#
|
491
|
-
# t = Time.
|
492
|
-
#
|
493
|
-
# t.mday
|
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
|
499
|
-
#
|
500
|
-
# #
|
501
|
-
#
|
502
|
-
#
|
503
|
-
#
|
504
|
-
#
|
505
|
-
#
|
506
|
-
#
|
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
|
-
# -
|
704
|
+
# - eql?(other_time)
|
521
705
|
# -->
|
522
|
-
# Returns `true` if
|
523
|
-
#
|
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
|
-
# -
|
713
|
+
# - friday? -> true or false
|
530
714
|
# -->
|
531
|
-
# Returns `true` if
|
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
|
-
#
|
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
|
-
# -
|
541
|
-
# - time.getutc -> new_time
|
726
|
+
# - getutc -> new_time
|
542
727
|
# -->
|
543
|
-
# Returns a new Time object representing
|
728
|
+
# Returns a new Time object representing the value of `self` converted to the
|
729
|
+
# UTC timezone:
|
544
730
|
#
|
545
|
-
#
|
546
|
-
#
|
547
|
-
#
|
548
|
-
#
|
549
|
-
#
|
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
|
-
# -
|
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
|
560
|
-
#
|
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
|
-
#
|
574
|
-
#
|
575
|
-
# t
|
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
|
-
#
|
578
|
-
#
|
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
|
758
|
+
# Returns a new Time object representing the value of `self` converted to the
|
759
|
+
# UTC timezone:
|
585
760
|
#
|
586
|
-
#
|
587
|
-
#
|
588
|
-
#
|
589
|
-
#
|
590
|
-
#
|
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
|
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
|
-
#
|
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
|
-
#
|
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
|
788
|
+
# Returns the offset in seconds between the timezones of UTC and `self`:
|
611
789
|
#
|
612
|
-
#
|
613
|
-
#
|
614
|
-
#
|
615
|
-
#
|
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
|
-
# -
|
622
|
-
# - time.utc -> time
|
799
|
+
# - utc -> self
|
623
800
|
# -->
|
624
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
# -
|
816
|
+
# - hash -> integer
|
641
817
|
# -->
|
642
|
-
# Returns
|
818
|
+
# Returns the integer hash code for `self`.
|
643
819
|
#
|
644
|
-
#
|
820
|
+
# Related: Object#hash.
|
645
821
|
#
|
646
822
|
def hash: () -> Integer
|
647
823
|
|
648
824
|
# <!--
|
649
825
|
# rdoc-file=time.c
|
650
|
-
# -
|
826
|
+
# - hour -> integer
|
651
827
|
# -->
|
652
|
-
# Returns the hour of the day (0..23)
|
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
|
-
#
|
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
|
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
|
-
#
|
888
|
+
# * `min`: Minute in range (0..59):
|
670
889
|
#
|
671
|
-
#
|
672
|
-
#
|
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
|
-
#
|
893
|
+
# * `sec`: Second in range (0...61):
|
676
894
|
#
|
677
|
-
#
|
678
|
-
#
|
679
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
# -
|
941
|
+
# - inspect -> string
|
704
942
|
# -->
|
705
|
-
# Returns a
|
706
|
-
# subsecond in the representation for easier debugging.
|
943
|
+
# Returns a string representation of `self` with subseconds:
|
707
944
|
#
|
708
|
-
# t = Time.
|
709
|
-
# t.inspect
|
710
|
-
# t.strftime "%Y-%m-%d %H:%M:%S.%N %z" #=> "2012-11-10 18:16:12.261257655 +0100"
|
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
|
-
#
|
713
|
-
#
|
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
|
-
# -
|
720
|
-
# - time.dst? -> true or false
|
957
|
+
# - dst? -> true or false
|
721
958
|
# -->
|
722
|
-
# Returns `true` if
|
723
|
-
#
|
724
|
-
# #
|
725
|
-
#
|
726
|
-
#
|
727
|
-
#
|
728
|
-
#
|
729
|
-
#
|
730
|
-
#
|
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
|
-
# -
|
745
|
-
# -
|
974
|
+
# - localtime -> self or new_time
|
975
|
+
# - localtime(zone) -> new_time
|
746
976
|
# -->
|
747
|
-
#
|
748
|
-
# creation time of *time*) modifying the receiver.
|
977
|
+
# With no argument given:
|
749
978
|
#
|
750
|
-
#
|
979
|
+
# * Returns `self` if `self` is a local time.
|
980
|
+
# * Otherwise returns a new Time in the user's local timezone:
|
751
981
|
#
|
752
|
-
#
|
753
|
-
#
|
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
|
-
#
|
759
|
-
#
|
986
|
+
# With argument `zone` given, returns the new Time object created by converting
|
987
|
+
# `self` to the given time zone:
|
760
988
|
#
|
761
|
-
#
|
762
|
-
#
|
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
|
-
# -
|
769
|
-
# - time.mday -> integer
|
999
|
+
# - mday -> integer
|
770
1000
|
# -->
|
771
|
-
# Returns the day of the month (1..31)
|
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
|
-
#
|
774
|
-
#
|
775
|
-
#
|
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
|
-
# -
|
1015
|
+
# - min -> integer
|
782
1016
|
# -->
|
783
|
-
# Returns the minute of the hour (0..59)
|
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
|
-
#
|
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
|
-
# -
|
793
|
-
# - time.month -> integer
|
1029
|
+
# - mon -> integer
|
794
1030
|
# -->
|
795
|
-
# Returns the month of the year (1..12)
|
1031
|
+
# Returns the integer month of the year for `self`, in range (1..12):
|
796
1032
|
#
|
797
|
-
# t = Time.
|
798
|
-
#
|
799
|
-
# t.
|
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
|
-
# -
|
1045
|
+
# - monday? -> true or false
|
806
1046
|
# -->
|
807
|
-
# Returns `true` if
|
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
|
-
#
|
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
|
816
|
-
#
|
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
|
819
|
-
# t.nsec
|
1060
|
+
# t = Time.now # => 2022-07-11 15:04:53.3219637 -0500
|
1061
|
+
# t.nsec # => 321963700
|
820
1062
|
#
|
821
|
-
#
|
1063
|
+
# Related: Time#subsec (returns exact subseconds).
|
822
1064
|
#
|
823
|
-
#
|
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
|
-
# -
|
1071
|
+
# - round(ndigits = 0) -> new_time
|
833
1072
|
# -->
|
834
|
-
#
|
835
|
-
#
|
836
|
-
#
|
837
|
-
# t = Time.utc(2010,3,30, 5,43,25.123456789r)
|
838
|
-
# t
|
839
|
-
# t.round
|
840
|
-
# t.round(0)
|
841
|
-
# t.round(1)
|
842
|
-
# t.round(2)
|
843
|
-
# t.round(3)
|
844
|
-
# t.round(4)
|
845
|
-
#
|
846
|
-
# t = Time.utc(1999,12,31, 23,59,59)
|
847
|
-
#
|
848
|
-
# (t + 0.
|
849
|
-
# (t + 0.
|
850
|
-
# (t +
|
851
|
-
# (t + 1.
|
852
|
-
# (t + 1.
|
853
|
-
#
|
854
|
-
#
|
855
|
-
#
|
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
|
-
# -
|
1100
|
+
# - saturday? -> true or false
|
862
1101
|
# -->
|
863
|
-
# Returns `true` if
|
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
|
-
#
|
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
|
-
# -
|
1113
|
+
# - sec -> integer
|
873
1114
|
# -->
|
874
|
-
# Returns the second of the minute (0..60)
|
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
|
-
#
|
877
|
-
#
|
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
|
-
#
|
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
|
-
# -
|
1130
|
+
# - strftime(format_string) -> string
|
887
1131
|
# -->
|
888
|
-
#
|
889
|
-
#
|
890
|
-
#
|
891
|
-
# directive will be passed through to the output string.
|
892
|
-
#
|
893
|
-
# The directive consists of a percent (%) character, zero or more flags,
|
894
|
-
# optional minimum field width, optional modifier and a conversion specifier as
|
895
|
-
# follows:
|
896
|
-
#
|
897
|
-
# %<flags><width><modifier><conversion>
|
898
|
-
#
|
899
|
-
# Flags:
|
900
|
-
# - don't pad a numerical output
|
901
|
-
# _ use spaces for padding
|
902
|
-
# 0 use zeros for padding
|
903
|
-
# ^ upcase the result string
|
904
|
-
# # change case
|
905
|
-
# : use colons for %z
|
906
|
-
#
|
907
|
-
# The minimum field width specifies the minimum width.
|
908
|
-
#
|
909
|
-
# The modifiers are "E" and "O". They are ignored.
|
910
|
-
#
|
911
|
-
# Format directives:
|
912
|
-
#
|
913
|
-
# Date (Year, Month, Day):
|
914
|
-
# %Y - Year with century if provided, will pad result at least 4 digits.
|
915
|
-
# -0001, 0000, 1995, 2009, 14292, etc.
|
916
|
-
# %C - year / 100 (rounded down such as 20 in 2009)
|
917
|
-
# %y - year % 100 (00..99)
|
918
|
-
#
|
919
|
-
# %m - Month of the year, zero-padded (01..12)
|
920
|
-
# %_m blank-padded ( 1..12)
|
921
|
-
# %-m no-padded (1..12)
|
922
|
-
# %B - The full month name (``January'')
|
923
|
-
# %^B uppercased (``JANUARY'')
|
924
|
-
# %b - The abbreviated month name (``Jan'')
|
925
|
-
# %^b uppercased (``JAN'')
|
926
|
-
# %h - Equivalent to %b
|
927
|
-
#
|
928
|
-
# %d - Day of the month, zero-padded (01..31)
|
929
|
-
# %-d no-padded (1..31)
|
930
|
-
# %e - Day of the month, blank-padded ( 1..31)
|
931
|
-
#
|
932
|
-
# %j - Day of the year (001..366)
|
933
|
-
#
|
934
|
-
# Time (Hour, Minute, Second, Subsecond):
|
935
|
-
# %H - Hour of the day, 24-hour clock, zero-padded (00..23)
|
936
|
-
# %k - Hour of the day, 24-hour clock, blank-padded ( 0..23)
|
937
|
-
# %I - Hour of the day, 12-hour clock, zero-padded (01..12)
|
938
|
-
# %l - Hour of the day, 12-hour clock, blank-padded ( 1..12)
|
939
|
-
# %P - Meridian indicator, lowercase (``am'' or ``pm'')
|
940
|
-
# %p - Meridian indicator, uppercase (``AM'' or ``PM'')
|
941
|
-
#
|
942
|
-
# %M - Minute of the hour (00..59)
|
943
|
-
#
|
944
|
-
# %S - Second of the minute (00..60)
|
945
|
-
#
|
946
|
-
# %L - Millisecond of the second (000..999)
|
947
|
-
# The digits under millisecond are truncated to not produce 1000.
|
948
|
-
# %N - Fractional seconds digits, default is 9 digits (nanosecond)
|
949
|
-
# %3N millisecond (3 digits)
|
950
|
-
# %6N microsecond (6 digits)
|
951
|
-
# %9N nanosecond (9 digits)
|
952
|
-
# %12N picosecond (12 digits)
|
953
|
-
# %15N femtosecond (15 digits)
|
954
|
-
# %18N attosecond (18 digits)
|
955
|
-
# %21N zeptosecond (21 digits)
|
956
|
-
# %24N yoctosecond (24 digits)
|
957
|
-
# The digits under the specified length are truncated to avoid
|
958
|
-
# carry up.
|
959
|
-
#
|
960
|
-
# Time zone:
|
961
|
-
# %z - Time zone as hour and minute offset from UTC (e.g. +0900)
|
962
|
-
# %:z - hour and minute offset from UTC with a colon (e.g. +09:00)
|
963
|
-
# %::z - hour, minute and second offset from UTC (e.g. +09:00:00)
|
964
|
-
# %Z - Abbreviated time zone name or similar information. (OS dependent)
|
965
|
-
#
|
966
|
-
# Weekday:
|
967
|
-
# %A - The full weekday name (``Sunday'')
|
968
|
-
# %^A uppercased (``SUNDAY'')
|
969
|
-
# %a - The abbreviated name (``Sun'')
|
970
|
-
# %^a uppercased (``SUN'')
|
971
|
-
# %u - Day of the week (Monday is 1, 1..7)
|
972
|
-
# %w - Day of the week (Sunday is 0, 0..6)
|
973
|
-
#
|
974
|
-
# ISO 8601 week-based year and week number:
|
975
|
-
# The first week of YYYY starts with a Monday and includes YYYY-01-04.
|
976
|
-
# The days in the year before the first week are in the last week of
|
977
|
-
# the previous year.
|
978
|
-
# %G - The week-based year
|
979
|
-
# %g - The last 2 digits of the week-based year (00..99)
|
980
|
-
# %V - Week number of the week-based year (01..53)
|
981
|
-
#
|
982
|
-
# Week number:
|
983
|
-
# The first week of YYYY that starts with a Sunday or Monday (according to %U
|
984
|
-
# or %W). The days in the year before the first week are in week 0.
|
985
|
-
# %U - Week number of the year. The week starts with Sunday. (00..53)
|
986
|
-
# %W - Week number of the year. The week starts with Monday. (00..53)
|
987
|
-
#
|
988
|
-
# Seconds since the Epoch:
|
989
|
-
# %s - Number of seconds since 1970-01-01 00:00:00 UTC.
|
990
|
-
#
|
991
|
-
# Literal string:
|
992
|
-
# %n - Newline character (\n)
|
993
|
-
# %t - Tab character (\t)
|
994
|
-
# %% - Literal ``%'' character
|
995
|
-
#
|
996
|
-
# Combination:
|
997
|
-
# %c - date and time (%a %b %e %T %Y)
|
998
|
-
# %D - Date (%m/%d/%y)
|
999
|
-
# %F - The ISO 8601 date format (%Y-%m-%d)
|
1000
|
-
# %v - VMS date (%e-%^b-%4Y)
|
1001
|
-
# %x - Same as %D
|
1002
|
-
# %X - Same as %T
|
1003
|
-
# %r - 12-hour time (%I:%M:%S %p)
|
1004
|
-
# %R - 24-hour time (%H:%M)
|
1005
|
-
# %T - 24-hour time (%H:%M:%S)
|
1006
|
-
#
|
1007
|
-
# This method is similar to strftime() function defined in ISO C and POSIX.
|
1008
|
-
#
|
1009
|
-
# While all directives are locale independent since Ruby 1.9, %Z is platform
|
1010
|
-
# dependent. So, the result may differ even if the same format string is used in
|
1011
|
-
# other systems such as C.
|
1012
|
-
#
|
1013
|
-
# %z is recommended over %Z. %Z doesn't identify the timezone. For example,
|
1014
|
-
# "CST" is used at America/Chicago (-06:00), America/Havana (-05:00),
|
1015
|
-
# Asia/Harbin (+08:00), Australia/Darwin (+09:30) and Australia/Adelaide
|
1016
|
-
# (+10:30). Also, %Z is highly dependent on the operating system. For example,
|
1017
|
-
# it may generate a non ASCII string on Japanese Windows, i.e. the result can be
|
1018
|
-
# different to "JST". So the numeric time zone offset, %z, is recommended.
|
1019
|
-
#
|
1020
|
-
# Examples:
|
1021
|
-
#
|
1022
|
-
# t = Time.new(2007,11,19,8,37,48,"-06:00") #=> 2007-11-19 08:37:48 -0600
|
1023
|
-
# t.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007"
|
1024
|
-
# t.strftime("at %I:%M %p") #=> "at 08:37 AM"
|
1025
|
-
#
|
1026
|
-
# Various ISO 8601 formats:
|
1027
|
-
# %Y%m%d => 20071119 Calendar date (basic)
|
1028
|
-
# %F => 2007-11-19 Calendar date (extended)
|
1029
|
-
# %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month
|
1030
|
-
# %Y => 2007 Calendar date, reduced accuracy, specific year
|
1031
|
-
# %C => 20 Calendar date, reduced accuracy, specific century
|
1032
|
-
# %Y%j => 2007323 Ordinal date (basic)
|
1033
|
-
# %Y-%j => 2007-323 Ordinal date (extended)
|
1034
|
-
# %GW%V%u => 2007W471 Week date (basic)
|
1035
|
-
# %G-W%V-%u => 2007-W47-1 Week date (extended)
|
1036
|
-
# %GW%V => 2007W47 Week date, reduced accuracy, specific week (basic)
|
1037
|
-
# %G-W%V => 2007-W47 Week date, reduced accuracy, specific week (extended)
|
1038
|
-
# %H%M%S => 083748 Local time (basic)
|
1039
|
-
# %T => 08:37:48 Local time (extended)
|
1040
|
-
# %H%M => 0837 Local time, reduced accuracy, specific minute (basic)
|
1041
|
-
# %H:%M => 08:37 Local time, reduced accuracy, specific minute (extended)
|
1042
|
-
# %H => 08 Local time, reduced accuracy, specific hour
|
1043
|
-
# %H%M%S,%L => 083748,000 Local time with decimal fraction, comma as decimal sign (basic)
|
1044
|
-
# %T,%L => 08:37:48,000 Local time with decimal fraction, comma as decimal sign (extended)
|
1045
|
-
# %H%M%S.%L => 083748.000 Local time with decimal fraction, full stop as decimal sign (basic)
|
1046
|
-
# %T.%L => 08:37:48.000 Local time with decimal fraction, full stop as decimal sign (extended)
|
1047
|
-
# %H%M%S%z => 083748-0600 Local time and the difference from UTC (basic)
|
1048
|
-
# %T%:z => 08:37:48-06:00 Local time and the difference from UTC (extended)
|
1049
|
-
# %Y%m%dT%H%M%S%z => 20071119T083748-0600 Date and time of day for calendar date (basic)
|
1050
|
-
# %FT%T%:z => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended)
|
1051
|
-
# %Y%jT%H%M%S%z => 2007323T083748-0600 Date and time of day for ordinal date (basic)
|
1052
|
-
# %Y-%jT%T%:z => 2007-323T08:37:48-06:00 Date and time of day for ordinal date (extended)
|
1053
|
-
# %GW%V%uT%H%M%S%z => 2007W471T083748-0600 Date and time of day for week date (basic)
|
1054
|
-
# %G-W%V-%uT%T%:z => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended)
|
1055
|
-
# %Y%m%dT%H%M => 20071119T0837 Calendar date and local time (basic)
|
1056
|
-
# %FT%R => 2007-11-19T08:37 Calendar date and local time (extended)
|
1057
|
-
# %Y%jT%H%MZ => 2007323T0837Z Ordinal date and UTC of day (basic)
|
1058
|
-
# %Y-%jT%RZ => 2007-323T08:37Z Ordinal date and UTC of day (extended)
|
1059
|
-
# %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic)
|
1060
|
-
# %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended)
|
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
|
-
# -
|
1140
|
+
# - subsec -> numeric
|
1067
1141
|
# -->
|
1068
|
-
# Returns the
|
1142
|
+
# Returns the exact subseconds for `self` as a Numeric (Integer or Rational):
|
1069
1143
|
#
|
1070
|
-
#
|
1144
|
+
# t = Time.now # => 2022-07-11 15:11:36.8490302 -0500
|
1145
|
+
# t.subsec # => (4245151/5000000)
|
1071
1146
|
#
|
1072
|
-
#
|
1073
|
-
# t.subsec #=> (867462289/1000000000)
|
1147
|
+
# If the subseconds is zero, returns integer zero:
|
1074
1148
|
#
|
1075
|
-
# t = Time.
|
1076
|
-
# t.subsec
|
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
|
-
# -
|
1156
|
+
# - sunday? -> true or false
|
1088
1157
|
# -->
|
1089
|
-
# Returns `true` if
|
1158
|
+
# Returns `true` if `self` represents a Sunday, `false` otherwise:
|
1090
1159
|
#
|
1091
|
-
# t = Time.
|
1092
|
-
# t.sunday?
|
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
|
-
# -
|
1169
|
+
# - thursday? -> true or false
|
1099
1170
|
# -->
|
1100
|
-
# Returns `true` if
|
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
|
-
#
|
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
|
-
# -
|
1182
|
+
# - to_a -> array
|
1110
1183
|
# -->
|
1111
|
-
# Returns a
|
1184
|
+
# Returns a 10-element array of values representing `self`:
|
1112
1185
|
#
|
1113
|
-
#
|
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
|
-
#
|
1116
|
-
#
|
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
|
-
# -
|
1197
|
+
# - to_f -> float
|
1127
1198
|
# -->
|
1128
|
-
# Returns the value of
|
1129
|
-
# Epoch
|
1130
|
-
#
|
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
|
-
#
|
1133
|
-
#
|
1134
|
-
#
|
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
|
-
#
|
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
|
-
# -
|
1148
|
-
# - time.tv_sec -> int
|
1216
|
+
# - to_i -> integer
|
1149
1217
|
# -->
|
1150
|
-
# Returns the value of
|
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
|
-
#
|
1226
|
+
# Time#tv_sec is an alias for Time#to_i.
|
1153
1227
|
#
|
1154
|
-
#
|
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
|
-
# -
|
1234
|
+
# - to_r -> rational
|
1162
1235
|
# -->
|
1163
|
-
# Returns the value of
|
1236
|
+
# Returns the value of `self` as a Rational exact number of [Epoch
|
1237
|
+
# seconds](rdoc-ref:Time@Epoch+Seconds);
|
1164
1238
|
#
|
1165
|
-
#
|
1166
|
-
# t.to_r #=> (1595250225212167333/1000000000)
|
1239
|
+
# Time.now.to_r # => (16571402750320203/10000000)
|
1167
1240
|
#
|
1168
|
-
#
|
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
|
-
# -
|
1247
|
+
# - to_s -> string
|
1176
1248
|
# -->
|
1177
|
-
# Returns a string
|
1178
|
-
# appropriate format string.
|
1249
|
+
# Returns a string representation of `self`, without subseconds:
|
1179
1250
|
#
|
1180
|
-
# t = Time.
|
1181
|
-
# t.to_s
|
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
|
-
#
|
1185
|
-
#
|
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
|
-
# -
|
1263
|
+
# - tuesday? -> true or false
|
1192
1264
|
# -->
|
1193
|
-
# Returns `true` if
|
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
|
-
#
|
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
|
-
# -
|
1203
|
-
# - time.tv_nsec -> int
|
1276
|
+
# - nsec -> integer
|
1204
1277
|
# -->
|
1205
|
-
# Returns the number of nanoseconds
|
1206
|
-
#
|
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
|
-
#
|
1281
|
+
# t = Time.now # => 2022-07-11 15:04:53.3219637 -0500
|
1282
|
+
# t.nsec # => 321963700
|
1212
1283
|
#
|
1213
|
-
#
|
1214
|
-
# t.nsec #=> 666777888
|
1284
|
+
# Related: Time#subsec (returns exact subseconds).
|
1215
1285
|
#
|
1216
|
-
# Time#
|
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
|
1291
|
+
# Returns the value of `self` as integer [Epoch
|
1292
|
+
# seconds](rdoc-ref:Time@Epoch+Seconds); subseconds are truncated (not rounded):
|
1222
1293
|
#
|
1223
|
-
#
|
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
|
-
#
|
1226
|
-
#
|
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
|
-
# -
|
1233
|
-
# - time.tv_usec -> int
|
1307
|
+
# - usec -> integer
|
1234
1308
|
# -->
|
1235
|
-
# Returns the number of microseconds
|
1236
|
-
#
|
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
|
-
#
|
1312
|
+
# t = Time.now # => 2022-07-11 14:59:47.5484697 -0500
|
1313
|
+
# t.usec # => 548469
|
1242
1314
|
#
|
1243
|
-
#
|
1244
|
-
# t.usec #=> 666777
|
1315
|
+
# Related: Time#subsec (returns exact subseconds).
|
1245
1316
|
#
|
1246
|
-
# Time#
|
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
|
1252
|
-
#
|
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
|
-
#
|
1325
|
+
# t = Time.now # => 2022-07-11 14:59:47.5484697 -0500
|
1326
|
+
# t.usec # => 548469
|
1258
1327
|
#
|
1259
|
-
#
|
1260
|
-
# t.usec #=> 666777
|
1328
|
+
# Related: Time#subsec (returns exact subseconds).
|
1261
1329
|
#
|
1262
|
-
# Time#
|
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
|
-
#
|
1335
|
+
# Returns `self`, converted to the UTC timezone:
|
1268
1336
|
#
|
1269
|
-
# t = Time.
|
1270
|
-
# t.
|
1271
|
-
# t.
|
1272
|
-
# t.
|
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
|
-
#
|
1275
|
-
#
|
1276
|
-
#
|
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
|
-
# -
|
1284
|
-
# - time.gmt? -> true or false
|
1350
|
+
# - utc? -> true or false
|
1285
1351
|
# -->
|
1286
|
-
# Returns `true` if
|
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
|
-
#
|
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
|
-
#
|
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
|
1368
|
+
# Returns the offset in seconds between the timezones of UTC and `self`:
|
1302
1369
|
#
|
1303
|
-
#
|
1304
|
-
#
|
1305
|
-
#
|
1306
|
-
#
|
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
|
-
# -
|
1379
|
+
# - wday -> integer
|
1313
1380
|
# -->
|
1314
|
-
# Returns
|
1315
|
-
#
|
1316
|
-
#
|
1317
|
-
# t.
|
1318
|
-
#
|
1319
|
-
# t.
|
1320
|
-
# t.
|
1321
|
-
#
|
1322
|
-
#
|
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
|
-
# -
|
1395
|
+
# - wednesday? -> true or false
|
1331
1396
|
# -->
|
1332
|
-
# Returns `true` if
|
1397
|
+
# Returns `true` if `self` represents a Wednesday, `false` otherwise:
|
1333
1398
|
#
|
1334
|
-
# t = Time.
|
1335
|
-
# t.wednesday?
|
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
|
-
# -
|
1408
|
+
# - yday -> integer
|
1342
1409
|
# -->
|
1343
|
-
# Returns
|
1410
|
+
# Returns the integer day of the year of `self`, in range (1..366).
|
1344
1411
|
#
|
1345
|
-
#
|
1346
|
-
#
|
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
|
-
# -
|
1419
|
+
# - year -> integer
|
1353
1420
|
# -->
|
1354
|
-
# Returns the year for
|
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
|
-
#
|
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
|
1366
|
-
# ``UTC'' rather than ``GMT'' for UTC times.
|
1435
|
+
# Returns the string name of the time zone for `self`:
|
1367
1436
|
#
|
1368
|
-
#
|
1369
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
# -
|
1384
|
-
# - time.gmtoff -> integer
|
1385
|
-
# - time.utc_offset -> integer
|
1457
|
+
# - utc_offset -> integer
|
1386
1458
|
# -->
|
1387
|
-
# Returns the offset in seconds between the
|
1459
|
+
# Returns the offset in seconds between the timezones of UTC and `self`:
|
1388
1460
|
#
|
1389
|
-
#
|
1390
|
-
#
|
1391
|
-
#
|
1392
|
-
#
|
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)
|
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
|
-
#
|
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
|
-
# -
|
1483
|
+
# - floor(ndigits = 0) -> new_time
|
1408
1484
|
# -->
|
1409
|
-
#
|
1410
|
-
#
|
1411
|
-
#
|
1412
|
-
# t = Time.utc(2010,3,30, 5,43,25.123456789r)
|
1413
|
-
# t
|
1414
|
-
# t.floor
|
1415
|
-
# t.floor(
|
1416
|
-
# t.floor(
|
1417
|
-
# t.floor(
|
1418
|
-
# t.floor(
|
1419
|
-
# t.floor(
|
1420
|
-
#
|
1421
|
-
# t = Time.utc(1999,12,31, 23,59,59)
|
1422
|
-
#
|
1423
|
-
# (t + 0.
|
1424
|
-
# (t +
|
1425
|
-
# (t + 1.
|
1426
|
-
#
|
1427
|
-
#
|
1428
|
-
#
|
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
|
-
# -
|
1510
|
+
# - ceil(ndigits = 0) -> new_time
|
1435
1511
|
# -->
|
1436
|
-
#
|
1437
|
-
#
|
1438
|
-
#
|
1439
|
-
# t = Time.utc(2010,3,30, 5,43,25.
|
1440
|
-
# t
|
1441
|
-
# t.ceil
|
1442
|
-
# t.ceil(
|
1443
|
-
# t.ceil(
|
1444
|
-
# t.ceil(
|
1445
|
-
# t.ceil(
|
1446
|
-
# t.ceil(
|
1447
|
-
#
|
1448
|
-
# t = Time.utc(1999,12,31, 23,59,59)
|
1449
|
-
#
|
1450
|
-
# (t + 0.
|
1451
|
-
# (t +
|
1452
|
-
# (t + 1.
|
1453
|
-
#
|
1454
|
-
#
|
1455
|
-
#
|
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
|