rbs 0.7.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -0
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/docs/syntax.md +14 -1
- data/lib/rbs/ast/comment.rb +6 -0
- data/lib/rbs/ast/members.rb +3 -8
- data/lib/rbs/cli.rb +83 -4
- data/lib/rbs/definition.rb +15 -5
- data/lib/rbs/definition_builder.rb +32 -13
- data/lib/rbs/environment.rb +0 -1
- data/lib/rbs/environment_loader.rb +55 -35
- data/lib/rbs/location.rb +15 -0
- data/lib/rbs/parser.y +30 -20
- data/lib/rbs/prototype/rb.rb +0 -1
- data/lib/rbs/prototype/rbi.rb +0 -2
- data/lib/rbs/prototype/runtime.rb +0 -4
- data/lib/rbs/test.rb +1 -0
- data/lib/rbs/test/errors.rb +5 -1
- data/lib/rbs/test/hook.rb +1 -0
- data/lib/rbs/test/setup.rb +37 -15
- data/lib/rbs/test/setup_helper.rb +44 -0
- data/lib/rbs/test/tester.rb +61 -15
- data/lib/rbs/test/type_check.rb +45 -17
- data/lib/rbs/validator.rb +4 -0
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +7 -3
- data/stdlib/builtin/array.rbs +2 -1
- data/stdlib/builtin/enumerable.rbs +2 -2
- data/stdlib/builtin/hash.rbs +1 -1
- data/stdlib/date/date.rbs +1056 -0
- data/stdlib/date/date_time.rbs +582 -0
- data/stdlib/json/json.rbs +6 -0
- data/stdlib/pty/pty.rbs +159 -0
- data/stdlib/zlib/zlib.rbs +392 -0
- metadata +7 -2
@@ -0,0 +1,582 @@
|
|
1
|
+
# ## DateTime
|
2
|
+
#
|
3
|
+
# A subclass of Date that easily handles date, hour, minute, second, and offset.
|
4
|
+
#
|
5
|
+
# DateTime does not consider any leap seconds, does not track any summer time
|
6
|
+
# rules.
|
7
|
+
#
|
8
|
+
# A DateTime object is created with DateTime::new, DateTime::jd,
|
9
|
+
# DateTime::ordinal, DateTime::commercial, DateTime::parse, DateTime::strptime,
|
10
|
+
# DateTime::now, Time#to_datetime, etc.
|
11
|
+
#
|
12
|
+
# require 'date'
|
13
|
+
#
|
14
|
+
# DateTime.new(2001,2,3,4,5,6)
|
15
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>
|
16
|
+
#
|
17
|
+
# The last element of day, hour, minute, or second can be a fractional number.
|
18
|
+
# The fractional number's precision is assumed at most nanosecond.
|
19
|
+
#
|
20
|
+
# DateTime.new(2001,2,3.5)
|
21
|
+
# #=> #<DateTime: 2001-02-03T12:00:00+00:00 ...>
|
22
|
+
#
|
23
|
+
# An optional argument, the offset, indicates the difference between the local
|
24
|
+
# time and UTC. For example, `Rational(3,24)` represents ahead of 3 hours of
|
25
|
+
# UTC, `Rational(-5,24)` represents behind of 5 hours of UTC. The offset should
|
26
|
+
# be -1 to +1, and its precision is assumed at most second. The default value is
|
27
|
+
# zero (equals to UTC).
|
28
|
+
#
|
29
|
+
# DateTime.new(2001,2,3,4,5,6,Rational(3,24))
|
30
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...>
|
31
|
+
#
|
32
|
+
# The offset also accepts string form:
|
33
|
+
#
|
34
|
+
# DateTime.new(2001,2,3,4,5,6,'+03:00')
|
35
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...>
|
36
|
+
#
|
37
|
+
# An optional argument, the day of calendar reform (`start`), denotes a Julian
|
38
|
+
# day number, which should be 2298874 to 2426355 or negative/positive infinity.
|
39
|
+
# The default value is `Date::ITALY` (2299161=1582-10-15).
|
40
|
+
#
|
41
|
+
# A DateTime object has various methods. See each reference.
|
42
|
+
#
|
43
|
+
# d = DateTime.parse('3rd Feb 2001 04:05:06+03:30')
|
44
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+03:30 ...>
|
45
|
+
# d.hour #=> 4
|
46
|
+
# d.min #=> 5
|
47
|
+
# d.sec #=> 6
|
48
|
+
# d.offset #=> (7/48)
|
49
|
+
# d.zone #=> "+03:30"
|
50
|
+
# d += Rational('1.5')
|
51
|
+
# #=> #<DateTime: 2001-02-04%16:05:06+03:30 ...>
|
52
|
+
# d = d.new_offset('+09:00')
|
53
|
+
# #=> #<DateTime: 2001-02-04%21:35:06+09:00 ...>
|
54
|
+
# d.strftime('%I:%M:%S %p')
|
55
|
+
# #=> "09:35:06 PM"
|
56
|
+
# d > DateTime.new(1999)
|
57
|
+
# #=> true
|
58
|
+
#
|
59
|
+
# ### When should you use DateTime and when should you use Time?
|
60
|
+
#
|
61
|
+
# It's a common misconception that [William
|
62
|
+
# Shakespeare](http://en.wikipedia.org/wiki/William_Shakespeare) and [Miguel de
|
63
|
+
# Cervantes](http://en.wikipedia.org/wiki/Miguel_de_Cervantes) died on the same
|
64
|
+
# day in history - so much so that UNESCO named April 23 as [World Book Day
|
65
|
+
# because of this fact](http://en.wikipedia.org/wiki/World_Book_Day). However,
|
66
|
+
# because England hadn't yet adopted the [Gregorian Calendar
|
67
|
+
# Reform](http://en.wikipedia.org/wiki/Gregorian_calendar#Gregorian_reform) (and
|
68
|
+
# wouldn't until
|
69
|
+
# [1752](http://en.wikipedia.org/wiki/Calendar_(New_Style)_Act_1750)) their
|
70
|
+
# deaths are actually 10 days apart. Since Ruby's Time class implements a
|
71
|
+
# [proleptic Gregorian
|
72
|
+
# calendar](http://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar) and has
|
73
|
+
# no concept of calendar reform there's no way to express this with Time
|
74
|
+
# objects. This is where DateTime steps in:
|
75
|
+
#
|
76
|
+
# shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
|
77
|
+
# #=> Tue, 23 Apr 1616 00:00:00 +0000
|
78
|
+
# cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
|
79
|
+
# #=> Sat, 23 Apr 1616 00:00:00 +0000
|
80
|
+
#
|
81
|
+
# Already you can see something is weird - the days of the week are different.
|
82
|
+
# Taking this further:
|
83
|
+
#
|
84
|
+
# cervantes == shakespeare
|
85
|
+
# #=> false
|
86
|
+
# (shakespeare - cervantes).to_i
|
87
|
+
# #=> 10
|
88
|
+
#
|
89
|
+
# This shows that in fact they died 10 days apart (in reality 11 days since
|
90
|
+
# Cervantes died a day earlier but was buried on the 23rd). We can see the
|
91
|
+
# actual date of Shakespeare's death by using the #gregorian method to convert
|
92
|
+
# it:
|
93
|
+
#
|
94
|
+
# shakespeare.gregorian
|
95
|
+
# #=> Tue, 03 May 1616 00:00:00 +0000
|
96
|
+
#
|
97
|
+
# So there's an argument that all the celebrations that take place on the 23rd
|
98
|
+
# April in Stratford-upon-Avon are actually the wrong date since England is now
|
99
|
+
# using the Gregorian calendar. You can see why when we transition across the
|
100
|
+
# reform date boundary:
|
101
|
+
#
|
102
|
+
# # start off with the anniversary of Shakespeare's birth in 1751
|
103
|
+
# shakespeare = DateTime.iso8601('1751-04-23', Date::ENGLAND)
|
104
|
+
# #=> Tue, 23 Apr 1751 00:00:00 +0000
|
105
|
+
#
|
106
|
+
# # add 366 days since 1752 is a leap year and April 23 is after February 29
|
107
|
+
# shakespeare + 366
|
108
|
+
# #=> Thu, 23 Apr 1752 00:00:00 +0000
|
109
|
+
#
|
110
|
+
# # add another 365 days to take us to the anniversary in 1753
|
111
|
+
# shakespeare + 366 + 365
|
112
|
+
# #=> Fri, 04 May 1753 00:00:00 +0000
|
113
|
+
#
|
114
|
+
# As you can see, if we're accurately tracking the number of [solar
|
115
|
+
# years](http://en.wikipedia.org/wiki/Tropical_year) since Shakespeare's
|
116
|
+
# birthday then the correct anniversary date would be the 4th May and not the
|
117
|
+
# 23rd April.
|
118
|
+
#
|
119
|
+
# So when should you use DateTime in Ruby and when should you use Time? Almost
|
120
|
+
# certainly you'll want to use Time since your app is probably dealing with
|
121
|
+
# current dates and times. However, if you need to deal with dates and times in
|
122
|
+
# a historical context you'll want to use DateTime to avoid making the same
|
123
|
+
# mistakes as UNESCO. If you also have to deal with timezones then best of luck
|
124
|
+
# - just bear in mind that you'll probably be dealing with [local solar
|
125
|
+
# times](http://en.wikipedia.org/wiki/Solar_time), since it wasn't until the
|
126
|
+
# 19th century that the introduction of the railways necessitated the need for
|
127
|
+
# [Standard Time](http://en.wikipedia.org/wiki/Standard_time#Great_Britain) and
|
128
|
+
# eventually timezones.
|
129
|
+
#
|
130
|
+
class DateTime < Date
|
131
|
+
# Creates a DateTime object denoting the given calendar date.
|
132
|
+
#
|
133
|
+
# DateTime.new(2001,2,3) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
|
134
|
+
# DateTime.new(2001,2,3,4,5,6,'+7')
|
135
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
136
|
+
# DateTime.new(2001,-11,-26,-20,-55,-54,'+7')
|
137
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
138
|
+
#
|
139
|
+
def initialize: (?Integer year, ?Integer month, ?Integer mday, ?Integer hour, ?Integer minute, ?Integer second, ?Integer offset, ?Integer start) -> void
|
140
|
+
|
141
|
+
# Parses the given representation of date and time with the given template, and
|
142
|
+
# returns a hash of parsed elements. _strptime does not support specification
|
143
|
+
# of flags and width unlike strftime.
|
144
|
+
#
|
145
|
+
# See also strptime(3) and #strftime.
|
146
|
+
#
|
147
|
+
def self._strptime: (String str, ?String format) -> Hash[Symbol, Integer | String]
|
148
|
+
|
149
|
+
# Creates a DateTime object denoting the given calendar date.
|
150
|
+
#
|
151
|
+
# DateTime.new(2001,2,3) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
|
152
|
+
# DateTime.new(2001,2,3,4,5,6,'+7')
|
153
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
154
|
+
# DateTime.new(2001,-11,-26,-20,-55,-54,'+7')
|
155
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
156
|
+
#
|
157
|
+
def self.civil: (?Integer year, ?Integer month, ?Integer mday, ?Integer hour, ?Integer minute, ?Integer second, ?Integer offset, ?Integer start) -> DateTime
|
158
|
+
|
159
|
+
# Creates a DateTime object denoting the given week date.
|
160
|
+
#
|
161
|
+
# DateTime.commercial(2001) #=> #<DateTime: 2001-01-01T00:00:00+00:00 ...>
|
162
|
+
# DateTime.commercial(2002) #=> #<DateTime: 2001-12-31T00:00:00+00:00 ...>
|
163
|
+
# DateTime.commercial(2001,5,6,4,5,6,'+7')
|
164
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
165
|
+
#
|
166
|
+
def self.commercial: (?Integer cwyear, ?Integer cweek, ?Integer cwday, ?Integer hour, ?Integer minute, ?Integer second, ?Integer offset, ?Integer start) -> DateTime
|
167
|
+
|
168
|
+
# Creates a new DateTime object by parsing from a string according to some RFC
|
169
|
+
# 2616 format.
|
170
|
+
#
|
171
|
+
# DateTime.httpdate('Sat, 03 Feb 2001 04:05:06 GMT')
|
172
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>
|
173
|
+
#
|
174
|
+
def self.httpdate: (String str, ?Integer start) -> DateTime
|
175
|
+
|
176
|
+
# Creates a new DateTime object by parsing from a string according to some
|
177
|
+
# typical ISO 8601 formats.
|
178
|
+
#
|
179
|
+
# DateTime.iso8601('2001-02-03T04:05:06+07:00')
|
180
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
181
|
+
# DateTime.iso8601('20010203T040506+0700')
|
182
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
183
|
+
# DateTime.iso8601('2001-W05-6T04:05:06+07:00')
|
184
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
185
|
+
#
|
186
|
+
def self.iso8601: (String str, ?Integer start) -> DateTime
|
187
|
+
|
188
|
+
# Creates a DateTime object denoting the given chronological Julian day number.
|
189
|
+
#
|
190
|
+
# DateTime.jd(2451944) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
|
191
|
+
# DateTime.jd(2451945) #=> #<DateTime: 2001-02-04T00:00:00+00:00 ...>
|
192
|
+
# DateTime.jd(Rational('0.5'))
|
193
|
+
# #=> #<DateTime: -4712-01-01T12:00:00+00:00 ...>
|
194
|
+
#
|
195
|
+
def self.jd: (?Integer jd, ?Integer hour, ?Integer minute, ?Integer second, ?Integer offset, ?Integer start) -> DateTime
|
196
|
+
|
197
|
+
# Creates a new DateTime object by parsing from a string according to some
|
198
|
+
# typical JIS X 0301 formats.
|
199
|
+
#
|
200
|
+
# DateTime.jisx0301('H13.02.03T04:05:06+07:00')
|
201
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
202
|
+
#
|
203
|
+
# For no-era year, legacy format, Heisei is assumed.
|
204
|
+
#
|
205
|
+
# DateTime.jisx0301('13.02.03T04:05:06+07:00')
|
206
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
207
|
+
#
|
208
|
+
def self.jisx0301: (String str, ?Integer start) -> DateTime
|
209
|
+
|
210
|
+
# Creates a DateTime object denoting the present time.
|
211
|
+
#
|
212
|
+
# DateTime.now #=> #<DateTime: 2011-06-11T21:20:44+09:00 ...>
|
213
|
+
#
|
214
|
+
def self.now: (?Integer start) -> DateTime
|
215
|
+
|
216
|
+
# Creates a DateTime object denoting the given ordinal date.
|
217
|
+
#
|
218
|
+
# DateTime.ordinal(2001,34) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
|
219
|
+
# DateTime.ordinal(2001,34,4,5,6,'+7')
|
220
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
221
|
+
# DateTime.ordinal(2001,-332,-20,-55,-54,'+7')
|
222
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
223
|
+
#
|
224
|
+
def self.ordinal: (?Integer year, ?Integer yday, ?Integer hour, ?Integer minute, ?Integer second, ?Integer offset, ?Integer start) -> DateTime
|
225
|
+
|
226
|
+
# Parses the given representation of date and time, and creates a DateTime
|
227
|
+
# object. This method does not function as a validator.
|
228
|
+
#
|
229
|
+
# If the optional second argument is true and the detected year is in the range
|
230
|
+
# "00" to "99", makes it full.
|
231
|
+
#
|
232
|
+
# DateTime.parse('2001-02-03T04:05:06+07:00')
|
233
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
234
|
+
# DateTime.parse('20010203T040506+0700')
|
235
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
236
|
+
# DateTime.parse('3rd Feb 2001 04:05:06 PM')
|
237
|
+
# #=> #<DateTime: 2001-02-03T16:05:06+00:00 ...>
|
238
|
+
#
|
239
|
+
def self.parse: (String str, ?bool complete, ?Integer start) -> DateTime
|
240
|
+
|
241
|
+
# Creates a new DateTime object by parsing from a string according to some
|
242
|
+
# typical RFC 2822 formats.
|
243
|
+
#
|
244
|
+
# DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700')
|
245
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
246
|
+
#
|
247
|
+
def self.rfc2822: (String str, ?Integer start) -> DateTime
|
248
|
+
|
249
|
+
# Creates a new DateTime object by parsing from a string according to some
|
250
|
+
# typical RFC 3339 formats.
|
251
|
+
#
|
252
|
+
# DateTime.rfc3339('2001-02-03T04:05:06+07:00')
|
253
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
254
|
+
#
|
255
|
+
def self.rfc3339: (String str, ?Integer start) -> DateTime
|
256
|
+
|
257
|
+
# Creates a new DateTime object by parsing from a string according to some
|
258
|
+
# typical RFC 2822 formats.
|
259
|
+
#
|
260
|
+
# DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700')
|
261
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
262
|
+
#
|
263
|
+
def self.rfc822: (String str, ?Integer start) -> DateTime
|
264
|
+
|
265
|
+
# Parses the given representation of date and time with the given template, and
|
266
|
+
# creates a DateTime object. strptime does not support specification of flags
|
267
|
+
# and width unlike strftime.
|
268
|
+
#
|
269
|
+
# DateTime.strptime('2001-02-03T04:05:06+07:00', '%Y-%m-%dT%H:%M:%S%z')
|
270
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
271
|
+
# DateTime.strptime('03-02-2001 04:05:06 PM', '%d-%m-%Y %I:%M:%S %p')
|
272
|
+
# #=> #<DateTime: 2001-02-03T16:05:06+00:00 ...>
|
273
|
+
# DateTime.strptime('2001-W05-6T04:05:06+07:00', '%G-W%V-%uT%H:%M:%S%z')
|
274
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
275
|
+
# DateTime.strptime('2001 04 6 04 05 06 +7', '%Y %U %w %H %M %S %z')
|
276
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
277
|
+
# DateTime.strptime('2001 05 6 04 05 06 +7', '%Y %W %u %H %M %S %z')
|
278
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
279
|
+
# DateTime.strptime('-1', '%s')
|
280
|
+
# #=> #<DateTime: 1969-12-31T23:59:59+00:00 ...>
|
281
|
+
# DateTime.strptime('-1000', '%Q')
|
282
|
+
# #=> #<DateTime: 1969-12-31T23:59:59+00:00 ...>
|
283
|
+
# DateTime.strptime('sat3feb014pm+7', '%a%d%b%y%H%p%z')
|
284
|
+
# #=> #<DateTime: 2001-02-03T16:00:00+07:00 ...>
|
285
|
+
#
|
286
|
+
# See also strptime(3) and #strftime.
|
287
|
+
#
|
288
|
+
def self.strptime: (String str, ?String format, ?Integer start) -> DateTime
|
289
|
+
|
290
|
+
# Creates a new DateTime object by parsing from a string according to some
|
291
|
+
# typical XML Schema formats.
|
292
|
+
#
|
293
|
+
# DateTime.xmlschema('2001-02-03T04:05:06+07:00')
|
294
|
+
# #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
295
|
+
#
|
296
|
+
def self.xmlschema: (String str, ?Integer start) -> DateTime
|
297
|
+
|
298
|
+
public
|
299
|
+
|
300
|
+
# Returns the hour (0-23).
|
301
|
+
#
|
302
|
+
# DateTime.new(2001,2,3,4,5,6).hour #=> 4
|
303
|
+
#
|
304
|
+
def hour: () -> Integer
|
305
|
+
|
306
|
+
# This method is equivalent to strftime('%FT%T%:z'). The optional argument `n`
|
307
|
+
# is the number of digits for fractional seconds.
|
308
|
+
#
|
309
|
+
# DateTime.parse('2001-02-03T04:05:06.123456789+07:00').iso8601(9)
|
310
|
+
# #=> "2001-02-03T04:05:06.123456789+07:00"
|
311
|
+
#
|
312
|
+
def iso8601: (?Integer n) -> String
|
313
|
+
|
314
|
+
# Returns a string in a JIS X 0301 format. The optional argument `n` is the
|
315
|
+
# number of digits for fractional seconds.
|
316
|
+
#
|
317
|
+
# DateTime.parse('2001-02-03T04:05:06.123456789+07:00').jisx0301(9)
|
318
|
+
# #=> "H13.02.03T04:05:06.123456789+07:00"
|
319
|
+
#
|
320
|
+
def jisx0301: (?Integer n) -> String
|
321
|
+
|
322
|
+
# Returns the minute (0-59).
|
323
|
+
#
|
324
|
+
# DateTime.new(2001,2,3,4,5,6).min #=> 5
|
325
|
+
#
|
326
|
+
def min: () -> Integer
|
327
|
+
|
328
|
+
# Returns the minute (0-59).
|
329
|
+
#
|
330
|
+
# DateTime.new(2001,2,3,4,5,6).min #=> 5
|
331
|
+
#
|
332
|
+
def minute: () -> Integer
|
333
|
+
|
334
|
+
# Duplicates self and resets its offset.
|
335
|
+
#
|
336
|
+
# d = DateTime.new(2001,2,3,4,5,6,'-02:00')
|
337
|
+
# #=> #<DateTime: 2001-02-03T04:05:06-02:00 ...>
|
338
|
+
# d.new_offset('+09:00') #=> #<DateTime: 2001-02-03T15:05:06+09:00 ...>
|
339
|
+
#
|
340
|
+
def new_offset: (?String offset) -> DateTime
|
341
|
+
|
342
|
+
# Returns the offset.
|
343
|
+
#
|
344
|
+
# DateTime.parse('04pm+0730').offset #=> (5/16)
|
345
|
+
#
|
346
|
+
def offset: () -> Rational
|
347
|
+
|
348
|
+
# This method is equivalent to strftime('%FT%T%:z'). The optional argument `n`
|
349
|
+
# is the number of digits for fractional seconds.
|
350
|
+
#
|
351
|
+
# DateTime.parse('2001-02-03T04:05:06.123456789+07:00').rfc3339(9)
|
352
|
+
# #=> "2001-02-03T04:05:06.123456789+07:00"
|
353
|
+
#
|
354
|
+
def rfc3339: (?Integer n) -> String
|
355
|
+
|
356
|
+
# Returns the second (0-59).
|
357
|
+
#
|
358
|
+
# DateTime.new(2001,2,3,4,5,6).sec #=> 6
|
359
|
+
#
|
360
|
+
def sec: () -> Integer
|
361
|
+
|
362
|
+
# Returns the fractional part of the second.
|
363
|
+
#
|
364
|
+
# DateTime.new(2001,2,3,4,5,6.5).sec_fraction #=> (1/2)
|
365
|
+
#
|
366
|
+
def sec_fraction: () -> Rational
|
367
|
+
|
368
|
+
# Returns the second (0-59).
|
369
|
+
#
|
370
|
+
# DateTime.new(2001,2,3,4,5,6).sec #=> 6
|
371
|
+
#
|
372
|
+
def second: () -> Integer
|
373
|
+
|
374
|
+
# Returns the fractional part of the second.
|
375
|
+
#
|
376
|
+
# DateTime.new(2001,2,3,4,5,6.5).sec_fraction #=> (1/2)
|
377
|
+
#
|
378
|
+
def second_fraction: () -> Rational
|
379
|
+
|
380
|
+
# Formats date according to the directives in the given format string. The
|
381
|
+
# directives begin with a percent (%) character. Any text not listed as a
|
382
|
+
# directive will be passed through to the output string.
|
383
|
+
#
|
384
|
+
# A directive consists of a percent (%) character, zero or more flags, an
|
385
|
+
# optional minimum field width, an optional modifier, and a conversion specifier
|
386
|
+
# as follows.
|
387
|
+
#
|
388
|
+
# %<flags><width><modifier><conversion>
|
389
|
+
#
|
390
|
+
# Flags:
|
391
|
+
# - don't pad a numerical output.
|
392
|
+
# _ use spaces for padding.
|
393
|
+
# 0 use zeros for padding.
|
394
|
+
# ^ upcase the result string.
|
395
|
+
# # change case.
|
396
|
+
# : use colons for %z.
|
397
|
+
#
|
398
|
+
# The minimum field width specifies the minimum width.
|
399
|
+
#
|
400
|
+
# The modifiers are "E" and "O". They are ignored.
|
401
|
+
#
|
402
|
+
# Format directives:
|
403
|
+
#
|
404
|
+
# Date (Year, Month, Day):
|
405
|
+
# %Y - Year with century (can be negative, 4 digits at least)
|
406
|
+
# -0001, 0000, 1995, 2009, 14292, etc.
|
407
|
+
# %C - year / 100 (round down. 20 in 2009)
|
408
|
+
# %y - year % 100 (00..99)
|
409
|
+
#
|
410
|
+
# %m - Month of the year, zero-padded (01..12)
|
411
|
+
# %_m blank-padded ( 1..12)
|
412
|
+
# %-m no-padded (1..12)
|
413
|
+
# %B - The full month name (``January'')
|
414
|
+
# %^B uppercased (``JANUARY'')
|
415
|
+
# %b - The abbreviated month name (``Jan'')
|
416
|
+
# %^b uppercased (``JAN'')
|
417
|
+
# %h - Equivalent to %b
|
418
|
+
#
|
419
|
+
# %d - Day of the month, zero-padded (01..31)
|
420
|
+
# %-d no-padded (1..31)
|
421
|
+
# %e - Day of the month, blank-padded ( 1..31)
|
422
|
+
#
|
423
|
+
# %j - Day of the year (001..366)
|
424
|
+
#
|
425
|
+
# Time (Hour, Minute, Second, Subsecond):
|
426
|
+
# %H - Hour of the day, 24-hour clock, zero-padded (00..23)
|
427
|
+
# %k - Hour of the day, 24-hour clock, blank-padded ( 0..23)
|
428
|
+
# %I - Hour of the day, 12-hour clock, zero-padded (01..12)
|
429
|
+
# %l - Hour of the day, 12-hour clock, blank-padded ( 1..12)
|
430
|
+
# %P - Meridian indicator, lowercase (``am'' or ``pm'')
|
431
|
+
# %p - Meridian indicator, uppercase (``AM'' or ``PM'')
|
432
|
+
#
|
433
|
+
# %M - Minute of the hour (00..59)
|
434
|
+
#
|
435
|
+
# %S - Second of the minute (00..60)
|
436
|
+
#
|
437
|
+
# %L - Millisecond of the second (000..999)
|
438
|
+
# %N - Fractional seconds digits, default is 9 digits (nanosecond)
|
439
|
+
# %3N millisecond (3 digits) %15N femtosecond (15 digits)
|
440
|
+
# %6N microsecond (6 digits) %18N attosecond (18 digits)
|
441
|
+
# %9N nanosecond (9 digits) %21N zeptosecond (21 digits)
|
442
|
+
# %12N picosecond (12 digits) %24N yoctosecond (24 digits)
|
443
|
+
#
|
444
|
+
# Time zone:
|
445
|
+
# %z - Time zone as hour and minute offset from UTC (e.g. +0900)
|
446
|
+
# %:z - hour and minute offset from UTC with a colon (e.g. +09:00)
|
447
|
+
# %::z - hour, minute and second offset from UTC (e.g. +09:00:00)
|
448
|
+
# %:::z - hour, minute and second offset from UTC
|
449
|
+
# (e.g. +09, +09:30, +09:30:30)
|
450
|
+
# %Z - Equivalent to %:z (e.g. +09:00)
|
451
|
+
#
|
452
|
+
# Weekday:
|
453
|
+
# %A - The full weekday name (``Sunday'')
|
454
|
+
# %^A uppercased (``SUNDAY'')
|
455
|
+
# %a - The abbreviated name (``Sun'')
|
456
|
+
# %^a uppercased (``SUN'')
|
457
|
+
# %u - Day of the week (Monday is 1, 1..7)
|
458
|
+
# %w - Day of the week (Sunday is 0, 0..6)
|
459
|
+
#
|
460
|
+
# ISO 8601 week-based year and week number:
|
461
|
+
# The week 1 of YYYY starts with a Monday and includes YYYY-01-04.
|
462
|
+
# The days in the year before the first week are in the last week of
|
463
|
+
# the previous year.
|
464
|
+
# %G - The week-based year
|
465
|
+
# %g - The last 2 digits of the week-based year (00..99)
|
466
|
+
# %V - Week number of the week-based year (01..53)
|
467
|
+
#
|
468
|
+
# Week number:
|
469
|
+
# The week 1 of YYYY starts with a Sunday or Monday (according to %U
|
470
|
+
# or %W). The days in the year before the first week are in week 0.
|
471
|
+
# %U - Week number of the year. The week starts with Sunday. (00..53)
|
472
|
+
# %W - Week number of the year. The week starts with Monday. (00..53)
|
473
|
+
#
|
474
|
+
# Seconds since the Unix Epoch:
|
475
|
+
# %s - Number of seconds since 1970-01-01 00:00:00 UTC.
|
476
|
+
# %Q - Number of milliseconds since 1970-01-01 00:00:00 UTC.
|
477
|
+
#
|
478
|
+
# Literal string:
|
479
|
+
# %n - Newline character (\n)
|
480
|
+
# %t - Tab character (\t)
|
481
|
+
# %% - Literal ``%'' character
|
482
|
+
#
|
483
|
+
# Combination:
|
484
|
+
# %c - date and time (%a %b %e %T %Y)
|
485
|
+
# %D - Date (%m/%d/%y)
|
486
|
+
# %F - The ISO 8601 date format (%Y-%m-%d)
|
487
|
+
# %v - VMS date (%e-%b-%Y)
|
488
|
+
# %x - Same as %D
|
489
|
+
# %X - Same as %T
|
490
|
+
# %r - 12-hour time (%I:%M:%S %p)
|
491
|
+
# %R - 24-hour time (%H:%M)
|
492
|
+
# %T - 24-hour time (%H:%M:%S)
|
493
|
+
# %+ - date(1) (%a %b %e %H:%M:%S %Z %Y)
|
494
|
+
#
|
495
|
+
# This method is similar to the strftime() function defined in ISO C and POSIX.
|
496
|
+
# Several directives (%a, %A, %b, %B, %c, %p, %r, %x, %X, %E*, %O* and %Z) are
|
497
|
+
# locale dependent in the function. However, this method is locale independent.
|
498
|
+
# So, the result may differ even if the same format string is used in other
|
499
|
+
# systems such as C. It is good practice to avoid %x and %X because there are
|
500
|
+
# corresponding locale independent representations, %D and %T.
|
501
|
+
#
|
502
|
+
# Examples:
|
503
|
+
#
|
504
|
+
# d = DateTime.new(2007,11,19,8,37,48,"-06:00")
|
505
|
+
# #=> #<DateTime: 2007-11-19T08:37:48-0600 ...>
|
506
|
+
# d.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007"
|
507
|
+
# d.strftime("at %I:%M%p") #=> "at 08:37AM"
|
508
|
+
#
|
509
|
+
# Various ISO 8601 formats:
|
510
|
+
# %Y%m%d => 20071119 Calendar date (basic)
|
511
|
+
# %F => 2007-11-19 Calendar date (extended)
|
512
|
+
# %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month
|
513
|
+
# %Y => 2007 Calendar date, reduced accuracy, specific year
|
514
|
+
# %C => 20 Calendar date, reduced accuracy, specific century
|
515
|
+
# %Y%j => 2007323 Ordinal date (basic)
|
516
|
+
# %Y-%j => 2007-323 Ordinal date (extended)
|
517
|
+
# %GW%V%u => 2007W471 Week date (basic)
|
518
|
+
# %G-W%V-%u => 2007-W47-1 Week date (extended)
|
519
|
+
# %GW%V => 2007W47 Week date, reduced accuracy, specific week (basic)
|
520
|
+
# %G-W%V => 2007-W47 Week date, reduced accuracy, specific week (extended)
|
521
|
+
# %H%M%S => 083748 Local time (basic)
|
522
|
+
# %T => 08:37:48 Local time (extended)
|
523
|
+
# %H%M => 0837 Local time, reduced accuracy, specific minute (basic)
|
524
|
+
# %H:%M => 08:37 Local time, reduced accuracy, specific minute (extended)
|
525
|
+
# %H => 08 Local time, reduced accuracy, specific hour
|
526
|
+
# %H%M%S,%L => 083748,000 Local time with decimal fraction, comma as decimal sign (basic)
|
527
|
+
# %T,%L => 08:37:48,000 Local time with decimal fraction, comma as decimal sign (extended)
|
528
|
+
# %H%M%S.%L => 083748.000 Local time with decimal fraction, full stop as decimal sign (basic)
|
529
|
+
# %T.%L => 08:37:48.000 Local time with decimal fraction, full stop as decimal sign (extended)
|
530
|
+
# %H%M%S%z => 083748-0600 Local time and the difference from UTC (basic)
|
531
|
+
# %T%:z => 08:37:48-06:00 Local time and the difference from UTC (extended)
|
532
|
+
# %Y%m%dT%H%M%S%z => 20071119T083748-0600 Date and time of day for calendar date (basic)
|
533
|
+
# %FT%T%:z => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended)
|
534
|
+
# %Y%jT%H%M%S%z => 2007323T083748-0600 Date and time of day for ordinal date (basic)
|
535
|
+
# %Y-%jT%T%:z => 2007-323T08:37:48-06:00 Date and time of day for ordinal date (extended)
|
536
|
+
# %GW%V%uT%H%M%S%z => 2007W471T083748-0600 Date and time of day for week date (basic)
|
537
|
+
# %G-W%V-%uT%T%:z => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended)
|
538
|
+
# %Y%m%dT%H%M => 20071119T0837 Calendar date and local time (basic)
|
539
|
+
# %FT%R => 2007-11-19T08:37 Calendar date and local time (extended)
|
540
|
+
# %Y%jT%H%MZ => 2007323T0837Z Ordinal date and UTC of day (basic)
|
541
|
+
# %Y-%jT%RZ => 2007-323T08:37Z Ordinal date and UTC of day (extended)
|
542
|
+
# %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic)
|
543
|
+
# %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended)
|
544
|
+
#
|
545
|
+
# See also strftime(3) and ::strptime.
|
546
|
+
#
|
547
|
+
def strftime: (?String format) -> String
|
548
|
+
|
549
|
+
# Returns a Date object which denotes self.
|
550
|
+
#
|
551
|
+
def to_date: () -> Date
|
552
|
+
|
553
|
+
# Returns self.
|
554
|
+
#
|
555
|
+
def to_datetime: () -> DateTime
|
556
|
+
|
557
|
+
# Returns a string in an ISO 8601 format. (This method doesn't use the expanded
|
558
|
+
# representations.)
|
559
|
+
#
|
560
|
+
# DateTime.new(2001,2,3,4,5,6,'-7').to_s
|
561
|
+
# #=> "2001-02-03T04:05:06-07:00"
|
562
|
+
#
|
563
|
+
def to_s: () -> String
|
564
|
+
|
565
|
+
# Returns a Time object which denotes self.
|
566
|
+
#
|
567
|
+
def to_time: () -> Time
|
568
|
+
|
569
|
+
# This method is equivalent to strftime('%FT%T%:z'). The optional argument `n`
|
570
|
+
# is the number of digits for fractional seconds.
|
571
|
+
#
|
572
|
+
# DateTime.parse('2001-02-03T04:05:06.123456789+07:00').iso8601(9)
|
573
|
+
# #=> "2001-02-03T04:05:06.123456789+07:00"
|
574
|
+
#
|
575
|
+
def xmlschema: (?Integer n) -> String
|
576
|
+
|
577
|
+
# Returns the timezone.
|
578
|
+
#
|
579
|
+
# DateTime.parse('04pm+0730').zone #=> "+07:30"
|
580
|
+
#
|
581
|
+
def zone: () -> String
|
582
|
+
end
|