rbs 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +5 -0
  3. data/CHANGELOG.md +23 -0
  4. data/README.md +6 -1
  5. data/core/array.rbs +2866 -1086
  6. data/core/basic_object.rbs +150 -30
  7. data/core/binding.rbs +33 -0
  8. data/core/builtin.rbs +4 -4
  9. data/core/class.rbs +43 -5
  10. data/core/comparable.rbs +57 -0
  11. data/core/complex.rbs +170 -4
  12. data/core/constants.rbs +51 -0
  13. data/core/deprecated.rbs +7 -0
  14. data/core/dir.rbs +305 -20
  15. data/core/encoding.rbs +472 -77
  16. data/core/enumerable.rbs +2173 -234
  17. data/core/enumerator.rbs +448 -182
  18. data/core/env.rbs +448 -1
  19. data/core/errno.rbs +1 -10
  20. data/core/errors.rbs +152 -2
  21. data/core/exception.rbs +201 -127
  22. data/core/false_class.rbs +27 -0
  23. data/core/fiber.rbs +118 -37
  24. data/core/fiber_error.rbs +8 -9
  25. data/core/file.rbs +1059 -139
  26. data/core/file_test.rbs +287 -32
  27. data/core/float.rbs +776 -300
  28. data/core/gc.rbs +185 -34
  29. data/core/global_variables.rbs +5 -1
  30. data/core/hash.rbs +1582 -649
  31. data/core/integer.rbs +974 -204
  32. data/core/io/buffer.rbs +710 -0
  33. data/core/io/wait.rbs +29 -8
  34. data/core/io.rbs +2438 -417
  35. data/core/kernel.rbs +2315 -316
  36. data/core/marshal.rbs +37 -2
  37. data/core/match_data.rbs +123 -6
  38. data/core/math.rbs +126 -6
  39. data/core/method.rbs +226 -102
  40. data/core/module.rbs +421 -45
  41. data/core/nil_class.rbs +64 -0
  42. data/core/numeric.rbs +620 -142
  43. data/core/object.rbs +453 -81
  44. data/core/object_space.rbs +92 -2
  45. data/core/proc.rbs +482 -285
  46. data/core/process.rbs +443 -34
  47. data/core/ractor.rbs +232 -9
  48. data/core/random.rbs +151 -52
  49. data/core/range.rbs +885 -160
  50. data/core/rational.rbs +122 -6
  51. data/core/rb_config.rbs +14 -4
  52. data/core/refinement.rbs +44 -0
  53. data/core/regexp.rbs +156 -14
  54. data/core/ruby_vm.rbs +42 -3
  55. data/core/signal.rbs +78 -39
  56. data/core/string.rbs +2123 -567
  57. data/core/string_io.rbs +204 -0
  58. data/core/struct.rbs +283 -28
  59. data/core/symbol.rbs +304 -30
  60. data/core/thread.rbs +1288 -688
  61. data/core/thread_group.rbs +66 -10
  62. data/core/time.rbs +643 -217
  63. data/core/trace_point.rbs +100 -12
  64. data/core/true_class.rbs +24 -0
  65. data/core/unbound_method.rbs +73 -7
  66. data/core/warning.rbs +37 -12
  67. data/docs/CONTRIBUTING.md +40 -34
  68. data/docs/stdlib.md +3 -102
  69. data/lib/rbs/annotate/annotations.rb +197 -0
  70. data/lib/rbs/annotate/formatter.rb +80 -0
  71. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  72. data/lib/rbs/annotate/rdoc_source.rb +120 -0
  73. data/lib/rbs/annotate.rb +6 -0
  74. data/lib/rbs/cli.rb +45 -1
  75. data/lib/rbs/definition_builder.rb +5 -1
  76. data/lib/rbs/location_aux.rb +12 -0
  77. data/lib/rbs/prototype/rb.rb +12 -0
  78. data/lib/rbs/version.rb +1 -1
  79. data/sig/annotate/annotations.rbs +102 -0
  80. data/sig/annotate/formatter.rbs +24 -0
  81. data/sig/annotate/rdoc_annotater.rbs +82 -0
  82. data/sig/annotate/rdoc_source.rbs +30 -0
  83. data/sig/cli.rbs +2 -0
  84. data/sig/collection/{collections.rbs → sources.rbs} +0 -0
  85. data/sig/location.rbs +6 -0
  86. data/sig/method_types.rbs +5 -1
  87. data/sig/polyfill.rbs +78 -0
  88. data/stdlib/abbrev/0/abbrev.rbs +6 -0
  89. data/stdlib/abbrev/0/array.rbs +26 -0
  90. data/stdlib/base64/0/base64.rbs +31 -0
  91. data/stdlib/benchmark/0/benchmark.rbs +74 -3
  92. data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
  93. data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
  94. data/stdlib/cgi/0/core.rbs +59 -0
  95. data/stdlib/coverage/0/coverage.rbs +164 -2
  96. data/stdlib/csv/0/csv.rbs +2862 -398
  97. data/stdlib/date/0/date.rbs +483 -25
  98. data/stdlib/date/0/date_time.rbs +187 -12
  99. data/stdlib/dbm/0/dbm.rbs +152 -17
  100. data/stdlib/digest/0/digest.rbs +146 -0
  101. data/stdlib/erb/0/erb.rbs +65 -245
  102. data/stdlib/fiber/0/fiber.rbs +73 -91
  103. data/stdlib/fileutils/0/fileutils.rbs +301 -1
  104. data/stdlib/find/0/find.rbs +9 -0
  105. data/stdlib/forwardable/0/forwardable.rbs +65 -1
  106. data/stdlib/io-console/0/io-console.rbs +227 -15
  107. data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
  108. data/stdlib/json/0/json.rbs +1146 -144
  109. data/stdlib/logger/0/formatter.rbs +24 -0
  110. data/stdlib/logger/0/log_device.rbs +64 -0
  111. data/stdlib/logger/0/logger.rbs +165 -13
  112. data/stdlib/logger/0/period.rbs +10 -0
  113. data/stdlib/logger/0/severity.rbs +26 -0
  114. data/stdlib/monitor/0/monitor.rbs +163 -0
  115. data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
  116. data/stdlib/net-http/0/net-http.rbs +1492 -683
  117. data/stdlib/nkf/0/nkf.rbs +372 -0
  118. data/stdlib/objspace/0/objspace.rbs +149 -90
  119. data/stdlib/openssl/0/openssl.rbs +8108 -71
  120. data/stdlib/optparse/0/optparse.rbs +487 -19
  121. data/stdlib/pathname/0/pathname.rbs +425 -124
  122. data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
  123. data/stdlib/prime/0/integer-extension.rbs +20 -2
  124. data/stdlib/prime/0/prime.rbs +88 -21
  125. data/stdlib/pstore/0/pstore.rbs +102 -0
  126. data/stdlib/pty/0/pty.rbs +64 -14
  127. data/stdlib/resolv/0/resolv.rbs +420 -31
  128. data/stdlib/rubygems/0/basic_specification.rbs +4 -1
  129. data/stdlib/rubygems/0/config_file.rbs +33 -1
  130. data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
  131. data/stdlib/rubygems/0/installer.rbs +13 -1
  132. data/stdlib/rubygems/0/path_support.rbs +4 -1
  133. data/stdlib/rubygems/0/platform.rbs +5 -1
  134. data/stdlib/rubygems/0/request_set.rbs +44 -2
  135. data/stdlib/rubygems/0/requirement.rbs +65 -2
  136. data/stdlib/rubygems/0/rubygems.rbs +407 -0
  137. data/stdlib/rubygems/0/source_list.rbs +13 -0
  138. data/stdlib/rubygems/0/specification.rbs +21 -1
  139. data/stdlib/rubygems/0/stream_ui.rbs +3 -1
  140. data/stdlib/rubygems/0/uninstaller.rbs +8 -1
  141. data/stdlib/rubygems/0/version.rbs +60 -157
  142. data/stdlib/securerandom/0/securerandom.rbs +44 -0
  143. data/stdlib/set/0/set.rbs +420 -106
  144. data/stdlib/shellwords/0/shellwords.rbs +55 -77
  145. data/stdlib/singleton/0/singleton.rbs +20 -0
  146. data/stdlib/socket/0/addrinfo.rbs +210 -9
  147. data/stdlib/socket/0/basic_socket.rbs +103 -11
  148. data/stdlib/socket/0/ip_socket.rbs +31 -9
  149. data/stdlib/socket/0/socket.rbs +586 -38
  150. data/stdlib/socket/0/tcp_server.rbs +22 -2
  151. data/stdlib/socket/0/tcp_socket.rbs +12 -1
  152. data/stdlib/socket/0/udp_socket.rbs +25 -2
  153. data/stdlib/socket/0/unix_server.rbs +22 -2
  154. data/stdlib/socket/0/unix_socket.rbs +45 -5
  155. data/stdlib/strscan/0/string_scanner.rbs +210 -9
  156. data/stdlib/tempfile/0/tempfile.rbs +58 -10
  157. data/stdlib/time/0/time.rbs +208 -116
  158. data/stdlib/timeout/0/timeout.rbs +10 -0
  159. data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
  160. data/stdlib/tsort/0/cyclic.rbs +1 -0
  161. data/stdlib/tsort/0/interfaces.rbs +1 -0
  162. data/stdlib/tsort/0/tsort.rbs +42 -0
  163. data/stdlib/uri/0/common.rbs +57 -8
  164. data/stdlib/uri/0/file.rbs +55 -109
  165. data/stdlib/uri/0/ftp.rbs +6 -3
  166. data/stdlib/uri/0/generic.rbs +556 -327
  167. data/stdlib/uri/0/http.rbs +26 -115
  168. data/stdlib/uri/0/https.rbs +8 -102
  169. data/stdlib/uri/0/ldap.rbs +143 -137
  170. data/stdlib/uri/0/ldaps.rbs +8 -102
  171. data/stdlib/uri/0/mailto.rbs +3 -0
  172. data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
  173. data/stdlib/uri/0/ws.rbs +6 -3
  174. data/stdlib/uri/0/wss.rbs +5 -3
  175. data/stdlib/yaml/0/dbm.rbs +151 -87
  176. data/stdlib/yaml/0/store.rbs +6 -0
  177. data/stdlib/zlib/0/zlib.rbs +90 -31
  178. metadata +17 -5
  179. data/lib/rbs/location.rb +0 -221
data/core/time.rbs CHANGED
@@ -1,32 +1,30 @@
1
+ # <!-- rdoc-file=timev.rb -->
1
2
  # Time is an abstraction of dates and times. Time is stored internally as the
2
- # number of seconds with fraction since the *Epoch*, January 1, 1970 00:00 UTC.
3
- # Also see the library module Date. The Time class treats GMT (Greenwich Mean
4
- # Time) and UTC (Coordinated Universal Time) as equivalent. GMT is the older way
5
- # of referring to these baseline times but persists in the names of calls on
6
- # POSIX systems.
3
+ # number of seconds with subsecond since the *Epoch*, 1970-01-01 00:00:00 UTC.
7
4
  #
8
- # All times may have fraction. Be aware of this fact when comparing times with
9
- # each other -- times that are apparently equal when displayed may be different
10
- # when compared.
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.
8
+ #
9
+ # Note: A Time object uses the resolution available on your system clock.
11
10
  #
12
- # Since Ruby 1.9.2, Time implementation uses a signed 63 bit integer, Bignum or
13
- # Rational. The integer is a number of nanoseconds since the *Epoch* which can
14
- # represent 1823-11-12 to 2116-02-20. When Bignum or Rational is used (before
15
- # 1823, after 2116, under nanosecond), Time works slower as when integer is
16
- # used.
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.)
17
15
  #
18
- # # Examples
16
+ # ## Examples
19
17
  #
20
18
  # All of these examples were done using the EST timezone which is GMT-5.
21
19
  #
22
- # ## Creating a new Time instance
20
+ # ### Creating a New Time Instance
23
21
  #
24
- # You can create a new instance of Time with Time::new. This will use the
25
- # current system time. Time::now is an alias for this. You can also pass parts
26
- # of the time to Time::new such as year, month, minute, etc. When you want to
27
- # construct a time this way you must pass at least a year. If you pass the year
28
- # with nothing else time will default to January 1 of that year at 00:00:00 with
29
- # the current system timezone. Here are some examples:
22
+ # You can create a new instance of Time with Time.new. This will use the current
23
+ # system time. Time.now is an alias for this. You can also pass parts of the
24
+ # time to Time.new such as year, month, minute, etc. When you want to construct
25
+ # a time this way you must pass at least a year. If you pass the year with
26
+ # nothing else time will default to January 1 of that year at 00:00:00 with the
27
+ # current system timezone. Here are some examples:
30
28
  #
31
29
  # Time.new(2002) #=> 2002-01-01 00:00:00 -0500
32
30
  # Time.new(2002, 10) #=> 2002-10-01 00:00:00 -0500
@@ -38,19 +36,19 @@
38
36
  #
39
37
  # Or a timezone object:
40
38
  #
41
- # tz = timezone("Europe/Athens") # Eastern European Time, UTC+2
42
- # Time.new(2002, 10, 31, 2, 2, 2, tz) #=> 2002-10-31 02:02:02 +0200
39
+ # zone = timezone("Europe/Athens") # Eastern European Time, UTC+2
40
+ # Time.new(2002, 10, 31, 2, 2, 2, zone) #=> 2002-10-31 02:02:02 +0200
43
41
  #
44
- # You can also use Time::gm, Time::local and Time::utc to infer GMT, local and
45
- # UTC timezones instead of using the current system setting.
42
+ # You can also use Time.local and Time.utc to infer local and UTC timezones
43
+ # instead of using the current system setting.
46
44
  #
47
- # You can also create a new time using Time::at which takes the number of
48
- # seconds (or fraction of seconds) since the [Unix
49
- # Epoch](http://en.wikipedia.org/wiki/Unix_time).
45
+ # You can also create a new time using Time.at which takes the number of seconds
46
+ # (with subsecond) since the [Unix
47
+ # Epoch](https://en.wikipedia.org/wiki/Unix_time).
50
48
  #
51
49
  # Time.at(628232400) #=> 1989-11-28 00:00:00 -0500
52
50
  #
53
- # ## Working with an instance of Time
51
+ # ### Working with an Instance of Time
54
52
  #
55
53
  # Once you have an instance of Time there is a multitude of things you can do
56
54
  # with it. Below are some examples. For all of the following examples, we will
@@ -90,7 +88,106 @@
90
88
  #
91
89
  # Time.new(2010,10,31).between?(t1, t2) #=> true
92
90
  #
93
- # ## Timezone argument
91
+ # ## What's Here
92
+ #
93
+ # First, what's elsewhere. Class Time:
94
+ #
95
+ # * Inherits from [class
96
+ # Object](Object.html#class-Object-label-What-27s+Here).
97
+ # * Includes [module
98
+ # Comparable](Comparable.html#module-Comparable-label-What-27s+Here).
99
+ #
100
+ #
101
+ # Here, class Time provides methods that are useful for:
102
+ #
103
+ # * [Creating \Time objects](#class-Time-label-Methods+for+Creating).
104
+ # * [Fetching \Time values](#class-Time-label-Methods+for+Fetching).
105
+ # * [Querying a \Time object](#class-Time-label-Methods+for+Querying).
106
+ # * [Comparing \Time objects](#class-Time-label-Methods+for+Comparing).
107
+ # * [Converting a \Time object](#class-Time-label-Methods+for+Converting).
108
+ # * [Rounding a \Time](#class-Time-label-Methods+for+Rounding).
109
+ #
110
+ #
111
+ # ### Methods for Creating
112
+ #
113
+ # * ::new: Returns a new time from specified arguments (year, month, etc.),
114
+ # including an optional timezone value.
115
+ # * ::local (aliased as ::mktime): Same as ::new, except the timezone is the
116
+ # local timezone.
117
+ # * ::utc (aliased as ::gm): Same as ::new, except the timezone is UTC.
118
+ # * ::at: Returns a new time based on seconds since epoch.
119
+ # * ::now: Returns a new time based on the current system time.
120
+ # * #+ (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.
123
+ #
124
+ #
125
+ # ### Methods for Fetching
126
+ #
127
+ # * #year: Returns the year of the time.
128
+ # * #month (aliased as #mon): Returns the month of the time.
129
+ # * #mday (aliased as #day): Returns the day of the month.
130
+ # * #hour: Returns the hours value for the time.
131
+ # * #min: Returns the minutes value for the time.
132
+ # * #sec: Returns the seconds value for the time.
133
+ # * #usec (aliased as #tv_usec): Returns the number of microseconds in the
134
+ # subseconds value of the time.
135
+ # * #nsec (aliased as #tv_nsec: Returns the number of nanoseconds in the
136
+ # subsecond part of the time.
137
+ # * #subsec: Returns the subseconds value for the time.
138
+ # * #wday: Returns the integer weekday value of the time (0 == Sunday).
139
+ # * #yday: Returns the integer yearday value of the time (1 == January 1).
140
+ # * #hash: Returns the integer hash value for the time.
141
+ # * #utc_offset (aliased as #gmt_offset and #gmtoff): Returns the offset in
142
+ # seconds between time and UTC.
143
+ # * #to_f: Returns the float number of seconds since epoch for the time.
144
+ # * #to_i (aliased as #tv_sec): Returns the integer number of seconds since
145
+ # epoch for the time.
146
+ # * #to_r: Returns the Rational number of seconds since epoch for the time.
147
+ # * #zone: Returns a string representation of the timezone of the time.
148
+ #
149
+ #
150
+ # ### Methods for Querying
151
+ #
152
+ # * #utc? (aliased as #gmt?): Returns whether the time is UTC.
153
+ # * #dst? (aliased as #isdst): Returns whether the time is DST (daylight
154
+ # saving time).
155
+ # * #sunday?: Returns whether the time is a Sunday.
156
+ # * #monday?: Returns whether the time is a Monday.
157
+ # * #tuesday?: Returns whether the time is a Tuesday.
158
+ # * #wednesday?: Returns whether the time is a Wednesday.
159
+ # * #thursday?: Returns whether the time is a Thursday.
160
+ # * #friday?: Returns whether time is a Friday.
161
+ # * #saturday?: Returns whether the time is a Saturday.
162
+ #
163
+ #
164
+ # ### Methods for Comparing
165
+ #
166
+ # * [#<=>](#method-i-3C-3D-3E): Compares `self` to another time.
167
+ # * #eql?: Returns whether the time is equal to another time.
168
+ #
169
+ #
170
+ # ### Methods for Converting
171
+ #
172
+ # * #asctime (aliased as #ctime): Returns the time as a string.
173
+ # * #inspect: Returns the time in detail as a string.
174
+ # * #strftime: Returns the time as a string, according to a given format.
175
+ # * #to_a: Returns a 10-element array of values from the time.
176
+ # * #to_s: Returns a string representation of the time.
177
+ # * #getutc (aliased as #getgm): Returns a new time converted to UTC.
178
+ # * #getlocal: Returns a new time converted to local time.
179
+ # * #utc (aliased as #gmtime): Converts time to UTC in place.
180
+ # * #localtime: Converts time to local time in place.
181
+ #
182
+ #
183
+ # ### Methods for Rounding
184
+ #
185
+ # * #round:Returns a new time with subseconds rounded.
186
+ # * #ceil: Returns a new time with subseconds raised to a ceiling.
187
+ # * #floor: Returns a new time with subseconds lowered to a floor.
188
+ #
189
+ #
190
+ # ## Timezone Argument
94
191
  #
95
192
  # A timezone argument must have `local_to_utc` and `utc_to_local` methods, and
96
193
  # may have `name`, `abbr`, and `dst?` methods.
@@ -99,8 +196,8 @@
99
196
  # to UTC, and `utc_to_local` is the opposite. The result also should be a Time
100
197
  # or Time-like object (not necessary to be the same class). The #zone of the
101
198
  # result is just ignored. Time-like argument to these methods is similar to a
102
- # Time object in UTC without sub-second; it has attribute readers for the parts,
103
- # e.g. #year, #month, and so on, and epoch time readers, #to_i. The sub-second
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
104
201
  # attributes are fixed as 0, and #utc_offset, #zone, #isdst, and their aliases
105
202
  # are same as a Time object in UTC. Also #to_time, #+, and #- methods are
106
203
  # defined.
@@ -114,7 +211,7 @@
114
211
  # The `dst?` method is called with a `Time` value and should return whether the
115
212
  # `Time` value is in daylight savings time in the zone.
116
213
  #
117
- # ### Auto conversion to Timezone
214
+ # ### Auto Conversion to Timezone
118
215
  #
119
216
  # At loading marshaled data, a timezone name will be converted to a timezone
120
217
  # object by `find_timezone` class method, if the method is defined.
@@ -125,25 +222,65 @@
125
222
  class Time < Object
126
223
  include Comparable
127
224
 
128
- # Creates a new Time object with the value given by `time`, the given number of
129
- # `seconds_with_frac`, or `seconds` and `microseconds_with_frac` since the
130
- # Epoch. `seconds_with_frac` and `microseconds_with_frac` can be an Integer,
131
- # Float, Rational, or other Numeric. non-portable feature allows the offset to
132
- # be negative on some systems.
133
- #
134
- # If `in` argument is given, the result is in that timezone or UTC offset, or if
135
- # a numeric argument is given, the result is in local time.
136
- #
137
- # Time.at(0) #=> 1969-12-31 18:00:00 -0600
138
- # Time.at(Time.at(0)) #=> 1969-12-31 18:00:00 -0600
139
- # Time.at(946702800) #=> 1999-12-31 23:00:00 -0600
140
- # Time.at(-284061600) #=> 1960-12-31 00:00:00 -0600
141
- # Time.at(946684800.2).usec #=> 200000
142
- # Time.at(946684800, 123456.789).nsec #=> 123456789
143
- # Time.at(946684800, 123456789, :nsec).nsec #=> 123456789
144
- #
145
- def self.at: (Time | Numeric seconds) -> Time
146
- | (Numeric seconds, ?Numeric microseconds_with_frac) -> Time
225
+ # <!--
226
+ # rdoc-file=timev.rb
227
+ # - at(time, subsec = false, unit = :microsecond, in: nil)
228
+ # -->
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.
278
+ #
279
+ def self.at: (Time, ?in: String | Integer | nil) -> Time
280
+ | (Numeric, ?in: String | Integer | nil) -> Time
281
+ | (Integer sec_i, Numeric msec, subsec_unit msec, ?in: String | Integer | nil) -> Time
282
+
283
+ type subsec_unit = :msec | :millisecond | :usec | :microsecond | :nsec | :nanosecond
147
284
 
148
285
  # Creates a Time object based on given values, interpreted as UTC (GMT). The
149
286
  # year must be specified. Other values default to the minimum value for that
@@ -159,49 +296,136 @@ class Time < Object
159
296
  #
160
297
  def self.gm: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
161
298
 
162
- # Same as Time::gm, but interprets the values in the local time zone.
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.
306
+ #
307
+ # In the first form (up to seven arguments), argument `year` is required.
308
+ #
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
311
+ #
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.
315
+ #
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
320
+ #
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`.
327
+ #
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`.
163
334
  #
164
- # Time.local(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 -0600
335
+ #
336
+ # Alias: Time.mktime.
337
+ #
338
+ # Related: Time.utc.
165
339
  #
166
340
  def self.local: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
167
341
 
168
- # Creates a new Time object for the current time. This is same as Time.new
169
- # without arguments.
342
+ # <!--
343
+ # rdoc-file=timev.rb
344
+ # - now(in: nil)
345
+ # -->
346
+ # Creates a new Time object from the current system time. This is the same as
347
+ # Time.new without arguments.
348
+ #
349
+ # Time.now # => 2009-06-24 12:39:54 +0900
350
+ # Time.now(in: '+04:00') # => 2009-06-24 07:39:54 +0400
170
351
  #
171
- # Time.now #=> 2009-06-24 12:39:54 +0900
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.
172
360
  #
173
- def self.now: () -> Time
361
+ def self.now: (?in: String | Integer | nil) -> Time
174
362
 
175
- # Creates a Time object based on given values, interpreted as UTC (GMT). The
176
- # year must be specified. Other values default to the minimum value for that
177
- # field (and may be `nil` or omitted). Months may be specified by numbers from 1
178
- # to 12, or by the three-letter English month names. Hours are specified on a
179
- # 24-hour clock (0..23). Raises an ArgumentError if any values are out of range.
180
- # Will also accept ten arguments in the order output by Time#to_a.
363
+ # <!--
364
+ # 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
367
+ # -->
368
+ # Returns a new Time object based the on given arguments; its timezone is UTC.
181
369
  #
182
- # `sec_with_frac` and `usec_with_frac` can have a fractional part.
370
+ # In the first form (up to seven arguments), argument `year` is required.
183
371
  #
184
- # Time.utc(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC
185
- # Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC
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
374
+ #
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.
378
+ #
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
383
+ #
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`.
390
+ #
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`.
397
+ #
398
+ #
399
+ # Alias: Time.gm.
400
+ #
401
+ # Related: Time.local.
186
402
  #
187
403
  def self.utc: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
188
404
 
189
- # Addition --- Adds some number of seconds (possibly fractional) to *time* and
405
+ # <!--
406
+ # rdoc-file=time.c
407
+ # - time + numeric -> time
408
+ # -->
409
+ # Adds some number of seconds (possibly including subsecond) to *time* and
190
410
  # returns that value as a new Time object.
191
411
  #
192
- # t = Time.now #=> 2007-11-19 08:22:21 -0600
193
- # t + (60 * 60 * 24) #=> 2007-11-20 08:22:21 -0600
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
194
414
  #
195
415
  def +: (Numeric arg0) -> Time
196
416
 
197
- # Difference --- Returns a difference in seconds as a Float between *time* and
198
- # `other_time`, or subtracts the given number of seconds in `numeric` from
199
- # *time*.
417
+ # <!--
418
+ # rdoc-file=time.c
419
+ # - time - other_time -> float
420
+ # - time - numeric -> time
421
+ # -->
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*.
200
424
  #
201
- # t = Time.now #=> 2007-11-19 08:23:10 -0600
202
- # t2 = t + 2592000 #=> 2007-12-19 08:23:10 -0600
425
+ # t = Time.now #=> 2020-07-20 22:15:49.302766336 +0900
426
+ # t2 = t + 2592000 #=> 2020-08-19 22:15:49.302766336 +0900
203
427
  # t2 - t #=> 2592000.0
204
- # t2 - 2592000 #=> 2007-11-19 08:23:10 -0600
428
+ # t2 - 2592000 #=> 2020-07-20 22:15:49.302766336 +0900
205
429
  #
206
430
  def -: (Time arg0) -> Float
207
431
  | (Numeric arg0) -> Time
@@ -210,9 +434,13 @@ class Time < Object
210
434
 
211
435
  def <=: (Time arg0) -> bool
212
436
 
213
- # Comparison---Compares `time` with `other_time`.
437
+ # <!--
438
+ # rdoc-file=time.c
439
+ # - time <=> other_time -> -1, 0, +1, or nil
440
+ # -->
441
+ # Compares `time` with `other_time`.
214
442
  #
215
- # -1, 0, +1 or nil depending on whether `time` is less than, equal to, or
443
+ # -1, 0, +1 or nil depending on whether `time` is less than, equal to, or
216
444
  # greater than `other_time`.
217
445
  #
218
446
  # `nil` is returned if the two values are incomparable.
@@ -237,6 +465,7 @@ class Time < Object
237
465
 
238
466
  def >=: (Time arg0) -> bool
239
467
 
468
+ # <!-- rdoc-file=time.c -->
240
469
  # Returns a canonical string representation of *time*.
241
470
  #
242
471
  # Time.now.asctime #=> "Wed Apr 9 08:56:03 2003"
@@ -244,6 +473,11 @@ class Time < Object
244
473
  #
245
474
  def asctime: () -> String
246
475
 
476
+ # <!--
477
+ # rdoc-file=time.c
478
+ # - time.asctime -> string
479
+ # - time.ctime -> string
480
+ # -->
247
481
  # Returns a canonical string representation of *time*.
248
482
  #
249
483
  # Time.now.asctime #=> "Wed Apr 9 08:56:03 2003"
@@ -251,7 +485,8 @@ class Time < Object
251
485
  #
252
486
  def ctime: () -> String
253
487
 
254
- # Returns the day of the month (1..n) for *time*.
488
+ # <!-- rdoc-file=time.c -->
489
+ # Returns the day of the month (1..31) for *time*.
255
490
  #
256
491
  # t = Time.now #=> 2007-11-19 08:27:03 -0600
257
492
  # t.day #=> 19
@@ -259,6 +494,7 @@ class Time < Object
259
494
  #
260
495
  def day: () -> Integer
261
496
 
497
+ # <!-- rdoc-file=time.c -->
262
498
  # Returns `true` if *time* occurs during Daylight Saving Time in its time zone.
263
499
  #
264
500
  # # CST6CDT:
@@ -279,11 +515,19 @@ class Time < Object
279
515
  #
280
516
  def dst?: () -> bool
281
517
 
518
+ # <!--
519
+ # rdoc-file=time.c
520
+ # - time.eql?(other_time)
521
+ # -->
282
522
  # Returns `true` if *time* and `other_time` are both Time objects with the same
283
- # seconds and fractional seconds.
523
+ # seconds (including subsecond) from the Epoch.
284
524
  #
285
525
  def eql?: (untyped arg0) -> bool
286
526
 
527
+ # <!--
528
+ # rdoc-file=time.c
529
+ # - time.friday? -> true or false
530
+ # -->
287
531
  # Returns `true` if *time* represents Friday.
288
532
  #
289
533
  # t = Time.local(1987, 12, 18) #=> 1987-12-18 00:00:00 -0600
@@ -291,6 +535,11 @@ class Time < Object
291
535
  #
292
536
  def friday?: () -> bool
293
537
 
538
+ # <!--
539
+ # rdoc-file=time.c
540
+ # - time.getgm -> new_time
541
+ # - time.getutc -> new_time
542
+ # -->
294
543
  # Returns a new Time object representing *time* in UTC.
295
544
  #
296
545
  # t = Time.local(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 -0600
@@ -301,6 +550,12 @@ class Time < Object
301
550
  #
302
551
  def getgm: () -> Time
303
552
 
553
+ # <!--
554
+ # rdoc-file=time.c
555
+ # - time.getlocal -> new_time
556
+ # - time.getlocal(utc_offset) -> new_time
557
+ # - time.getlocal(timezone) -> new_time
558
+ # -->
304
559
  # Returns a new Time object representing *time* in local time (using the local
305
560
  # time zone in effect for this process).
306
561
  #
@@ -325,6 +580,7 @@ class Time < Object
325
580
  #
326
581
  def getlocal: (?Integer utc_offset) -> Time
327
582
 
583
+ # <!-- rdoc-file=time.c -->
328
584
  # Returns a new Time object representing *time* in UTC.
329
585
  #
330
586
  # t = Time.local(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 -0600
@@ -335,6 +591,7 @@ class Time < Object
335
591
  #
336
592
  def getutc: () -> Time
337
593
 
594
+ # <!-- rdoc-file=time.c -->
338
595
  # Returns `true` if *time* represents a time in UTC (GMT).
339
596
  #
340
597
  # t = Time.now #=> 2007-11-19 08:15:23 -0600
@@ -349,6 +606,7 @@ class Time < Object
349
606
  #
350
607
  def gmt?: () -> bool
351
608
 
609
+ # <!-- rdoc-file=time.c -->
352
610
  # Returns the offset in seconds between the timezone of *time* and UTC.
353
611
  #
354
612
  # t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
@@ -358,6 +616,11 @@ class Time < Object
358
616
  #
359
617
  def gmt_offset: () -> Integer
360
618
 
619
+ # <!--
620
+ # rdoc-file=time.c
621
+ # - time.gmtime -> time
622
+ # - time.utc -> time
623
+ # -->
361
624
  # Converts *time* to UTC (GMT), modifying the receiver.
362
625
  #
363
626
  # t = Time.now #=> 2007-11-19 08:18:31 -0600
@@ -372,12 +635,20 @@ class Time < Object
372
635
  #
373
636
  def gmtime: () -> Time
374
637
 
638
+ # <!--
639
+ # rdoc-file=time.c
640
+ # - time.hash -> integer
641
+ # -->
375
642
  # Returns a hash code for this Time object.
376
643
  #
377
644
  # See also Object#hash.
378
645
  #
379
646
  def hash: () -> Integer
380
647
 
648
+ # <!--
649
+ # rdoc-file=time.c
650
+ # - time.hour -> integer
651
+ # -->
381
652
  # Returns the hour of the day (0..23) for *time*.
382
653
  #
383
654
  # t = Time.now #=> 2007-11-19 08:26:20 -0600
@@ -385,50 +656,54 @@ class Time < Object
385
656
  #
386
657
  def hour: () -> Integer
387
658
 
388
- # Returns a Time object.
659
+ # <!--
660
+ # rdoc-file=timev.rb
661
+ # - new(year = (now = true), mon = nil, mday = nil, hour = nil, min = nil, sec = nil, zone = nil, in: nil)
662
+ # -->
663
+ # Returns a new Time object based on the given arguments.
389
664
  #
390
- # It is initialized to the current system time if no argument is given.
665
+ # With no positional arguments, returns the value of Time.now:
391
666
  #
392
- # **Note:** The new object will use the resolution available on your system
393
- # clock, and may include fractional seconds.
667
+ # Time.new # => 2021-04-24 17:27:46.0512465 -0500
394
668
  #
395
- # If one or more arguments are specified, the time is initialized to the
396
- # specified time.
669
+ # Otherwise, returns a new Time object based on the given parameters:
397
670
  #
398
- # `sec` may have fraction if it is a rational.
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
399
674
  #
400
- # `tz` specifies the timezone. It can be an offset from UTC, given either as a
401
- # string such as "+09:00" or a single letter "A".."Z" excluding "J" (so-called
402
- # military time zone), or as a number of seconds such as 32400. Or it can be a
403
- # timezone object, see [Timezone argument](#class-Time-label-Timezone+argument)
404
- # for details.
675
+ # Parameters:
405
676
  #
406
- # a = Time.new #=> 2007-11-19 07:50:02 -0600
407
- # b = Time.new #=> 2007-11-19 07:50:02 -0600
408
- # a == b #=> false
409
- # "%.6f" % a.to_f #=> "1195480202.282373"
410
- # "%.6f" % b.to_f #=> "1195480202.283415"
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`.
411
682
  #
412
- # Time.new(2008,6,21, 13,30,0, "+09:00") #=> 2008-06-21 13:30:00 +0900
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.
413
695
  #
414
- # # A trip for RubyConf 2007
415
- # t1 = Time.new(2007,11,1,15,25,0, "+09:00") # JST (Narita)
416
- # t2 = Time.new(2007,11,1,12, 5,0, "-05:00") # CDT (Minneapolis)
417
- # t3 = Time.new(2007,11,1,13,25,0, "-05:00") # CDT (Minneapolis)
418
- # t4 = Time.new(2007,11,1,16,53,0, "-04:00") # EDT (Charlotte)
419
- # t5 = Time.new(2007,11,5, 9,24,0, "-05:00") # EST (Charlotte)
420
- # t6 = Time.new(2007,11,5,11,21,0, "-05:00") # EST (Detroit)
421
- # t7 = Time.new(2007,11,5,13,45,0, "-05:00") # EST (Detroit)
422
- # t8 = Time.new(2007,11,6,17,10,0, "+09:00") # JST (Narita)
423
- # (t2-t1)/3600.0 #=> 10.666666666666666
424
- # (t4-t3)/3600.0 #=> 2.466666666666667
425
- # (t6-t5)/3600.0 #=> 1.95
426
- # (t8-t7)/3600.0 #=> 13.416666666666666
696
+ # * `in: zone`: a timezone *zone*, which may be as above.
427
697
  #
428
- def initialize: (?Integer | String year, ?Integer | String month, ?Integer | String day, ?Integer | String hour, ?Integer | String min, ?Numeric | String sec, ?Numeric | String usec_with_frac) -> void
698
+ def initialize: (?Integer? year, ?Integer? month, ?Integer? day, ?Integer? hour, ?Integer? min, ?Numeric? sec, ?String | Integer | nil) -> void
699
+ | (?Integer? year, ?Integer? month, ?Integer? day, ?Integer? hour, ?Integer? min, ?Numeric? sec, in: String | Integer | nil) -> void
429
700
 
701
+ # <!--
702
+ # rdoc-file=time.c
703
+ # - time.inspect -> string
704
+ # -->
430
705
  # Returns a detailed string representing *time*. Unlike to_s, preserves
431
- # nanoseconds in the representation for easier debugging.
706
+ # subsecond in the representation for easier debugging.
432
707
  #
433
708
  # t = Time.now
434
709
  # t.inspect #=> "2012-11-10 18:16:12.261257655 +0100"
@@ -439,6 +714,11 @@ class Time < Object
439
714
  #
440
715
  def inspect: () -> String
441
716
 
717
+ # <!--
718
+ # rdoc-file=time.c
719
+ # - time.isdst -> true or false
720
+ # - time.dst? -> true or false
721
+ # -->
442
722
  # Returns `true` if *time* occurs during Daylight Saving Time in its time zone.
443
723
  #
444
724
  # # CST6CDT:
@@ -459,6 +739,11 @@ class Time < Object
459
739
  #
460
740
  def isdst: () -> bool
461
741
 
742
+ # <!--
743
+ # rdoc-file=time.c
744
+ # - time.localtime -> time
745
+ # - time.localtime(utc_offset) -> time
746
+ # -->
462
747
  # Converts *time* to local time (using the local time zone in effect at the
463
748
  # creation time of *time*) modifying the receiver.
464
749
  #
@@ -478,7 +763,12 @@ class Time < Object
478
763
  #
479
764
  def localtime: (?String utc_offset) -> Time
480
765
 
481
- # Returns the day of the month (1..n) for *time*.
766
+ # <!--
767
+ # rdoc-file=time.c
768
+ # - time.day -> integer
769
+ # - time.mday -> integer
770
+ # -->
771
+ # Returns the day of the month (1..31) for *time*.
482
772
  #
483
773
  # t = Time.now #=> 2007-11-19 08:27:03 -0600
484
774
  # t.day #=> 19
@@ -486,6 +776,10 @@ class Time < Object
486
776
  #
487
777
  def mday: () -> Integer
488
778
 
779
+ # <!--
780
+ # rdoc-file=time.c
781
+ # - time.min -> integer
782
+ # -->
489
783
  # Returns the minute of the hour (0..59) for *time*.
490
784
  #
491
785
  # t = Time.now #=> 2007-11-19 08:25:51 -0600
@@ -493,6 +787,11 @@ class Time < Object
493
787
  #
494
788
  def min: () -> Integer
495
789
 
790
+ # <!--
791
+ # rdoc-file=time.c
792
+ # - time.mon -> integer
793
+ # - time.month -> integer
794
+ # -->
496
795
  # Returns the month of the year (1..12) for *time*.
497
796
  #
498
797
  # t = Time.now #=> 2007-11-19 08:27:30 -0600
@@ -501,6 +800,10 @@ class Time < Object
501
800
  #
502
801
  def mon: () -> Integer
503
802
 
803
+ # <!--
804
+ # rdoc-file=time.c
805
+ # - time.monday? -> true or false
806
+ # -->
504
807
  # Returns `true` if *time* represents Monday.
505
808
  #
506
809
  # t = Time.local(2003, 8, 4) #=> 2003-08-04 00:00:00 -0500
@@ -508,48 +811,55 @@ class Time < Object
508
811
  #
509
812
  def monday?: () -> bool
510
813
 
511
- # Returns the number of nanoseconds for *time*.
814
+ # <!-- 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.
512
817
  #
513
- # t = Time.now #=> 2007-11-17 15:18:03 +0900
514
- # "%10.9f" % t.to_f #=> "1195280283.536151409"
515
- # t.nsec #=> 536151406
818
+ # t = Time.now #=> 2020-07-20 22:07:10.963933942 +0900
819
+ # t.nsec #=> 963933942
516
820
  #
517
- # The lowest digits of #to_f and #nsec are different because IEEE 754 double is
518
- # not accurate enough to represent the exact number of nanoseconds since the
519
- # Epoch.
821
+ # If *time* has fraction of nanosecond (such as picoseconds), it is truncated.
520
822
  #
521
- # The more accurate value is returned by #nsec.
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.
522
827
  #
523
828
  def nsec: () -> Integer
524
829
 
525
- # Rounds sub seconds to a given precision in decimal digits (0 digits by
526
- # default). It returns a new Time object. `ndigits` should be zero or a positive
527
- # integer.
528
- #
529
- # require 'time'
830
+ # <!--
831
+ # rdoc-file=time.c
832
+ # - time.round([ndigits]) -> new_time
833
+ # -->
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.
530
836
  #
531
837
  # t = Time.utc(2010,3,30, 5,43,25.123456789r)
532
- # t.iso8601(10) #=> "2010-03-30T05:43:25.1234567890Z"
533
- # t.round.iso8601(10) #=> "2010-03-30T05:43:25.0000000000Z"
534
- # t.round(0).iso8601(10) #=> "2010-03-30T05:43:25.0000000000Z"
535
- # t.round(1).iso8601(10) #=> "2010-03-30T05:43:25.1000000000Z"
536
- # t.round(2).iso8601(10) #=> "2010-03-30T05:43:25.1200000000Z"
537
- # t.round(3).iso8601(10) #=> "2010-03-30T05:43:25.1230000000Z"
538
- # t.round(4).iso8601(10) #=> "2010-03-30T05:43:25.1235000000Z"
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
539
845
  #
540
846
  # t = Time.utc(1999,12,31, 23,59,59)
541
- # (t + 0.4).round.iso8601(3) #=> "1999-12-31T23:59:59.000Z"
542
- # (t + 0.49).round.iso8601(3) #=> "1999-12-31T23:59:59.000Z"
543
- # (t + 0.5).round.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
544
- # (t + 1.4).round.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
545
- # (t + 1.49).round.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
546
- # (t + 1.5).round.iso8601(3) #=> "2000-01-01T00:00:01.000Z"
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
547
853
  #
548
- # t = Time.utc(1999,12,31, 23,59,59)
549
- # (t + 0.123456789).round(4).iso8601(6) #=> "1999-12-31T23:59:59.123500Z"
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
550
856
  #
551
857
  def round: (?Integer arg0) -> Time
552
858
 
859
+ # <!--
860
+ # rdoc-file=time.c
861
+ # - time.saturday? -> true or false
862
+ # -->
553
863
  # Returns `true` if *time* represents Saturday.
554
864
  #
555
865
  # t = Time.local(2006, 6, 10) #=> 2006-06-10 00:00:00 -0500
@@ -557,16 +867,24 @@ class Time < Object
557
867
  #
558
868
  def saturday?: () -> bool
559
869
 
870
+ # <!--
871
+ # rdoc-file=time.c
872
+ # - time.sec -> integer
873
+ # -->
560
874
  # Returns the second of the minute (0..60) for *time*.
561
875
  #
562
876
  # **Note:** Seconds range from zero to 60 to allow the system to inject leap
563
- # seconds. See http://en.wikipedia.org/wiki/Leap_second for further details.
877
+ # seconds. See https://en.wikipedia.org/wiki/Leap_second for further details.
564
878
  #
565
879
  # t = Time.now #=> 2007-11-19 08:25:02 -0600
566
880
  # t.sec #=> 2
567
881
  #
568
882
  def sec: () -> Integer
569
883
 
884
+ # <!--
885
+ # rdoc-file=time.c
886
+ # - time.strftime( string ) -> string
887
+ # -->
570
888
  # Formats *time* according to the directives in the given format string.
571
889
  #
572
890
  # The directives begin with a percent (%) character. Any text not listed as a
@@ -743,21 +1061,31 @@ class Time < Object
743
1061
  #
744
1062
  def strftime: (String arg0) -> String
745
1063
 
746
- # Returns the fraction for *time*.
1064
+ # <!--
1065
+ # rdoc-file=time.c
1066
+ # - time.subsec -> number
1067
+ # -->
1068
+ # Returns the subsecond for *time*.
747
1069
  #
748
1070
  # The return value can be a rational number.
749
1071
  #
750
- # t = Time.now #=> 2009-03-26 22:33:12 +0900
751
- # "%10.9f" % t.to_f #=> "1238074392.940563917"
752
- # t.subsec #=> (94056401/100000000)
1072
+ # t = Time.now #=> 2020-07-20 15:40:26.867462289 +0900
1073
+ # t.subsec #=> (867462289/1000000000)
753
1074
  #
754
- # The lowest digits of #to_f and #subsec are different because IEEE 754 double
755
- # is not accurate enough to represent the rational number.
1075
+ # t = Time.now #=> 2020-07-20 15:40:50.313828595 +0900
1076
+ # t.subsec #=> (62765719/200000000)
756
1077
  #
757
- # The more accurate value is returned by #subsec.
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)
758
1082
  #
759
1083
  def subsec: () -> Numeric
760
1084
 
1085
+ # <!--
1086
+ # rdoc-file=time.c
1087
+ # - time.sunday? -> true or false
1088
+ # -->
761
1089
  # Returns `true` if *time* represents Sunday.
762
1090
  #
763
1091
  # t = Time.local(1990, 4, 1) #=> 1990-04-01 00:00:00 -0600
@@ -765,6 +1093,10 @@ class Time < Object
765
1093
  #
766
1094
  def sunday?: () -> bool
767
1095
 
1096
+ # <!--
1097
+ # rdoc-file=time.c
1098
+ # - time.thursday? -> true or false
1099
+ # -->
768
1100
  # Returns `true` if *time* represents Thursday.
769
1101
  #
770
1102
  # t = Time.local(1995, 12, 21) #=> 1995-12-21 00:00:00 -0600
@@ -772,12 +1104,16 @@ class Time < Object
772
1104
  #
773
1105
  def thursday?: () -> bool
774
1106
 
1107
+ # <!--
1108
+ # rdoc-file=time.c
1109
+ # - time.to_a -> array
1110
+ # -->
775
1111
  # Returns a ten-element *array* of values for *time*:
776
1112
  #
777
1113
  # [sec, min, hour, day, month, year, wday, yday, isdst, zone]
778
1114
  #
779
1115
  # See the individual methods for an explanation of the valid ranges of each
780
- # value. The ten elements can be passed directly to Time::utc or Time::local to
1116
+ # value. The ten elements can be passed directly to Time.utc or Time.local to
781
1117
  # create a new Time object.
782
1118
  #
783
1119
  # t = Time.now #=> 2007-11-19 08:36:01 -0600
@@ -785,37 +1121,59 @@ class Time < Object
785
1121
  #
786
1122
  def to_a: () -> [ Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, bool, String ]
787
1123
 
1124
+ # <!--
1125
+ # rdoc-file=time.c
1126
+ # - time.to_f -> float
1127
+ # -->
788
1128
  # Returns the value of *time* as a floating point number of seconds since the
789
- # Epoch.
1129
+ # Epoch. The return value approximate the exact value in the Time object because
1130
+ # floating point numbers cannot represent all rational numbers exactly.
790
1131
  #
791
- # t = Time.now
792
- # "%10.5f" % t.to_f #=> "1270968744.77658"
793
- # t.to_i #=> 1270968744
1132
+ # t = Time.now #=> 2020-07-20 22:00:29.38740268 +0900
1133
+ # t.to_f #=> 1595250029.3874028
1134
+ # t.to_i #=> 1595250029
794
1135
  #
795
1136
  # Note that IEEE 754 double is not accurate enough to represent the exact number
796
- # of nanoseconds since the Epoch.
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`.
797
1142
  #
798
1143
  def to_f: () -> Float
799
1144
 
1145
+ # <!--
1146
+ # rdoc-file=time.c
1147
+ # - time.to_i -> int
1148
+ # - time.tv_sec -> int
1149
+ # -->
800
1150
  # Returns the value of *time* as an integer number of seconds since the Epoch.
801
1151
  #
802
- # t = Time.now
803
- # "%10.5f" % t.to_f #=> "1270968656.89607"
804
- # t.to_i #=> 1270968656
1152
+ # If *time* contains subsecond, they are truncated.
1153
+ #
1154
+ # t = Time.now #=> 2020-07-21 01:41:29.746012609 +0900
1155
+ # t.to_i #=> 1595263289
805
1156
  #
806
1157
  def to_i: () -> Integer
807
1158
 
1159
+ # <!--
1160
+ # rdoc-file=time.c
1161
+ # - time.to_r -> a_rational
1162
+ # -->
808
1163
  # Returns the value of *time* as a rational number of seconds since the Epoch.
809
1164
  #
810
- # t = Time.now
811
- # t.to_r #=> (1270968792716287611/1000000000)
1165
+ # t = Time.now #=> 2020-07-20 22:03:45.212167333 +0900
1166
+ # t.to_r #=> (1595250225212167333/1000000000)
812
1167
  #
813
- # This methods is intended to be used to get an accurate value representing the
814
- # nanoseconds since the Epoch. You can use this method to convert *time* to
815
- # another Epoch.
1168
+ # This method is intended to be used to get an accurate value representing the
1169
+ # seconds (including subsecond) since the Epoch.
816
1170
  #
817
1171
  def to_r: () -> Rational
818
1172
 
1173
+ # <!--
1174
+ # rdoc-file=time.c
1175
+ # - time.to_s -> string
1176
+ # -->
819
1177
  # Returns a string representing *time*. Equivalent to calling #strftime with the
820
1178
  # appropriate format string.
821
1179
  #
@@ -828,6 +1186,10 @@ class Time < Object
828
1186
  #
829
1187
  def to_s: () -> String
830
1188
 
1189
+ # <!--
1190
+ # rdoc-file=time.c
1191
+ # - time.tuesday? -> true or false
1192
+ # -->
831
1193
  # Returns `true` if *time* represents Tuesday.
832
1194
  #
833
1195
  # t = Time.local(1991, 2, 19) #=> 1991-02-19 00:00:00 -0600
@@ -835,44 +1197,73 @@ class Time < Object
835
1197
  #
836
1198
  def tuesday?: () -> bool
837
1199
 
838
- # Returns the number of nanoseconds for *time*.
1200
+ # <!--
1201
+ # rdoc-file=time.c
1202
+ # - time.nsec -> int
1203
+ # - time.tv_nsec -> int
1204
+ # -->
1205
+ # Returns the number of nanoseconds for the subsecond part of *time*. The result
1206
+ # is a non-negative integer less than 10**9.
839
1207
  #
840
- # t = Time.now #=> 2007-11-17 15:18:03 +0900
841
- # "%10.9f" % t.to_f #=> "1195280283.536151409"
842
- # t.nsec #=> 536151406
1208
+ # t = Time.now #=> 2020-07-20 22:07:10.963933942 +0900
1209
+ # t.nsec #=> 963933942
843
1210
  #
844
- # The lowest digits of #to_f and #nsec are different because IEEE 754 double is
845
- # not accurate enough to represent the exact number of nanoseconds since the
846
- # Epoch.
1211
+ # If *time* has fraction of nanosecond (such as picoseconds), it is truncated.
847
1212
  #
848
- # The more accurate value is returned by #nsec.
1213
+ # t = Time.new(2000,1,1,0,0,0.666_777_888_999r)
1214
+ # t.nsec #=> 666777888
1215
+ #
1216
+ # Time#subsec can be used to obtain the subsecond part exactly.
849
1217
  #
850
1218
  def tv_nsec: () -> Numeric
851
1219
 
1220
+ # <!-- rdoc-file=time.c -->
852
1221
  # Returns the value of *time* as an integer number of seconds since the Epoch.
853
1222
  #
854
- # t = Time.now
855
- # "%10.5f" % t.to_f #=> "1270968656.89607"
856
- # t.to_i #=> 1270968656
1223
+ # If *time* contains subsecond, they are truncated.
1224
+ #
1225
+ # t = Time.now #=> 2020-07-21 01:41:29.746012609 +0900
1226
+ # t.to_i #=> 1595263289
857
1227
  #
858
1228
  def tv_sec: () -> Numeric
859
1229
 
860
- # Returns the number of microseconds for *time*.
1230
+ # <!--
1231
+ # rdoc-file=time.c
1232
+ # - time.usec -> int
1233
+ # - time.tv_usec -> int
1234
+ # -->
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
1240
+ #
1241
+ # If *time* has fraction of microsecond (such as nanoseconds), it is truncated.
861
1242
  #
862
- # t = Time.now #=> 2007-11-19 08:03:26 -0600
863
- # "%10.6f" % t.to_f #=> "1195481006.775195"
864
- # t.usec #=> 775195
1243
+ # t = Time.new(2000,1,1,0,0,0.666_777_888_999r)
1244
+ # t.usec #=> 666777
1245
+ #
1246
+ # Time#subsec can be used to obtain the subsecond part exactly.
865
1247
  #
866
1248
  def tv_usec: () -> Numeric
867
1249
 
868
- # Returns the number of microseconds for *time*.
1250
+ # <!-- 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
869
1256
  #
870
- # t = Time.now #=> 2007-11-19 08:03:26 -0600
871
- # "%10.6f" % t.to_f #=> "1195481006.775195"
872
- # t.usec #=> 775195
1257
+ # If *time* has fraction of microsecond (such as nanoseconds), it is truncated.
1258
+ #
1259
+ # t = Time.new(2000,1,1,0,0,0.666_777_888_999r)
1260
+ # t.usec #=> 666777
1261
+ #
1262
+ # Time#subsec can be used to obtain the subsecond part exactly.
873
1263
  #
874
1264
  def usec: () -> Numeric
875
1265
 
1266
+ # <!-- rdoc-file=time.c -->
876
1267
  # Converts *time* to UTC (GMT), modifying the receiver.
877
1268
  #
878
1269
  # t = Time.now #=> 2007-11-19 08:18:31 -0600
@@ -887,6 +1278,11 @@ class Time < Object
887
1278
  #
888
1279
  def utc: () -> Time
889
1280
 
1281
+ # <!--
1282
+ # rdoc-file=time.c
1283
+ # - time.utc? -> true or false
1284
+ # - time.gmt? -> true or false
1285
+ # -->
890
1286
  # Returns `true` if *time* represents a time in UTC (GMT).
891
1287
  #
892
1288
  # t = Time.now #=> 2007-11-19 08:15:23 -0600
@@ -901,6 +1297,7 @@ class Time < Object
901
1297
  #
902
1298
  def utc?: () -> bool
903
1299
 
1300
+ # <!-- rdoc-file=time.c -->
904
1301
  # Returns the offset in seconds between the timezone of *time* and UTC.
905
1302
  #
906
1303
  # t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
@@ -910,6 +1307,10 @@ class Time < Object
910
1307
  #
911
1308
  def utc_offset: () -> Integer
912
1309
 
1310
+ # <!--
1311
+ # rdoc-file=time.c
1312
+ # - time.wday -> integer
1313
+ # -->
913
1314
  # Returns an integer representing the day of the week, 0..6, with Sunday == 0.
914
1315
  #
915
1316
  # t = Time.now #=> 2007-11-20 02:35:35 -0600
@@ -924,6 +1325,10 @@ class Time < Object
924
1325
  #
925
1326
  def wday: () -> Integer
926
1327
 
1328
+ # <!--
1329
+ # rdoc-file=time.c
1330
+ # - time.wednesday? -> true or false
1331
+ # -->
927
1332
  # Returns `true` if *time* represents Wednesday.
928
1333
  #
929
1334
  # t = Time.local(1993, 2, 24) #=> 1993-02-24 00:00:00 -0600
@@ -931,6 +1336,10 @@ class Time < Object
931
1336
  #
932
1337
  def wednesday?: () -> bool
933
1338
 
1339
+ # <!--
1340
+ # rdoc-file=time.c
1341
+ # - time.yday -> integer
1342
+ # -->
934
1343
  # Returns an integer representing the day of the year, 1..366.
935
1344
  #
936
1345
  # t = Time.now #=> 2007-11-19 08:32:31 -0600
@@ -938,6 +1347,10 @@ class Time < Object
938
1347
  #
939
1348
  def yday: () -> Integer
940
1349
 
1350
+ # <!--
1351
+ # rdoc-file=time.c
1352
+ # - time.year -> integer
1353
+ # -->
941
1354
  # Returns the year for *time* (including the century).
942
1355
  #
943
1356
  # t = Time.now #=> 2007-11-19 08:27:51 -0600
@@ -945,6 +1358,10 @@ class Time < Object
945
1358
  #
946
1359
  def year: () -> Integer
947
1360
 
1361
+ # <!--
1362
+ # rdoc-file=time.c
1363
+ # - time.zone -> string or timezone
1364
+ # -->
948
1365
  # Returns the name of the time zone used for *time*. As of Ruby 1.8, returns
949
1366
  # ``UTC'' rather than ``GMT'' for UTC times.
950
1367
  #
@@ -961,6 +1378,12 @@ class Time < Object
961
1378
  #
962
1379
  def self.mktime: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
963
1380
 
1381
+ # <!--
1382
+ # rdoc-file=time.c
1383
+ # - time.gmt_offset -> integer
1384
+ # - time.gmtoff -> integer
1385
+ # - time.utc_offset -> integer
1386
+ # -->
964
1387
  # Returns the offset in seconds between the timezone of *time* and UTC.
965
1388
  #
966
1389
  # t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
@@ -970,6 +1393,7 @@ class Time < Object
970
1393
  #
971
1394
  def gmtoff: () -> Integer
972
1395
 
1396
+ # <!-- rdoc-file=time.c -->
973
1397
  # Returns the month of the year (1..12) for *time*.
974
1398
  #
975
1399
  # t = Time.now #=> 2007-11-19 08:27:30 -0600
@@ -978,55 +1402,57 @@ class Time < Object
978
1402
  #
979
1403
  def month: () -> Integer
980
1404
 
981
- # Floors sub seconds to a given precision in decimal digits (0 digits by
982
- # default). It returns a new Time object. `ndigits` should be zero or a positive
983
- # integer.
984
- #
985
- # require 'time'
1405
+ # <!--
1406
+ # rdoc-file=time.c
1407
+ # - time.floor([ndigits]) -> new_time
1408
+ # -->
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.
986
1411
  #
987
1412
  # t = Time.utc(2010,3,30, 5,43,25.123456789r)
988
- # t.iso8601(10) #=> "2010-03-30T05:43:25.1234567890Z"
989
- # t.floor.iso8601(10) #=> "2010-03-30T05:43:25.0000000000Z"
990
- # t.floor(0).iso8601(10) #=> "2010-03-30T05:43:25.0000000000Z"
991
- # t.floor(1).iso8601(10) #=> "2010-03-30T05:43:25.1000000000Z"
992
- # t.floor(2).iso8601(10) #=> "2010-03-30T05:43:25.1200000000Z"
993
- # t.floor(3).iso8601(10) #=> "2010-03-30T05:43:25.1230000000Z"
994
- # t.floor(4).iso8601(10) #=> "2010-03-30T05:43:25.1234000000Z"
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
995
1420
  #
996
1421
  # t = Time.utc(1999,12,31, 23,59,59)
997
- # (t + 0.4).floor.iso8601(3) #=> "1999-12-31T23:59:59.000Z"
998
- # (t + 0.9).floor.iso8601(3) #=> "1999-12-31T23:59:59.000Z"
999
- # (t + 1.4).floor.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
1000
- # (t + 1.9).floor.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
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
1001
1426
  #
1002
1427
  # t = Time.utc(1999,12,31, 23,59,59)
1003
- # (t + 0.123456789).floor(4).iso8601(6) #=> "1999-12-31T23:59:59.123400Z"
1428
+ # (t + 0.123456789).floor(4) #=> 1999-12-31 23:59:59.1234 UTC
1004
1429
  #
1005
1430
  def floor: (?Integer ndigits) -> Time
1006
1431
 
1007
- # Ceils sub seconds to a given precision in decimal digits (0 digits by
1008
- # default). It returns a new Time object. `ndigits` should be zero or a positive
1009
- # integer.
1010
- #
1011
- # require 'time'
1432
+ # <!--
1433
+ # rdoc-file=time.c
1434
+ # - time.ceil([ndigits]) -> new_time
1435
+ # -->
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.
1012
1438
  #
1013
1439
  # t = Time.utc(2010,3,30, 5,43,25.0123456789r)
1014
- # t.iso8601(10) #=> "2010-03-30T05:43:25.0123456789Z"
1015
- # t.ceil.iso8601(10) #=> "2010-03-30T05:43:26.0000000000Z"
1016
- # t.ceil(0).iso8601(10) #=> "2010-03-30T05:43:26.0000000000Z"
1017
- # t.ceil(1).iso8601(10) #=> "2010-03-30T05:43:25.1000000000Z"
1018
- # t.ceil(2).iso8601(10) #=> "2010-03-30T05:43:25.0200000000Z"
1019
- # t.ceil(3).iso8601(10) #=> "2010-03-30T05:43:25.0130000000Z"
1020
- # t.ceil(4).iso8601(10) #=> "2010-03-30T05:43:25.0124000000Z"
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
1021
1447
  #
1022
1448
  # t = Time.utc(1999,12,31, 23,59,59)
1023
- # (t + 0.4).ceil.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
1024
- # (t + 0.9).ceil.iso8601(3) #=> "2000-01-01T00:00:00.000Z"
1025
- # (t + 1.4).ceil.iso8601(3) #=> "2000-01-01T00:00:01.000Z"
1026
- # (t + 1.9).ceil.iso8601(3) #=> "2000-01-01T00:00:01.000Z"
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
1027
1453
  #
1028
1454
  # t = Time.utc(1999,12,31, 23,59,59)
1029
- # (t + 0.123456789).ceil(4).iso8601(6) #=> "1999-12-31T23:59:59.123500Z"
1455
+ # (t + 0.123456789).ceil(4) #=> 1999-12-31 23:59:59.1235 UTC
1030
1456
  #
1031
1457
  def ceil: (?Integer ndigits) -> Time
1032
1458
  end