steep 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (299) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +27 -0
  3. data/.gitmodules +3 -0
  4. data/CHANGELOG.md +5 -0
  5. data/README.md +48 -90
  6. data/Rakefile +10 -6
  7. data/Steepfile +1 -0
  8. data/bin/setup +1 -0
  9. data/bin/smoke_runner.rb +9 -14
  10. data/exe/rbs +3 -0
  11. data/exe/ruby-signature +3 -0
  12. data/exe/steep +1 -0
  13. data/lib/steep.rb +32 -26
  14. data/lib/steep/annotation_parser.rb +167 -0
  15. data/lib/steep/ast/annotation/collection.rb +7 -7
  16. data/lib/steep/ast/types.rb +60 -0
  17. data/lib/steep/ast/types/any.rb +1 -1
  18. data/lib/steep/ast/types/factory.rb +535 -0
  19. data/lib/steep/ast/types/name.rb +3 -3
  20. data/lib/steep/ast/types/var.rb +1 -1
  21. data/lib/steep/cli.rb +56 -240
  22. data/lib/steep/drivers/annotations.rb +36 -19
  23. data/lib/steep/drivers/check.rb +55 -91
  24. data/lib/steep/drivers/init.rb +54 -0
  25. data/lib/steep/drivers/langserver.rb +241 -150
  26. data/lib/steep/drivers/print_project.rb +56 -0
  27. data/lib/steep/drivers/signature_error_printer.rb +25 -0
  28. data/lib/steep/drivers/trace_printer.rb +25 -0
  29. data/lib/steep/drivers/utils/driver_helper.rb +26 -0
  30. data/lib/steep/drivers/validate.rb +18 -38
  31. data/lib/steep/drivers/vendor.rb +46 -0
  32. data/lib/steep/drivers/watch.rb +78 -140
  33. data/lib/steep/errors.rb +22 -13
  34. data/lib/steep/interface/interface.rb +91 -0
  35. data/lib/steep/interface/method.rb +0 -4
  36. data/lib/steep/interface/method_type.rb +362 -2
  37. data/lib/steep/interface/substitution.rb +22 -0
  38. data/lib/steep/project.rb +25 -233
  39. data/lib/steep/project/dsl.rb +132 -0
  40. data/lib/steep/project/file.rb +93 -76
  41. data/lib/steep/project/file_loader.rb +63 -0
  42. data/lib/steep/project/options.rb +7 -0
  43. data/lib/steep/project/target.rb +190 -0
  44. data/lib/steep/signature/errors.rb +25 -77
  45. data/lib/steep/signature/validator.rb +122 -0
  46. data/lib/steep/source.rb +12 -7
  47. data/lib/steep/subtyping/check.rb +357 -633
  48. data/lib/steep/subtyping/constraints.rb +2 -2
  49. data/lib/steep/subtyping/trace.rb +23 -0
  50. data/lib/steep/type_construction.rb +509 -455
  51. data/lib/steep/type_inference/constant_env.rb +16 -24
  52. data/lib/steep/type_inference/type_env.rb +26 -18
  53. data/lib/steep/version.rb +1 -1
  54. data/sample/Steepfile +6 -0
  55. data/sample/lib/conference.rb +12 -0
  56. data/sample/sig/conference.rbs +6 -0
  57. data/smoke/alias/Steepfile +4 -0
  58. data/smoke/alias/a.rb +2 -2
  59. data/smoke/alias/{a.rbi → a.rbs} +1 -1
  60. data/smoke/and/Steepfile +4 -0
  61. data/smoke/array/Steepfile +4 -0
  62. data/smoke/array/a.rb +2 -2
  63. data/smoke/array/b.rb +4 -4
  64. data/smoke/array/c.rb +2 -2
  65. data/smoke/block/Steepfile +5 -0
  66. data/smoke/block/{a.rbi → a.rbs} +1 -1
  67. data/smoke/block/{c.rbi → c.rbs} +0 -0
  68. data/smoke/block/d.rb +6 -6
  69. data/smoke/case/Steepfile +4 -0
  70. data/smoke/case/a.rb +4 -3
  71. data/smoke/class/Steepfile +4 -0
  72. data/smoke/class/a.rb +1 -4
  73. data/smoke/class/a.rbs +24 -0
  74. data/smoke/class/h.rb +6 -2
  75. data/smoke/class/{h.rbi → h.rbs} +1 -2
  76. data/smoke/class/i.rb +1 -2
  77. data/smoke/class/i.rbs +9 -0
  78. data/smoke/const/Steepfile +4 -0
  79. data/smoke/dstr/Steepfile +4 -0
  80. data/smoke/ensure/Steepfile +4 -0
  81. data/smoke/ensure/a.rb +1 -1
  82. data/smoke/enumerator/Steepfile +4 -0
  83. data/smoke/enumerator/a.rb +7 -7
  84. data/smoke/enumerator/b.rb +6 -6
  85. data/smoke/extension/Steepfile +4 -0
  86. data/smoke/extension/{a.rbi → a.rbs} +2 -2
  87. data/smoke/extension/{e.rbi → e.rbs} +2 -2
  88. data/smoke/hash/Steepfile +4 -0
  89. data/smoke/hash/{a.rbi → a.rbs} +0 -0
  90. data/smoke/hash/b.rb +2 -2
  91. data/smoke/hash/c.rb +1 -1
  92. data/smoke/hash/e.rbs +3 -0
  93. data/smoke/hash/f.rb +1 -1
  94. data/smoke/hello/Steepfile +4 -0
  95. data/smoke/hello/hello.rbs +7 -0
  96. data/smoke/if/Steepfile +4 -0
  97. data/smoke/implements/Steepfile +4 -0
  98. data/smoke/implements/a.rbs +6 -0
  99. data/smoke/initialize/Steepfile +4 -0
  100. data/smoke/initialize/a.rbs +3 -0
  101. data/smoke/integer/Steepfile +4 -0
  102. data/smoke/integer/a.rb +5 -3
  103. data/smoke/interface/Steepfile +4 -0
  104. data/smoke/interface/{a.rbi → a.rbs} +0 -0
  105. data/smoke/kwbegin/Steepfile +4 -0
  106. data/smoke/lambda/Steepfile +4 -0
  107. data/smoke/lambda/a.rb +9 -2
  108. data/smoke/literal/Steepfile +4 -0
  109. data/smoke/literal/{literal_methods.rbi → literal_methods.rbs} +0 -0
  110. data/smoke/map/Steepfile +4 -0
  111. data/smoke/map/a.rb +1 -1
  112. data/smoke/method/Steepfile +4 -0
  113. data/smoke/method/{a.rbi → a.rbs} +0 -0
  114. data/smoke/method/b.rb +1 -4
  115. data/smoke/method/d.rb +1 -0
  116. data/smoke/method/d.rbs +3 -0
  117. data/smoke/module/Steepfile +4 -0
  118. data/smoke/module/a.rb +1 -1
  119. data/smoke/module/a.rbs +16 -0
  120. data/smoke/module/c.rb +1 -1
  121. data/smoke/regexp/Steepfile +4 -0
  122. data/smoke/regexp/a.rb +2 -2
  123. data/smoke/regexp/b.rb +16 -16
  124. data/smoke/regression/Steepfile +5 -0
  125. data/smoke/regression/array.rb +2 -2
  126. data/smoke/regression/hash.rb +2 -2
  127. data/smoke/regression/poly_new.rb +2 -0
  128. data/smoke/regression/poly_new.rbs +4 -0
  129. data/smoke/regression/set_divide.rb +2 -2
  130. data/smoke/rescue/Steepfile +4 -0
  131. data/smoke/rescue/a.rb +1 -1
  132. data/smoke/self/Steepfile +4 -0
  133. data/smoke/self/a.rbs +4 -0
  134. data/smoke/skip/Steepfile +4 -0
  135. data/smoke/stdout/Steepfile +4 -0
  136. data/smoke/stdout/{a.rbi → a.rbs} +1 -1
  137. data/smoke/super/Steepfile +4 -0
  138. data/smoke/super/a.rbs +10 -0
  139. data/smoke/type_case/Steepfile +4 -0
  140. data/smoke/type_case/a.rb +1 -1
  141. data/smoke/yield/Steepfile +4 -0
  142. data/smoke/yield/a.rb +2 -2
  143. data/steep.gemspec +14 -7
  144. data/vendor/ruby-signature/.github/workflows/ruby.yml +27 -0
  145. data/vendor/ruby-signature/.gitignore +12 -0
  146. data/vendor/ruby-signature/.rubocop.yml +15 -0
  147. data/vendor/ruby-signature/BSDL +22 -0
  148. data/vendor/ruby-signature/COPYING +56 -0
  149. data/vendor/ruby-signature/Gemfile +6 -0
  150. data/vendor/ruby-signature/README.md +93 -0
  151. data/vendor/ruby-signature/Rakefile +66 -0
  152. data/vendor/ruby-signature/bin/annotate-with-rdoc +156 -0
  153. data/vendor/ruby-signature/bin/console +14 -0
  154. data/vendor/ruby-signature/bin/query-rdoc +103 -0
  155. data/vendor/ruby-signature/bin/setup +10 -0
  156. data/vendor/ruby-signature/bin/sort +88 -0
  157. data/vendor/ruby-signature/bin/test_runner.rb +17 -0
  158. data/vendor/ruby-signature/docs/CONTRIBUTING.md +97 -0
  159. data/vendor/ruby-signature/docs/sigs.md +148 -0
  160. data/vendor/ruby-signature/docs/stdlib.md +152 -0
  161. data/vendor/ruby-signature/docs/syntax.md +528 -0
  162. data/vendor/ruby-signature/exe/rbs +3 -0
  163. data/vendor/ruby-signature/exe/ruby-signature +7 -0
  164. data/vendor/ruby-signature/lib/ruby/signature.rb +64 -0
  165. data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +29 -0
  166. data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +29 -0
  167. data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +391 -0
  168. data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +364 -0
  169. data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +52 -0
  170. data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +54 -0
  171. data/vendor/ruby-signature/lib/ruby/signature/cli.rb +534 -0
  172. data/vendor/ruby-signature/lib/ruby/signature/constant.rb +28 -0
  173. data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +152 -0
  174. data/vendor/ruby-signature/lib/ruby/signature/definition.rb +172 -0
  175. data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +921 -0
  176. data/vendor/ruby-signature/lib/ruby/signature/environment.rb +283 -0
  177. data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +138 -0
  178. data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +126 -0
  179. data/vendor/ruby-signature/lib/ruby/signature/errors.rb +189 -0
  180. data/vendor/ruby-signature/lib/ruby/signature/location.rb +104 -0
  181. data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +125 -0
  182. data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +93 -0
  183. data/vendor/ruby-signature/lib/ruby/signature/parser.y +1343 -0
  184. data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +441 -0
  185. data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +579 -0
  186. data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +383 -0
  187. data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +48 -0
  188. data/vendor/ruby-signature/lib/ruby/signature/test.rb +28 -0
  189. data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +63 -0
  190. data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +290 -0
  191. data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +58 -0
  192. data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +324 -0
  193. data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +185 -0
  194. data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +256 -0
  195. data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +72 -0
  196. data/vendor/ruby-signature/lib/ruby/signature/types.rb +932 -0
  197. data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +140 -0
  198. data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +49 -0
  199. data/vendor/ruby-signature/lib/ruby/signature/version.rb +5 -0
  200. data/vendor/ruby-signature/lib/ruby/signature/writer.rb +271 -0
  201. data/vendor/ruby-signature/ruby-signature.gemspec +45 -0
  202. data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +3 -0
  203. data/vendor/ruby-signature/stdlib/base64/base64.rbs +15 -0
  204. data/vendor/ruby-signature/stdlib/builtin/array.rbs +1997 -0
  205. data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +280 -0
  206. data/vendor/ruby-signature/stdlib/builtin/binding.rbs +177 -0
  207. data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +35 -0
  208. data/vendor/ruby-signature/stdlib/builtin/class.rbs +145 -0
  209. data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +116 -0
  210. data/vendor/ruby-signature/stdlib/builtin/complex.rbs +400 -0
  211. data/vendor/ruby-signature/stdlib/builtin/constants.rbs +37 -0
  212. data/vendor/ruby-signature/stdlib/builtin/data.rbs +5 -0
  213. data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +2 -0
  214. data/vendor/ruby-signature/stdlib/builtin/dir.rbs +419 -0
  215. data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +606 -0
  216. data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +404 -0
  217. data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +260 -0
  218. data/vendor/ruby-signature/stdlib/builtin/errno.rbs +781 -0
  219. data/vendor/ruby-signature/stdlib/builtin/errors.rbs +582 -0
  220. data/vendor/ruby-signature/stdlib/builtin/exception.rbs +193 -0
  221. data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +40 -0
  222. data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +68 -0
  223. data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +12 -0
  224. data/vendor/ruby-signature/stdlib/builtin/file.rbs +476 -0
  225. data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +59 -0
  226. data/vendor/ruby-signature/stdlib/builtin/float.rbs +696 -0
  227. data/vendor/ruby-signature/stdlib/builtin/gc.rbs +121 -0
  228. data/vendor/ruby-signature/stdlib/builtin/hash.rbs +1029 -0
  229. data/vendor/ruby-signature/stdlib/builtin/integer.rbs +710 -0
  230. data/vendor/ruby-signature/stdlib/builtin/io.rbs +683 -0
  231. data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +574 -0
  232. data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +135 -0
  233. data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +141 -0
  234. data/vendor/ruby-signature/stdlib/builtin/math.rbs +66 -0
  235. data/vendor/ruby-signature/stdlib/builtin/method.rbs +182 -0
  236. data/vendor/ruby-signature/stdlib/builtin/module.rbs +248 -0
  237. data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +82 -0
  238. data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +409 -0
  239. data/vendor/ruby-signature/stdlib/builtin/object.rbs +824 -0
  240. data/vendor/ruby-signature/stdlib/builtin/proc.rbs +426 -0
  241. data/vendor/ruby-signature/stdlib/builtin/process.rbs +354 -0
  242. data/vendor/ruby-signature/stdlib/builtin/random.rbs +93 -0
  243. data/vendor/ruby-signature/stdlib/builtin/range.rbs +226 -0
  244. data/vendor/ruby-signature/stdlib/builtin/rational.rbs +424 -0
  245. data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +10 -0
  246. data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +131 -0
  247. data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +14 -0
  248. data/vendor/ruby-signature/stdlib/builtin/signal.rbs +55 -0
  249. data/vendor/ruby-signature/stdlib/builtin/string.rbs +770 -0
  250. data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +13 -0
  251. data/vendor/ruby-signature/stdlib/builtin/struct.rbs +40 -0
  252. data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +230 -0
  253. data/vendor/ruby-signature/stdlib/builtin/thread.rbs +1112 -0
  254. data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +23 -0
  255. data/vendor/ruby-signature/stdlib/builtin/time.rbs +739 -0
  256. data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +91 -0
  257. data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +46 -0
  258. data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +159 -0
  259. data/vendor/ruby-signature/stdlib/builtin/warning.rbs +17 -0
  260. data/vendor/ruby-signature/stdlib/erb/erb.rbs +18 -0
  261. data/vendor/ruby-signature/stdlib/find/find.rbs +44 -0
  262. data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +21 -0
  263. data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +23 -0
  264. data/vendor/ruby-signature/stdlib/prime/prime.rbs +188 -0
  265. data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +9 -0
  266. data/vendor/ruby-signature/stdlib/set/set.rbs +77 -0
  267. data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +53 -0
  268. metadata +244 -54
  269. data/.travis.yml +0 -7
  270. data/lib/steep/ast/signature/alias.rb +0 -19
  271. data/lib/steep/ast/signature/class.rb +0 -33
  272. data/lib/steep/ast/signature/const.rb +0 -17
  273. data/lib/steep/ast/signature/env.rb +0 -138
  274. data/lib/steep/ast/signature/extension.rb +0 -21
  275. data/lib/steep/ast/signature/gvar.rb +0 -17
  276. data/lib/steep/ast/signature/interface.rb +0 -31
  277. data/lib/steep/ast/signature/members.rb +0 -115
  278. data/lib/steep/ast/signature/module.rb +0 -21
  279. data/lib/steep/drivers/print_interface.rb +0 -94
  280. data/lib/steep/drivers/scaffold.rb +0 -321
  281. data/lib/steep/drivers/utils/each_signature.rb +0 -31
  282. data/lib/steep/interface/abstract.rb +0 -68
  283. data/lib/steep/interface/builder.rb +0 -637
  284. data/lib/steep/interface/instantiated.rb +0 -163
  285. data/lib/steep/interface/ivar_chain.rb +0 -26
  286. data/lib/steep/parser.y +0 -1278
  287. data/lib/steep/project/listener.rb +0 -53
  288. data/smoke/class/a.rbi +0 -24
  289. data/smoke/class/d.rb +0 -9
  290. data/smoke/class/e.rb +0 -12
  291. data/smoke/class/i.rbi +0 -9
  292. data/smoke/hash/e.rbi +0 -3
  293. data/smoke/hello/hello.rbi +0 -7
  294. data/smoke/implements/a.rbi +0 -6
  295. data/smoke/initialize/a.rbi +0 -3
  296. data/smoke/module/a.rbi +0 -16
  297. data/smoke/self/a.rbi +0 -4
  298. data/smoke/super/a.rbi +0 -10
  299. data/stdlib/builtin.rbi +0 -787
@@ -0,0 +1,23 @@
1
+ # [ThreadGroup](ThreadGroup) provides a means of
2
+ # keeping track of a number of threads as a group.
3
+ #
4
+ # A given [Thread](https://ruby-doc.org/core-2.6.3/Thread.html) object can
5
+ # only belong to one [ThreadGroup](ThreadGroup) at a
6
+ # time; adding a thread to a new group will remove it from any previous
7
+ # group.
8
+ #
9
+ # Newly created threads belong to the same group as the thread from which
10
+ # they were created.
11
+ class ThreadGroup < Object
12
+ def add: (Thread thread) -> ThreadGroup
13
+
14
+ def enclose: () -> ThreadGroup
15
+
16
+ # Returns `true` if the `thgrp` is enclosed. See also
17
+ # [\#enclose](ThreadGroup.downloaded.ruby_doc#method-i-enclose).
18
+ def enclosed?: () -> bool
19
+
20
+ def list: () -> ::Array[Thread]
21
+ end
22
+
23
+ ThreadGroup::Default: ThreadGroup
@@ -0,0 +1,739 @@
1
+ # [Time](Time) is an abstraction of dates and times.
2
+ # [Time](Time) is stored internally as the number of
3
+ # seconds with fraction since the *Epoch* , January 1, 1970 00:00 UTC.
4
+ # Also see the library module Date. The [Time](Time)
5
+ # class treats GMT (Greenwich Mean [Time](Time) ) and
6
+ # UTC (Coordinated Universal [Time](Time) ) as
7
+ # equivalent. GMT is the older way of referring to these baseline times
8
+ # but persists in the names of calls on POSIX systems.
9
+ #
10
+ # All times may have fraction. Be aware of this fact when comparing times
11
+ # with each other – times that are apparently equal when displayed may be
12
+ # different when compared.
13
+ #
14
+ # Since Ruby 1.9.2, [Time](Time) implementation uses a
15
+ # signed 63 bit integer, Bignum or
16
+ # [Rational](https://ruby-doc.org/core-2.6.3/Rational.html). The integer
17
+ # is a number of nanoseconds since the *Epoch* which can represent
18
+ # 1823-11-12 to 2116-02-20. When Bignum or
19
+ # [Rational](https://ruby-doc.org/core-2.6.3/Rational.html) is used
20
+ # (before 1823, after 2116, under nanosecond),
21
+ # [Time](Time) works slower as when integer is used.
22
+ #
23
+ #
24
+ # All of these examples were done using the EST timezone which is GMT-5.
25
+ #
26
+ #
27
+ # You can create a new instance of [Time](Time) with
28
+ # [::new](Time#method-c-new). This will use the
29
+ # current system time. [::now](Time#method-c-now) is
30
+ # an alias for this. You can also pass parts of the time to
31
+ # [::new](Time#method-c-new) such as year, month,
32
+ # minute, etc. When you want to construct a time this way you must pass at
33
+ # least a year. If you pass the year with nothing else time will default
34
+ # to January 1 of that year at 00:00:00 with the current system timezone.
35
+ # Here are some examples:
36
+ #
37
+ # ```ruby
38
+ # Time.new(2002) #=> 2002-01-01 00:00:00 -0500
39
+ # Time.new(2002, 10) #=> 2002-10-01 00:00:00 -0500
40
+ # Time.new(2002, 10, 31) #=> 2002-10-31 00:00:00 -0500
41
+ # ```
42
+ #
43
+ # You can pass a UTC offset:
44
+ #
45
+ # ```ruby
46
+ # Time.new(2002, 10, 31, 2, 2, 2, "+02:00") #=> 2002-10-31 02:02:02 +0200
47
+ # ```
48
+ #
49
+ # Or a timezone object:
50
+ #
51
+ # ```ruby
52
+ # tz = timezone("Europe/Athens") # Eastern European Time, UTC+2
53
+ # Time.new(2002, 10, 31, 2, 2, 2, tz) #=> 2002-10-31 02:02:02 +0200
54
+ # ```
55
+ #
56
+ # You can also use [::gm](Time#method-c-gm),
57
+ # [::local](Time#method-c-local) and
58
+ # [::utc](Time#method-c-utc) to infer GMT, local and
59
+ # UTC timezones instead of using the current system setting.
60
+ #
61
+ # You can also create a new time using
62
+ # [::at](Time#method-c-at) which takes the number of
63
+ # seconds (or fraction of seconds) since the [Unix
64
+ # Epoch](http://en.wikipedia.org/wiki/Unix_time).
65
+ #
66
+ # ```ruby
67
+ # Time.at(628232400) #=> 1989-11-28 00:00:00 -0500
68
+ # ```
69
+ #
70
+ #
71
+ # Once you have an instance of [Time](Time) there is a
72
+ # multitude of things you can do with it. Below are some examples. For all
73
+ # of the following examples, we will work on the assumption that you have
74
+ # done the following:
75
+ #
76
+ # ```ruby
77
+ # t = Time.new(1993, 02, 24, 12, 0, 0, "+09:00")
78
+ # ```
79
+ #
80
+ # Was that a monday?
81
+ #
82
+ # ```ruby
83
+ # t.monday? #=> false
84
+ # ```
85
+ #
86
+ # What year was that again?
87
+ #
88
+ # ```ruby
89
+ # t.year #=> 1993
90
+ # ```
91
+ #
92
+ # Was it daylight savings at the time?
93
+ #
94
+ # ```ruby
95
+ # t.dst? #=> false
96
+ # ```
97
+ #
98
+ # What’s the day a year later?
99
+ #
100
+ # ```ruby
101
+ # t + (60*60*24*365) #=> 1994-02-24 12:00:00 +0900
102
+ # ```
103
+ #
104
+ # How many seconds was that since the Unix Epoch?
105
+ #
106
+ # ```ruby
107
+ # t.to_i #=> 730522800
108
+ # ```
109
+ #
110
+ # You can also do standard functions like compare two times.
111
+ #
112
+ # ```ruby
113
+ # t1 = Time.new(2010)
114
+ # t2 = Time.new(2011)
115
+ #
116
+ # t1 == t2 #=> false
117
+ # t1 == t1 #=> true
118
+ # t1 < t2 #=> true
119
+ # t1 > t2 #=> false
120
+ #
121
+ # Time.new(2010,10,31).between?(t1, t2) #=> true
122
+ # ```
123
+ #
124
+ #
125
+ # A timezone argument must have `local_to_utc` and `utc_to_local` methods,
126
+ # and may have `name` and `abbr` methods.
127
+ #
128
+ # The `local_to_utc` method should convert a Time-like object from the
129
+ # timezone to UTC, and `utc_to_local` is the opposite. The result also
130
+ # should be a [Time](Time) or Time-like object (not
131
+ # necessary to be the same class). The
132
+ # [zone](Time#method-i-zone) of the result is just
133
+ # ignored. Time-like argument to these methods is similar to a
134
+ # [Time](Time) object in UTC without sub-second; it
135
+ # has attribute readers for the parts, e.g.
136
+ # [year](Time#method-i-year),
137
+ # [month](Time#method-i-month), and so on, and epoch
138
+ # time readers, [to\_i](Time#method-i-to_i). The
139
+ # sub-second attributes are fixed as 0, and
140
+ # [utc\_offset](Time#method-i-utc_offset),
141
+ # [zone](Time#method-i-zone),
142
+ # [isdst](Time#method-i-isdst), and their aliases are
143
+ # same as a [Time](Time) object in UTC. Also to\_time,
144
+ # \#+, and \#- methods are defined.
145
+ #
146
+ # The `name` method is used for marshaling. If this method is not defined
147
+ # on a timezone object, [Time](Time) objects using
148
+ # that timezone object can not be dumped by
149
+ # [Marshal](https://ruby-doc.org/core-2.6.3/Marshal.html).
150
+ #
151
+ # The `abbr` method is used by ‘%Z’ in
152
+ # [strftime](Time#method-i-strftime).
153
+ #
154
+ #
155
+ # At loading marshaled data, a timezone name will be converted to a
156
+ # timezone object by `find_timezone` class method, if the method is
157
+ # defined.
158
+ #
159
+ # Similary, that class method will be called when a timezone argument does
160
+ # not have the necessary methods mentioned above.
161
+ class Time < Object
162
+ include Comparable
163
+
164
+ def self.at: (Time | Numeric seconds) -> Time
165
+ | (Numeric seconds, ?Numeric microseconds_with_frac) -> Time
166
+
167
+ def self.gm: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
168
+
169
+ def self.local: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
170
+
171
+ # Creates a new [Time](Time.downloaded.ruby_doc) object for the current
172
+ # time. This is same as [::new](Time.downloaded.ruby_doc#method-c-new)
173
+ # without arguments.
174
+ #
175
+ # ```ruby
176
+ # Time.now #=> 2009-06-24 12:39:54 +0900
177
+ # ```
178
+ def self.now: () -> Time
179
+
180
+ def self.utc: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
181
+
182
+ def +: (Numeric arg0) -> Time
183
+
184
+ def -: (Time arg0) -> Float
185
+ | (Numeric arg0) -> Time
186
+
187
+ def <: (Time arg0) -> bool
188
+
189
+ def <=: (Time arg0) -> bool
190
+
191
+ def <=>: (Time other) -> Integer?
192
+
193
+ def >: (Time arg0) -> bool
194
+
195
+ def >=: (Time arg0) -> bool
196
+
197
+ # Returns a canonical string representation of *time* .
198
+ #
199
+ # ```ruby
200
+ # Time.now.asctime #=> "Wed Apr 9 08:56:03 2003"
201
+ # Time.now.ctime #=> "Wed Apr 9 08:56:03 2003"
202
+ # ```
203
+ def asctime: () -> String
204
+
205
+ # Returns a canonical string representation of *time* .
206
+ #
207
+ # ```ruby
208
+ # Time.now.asctime #=> "Wed Apr 9 08:56:03 2003"
209
+ # Time.now.ctime #=> "Wed Apr 9 08:56:03 2003"
210
+ # ```
211
+ def ctime: () -> String
212
+
213
+ # Returns the day of the month (1..n) for *time* .
214
+ #
215
+ # ```ruby
216
+ # t = Time.now #=> 2007-11-19 08:27:03 -0600
217
+ # t.day #=> 19
218
+ # t.mday #=> 19
219
+ # ```
220
+ def day: () -> Integer
221
+
222
+ # Returns `true` if *time* occurs during Daylight Saving
223
+ # [Time](Time.downloaded.ruby_doc) in its time zone.
224
+ #
225
+ # ```ruby
226
+ # # CST6CDT:
227
+ # Time.local(2000, 1, 1).zone #=> "CST"
228
+ # Time.local(2000, 1, 1).isdst #=> false
229
+ # Time.local(2000, 1, 1).dst? #=> false
230
+ # Time.local(2000, 7, 1).zone #=> "CDT"
231
+ # Time.local(2000, 7, 1).isdst #=> true
232
+ # Time.local(2000, 7, 1).dst? #=> true
233
+ #
234
+ # # Asia/Tokyo:
235
+ # Time.local(2000, 1, 1).zone #=> "JST"
236
+ # Time.local(2000, 1, 1).isdst #=> false
237
+ # Time.local(2000, 1, 1).dst? #=> false
238
+ # Time.local(2000, 7, 1).zone #=> "JST"
239
+ # Time.local(2000, 7, 1).isdst #=> false
240
+ # Time.local(2000, 7, 1).dst? #=> false
241
+ # ```
242
+ def dst?: () -> bool
243
+
244
+ def eql?: (untyped arg0) -> bool
245
+
246
+ # Returns `true` if *time* represents Friday.
247
+ #
248
+ # ```ruby
249
+ # t = Time.local(1987, 12, 18) #=> 1987-12-18 00:00:00 -0600
250
+ # t.friday? #=> true
251
+ # ```
252
+ def friday?: () -> bool
253
+
254
+ # Returns a new [Time](Time.downloaded.ruby_doc) object representing
255
+ # *time* in UTC.
256
+ #
257
+ # ```ruby
258
+ # t = Time.local(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 -0600
259
+ # t.gmt? #=> false
260
+ # y = t.getgm #=> 2000-01-02 02:15:01 UTC
261
+ # y.gmt? #=> true
262
+ # t == y #=> true
263
+ # ```
264
+ def getgm: () -> Time
265
+
266
+ def getlocal: (?Integer utc_offset) -> Time
267
+
268
+ # Returns a new [Time](Time.downloaded.ruby_doc) object representing
269
+ # *time* in UTC.
270
+ #
271
+ # ```ruby
272
+ # t = Time.local(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 -0600
273
+ # t.gmt? #=> false
274
+ # y = t.getgm #=> 2000-01-02 02:15:01 UTC
275
+ # y.gmt? #=> true
276
+ # t == y #=> true
277
+ # ```
278
+ def getutc: () -> Time
279
+
280
+ # Returns `true` if *time* represents a time in UTC (GMT).
281
+ #
282
+ # ```ruby
283
+ # t = Time.now #=> 2007-11-19 08:15:23 -0600
284
+ # t.utc? #=> false
285
+ # t = Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC
286
+ # t.utc? #=> true
287
+ #
288
+ # t = Time.now #=> 2007-11-19 08:16:03 -0600
289
+ # t.gmt? #=> false
290
+ # t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
291
+ # t.gmt? #=> true
292
+ # ```
293
+ def gmt?: () -> bool
294
+
295
+ # Returns the offset in seconds between the timezone of *time* and UTC.
296
+ #
297
+ # ```ruby
298
+ # t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
299
+ # t.gmt_offset #=> 0
300
+ # l = t.getlocal #=> 2000-01-01 14:15:01 -0600
301
+ # l.gmt_offset #=> -21600
302
+ # ```
303
+ def gmt_offset: () -> Integer
304
+
305
+ # Converts *time* to UTC (GMT), modifying the receiver.
306
+ #
307
+ # ```ruby
308
+ # t = Time.now #=> 2007-11-19 08:18:31 -0600
309
+ # t.gmt? #=> false
310
+ # t.gmtime #=> 2007-11-19 14:18:31 UTC
311
+ # t.gmt? #=> true
312
+ #
313
+ # t = Time.now #=> 2007-11-19 08:18:51 -0600
314
+ # t.utc? #=> false
315
+ # t.utc #=> 2007-11-19 14:18:51 UTC
316
+ # t.utc? #=> true
317
+ # ```
318
+ def gmtime: () -> Time
319
+
320
+ # Returns a hash code for this [Time](Time.downloaded.ruby_doc) object.
321
+ #
322
+ # See also Object\#hash.
323
+ def hash: () -> Integer
324
+
325
+ # Returns the hour of the day (0..23) for *time* .
326
+ #
327
+ # ```ruby
328
+ # t = Time.now #=> 2007-11-19 08:26:20 -0600
329
+ # t.hour #=> 8
330
+ # ```
331
+ def hour: () -> Integer
332
+
333
+ 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
334
+
335
+ # Returns a string representing *time* . Equivalent to calling
336
+ # [strftime](Time.downloaded.ruby_doc#method-i-strftime) with the
337
+ # appropriate format string.
338
+ #
339
+ # ```ruby
340
+ # t = Time.now
341
+ # t.to_s #=> "2012-11-10 18:16:12 +0100"
342
+ # t.strftime "%Y-%m-%d %H:%M:%S %z" #=> "2012-11-10 18:16:12 +0100"
343
+ #
344
+ # t.utc.to_s #=> "2012-11-10 17:16:12 UTC"
345
+ # t.strftime "%Y-%m-%d %H:%M:%S UTC" #=> "2012-11-10 17:16:12 UTC"
346
+ # ```
347
+ def inspect: () -> String
348
+
349
+ # Returns `true` if *time* occurs during Daylight Saving
350
+ # [Time](Time.downloaded.ruby_doc) in its time zone.
351
+ #
352
+ # ```ruby
353
+ # # CST6CDT:
354
+ # Time.local(2000, 1, 1).zone #=> "CST"
355
+ # Time.local(2000, 1, 1).isdst #=> false
356
+ # Time.local(2000, 1, 1).dst? #=> false
357
+ # Time.local(2000, 7, 1).zone #=> "CDT"
358
+ # Time.local(2000, 7, 1).isdst #=> true
359
+ # Time.local(2000, 7, 1).dst? #=> true
360
+ #
361
+ # # Asia/Tokyo:
362
+ # Time.local(2000, 1, 1).zone #=> "JST"
363
+ # Time.local(2000, 1, 1).isdst #=> false
364
+ # Time.local(2000, 1, 1).dst? #=> false
365
+ # Time.local(2000, 7, 1).zone #=> "JST"
366
+ # Time.local(2000, 7, 1).isdst #=> false
367
+ # Time.local(2000, 7, 1).dst? #=> false
368
+ # ```
369
+ def isdst: () -> bool
370
+
371
+ def localtime: (?String utc_offset) -> Time
372
+
373
+ # Returns the day of the month (1..n) for *time* .
374
+ #
375
+ # ```ruby
376
+ # t = Time.now #=> 2007-11-19 08:27:03 -0600
377
+ # t.day #=> 19
378
+ # t.mday #=> 19
379
+ # ```
380
+ def mday: () -> Integer
381
+
382
+ # Returns the minute of the hour (0..59) for *time* .
383
+ #
384
+ # ```ruby
385
+ # t = Time.now #=> 2007-11-19 08:25:51 -0600
386
+ # t.min #=> 25
387
+ # ```
388
+ def min: () -> Integer
389
+
390
+ # Returns the month of the year (1..12) for *time* .
391
+ #
392
+ # ```ruby
393
+ # t = Time.now #=> 2007-11-19 08:27:30 -0600
394
+ # t.mon #=> 11
395
+ # t.month #=> 11
396
+ # ```
397
+ def mon: () -> Integer
398
+
399
+ # Returns `true` if *time* represents Monday.
400
+ #
401
+ # ```ruby
402
+ # t = Time.local(2003, 8, 4) #=> 2003-08-04 00:00:00 -0500
403
+ # t.monday? #=> true
404
+ # ```
405
+ def monday?: () -> bool
406
+
407
+ # Returns the number of nanoseconds for *time* .
408
+ #
409
+ # ```ruby
410
+ # t = Time.now #=> 2007-11-17 15:18:03 +0900
411
+ # "%10.9f" % t.to_f #=> "1195280283.536151409"
412
+ # t.nsec #=> 536151406
413
+ # ```
414
+ #
415
+ # The lowest digits of [to\_f](Time.downloaded.ruby_doc#method-i-to_f) and
416
+ # [nsec](Time.downloaded.ruby_doc#method-i-nsec) are different because
417
+ # IEEE 754 double is not accurate enough to represent the exact number of
418
+ # nanoseconds since the Epoch.
419
+ #
420
+ # The more accurate value is returned by
421
+ # [nsec](Time.downloaded.ruby_doc#method-i-nsec).
422
+ def nsec: () -> Integer
423
+
424
+ def round: (Integer arg0) -> Time
425
+
426
+ # Returns `true` if *time* represents Saturday.
427
+ #
428
+ # ```ruby
429
+ # t = Time.local(2006, 6, 10) #=> 2006-06-10 00:00:00 -0500
430
+ # t.saturday? #=> true
431
+ # ```
432
+ def saturday?: () -> bool
433
+
434
+ # Returns the second of the minute (0..60) for *time* .
435
+ #
436
+ # **Note:** Seconds range from zero to 60 to allow the system to inject
437
+ # leap seconds. See
438
+ # [en.wikipedia.org/wiki/Leap\_second](http://en.wikipedia.org/wiki/Leap_second)
439
+ # for further details.
440
+ #
441
+ # ```ruby
442
+ # t = Time.now #=> 2007-11-19 08:25:02 -0600
443
+ # t.sec #=> 2
444
+ # ```
445
+ def sec: () -> Integer
446
+
447
+ def strftime: (String arg0) -> String
448
+
449
+ # Returns the fraction for *time* .
450
+ #
451
+ # The return value can be a rational number.
452
+ #
453
+ # ```ruby
454
+ # t = Time.now #=> 2009-03-26 22:33:12 +0900
455
+ # "%10.9f" % t.to_f #=> "1238074392.940563917"
456
+ # t.subsec #=> (94056401/100000000)
457
+ # ```
458
+ #
459
+ # The lowest digits of [to\_f](Time.downloaded.ruby_doc#method-i-to_f) and
460
+ # [subsec](Time.downloaded.ruby_doc#method-i-subsec) are different because
461
+ # IEEE 754 double is not accurate enough to represent the rational number.
462
+ #
463
+ # The more accurate value is returned by
464
+ # [subsec](Time.downloaded.ruby_doc#method-i-subsec).
465
+ def subsec: () -> Numeric
466
+
467
+ # Returns a new [Time](Time.downloaded.ruby_doc) object, one second later
468
+ # than *time* . [\#succ](Time.downloaded.ruby_doc#method-i-succ) is
469
+ # obsolete since 1.9.2 for time is not a discrete value.
470
+ #
471
+ # ```ruby
472
+ # t = Time.now #=> 2007-11-19 08:23:57 -0600
473
+ # t.succ #=> 2007-11-19 08:23:58 -0600
474
+ # ```
475
+ #
476
+ # Use instead `time + 1`
477
+ #
478
+ # ```ruby
479
+ # t + 1 #=> 2007-11-19 08:23:58 -0600
480
+ # ```
481
+ def succ: () -> Time
482
+
483
+ # Returns `true` if *time* represents Sunday.
484
+ #
485
+ # ```ruby
486
+ # t = Time.local(1990, 4, 1) #=> 1990-04-01 00:00:00 -0600
487
+ # t.sunday? #=> true
488
+ # ```
489
+ def sunday?: () -> bool
490
+
491
+ # Returns `true` if *time* represents Thursday.
492
+ #
493
+ # ```ruby
494
+ # t = Time.local(1995, 12, 21) #=> 1995-12-21 00:00:00 -0600
495
+ # t.thursday? #=> true
496
+ # ```
497
+ def thursday?: () -> bool
498
+
499
+ # Returns a ten-element *array* of values for *time* :
500
+ #
501
+ # ```ruby
502
+ # [sec, min, hour, day, month, year, wday, yday, isdst, zone]
503
+ # ```
504
+ #
505
+ # See the individual methods for an explanation of the valid ranges of
506
+ # each value. The ten elements can be passed directly to
507
+ # [::utc](Time.downloaded.ruby_doc#method-c-utc) or
508
+ # [::local](Time.downloaded.ruby_doc#method-c-local) to create a new
509
+ # [Time](Time.downloaded.ruby_doc) object.
510
+ #
511
+ # ```ruby
512
+ # t = Time.now #=> 2007-11-19 08:36:01 -0600
513
+ # now = t.to_a #=> [1, 36, 8, 19, 11, 2007, 1, 323, false, "CST"]
514
+ # ```
515
+ def to_a: () -> [ Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, bool, String ]
516
+
517
+ # Returns the value of *time* as a floating point number of seconds since
518
+ # the Epoch.
519
+ #
520
+ # ```ruby
521
+ # t = Time.now
522
+ # "%10.5f" % t.to_f #=> "1270968744.77658"
523
+ # t.to_i #=> 1270968744
524
+ # ```
525
+ #
526
+ # Note that IEEE 754 double is not accurate enough to represent the exact
527
+ # number of nanoseconds since the Epoch.
528
+ def to_f: () -> Float
529
+
530
+ # Returns the value of *time* as an integer number of seconds since the
531
+ # Epoch.
532
+ #
533
+ # ```ruby
534
+ # t = Time.now
535
+ # "%10.5f" % t.to_f #=> "1270968656.89607"
536
+ # t.to_i #=> 1270968656
537
+ # ```
538
+ def to_i: () -> Integer
539
+
540
+ # Returns the value of *time* as a rational number of seconds since the
541
+ # Epoch.
542
+ #
543
+ # ```ruby
544
+ # t = Time.now
545
+ # t.to_r #=> (1270968792716287611/1000000000)
546
+ # ```
547
+ #
548
+ # This methods is intended to be used to get an accurate value
549
+ # representing the nanoseconds since the Epoch. You can use this method to
550
+ # convert *time* to another Epoch.
551
+ def to_r: () -> Rational
552
+
553
+ # Returns a string representing *time* . Equivalent to calling
554
+ # [strftime](Time.downloaded.ruby_doc#method-i-strftime) with the
555
+ # appropriate format string.
556
+ #
557
+ # ```ruby
558
+ # t = Time.now
559
+ # t.to_s #=> "2012-11-10 18:16:12 +0100"
560
+ # t.strftime "%Y-%m-%d %H:%M:%S %z" #=> "2012-11-10 18:16:12 +0100"
561
+ #
562
+ # t.utc.to_s #=> "2012-11-10 17:16:12 UTC"
563
+ # t.strftime "%Y-%m-%d %H:%M:%S UTC" #=> "2012-11-10 17:16:12 UTC"
564
+ # ```
565
+ def to_s: () -> String
566
+
567
+ # Returns `true` if *time* represents Tuesday.
568
+ #
569
+ # ```ruby
570
+ # t = Time.local(1991, 2, 19) #=> 1991-02-19 00:00:00 -0600
571
+ # t.tuesday? #=> true
572
+ # ```
573
+ def tuesday?: () -> bool
574
+
575
+ # Returns the number of nanoseconds for *time* .
576
+ #
577
+ # ```ruby
578
+ # t = Time.now #=> 2007-11-17 15:18:03 +0900
579
+ # "%10.9f" % t.to_f #=> "1195280283.536151409"
580
+ # t.nsec #=> 536151406
581
+ # ```
582
+ #
583
+ # The lowest digits of [to\_f](Time.downloaded.ruby_doc#method-i-to_f) and
584
+ # [nsec](Time.downloaded.ruby_doc#method-i-nsec) are different because
585
+ # IEEE 754 double is not accurate enough to represent the exact number of
586
+ # nanoseconds since the Epoch.
587
+ #
588
+ # The more accurate value is returned by
589
+ # [nsec](Time.downloaded.ruby_doc#method-i-nsec).
590
+ def tv_nsec: () -> Numeric
591
+
592
+ # Returns the value of *time* as an integer number of seconds since the
593
+ # Epoch.
594
+ #
595
+ # ```ruby
596
+ # t = Time.now
597
+ # "%10.5f" % t.to_f #=> "1270968656.89607"
598
+ # t.to_i #=> 1270968656
599
+ # ```
600
+ def tv_sec: () -> Numeric
601
+
602
+ # Returns the number of microseconds for *time* .
603
+ #
604
+ # ```ruby
605
+ # t = Time.now #=> 2007-11-19 08:03:26 -0600
606
+ # "%10.6f" % t.to_f #=> "1195481006.775195"
607
+ # t.usec #=> 775195
608
+ # ```
609
+ def tv_usec: () -> Numeric
610
+
611
+ # Returns the number of microseconds for *time* .
612
+ #
613
+ # ```ruby
614
+ # t = Time.now #=> 2007-11-19 08:03:26 -0600
615
+ # "%10.6f" % t.to_f #=> "1195481006.775195"
616
+ # t.usec #=> 775195
617
+ # ```
618
+ def usec: () -> Numeric
619
+
620
+ # Converts *time* to UTC (GMT), modifying the receiver.
621
+ #
622
+ # ```ruby
623
+ # t = Time.now #=> 2007-11-19 08:18:31 -0600
624
+ # t.gmt? #=> false
625
+ # t.gmtime #=> 2007-11-19 14:18:31 UTC
626
+ # t.gmt? #=> true
627
+ #
628
+ # t = Time.now #=> 2007-11-19 08:18:51 -0600
629
+ # t.utc? #=> false
630
+ # t.utc #=> 2007-11-19 14:18:51 UTC
631
+ # t.utc? #=> true
632
+ # ```
633
+ def utc: () -> Time
634
+
635
+ # Returns `true` if *time* represents a time in UTC (GMT).
636
+ #
637
+ # ```ruby
638
+ # t = Time.now #=> 2007-11-19 08:15:23 -0600
639
+ # t.utc? #=> false
640
+ # t = Time.gm(2000,"jan",1,20,15,1) #=> 2000-01-01 20:15:01 UTC
641
+ # t.utc? #=> true
642
+ #
643
+ # t = Time.now #=> 2007-11-19 08:16:03 -0600
644
+ # t.gmt? #=> false
645
+ # t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
646
+ # t.gmt? #=> true
647
+ # ```
648
+ def utc?: () -> bool
649
+
650
+ # Returns the offset in seconds between the timezone of *time* and UTC.
651
+ #
652
+ # ```ruby
653
+ # t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
654
+ # t.gmt_offset #=> 0
655
+ # l = t.getlocal #=> 2000-01-01 14:15:01 -0600
656
+ # l.gmt_offset #=> -21600
657
+ # ```
658
+ def utc_offset: () -> Integer
659
+
660
+ # Returns an integer representing the day of the week, 0..6, with Sunday
661
+ # == 0.
662
+ #
663
+ # ```ruby
664
+ # t = Time.now #=> 2007-11-20 02:35:35 -0600
665
+ # t.wday #=> 2
666
+ # t.sunday? #=> false
667
+ # t.monday? #=> false
668
+ # t.tuesday? #=> true
669
+ # t.wednesday? #=> false
670
+ # t.thursday? #=> false
671
+ # t.friday? #=> false
672
+ # t.saturday? #=> false
673
+ # ```
674
+ def wday: () -> Integer
675
+
676
+ # Returns `true` if *time* represents Wednesday.
677
+ #
678
+ # ```ruby
679
+ # t = Time.local(1993, 2, 24) #=> 1993-02-24 00:00:00 -0600
680
+ # t.wednesday? #=> true
681
+ # ```
682
+ def wednesday?: () -> bool
683
+
684
+ # Returns an integer representing the day of the year, 1..366.
685
+ #
686
+ # ```ruby
687
+ # t = Time.now #=> 2007-11-19 08:32:31 -0600
688
+ # t.yday #=> 323
689
+ # ```
690
+ def yday: () -> Integer
691
+
692
+ # Returns the year for *time* (including the century).
693
+ #
694
+ # ```ruby
695
+ # t = Time.now #=> 2007-11-19 08:27:51 -0600
696
+ # t.year #=> 2007
697
+ # ```
698
+ def year: () -> Integer
699
+
700
+ # Returns the name of the time zone used for *time* . As of Ruby 1.8,
701
+ # returns “UTC” rather than “GMT” for UTC times.
702
+ #
703
+ # ```ruby
704
+ # t = Time.gm(2000, "jan", 1, 20, 15, 1)
705
+ # t.zone #=> "UTC"
706
+ # t = Time.local(2000, "jan", 1, 20, 15, 1)
707
+ # t.zone #=> "CST"
708
+ # ```
709
+ def zone: () -> String
710
+
711
+ def self.mktime: (Integer year, ?Integer | String month, ?Integer day, ?Integer hour, ?Integer min, ?Numeric sec, ?Numeric usec_with_frac) -> Time
712
+
713
+ # Returns the offset in seconds between the timezone of *time* and UTC.
714
+ #
715
+ # ```ruby
716
+ # t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
717
+ # t.gmt_offset #=> 0
718
+ # l = t.getlocal #=> 2000-01-01 14:15:01 -0600
719
+ # l.gmt_offset #=> -21600
720
+ # ```
721
+ def gmtoff: () -> Integer
722
+
723
+ # Returns the month of the year (1..12) for *time* .
724
+ #
725
+ # ```ruby
726
+ # t = Time.now #=> 2007-11-19 08:27:30 -0600
727
+ # t.mon #=> 11
728
+ # t.month #=> 11
729
+ # ```
730
+ def month: () -> Integer
731
+
732
+ def floor: (?Integer ndigits) -> Time
733
+
734
+ def ceil: (?Integer ndigits) -> Time
735
+ end
736
+
737
+ Time::RFC2822_DAY_NAME: Array[String]
738
+
739
+ Time::RFC2822_MONTH_NAME: Array[String]