rbs 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -130,7 +130,6 @@ module RBS
130
130
  types: types,
131
131
  kind: kind,
132
132
  comment: comments[node.first_lineno - 1],
133
- attributes: [],
134
133
  overload: false
135
134
  )
136
135
 
@@ -173,7 +173,6 @@ module RBS
173
173
  types: types,
174
174
  kind: :singleton,
175
175
  comment: comment,
176
- attributes: [],
177
176
  overload: false
178
177
  )
179
178
  end
@@ -194,7 +193,6 @@ module RBS
194
193
  types: types,
195
194
  kind: :instance,
196
195
  comment: comment,
197
- attributes: [],
198
196
  overload: false
199
197
  )
200
198
  end
@@ -154,7 +154,6 @@ module RBS
154
154
  location: nil,
155
155
  comment: method.comments[0],
156
156
  annotations: method.annotations,
157
- attributes: method.attributes,
158
157
  overload: false
159
158
  )
160
159
  return
@@ -193,7 +192,6 @@ module RBS
193
192
  location: nil,
194
193
  comment: nil,
195
194
  annotations: [],
196
- attributes: [],
197
195
  overload: false
198
196
  )
199
197
  end
@@ -227,7 +225,6 @@ module RBS
227
225
  location: nil,
228
226
  comment: nil,
229
227
  annotations: [],
230
- attributes: [],
231
228
  overload: false
232
229
  )
233
230
  end
@@ -262,7 +259,6 @@ module RBS
262
259
  location: nil,
263
260
  comment: nil,
264
261
  annotations: [],
265
- attributes: [],
266
262
  overload: false
267
263
  )
268
264
  end
@@ -13,6 +13,8 @@ begin
13
13
  skips = (ENV['RBS_TEST_SKIP'] || '').split(',').map! { |e| e.strip }
14
14
  RBS.logger_level = (ENV["RBS_TEST_LOGLEVEL"] || "info")
15
15
  sample_size = get_sample_size(ENV['RBS_TEST_SAMPLE_SIZE'] || '')
16
+ double_class = to_double_class(ENV['RBS_TEST_DOUBLE_SUITE'])
17
+ unchecked_classes = (ENV['RBS_TEST_UNCHECKED_CLASSES'] || '').split(',').map! { |unchecked_class| unchecked_class.strip }.push(*double_class)
16
18
  rescue InvalidSampleSizeError => exception
17
19
  RBS.logger.error exception.message
18
20
  exit 1
@@ -25,6 +27,8 @@ if filter.empty?
25
27
  STDERR.puts " [OPTIONAL] RBS_TEST_OPT: options for signatures (`-r` for libraries or `-I` for signatures)"
26
28
  STDERR.puts " [OPTIONAL] RBS_TEST_LOGLEVEL: one of debug|info|warn|error|fatal (defaults to info)"
27
29
  STDERR.puts " [OPTIONAL] RBS_TEST_SAMPLE_SIZE: sets the amount of values in a collection to be type-checked (Set to `ALL` to type check all the values)"
30
+ STDERR.puts " [OPTIONAL] RBS_TEST_DOUBLE_SUITE: sets the double suite in use (currently supported: minitest | rspec)"
31
+ STDERR.puts " [OPTIONAL] RBS_TEST_UNCHECKED_CLASSES: sets the classes that would not be checked"
28
32
  exit 1
29
33
  end
30
34
 
@@ -60,7 +64,7 @@ TracePoint.trace :end do |tp|
60
64
  if filter.any? {|f| match(to_absolute_typename(f).to_s, class_name.to_s) } && skips.none? {|f| match(f, class_name.to_s) }
61
65
  if env.class_decls.key?(class_name)
62
66
  logger.info "Setting up hooks for #{class_name}"
63
- tester.install!(tp.self, sample_size: sample_size)
67
+ tester.install!(tp.self, sample_size: sample_size, unchecked_classes: unchecked_classes)
64
68
  end
65
69
  end
66
70
  end
@@ -24,6 +24,21 @@ module RBS
24
24
  int_size
25
25
  end
26
26
  end
27
+
28
+ def to_double_class(double_suite)
29
+ return nil unless double_suite
30
+
31
+ case double_suite.downcase.strip
32
+ when 'rspec'
33
+ ['::RSpec::Mocks::Double']
34
+ when 'minitest'
35
+ ['::Minitest::Mock']
36
+ else
37
+ RBS.logger.warn "Unknown test suite - defaults to nil"
38
+ nil
39
+ end
40
+ end
41
+
27
42
  end
28
43
  end
29
44
  end
@@ -37,7 +37,7 @@ module RBS
37
37
  end
38
38
  end
39
39
 
40
- def install!(klass, sample_size:)
40
+ def install!(klass, sample_size:, unchecked_classes:)
41
41
  RBS.logger.info { "Installing runtime type checker in #{klass}..." }
42
42
 
43
43
  type_name = factory.type_name(klass.name).absolute!
@@ -45,7 +45,7 @@ module RBS
45
45
  builder.build_instance(type_name).tap do |definition|
46
46
  instance_key = new_key(type_name, "InstanceChecker")
47
47
  tester, set = instance_testers[klass] ||= [
48
- MethodCallTester.new(klass, builder, definition, kind: :instance, sample_size: sample_size),
48
+ MethodCallTester.new(klass, builder, definition, kind: :instance, sample_size: sample_size, unchecked_classes: unchecked_classes),
49
49
  Set[]
50
50
  ]
51
51
  Observer.register(instance_key, tester)
@@ -68,7 +68,7 @@ module RBS
68
68
  builder.build_singleton(type_name).tap do |definition|
69
69
  singleton_key = new_key(type_name, "SingletonChecker")
70
70
  tester, set = singleton_testers[klass] ||= [
71
- MethodCallTester.new(klass.singleton_class, builder, definition, kind: :singleton, sample_size: sample_size),
71
+ MethodCallTester.new(klass.singleton_class, builder, definition, kind: :singleton, sample_size: sample_size, unchecked_classes: unchecked_classes),
72
72
  Set[]
73
73
  ]
74
74
  Observer.register(singleton_key, tester)
@@ -111,13 +111,15 @@ module RBS
111
111
  attr_reader :builder
112
112
  attr_reader :kind
113
113
  attr_reader :sample_size
114
+ attr_reader :unchecked_classes
114
115
 
115
- def initialize(self_class, builder, definition, kind:, sample_size:)
116
+ def initialize(self_class, builder, definition, kind:, sample_size:, unchecked_classes:)
116
117
  @self_class = self_class
117
118
  @definition = definition
118
119
  @builder = builder
119
120
  @kind = kind
120
121
  @sample_size = sample_size
122
+ @unchecked_classes = unchecked_classes
121
123
  end
122
124
 
123
125
  def env
@@ -125,7 +127,7 @@ module RBS
125
127
  end
126
128
 
127
129
  def check
128
- @check ||= TypeCheck.new(self_class: self_class, builder: builder, sample_size: sample_size)
130
+ @check ||= TypeCheck.new(self_class: self_class, builder: builder, sample_size: sample_size, unchecked_classes: unchecked_classes)
129
131
  end
130
132
 
131
133
  def format_method_name(name)
@@ -4,15 +4,17 @@ module RBS
4
4
  attr_reader :self_class
5
5
  attr_reader :builder
6
6
  attr_reader :sample_size
7
+ attr_reader :unchecked_classes
7
8
 
8
9
  attr_reader :const_cache
9
10
 
10
11
  DEFAULT_SAMPLE_SIZE = 100
11
12
 
12
- def initialize(self_class:, builder:, sample_size:)
13
+ def initialize(self_class:, builder:, sample_size:, unchecked_classes:)
13
14
  @self_class = self_class
14
15
  @builder = builder
15
16
  @sample_size = sample_size
17
+ @unchecked_classes = unchecked_classes.uniq
16
18
  @const_cache = {}
17
19
  end
18
20
 
@@ -203,7 +205,16 @@ module RBS
203
205
  const_cache[type_name] ||= Object.const_get(type_name.to_s)
204
206
  end
205
207
 
208
+ def is_double?(value)
209
+ unchecked_classes.any? { |unchecked_class| Test.call(value, IS_AP, Object.const_get(unchecked_class))}
210
+ end
211
+
206
212
  def value(val, type)
213
+ if is_double?(val)
214
+ RBS.logger.info("A double (#{val.inspect}) is detected!")
215
+ return true
216
+ end
217
+
207
218
  case type
208
219
  when Types::Bases::Any
209
220
  true
@@ -295,7 +306,8 @@ module RBS
295
306
  Test.call(val, IS_AP, ::Array) &&
296
307
  type.types.map.with_index {|ty, index| value(val[index], ty) }.all?
297
308
  when Types::Record
298
- Test::call(val, IS_AP, ::Hash)
309
+ Test::call(val, IS_AP, ::Hash) &&
310
+ type.fields.map {|key, type| value(val[key], type) }.all?
299
311
  when Types::Proc
300
312
  Test::call(val, IS_AP, ::Proc)
301
313
  else
@@ -1,3 +1,3 @@
1
1
  module RBS
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
@@ -250,8 +250,7 @@ module RBS
250
250
 
251
251
  string = ""
252
252
 
253
- attrs = member.attributes.empty? ? "" : member.attributes.join(" ") + " "
254
- prefix = "#{attrs}def #{name}:"
253
+ prefix = "def #{name}:"
255
254
  padding = " " * (prefix.size-1)
256
255
 
257
256
  string << prefix
@@ -626,7 +626,8 @@ class Array[unchecked out Elem] < Object
626
626
  # a.collect!.with_index {|x, i| x[0...i] }
627
627
  # a #=> ["", "b", "c!", "d!"]
628
628
  #
629
- def collect!: () { (Elem item) -> Elem } -> self # collect! is monomorphic because of RBS limitation.
629
+ # collect! is monomorphic because of RBS limitation.
630
+ def collect!: () { (Elem item) -> Elem } -> self
630
631
  | () -> ::Enumerator[Elem, self]
631
632
 
632
633
  # When invoked with a block, yields all combinations of length `n` of elements
@@ -1016,7 +1016,7 @@ class Hash[unchecked out K, unchecked out V] < Object
1016
1016
  # h["d"] #=> "Go Fish: d"
1017
1017
  # h.keys #=> ["c", "d"]
1018
1018
  #
1019
- incompatible def initialize: () -> void
1019
+ def initialize: () -> void
1020
1020
  | (untyped default) -> void
1021
1021
  | [A, B] () { (Hash[A, B] hash, A key) -> B } -> void
1022
1022
 
@@ -0,0 +1,1056 @@
1
+ # date and datetime class - Tadayoshi Funaba 1998-2011
2
+ #
3
+ # 'date' provides two classes: Date and DateTime.
4
+ #
5
+ # ## Terms and Definitions
6
+ #
7
+ # Some terms and definitions are based on ISO 8601 and JIS X 0301.
8
+ #
9
+ # ### Calendar Date
10
+ #
11
+ # The calendar date is a particular day of a calendar year, identified by its
12
+ # ordinal number within a calendar month within that year.
13
+ #
14
+ # In those classes, this is so-called "civil".
15
+ #
16
+ # ### Ordinal Date
17
+ #
18
+ # The ordinal date is a particular day of a calendar year identified by its
19
+ # ordinal number within the year.
20
+ #
21
+ # In those classes, this is so-called "ordinal".
22
+ #
23
+ # ### Week Date
24
+ #
25
+ # The week date is a date identified by calendar week and day numbers.
26
+ #
27
+ # The calendar week is a seven day period within a calendar year, starting on a
28
+ # Monday and identified by its ordinal number within the year; the first
29
+ # calendar week of the year is the one that includes the first Thursday of that
30
+ # year. In the Gregorian calendar, this is equivalent to the week which includes
31
+ # January 4.
32
+ #
33
+ # In those classes, this is so-called "commercial".
34
+ #
35
+ # ### Julian Day Number
36
+ #
37
+ # The Julian day number is in elapsed days since noon (Greenwich Mean Time) on
38
+ # January 1, 4713 BCE (in the Julian calendar).
39
+ #
40
+ # In this document, the astronomical Julian day number is the same as the
41
+ # original Julian day number. And the chronological Julian day number is a
42
+ # variation of the Julian day number. Its days begin at midnight on local time.
43
+ #
44
+ # In this document, when the term "Julian day number" simply appears, it just
45
+ # refers to "chronological Julian day number", not the original.
46
+ #
47
+ # In those classes, those are so-called "ajd" and "jd".
48
+ #
49
+ # ### Modified Julian Day Number
50
+ #
51
+ # The modified Julian day number is in elapsed days since midnight (Coordinated
52
+ # Universal Time) on November 17, 1858 CE (in the Gregorian calendar).
53
+ #
54
+ # In this document, the astronomical modified Julian day number is the same as
55
+ # the original modified Julian day number. And the chronological modified Julian
56
+ # day number is a variation of the modified Julian day number. Its days begin at
57
+ # midnight on local time.
58
+ #
59
+ # In this document, when the term "modified Julian day number" simply appears,
60
+ # it just refers to "chronological modified Julian day number", not the
61
+ # original.
62
+ #
63
+ # In those classes, those are so-called "amjd" and "mjd".
64
+ #
65
+ # ## Date
66
+ #
67
+ # A subclass of Object that includes the Comparable module and easily handles
68
+ # date.
69
+ #
70
+ # A Date object is created with Date::new, Date::jd, Date::ordinal,
71
+ # Date::commercial, Date::parse, Date::strptime, Date::today, Time#to_date, etc.
72
+ #
73
+ # require 'date'
74
+ #
75
+ # Date.new(2001,2,3)
76
+ # #=> #<Date: 2001-02-03 ...>
77
+ # Date.jd(2451944)
78
+ # #=> #<Date: 2001-02-03 ...>
79
+ # Date.ordinal(2001,34)
80
+ # #=> #<Date: 2001-02-03 ...>
81
+ # Date.commercial(2001,5,6)
82
+ # #=> #<Date: 2001-02-03 ...>
83
+ # Date.parse('2001-02-03')
84
+ # #=> #<Date: 2001-02-03 ...>
85
+ # Date.strptime('03-02-2001', '%d-%m-%Y')
86
+ # #=> #<Date: 2001-02-03 ...>
87
+ # Time.new(2001,2,3).to_date
88
+ # #=> #<Date: 2001-02-03 ...>
89
+ #
90
+ # All date objects are immutable; hence cannot modify themselves.
91
+ #
92
+ # The concept of a date object can be represented as a tuple of the day count,
93
+ # the offset and the day of calendar reform.
94
+ #
95
+ # The day count denotes the absolute position of a temporal dimension. The
96
+ # offset is relative adjustment, which determines decoded local time with the
97
+ # day count. The day of calendar reform denotes the start day of the new style.
98
+ # The old style of the West is the Julian calendar which was adopted by Caesar.
99
+ # The new style is the Gregorian calendar, which is the current civil calendar
100
+ # of many countries.
101
+ #
102
+ # The day count is virtually the astronomical Julian day number. The offset in
103
+ # this class is usually zero, and cannot be specified directly.
104
+ #
105
+ # A Date object can be created with an optional argument, the day of calendar
106
+ # reform as a Julian day number, which should be 2298874 to 2426355 or
107
+ # negative/positive infinity. The default value is `Date::ITALY`
108
+ # (2299161=1582-10-15). See also sample/cal.rb.
109
+ #
110
+ # $ ruby sample/cal.rb -c it 10 1582
111
+ # October 1582
112
+ # S M Tu W Th F S
113
+ # 1 2 3 4 15 16
114
+ # 17 18 19 20 21 22 23
115
+ # 24 25 26 27 28 29 30
116
+ # 31
117
+ #
118
+ # $ ruby sample/cal.rb -c gb 9 1752
119
+ # September 1752
120
+ # S M Tu W Th F S
121
+ # 1 2 14 15 16
122
+ # 17 18 19 20 21 22 23
123
+ # 24 25 26 27 28 29 30
124
+ #
125
+ # A Date object has various methods. See each reference.
126
+ #
127
+ # d = Date.parse('3rd Feb 2001')
128
+ # #=> #<Date: 2001-02-03 ...>
129
+ # d.year #=> 2001
130
+ # d.mon #=> 2
131
+ # d.mday #=> 3
132
+ # d.wday #=> 6
133
+ # d += 1 #=> #<Date: 2001-02-04 ...>
134
+ # d.strftime('%a %d %b %Y') #=> "Sun 04 Feb 2001"
135
+ #
136
+ class Date
137
+ # Creates a date object denoting the given calendar date.
138
+ #
139
+ # In this class, BCE years are counted astronomically. Thus, the year before
140
+ # the year 1 is the year zero, and the year preceding the year zero is the year
141
+ # -1. The month and the day of month should be a negative or a positive number
142
+ # (as a relative month/day from the end of year/month when negative). They
143
+ # should not be zero.
144
+ #
145
+ # The last argument should be a Julian day number which denotes the day of
146
+ # calendar reform. Date::ITALY (2299161=1582-10-15), Date::ENGLAND
147
+ # (2361222=1752-09-14), Date::GREGORIAN (the proleptic Gregorian calendar) and
148
+ # Date::JULIAN (the proleptic Julian calendar) can be specified as a day of
149
+ # calendar reform.
150
+ #
151
+ # Date.new(2001) #=> #<Date: 2001-01-01 ...>
152
+ # Date.new(2001,2,3) #=> #<Date: 2001-02-03 ...>
153
+ # Date.new(2001,2,-1) #=> #<Date: 2001-02-28 ...>
154
+ #
155
+ # See also ::jd.
156
+ #
157
+ def initialize: (?Integer year, ?Integer month, ?Integer mday, ?Integer start) -> void
158
+
159
+ include Comparable
160
+
161
+ # Returns a hash of parsed elements.
162
+ #
163
+ def self._httpdate: (String str) -> Hash[Symbol, Integer]
164
+
165
+ # Returns a hash of parsed elements.
166
+ #
167
+ def self._iso8601: (String str) -> Hash[Symbol, Integer]
168
+
169
+ # Returns a hash of parsed elements.
170
+ #
171
+ def self._jisx0301: (String str) -> Hash[Symbol, Integer]
172
+
173
+ # Parses the given representation of date and time, and returns a hash of parsed
174
+ # elements. This method does not function as a validator.
175
+ #
176
+ # If the optional second argument is true and the detected year is in the range
177
+ # "00" to "99", considers the year a 2-digit form and makes it full.
178
+ #
179
+ # Date._parse('2001-02-03') #=> {:year=>2001, :mon=>2, :mday=>3}
180
+ #
181
+ def self._parse: (String str, ?bool complete) -> Hash[Symbol, Integer]
182
+
183
+ # Returns a hash of parsed elements.
184
+ #
185
+ def self._rfc2822: (String str) -> Hash[Symbol, Integer | String]
186
+
187
+ # Returns a hash of parsed elements.
188
+ #
189
+ def self._rfc3339: (String str) -> Hash[Symbol, Integer | String]
190
+
191
+ # Returns a hash of parsed elements.
192
+ #
193
+ def self._rfc822: (String str) -> Hash[Symbol, Integer | String]
194
+
195
+ # Parses the given representation of date and time with the given template, and
196
+ # returns a hash of parsed elements. _strptime does not support specification
197
+ # of flags and width unlike strftime.
198
+ #
199
+ # Date._strptime('2001-02-03', '%Y-%m-%d')
200
+ # #=> {:year=>2001, :mon=>2, :mday=>3}
201
+ #
202
+ # See also strptime(3) and #strftime.
203
+ #
204
+ def self._strptime: (String str, ?String format) -> Hash[Symbol, Integer]
205
+
206
+ # Returns a hash of parsed elements.
207
+ #
208
+ def self._xmlschema: (String str) -> Hash[Symbol, Integer]
209
+
210
+ # Creates a date object denoting the given calendar date.
211
+ #
212
+ # In this class, BCE years are counted astronomically. Thus, the year before
213
+ # the year 1 is the year zero, and the year preceding the year zero is the year
214
+ # -1. The month and the day of month should be a negative or a positive number
215
+ # (as a relative month/day from the end of year/month when negative). They
216
+ # should not be zero.
217
+ #
218
+ # The last argument should be a Julian day number which denotes the day of
219
+ # calendar reform. Date::ITALY (2299161=1582-10-15), Date::ENGLAND
220
+ # (2361222=1752-09-14), Date::GREGORIAN (the proleptic Gregorian calendar) and
221
+ # Date::JULIAN (the proleptic Julian calendar) can be specified as a day of
222
+ # calendar reform.
223
+ #
224
+ # Date.new(2001) #=> #<Date: 2001-01-01 ...>
225
+ # Date.new(2001,2,3) #=> #<Date: 2001-02-03 ...>
226
+ # Date.new(2001,2,-1) #=> #<Date: 2001-02-28 ...>
227
+ #
228
+ # See also ::jd.
229
+ #
230
+ def self.civil: (?Integer year, ?Integer month, ?Integer mday, ?Integer start) -> Date
231
+
232
+ # Creates a date object denoting the given week date.
233
+ #
234
+ # The week and the day of week should be a negative or a positive number (as a
235
+ # relative week/day from the end of year/week when negative). They should not
236
+ # be zero.
237
+ #
238
+ # Date.commercial(2001) #=> #<Date: 2001-01-01 ...>
239
+ # Date.commercial(2002) #=> #<Date: 2001-12-31 ...>
240
+ # Date.commercial(2001,5,6) #=> #<Date: 2001-02-03 ...>
241
+ #
242
+ # See also ::jd and ::new.
243
+ #
244
+ def self.commercial: (?Integer cwyear, ?Integer cweek, ?Integer cwday, ?Integer start) -> Date
245
+
246
+ # Returns true if the given year is a leap year of the proleptic Gregorian
247
+ # calendar.
248
+ #
249
+ # Date.gregorian_leap?(1900) #=> false
250
+ # Date.gregorian_leap?(2000) #=> true
251
+ #
252
+ def self.gregorian_leap?: (Integer year) -> bool
253
+
254
+ # Creates a new Date object by parsing from a string according to some RFC 2616
255
+ # format.
256
+ #
257
+ # Date.httpdate('Sat, 03 Feb 2001 00:00:00 GMT')
258
+ # #=> #<Date: 2001-02-03 ...>
259
+ #
260
+ def self.httpdate: (String str, ?Integer start) -> Date
261
+
262
+ # Creates a new Date object by parsing from a string according to some typical
263
+ # ISO 8601 formats.
264
+ #
265
+ # Date.iso8601('2001-02-03') #=> #<Date: 2001-02-03 ...>
266
+ # Date.iso8601('20010203') #=> #<Date: 2001-02-03 ...>
267
+ # Date.iso8601('2001-W05-6') #=> #<Date: 2001-02-03 ...>
268
+ #
269
+ def self.iso8601: (String str, ?Integer start) -> Date
270
+
271
+ # Creates a date object denoting the given chronological Julian day number.
272
+ #
273
+ # Date.jd(2451944) #=> #<Date: 2001-02-03 ...>
274
+ # Date.jd(2451945) #=> #<Date: 2001-02-04 ...>
275
+ # Date.jd(0) #=> #<Date: -4712-01-01 ...>
276
+ #
277
+ # See also ::new.
278
+ #
279
+ def self.jd: (Integer jd, ?Integer start) -> Date
280
+
281
+ # Creates a new Date object by parsing from a string according to some typical
282
+ # JIS X 0301 formats.
283
+ #
284
+ # Date.jisx0301('H13.02.03') #=> #<Date: 2001-02-03 ...>
285
+ #
286
+ # For no-era year, legacy format, Heisei is assumed.
287
+ #
288
+ # Date.jisx0301('13.02.03') #=> #<Date: 2001-02-03 ...>
289
+ #
290
+ def self.jisx0301: (String str, ?Integer start) -> Date
291
+
292
+ # Returns true if the given year is a leap year of the proleptic Julian
293
+ # calendar.
294
+ #
295
+ # Date.julian_leap?(1900) #=> true
296
+ # Date.julian_leap?(1901) #=> false
297
+ #
298
+ def self.julian_leap?: (Integer year) -> bool
299
+
300
+ # Returns true if the given year is a leap year of the proleptic Gregorian
301
+ # calendar.
302
+ #
303
+ # Date.gregorian_leap?(1900) #=> false
304
+ # Date.gregorian_leap?(2000) #=> true
305
+ #
306
+ def self.leap?: (Integer year) -> bool
307
+
308
+ # Creates a date object denoting the given ordinal date.
309
+ #
310
+ # The day of year should be a negative or a positive number (as a relative day
311
+ # from the end of year when negative). It should not be zero.
312
+ #
313
+ # Date.ordinal(2001) #=> #<Date: 2001-01-01 ...>
314
+ # Date.ordinal(2001,34) #=> #<Date: 2001-02-03 ...>
315
+ # Date.ordinal(2001,-1) #=> #<Date: 2001-12-31 ...>
316
+ #
317
+ # See also ::jd and ::new.
318
+ #
319
+ def self.ordinal: (?Integer year, ?Integer yday, ?Integer start) -> Date
320
+
321
+ # Parses the given representation of date and time, and creates a date object.
322
+ # This method does not function as a validator.
323
+ #
324
+ # If the optional second argument is true and the detected year is in the range
325
+ # "00" to "99", considers the year a 2-digit form and makes it full.
326
+ #
327
+ # Date.parse('2001-02-03') #=> #<Date: 2001-02-03 ...>
328
+ # Date.parse('20010203') #=> #<Date: 2001-02-03 ...>
329
+ # Date.parse('3rd Feb 2001') #=> #<Date: 2001-02-03 ...>
330
+ #
331
+ def self.parse: (String str, ?bool complete, ?Integer start) -> Date
332
+
333
+ # Creates a new Date object by parsing from a string according to some typical
334
+ # RFC 2822 formats.
335
+ #
336
+ # Date.rfc2822('Sat, 3 Feb 2001 00:00:00 +0000')
337
+ # #=> #<Date: 2001-02-03 ...>
338
+ #
339
+ def self.rfc2822: (String str, ?Integer start) -> Date
340
+
341
+ # Creates a new Date object by parsing from a string according to some typical
342
+ # RFC 3339 formats.
343
+ #
344
+ # Date.rfc3339('2001-02-03T04:05:06+07:00') #=> #<Date: 2001-02-03 ...>
345
+ #
346
+ def self.rfc3339: (String str, ?Integer start) -> Date
347
+
348
+ # Creates a new Date object by parsing from a string according to some typical
349
+ # RFC 2822 formats.
350
+ #
351
+ # Date.rfc2822('Sat, 3 Feb 2001 00:00:00 +0000')
352
+ # #=> #<Date: 2001-02-03 ...>
353
+ #
354
+ def self.rfc822: (String str, ?Integer start) -> Date
355
+
356
+ # Parses the given representation of date and time with the given template, and
357
+ # creates a date object. strptime does not support specification of flags and
358
+ # width unlike strftime.
359
+ #
360
+ # Date.strptime('2001-02-03', '%Y-%m-%d') #=> #<Date: 2001-02-03 ...>
361
+ # Date.strptime('03-02-2001', '%d-%m-%Y') #=> #<Date: 2001-02-03 ...>
362
+ # Date.strptime('2001-034', '%Y-%j') #=> #<Date: 2001-02-03 ...>
363
+ # Date.strptime('2001-W05-6', '%G-W%V-%u') #=> #<Date: 2001-02-03 ...>
364
+ # Date.strptime('2001 04 6', '%Y %U %w') #=> #<Date: 2001-02-03 ...>
365
+ # Date.strptime('2001 05 6', '%Y %W %u') #=> #<Date: 2001-02-03 ...>
366
+ # Date.strptime('sat3feb01', '%a%d%b%y') #=> #<Date: 2001-02-03 ...>
367
+ #
368
+ # See also strptime(3) and #strftime.
369
+ #
370
+ def self.strptime: (String str, ?String format, ?Integer start) -> Date
371
+
372
+ # Creates a date object denoting the present day.
373
+ #
374
+ # Date.today #=> #<Date: 2011-06-11 ...>
375
+ #
376
+ def self.today: (?Integer start) -> Date
377
+
378
+ # Returns true if the given calendar date is valid, and false if not. Valid in
379
+ # this context is whether the arguments passed to this method would be accepted
380
+ # by ::new.
381
+ #
382
+ # Date.valid_date?(2001,2,3) #=> true
383
+ # Date.valid_date?(2001,2,29) #=> false
384
+ # Date.valid_date?(2001,2,-1) #=> true
385
+ #
386
+ # See also ::jd and ::civil.
387
+ #
388
+ def self.valid_civil?: (Integer year, Integer month, Integer mday, ?Integer start) -> bool
389
+
390
+ # Returns true if the given week date is valid, and false if not.
391
+ #
392
+ # Date.valid_commercial?(2001,5,6) #=> true
393
+ # Date.valid_commercial?(2001,5,8) #=> false
394
+ #
395
+ # See also ::jd and ::commercial.
396
+ #
397
+ def self.valid_commercial?: (Integer cwyear, Integer cweek, Integer cwday, ?Integer start) -> bool
398
+
399
+ # Returns true if the given calendar date is valid, and false if not. Valid in
400
+ # this context is whether the arguments passed to this method would be accepted
401
+ # by ::new.
402
+ #
403
+ # Date.valid_date?(2001,2,3) #=> true
404
+ # Date.valid_date?(2001,2,29) #=> false
405
+ # Date.valid_date?(2001,2,-1) #=> true
406
+ #
407
+ # See also ::jd and ::civil.
408
+ #
409
+ def self.valid_date?: (Integer year, Integer month, Integer mday, ?Integer start) -> bool
410
+
411
+ # Just returns true. It's nonsense, but is for symmetry.
412
+ #
413
+ # Date.valid_jd?(2451944) #=> true
414
+ #
415
+ # See also ::jd.
416
+ #
417
+ def self.valid_jd?: (Integer jd, ?Integer start) -> bool
418
+
419
+ # Returns true if the given ordinal date is valid, and false if not.
420
+ #
421
+ # Date.valid_ordinal?(2001,34) #=> true
422
+ # Date.valid_ordinal?(2001,366) #=> false
423
+ #
424
+ # See also ::jd and ::ordinal.
425
+ #
426
+ def self.valid_ordinal?: (Integer year, Integer yday, ?Integer start) -> bool
427
+
428
+ # Creates a new Date object by parsing from a string according to some typical
429
+ # XML Schema formats.
430
+ #
431
+ # Date.xmlschema('2001-02-03') #=> #<Date: 2001-02-03 ...>
432
+ #
433
+ def self.xmlschema: (String str, ?Integer start) -> Date
434
+
435
+ public
436
+
437
+ # Returns a date object pointing `other` days after self. The other should be a
438
+ # numeric value. If the other is a fractional number, assumes its precision is
439
+ # at most nanosecond.
440
+ #
441
+ # Date.new(2001,2,3) + 1 #=> #<Date: 2001-02-04 ...>
442
+ # DateTime.new(2001,2,3) + Rational(1,2)
443
+ # #=> #<DateTime: 2001-02-03T12:00:00+00:00 ...>
444
+ # DateTime.new(2001,2,3) + Rational(-1,2)
445
+ # #=> #<DateTime: 2001-02-02T12:00:00+00:00 ...>
446
+ # DateTime.jd(0,12) + DateTime.new(2001,2,3).ajd
447
+ # #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
448
+ #
449
+ def +: (Integer | Rational other) -> Date
450
+
451
+ # Returns the difference between the two dates if the other is a date object.
452
+ # If the other is a numeric value, returns a date object pointing `other` days
453
+ # before self. If the other is a fractional number, assumes its precision is at
454
+ # most nanosecond.
455
+ #
456
+ # Date.new(2001,2,3) - 1 #=> #<Date: 2001-02-02 ...>
457
+ # DateTime.new(2001,2,3) - Rational(1,2)
458
+ # #=> #<DateTime: 2001-02-02T12:00:00+00:00 ...>
459
+ # Date.new(2001,2,3) - Date.new(2001)
460
+ # #=> (33/1)
461
+ # DateTime.new(2001,2,3) - DateTime.new(2001,2,2,12)
462
+ # #=> (1/2)
463
+ #
464
+ def -: (Integer | Rational other) -> Date
465
+ | (Date other) -> Rational
466
+
467
+ # Returns a date object pointing `n` months before self. The argument `n` should
468
+ # be a numeric value.
469
+ #
470
+ # Date.new(2001,2,3) << 1 #=> #<Date: 2001-01-03 ...>
471
+ # Date.new(2001,2,3) << -2 #=> #<Date: 2001-04-03 ...>
472
+ #
473
+ # When the same day does not exist for the corresponding month, the last day of
474
+ # the month is used instead:
475
+ #
476
+ # Date.new(2001,3,28) << 1 #=> #<Date: 2001-02-28 ...>
477
+ # Date.new(2001,3,31) << 1 #=> #<Date: 2001-02-28 ...>
478
+ #
479
+ # This also results in the following, possibly unexpected, behavior:
480
+ #
481
+ # Date.new(2001,3,31) << 2 #=> #<Date: 2001-01-31 ...>
482
+ # Date.new(2001,3,31) << 1 << 1 #=> #<Date: 2001-01-28 ...>
483
+ #
484
+ # Date.new(2001,3,31) << 1 << -1 #=> #<Date: 2001-03-28 ...>
485
+ #
486
+ def <<: (Integer month) -> Date
487
+
488
+ # Compares the two dates and returns -1, zero, 1 or nil. The other should be a
489
+ # date object or a numeric value as an astronomical Julian day number.
490
+ #
491
+ # Date.new(2001,2,3) <=> Date.new(2001,2,4) #=> -1
492
+ # Date.new(2001,2,3) <=> Date.new(2001,2,3) #=> 0
493
+ # Date.new(2001,2,3) <=> Date.new(2001,2,2) #=> 1
494
+ # Date.new(2001,2,3) <=> Object.new #=> nil
495
+ # Date.new(2001,2,3) <=> Rational(4903887,2) #=> 0
496
+ #
497
+ # See also Comparable.
498
+ #
499
+ def <=>: (Date | Rational | Object other) -> Integer?
500
+
501
+ # Returns true if they are the same day.
502
+ #
503
+ # Date.new(2001,2,3) === Date.new(2001,2,3)
504
+ # #=> true
505
+ # Date.new(2001,2,3) === Date.new(2001,2,4)
506
+ # #=> false
507
+ # DateTime.new(2001,2,3) === DateTime.new(2001,2,3,12)
508
+ # #=> true
509
+ # DateTime.new(2001,2,3) === DateTime.new(2001,2,3,0,0,0,'+24:00')
510
+ # #=> true
511
+ # DateTime.new(2001,2,3) === DateTime.new(2001,2,4,0,0,0,'+24:00')
512
+ # #=> false
513
+ #
514
+ def ===: (Date other) -> bool
515
+
516
+ # Returns a date object pointing `n` months after self. The argument `n` should
517
+ # be a numeric value.
518
+ #
519
+ # Date.new(2001,2,3) >> 1 #=> #<Date: 2001-03-03 ...>
520
+ # Date.new(2001,2,3) >> -2 #=> #<Date: 2000-12-03 ...>
521
+ #
522
+ # When the same day does not exist for the corresponding month, the last day of
523
+ # the month is used instead:
524
+ #
525
+ # Date.new(2001,1,28) >> 1 #=> #<Date: 2001-02-28 ...>
526
+ # Date.new(2001,1,31) >> 1 #=> #<Date: 2001-02-28 ...>
527
+ #
528
+ # This also results in the following, possibly unexpected, behavior:
529
+ #
530
+ # Date.new(2001,1,31) >> 2 #=> #<Date: 2001-03-31 ...>
531
+ # Date.new(2001,1,31) >> 1 >> 1 #=> #<Date: 2001-03-28 ...>
532
+ #
533
+ # Date.new(2001,1,31) >> 1 >> -1 #=> #<Date: 2001-01-28 ...>
534
+ #
535
+ def >>: (Integer month) -> Date
536
+
537
+ # Returns the astronomical Julian day number. This is a fractional number,
538
+ # which is not adjusted by the offset.
539
+ #
540
+ # DateTime.new(2001,2,3,4,5,6,'+7').ajd #=> (11769328217/4800)
541
+ # DateTime.new(2001,2,2,14,5,6,'-7').ajd #=> (11769328217/4800)
542
+ #
543
+ def ajd: () -> Rational
544
+
545
+ # Returns the astronomical modified Julian day number. This is a fractional
546
+ # number, which is not adjusted by the offset.
547
+ #
548
+ # DateTime.new(2001,2,3,4,5,6,'+7').amjd #=> (249325817/4800)
549
+ # DateTime.new(2001,2,2,14,5,6,'-7').amjd #=> (249325817/4800)
550
+ #
551
+ def amjd: () -> Rational
552
+
553
+ # Returns a string in asctime(3) format (but without "n\0" at the end). This
554
+ # method is equivalent to strftime('%c').
555
+ #
556
+ # See also asctime(3) or ctime(3).
557
+ #
558
+ def asctime: () -> String
559
+
560
+ # Returns a string in asctime(3) format (but without "n\0" at the end). This
561
+ # method is equivalent to strftime('%c').
562
+ #
563
+ # See also asctime(3) or ctime(3).
564
+ #
565
+ def ctime: () -> String
566
+
567
+ # Returns the day of calendar week (1-7, Monday is 1).
568
+ #
569
+ # Date.new(2001,2,3).cwday #=> 6
570
+ #
571
+ def cwday: () -> Integer
572
+
573
+ # Returns the calendar week number (1-53).
574
+ #
575
+ # Date.new(2001,2,3).cweek #=> 5
576
+ #
577
+ def cweek: () -> Integer
578
+
579
+ # Returns the calendar week based year.
580
+ #
581
+ # Date.new(2001,2,3).cwyear #=> 2001
582
+ # Date.new(2000,1,1).cwyear #=> 1999
583
+ #
584
+ def cwyear: () -> Integer
585
+
586
+ # Returns the day of the month (1-31).
587
+ #
588
+ # Date.new(2001,2,3).mday #=> 3
589
+ #
590
+ def day: () -> Integer
591
+
592
+ # This method is equivalent to step(min, -1){|date| ...}.
593
+ #
594
+ def downto: (Date min) { (Date) -> untyped } -> Date
595
+ | (Date min) -> Enumerator[Date, Date]
596
+
597
+ # This method is equivalent to new_start(Date::ENGLAND).
598
+ #
599
+ def england: () -> Date
600
+
601
+ # Returns true if the date is Friday.
602
+ #
603
+ def friday?: () -> bool
604
+
605
+ # This method is equivalent to new_start(Date::GREGORIAN).
606
+ #
607
+ def gregorian: () -> Date
608
+
609
+ # Returns true if the date is on or after the day of calendar reform.
610
+ #
611
+ # Date.new(1582,10,15).gregorian? #=> true
612
+ # (Date.new(1582,10,15) - 1).gregorian? #=> false
613
+ #
614
+ def gregorian?: () -> bool
615
+
616
+ # This method is equivalent to strftime('%a, %d %b %Y %T GMT'). See also RFC
617
+ # 2616.
618
+ #
619
+ def httpdate: () -> String
620
+
621
+ # Returns the value as a string for inspection.
622
+ #
623
+ # Date.new(2001,2,3).inspect
624
+ # #=> "#<Date: 2001-02-03>"
625
+ # DateTime.new(2001,2,3,4,5,6,'-7').inspect
626
+ # #=> "#<DateTime: 2001-02-03T04:05:06-07:00>"
627
+ #
628
+ def inspect: () -> String
629
+
630
+ # This method is equivalent to strftime('%F').
631
+ #
632
+ def iso8601: () -> String
633
+
634
+ # This method is equivalent to new_start(Date::ITALY).
635
+ #
636
+ def italy: () -> Date
637
+
638
+ # Returns the Julian day number. This is a whole number, which is adjusted by
639
+ # the offset as the local time.
640
+ #
641
+ # DateTime.new(2001,2,3,4,5,6,'+7').jd #=> 2451944
642
+ # DateTime.new(2001,2,3,4,5,6,'-7').jd #=> 2451944
643
+ #
644
+ def jd: () -> Integer
645
+
646
+ # Returns a string in a JIS X 0301 format.
647
+ #
648
+ # Date.new(2001,2,3).jisx0301 #=> "H13.02.03"
649
+ #
650
+ def jisx0301: () -> String
651
+
652
+ # This method is equivalent to new_start(Date::JULIAN).
653
+ #
654
+ def julian: () -> Date
655
+
656
+ # Returns true if the date is before the day of calendar reform.
657
+ #
658
+ # Date.new(1582,10,15).julian? #=> false
659
+ # (Date.new(1582,10,15) - 1).julian? #=> true
660
+ #
661
+ def julian?: () -> bool
662
+
663
+ # Returns the Lilian day number. This is a whole number, which is adjusted by
664
+ # the offset as the local time.
665
+ #
666
+ # Date.new(2001,2,3).ld #=> 152784
667
+ #
668
+ def ld: () -> Integer
669
+
670
+ # Returns true if the year is a leap year.
671
+ #
672
+ # Date.new(2000).leap? #=> true
673
+ # Date.new(2001).leap? #=> false
674
+ #
675
+ def leap?: () -> bool
676
+
677
+ # Returns the day of the month (1-31).
678
+ #
679
+ # Date.new(2001,2,3).mday #=> 3
680
+ #
681
+ def mday: () -> Integer
682
+
683
+ # Returns the modified Julian day number. This is a whole number, which is
684
+ # adjusted by the offset as the local time.
685
+ #
686
+ # DateTime.new(2001,2,3,4,5,6,'+7').mjd #=> 51943
687
+ # DateTime.new(2001,2,3,4,5,6,'-7').mjd #=> 51943
688
+ #
689
+ def mjd: () -> Integer
690
+
691
+ # Returns the month (1-12).
692
+ #
693
+ # Date.new(2001,2,3).mon #=> 2
694
+ #
695
+ def mon: () -> Integer
696
+
697
+ # Returns true if the date is Monday.
698
+ #
699
+ def monday?: () -> bool
700
+
701
+ # Returns the month (1-12).
702
+ #
703
+ # Date.new(2001,2,3).mon #=> 2
704
+ #
705
+ def month: () -> Integer
706
+
707
+ # Duplicates self and resets its day of calendar reform.
708
+ #
709
+ # d = Date.new(1582,10,15)
710
+ # d.new_start(Date::JULIAN) #=> #<Date: 1582-10-05 ...>
711
+ #
712
+ def new_start: (?Integer start) -> Date
713
+
714
+ # Returns a date object denoting the following day.
715
+ #
716
+ def next: () -> Date
717
+
718
+ # This method is equivalent to d + n.
719
+ #
720
+ def next_day: (?Integer day) -> Date
721
+
722
+ # This method is equivalent to d >> n.
723
+ #
724
+ def next_month: (?Integer month) -> Date
725
+
726
+ # This method is equivalent to d >> (n * 12).
727
+ #
728
+ # Date.new(2001,2,3).next_year #=> #<Date: 2002-02-03 ...>
729
+ # Date.new(2008,2,29).next_year #=> #<Date: 2009-02-28 ...>
730
+ # Date.new(2008,2,29).next_year(4) #=> #<Date: 2012-02-29 ...>
731
+ #
732
+ def next_year: (?Integer year) -> Date
733
+
734
+ # This method is equivalent to d - n.
735
+ #
736
+ def prev_day: (?Integer day) -> Date
737
+
738
+ # This method is equivalent to d << n.
739
+ #
740
+ def prev_month: (?Integer month) -> Date
741
+
742
+ # This method is equivalent to d << (n * 12).
743
+ #
744
+ # Date.new(2001,2,3).prev_year #=> #<Date: 2000-02-03 ...>
745
+ # Date.new(2008,2,29).prev_year #=> #<Date: 2007-02-28 ...>
746
+ # Date.new(2008,2,29).prev_year(4) #=> #<Date: 2004-02-29 ...>
747
+ #
748
+ def prev_year: (?Integer year) -> Date
749
+
750
+ # This method is equivalent to strftime('%a, %-d %b %Y %T %z').
751
+ #
752
+ def rfc2822: () -> String
753
+
754
+ # This method is equivalent to strftime('%FT%T%:z').
755
+ #
756
+ def rfc3339: () -> String
757
+
758
+ # This method is equivalent to strftime('%a, %-d %b %Y %T %z').
759
+ #
760
+ def rfc822: () -> String
761
+
762
+ # Returns true if the date is Saturday.
763
+ #
764
+ def saturday?: () -> bool
765
+
766
+ # Returns the Julian day number denoting the day of calendar reform.
767
+ #
768
+ # Date.new(2001,2,3).start #=> 2299161.0
769
+ # Date.new(2001,2,3,Date::GREGORIAN).start #=> -Infinity
770
+ #
771
+ def start: () -> Float
772
+
773
+ # Iterates evaluation of the given block, which takes a date object. The limit
774
+ # should be a date object.
775
+ #
776
+ # Date.new(2001).step(Date.new(2001,-1,-1)).select{|d| d.sunday?}.size
777
+ # #=> 52
778
+ #
779
+ def step: (Date limit, ?Integer step) { (Date) -> untyped } -> Date
780
+ | (Date limit, ?Integer step) -> ::Enumerator[Date, Date]
781
+
782
+ # Formats date according to the directives in the given format string. The
783
+ # directives begin with a percent (%) character. Any text not listed as a
784
+ # directive will be passed through to the output string.
785
+ #
786
+ # A directive consists of a percent (%) character, zero or more flags, an
787
+ # optional minimum field width, an optional modifier, and a conversion specifier
788
+ # as follows.
789
+ #
790
+ # %<flags><width><modifier><conversion>
791
+ #
792
+ # Flags:
793
+ # - don't pad a numerical output.
794
+ # _ use spaces for padding.
795
+ # 0 use zeros for padding.
796
+ # ^ upcase the result string.
797
+ # # change case.
798
+ #
799
+ # The minimum field width specifies the minimum width.
800
+ #
801
+ # The modifiers are "E", "O", ":", "::" and ":::". "E" and "O" are ignored. No
802
+ # effect to result currently.
803
+ #
804
+ # Format directives:
805
+ #
806
+ # Date (Year, Month, Day):
807
+ # %Y - Year with century (can be negative, 4 digits at least)
808
+ # -0001, 0000, 1995, 2009, 14292, etc.
809
+ # %C - year / 100 (round down. 20 in 2009)
810
+ # %y - year % 100 (00..99)
811
+ #
812
+ # %m - Month of the year, zero-padded (01..12)
813
+ # %_m blank-padded ( 1..12)
814
+ # %-m no-padded (1..12)
815
+ # %B - The full month name (``January'')
816
+ # %^B uppercased (``JANUARY'')
817
+ # %b - The abbreviated month name (``Jan'')
818
+ # %^b uppercased (``JAN'')
819
+ # %h - Equivalent to %b
820
+ #
821
+ # %d - Day of the month, zero-padded (01..31)
822
+ # %-d no-padded (1..31)
823
+ # %e - Day of the month, blank-padded ( 1..31)
824
+ #
825
+ # %j - Day of the year (001..366)
826
+ #
827
+ # Time (Hour, Minute, Second, Subsecond):
828
+ # %H - Hour of the day, 24-hour clock, zero-padded (00..23)
829
+ # %k - Hour of the day, 24-hour clock, blank-padded ( 0..23)
830
+ # %I - Hour of the day, 12-hour clock, zero-padded (01..12)
831
+ # %l - Hour of the day, 12-hour clock, blank-padded ( 1..12)
832
+ # %P - Meridian indicator, lowercase (``am'' or ``pm'')
833
+ # %p - Meridian indicator, uppercase (``AM'' or ``PM'')
834
+ #
835
+ # %M - Minute of the hour (00..59)
836
+ #
837
+ # %S - Second of the minute (00..60)
838
+ #
839
+ # %L - Millisecond of the second (000..999)
840
+ # %N - Fractional seconds digits, default is 9 digits (nanosecond)
841
+ # %3N millisecond (3 digits) %15N femtosecond (15 digits)
842
+ # %6N microsecond (6 digits) %18N attosecond (18 digits)
843
+ # %9N nanosecond (9 digits) %21N zeptosecond (21 digits)
844
+ # %12N picosecond (12 digits) %24N yoctosecond (24 digits)
845
+ #
846
+ # Time zone:
847
+ # %z - Time zone as hour and minute offset from UTC (e.g. +0900)
848
+ # %:z - hour and minute offset from UTC with a colon (e.g. +09:00)
849
+ # %::z - hour, minute and second offset from UTC (e.g. +09:00:00)
850
+ # %:::z - hour, minute and second offset from UTC
851
+ # (e.g. +09, +09:30, +09:30:30)
852
+ # %Z - Equivalent to %:z (e.g. +09:00)
853
+ #
854
+ # Weekday:
855
+ # %A - The full weekday name (``Sunday'')
856
+ # %^A uppercased (``SUNDAY'')
857
+ # %a - The abbreviated name (``Sun'')
858
+ # %^a uppercased (``SUN'')
859
+ # %u - Day of the week (Monday is 1, 1..7)
860
+ # %w - Day of the week (Sunday is 0, 0..6)
861
+ #
862
+ # ISO 8601 week-based year and week number:
863
+ # The week 1 of YYYY starts with a Monday and includes YYYY-01-04.
864
+ # The days in the year before the first week are in the last week of
865
+ # the previous year.
866
+ # %G - The week-based year
867
+ # %g - The last 2 digits of the week-based year (00..99)
868
+ # %V - Week number of the week-based year (01..53)
869
+ #
870
+ # Week number:
871
+ # The week 1 of YYYY starts with a Sunday or Monday (according to %U
872
+ # or %W). The days in the year before the first week are in week 0.
873
+ # %U - Week number of the year. The week starts with Sunday. (00..53)
874
+ # %W - Week number of the year. The week starts with Monday. (00..53)
875
+ #
876
+ # Seconds since the Unix Epoch:
877
+ # %s - Number of seconds since 1970-01-01 00:00:00 UTC.
878
+ # %Q - Number of milliseconds since 1970-01-01 00:00:00 UTC.
879
+ #
880
+ # Literal string:
881
+ # %n - Newline character (\n)
882
+ # %t - Tab character (\t)
883
+ # %% - Literal ``%'' character
884
+ #
885
+ # Combination:
886
+ # %c - date and time (%a %b %e %T %Y)
887
+ # %D - Date (%m/%d/%y)
888
+ # %F - The ISO 8601 date format (%Y-%m-%d)
889
+ # %v - VMS date (%e-%b-%Y)
890
+ # %x - Same as %D
891
+ # %X - Same as %T
892
+ # %r - 12-hour time (%I:%M:%S %p)
893
+ # %R - 24-hour time (%H:%M)
894
+ # %T - 24-hour time (%H:%M:%S)
895
+ # %+ - date(1) (%a %b %e %H:%M:%S %Z %Y)
896
+ #
897
+ # This method is similar to the strftime() function defined in ISO C and POSIX.
898
+ # Several directives (%a, %A, %b, %B, %c, %p, %r, %x, %X, %E*, %O* and %Z) are
899
+ # locale dependent in the function. However, this method is locale independent.
900
+ # So, the result may differ even if the same format string is used in other
901
+ # systems such as C. It is good practice to avoid %x and %X because there are
902
+ # corresponding locale independent representations, %D and %T.
903
+ #
904
+ # Examples:
905
+ #
906
+ # d = DateTime.new(2007,11,19,8,37,48,"-06:00")
907
+ # #=> #<DateTime: 2007-11-19T08:37:48-0600 ...>
908
+ # d.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007"
909
+ # d.strftime("at %I:%M%p") #=> "at 08:37AM"
910
+ #
911
+ # Various ISO 8601 formats:
912
+ # %Y%m%d => 20071119 Calendar date (basic)
913
+ # %F => 2007-11-19 Calendar date (extended)
914
+ # %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month
915
+ # %Y => 2007 Calendar date, reduced accuracy, specific year
916
+ # %C => 20 Calendar date, reduced accuracy, specific century
917
+ # %Y%j => 2007323 Ordinal date (basic)
918
+ # %Y-%j => 2007-323 Ordinal date (extended)
919
+ # %GW%V%u => 2007W471 Week date (basic)
920
+ # %G-W%V-%u => 2007-W47-1 Week date (extended)
921
+ # %GW%V => 2007W47 Week date, reduced accuracy, specific week (basic)
922
+ # %G-W%V => 2007-W47 Week date, reduced accuracy, specific week (extended)
923
+ # %H%M%S => 083748 Local time (basic)
924
+ # %T => 08:37:48 Local time (extended)
925
+ # %H%M => 0837 Local time, reduced accuracy, specific minute (basic)
926
+ # %H:%M => 08:37 Local time, reduced accuracy, specific minute (extended)
927
+ # %H => 08 Local time, reduced accuracy, specific hour
928
+ # %H%M%S,%L => 083748,000 Local time with decimal fraction, comma as decimal sign (basic)
929
+ # %T,%L => 08:37:48,000 Local time with decimal fraction, comma as decimal sign (extended)
930
+ # %H%M%S.%L => 083748.000 Local time with decimal fraction, full stop as decimal sign (basic)
931
+ # %T.%L => 08:37:48.000 Local time with decimal fraction, full stop as decimal sign (extended)
932
+ # %H%M%S%z => 083748-0600 Local time and the difference from UTC (basic)
933
+ # %T%:z => 08:37:48-06:00 Local time and the difference from UTC (extended)
934
+ # %Y%m%dT%H%M%S%z => 20071119T083748-0600 Date and time of day for calendar date (basic)
935
+ # %FT%T%:z => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended)
936
+ # %Y%jT%H%M%S%z => 2007323T083748-0600 Date and time of day for ordinal date (basic)
937
+ # %Y-%jT%T%:z => 2007-323T08:37:48-06:00 Date and time of day for ordinal date (extended)
938
+ # %GW%V%uT%H%M%S%z => 2007W471T083748-0600 Date and time of day for week date (basic)
939
+ # %G-W%V-%uT%T%:z => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended)
940
+ # %Y%m%dT%H%M => 20071119T0837 Calendar date and local time (basic)
941
+ # %FT%R => 2007-11-19T08:37 Calendar date and local time (extended)
942
+ # %Y%jT%H%MZ => 2007323T0837Z Ordinal date and UTC of day (basic)
943
+ # %Y-%jT%RZ => 2007-323T08:37Z Ordinal date and UTC of day (extended)
944
+ # %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic)
945
+ # %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended)
946
+ #
947
+ # See also strftime(3) and ::strptime.
948
+ #
949
+ def strftime: (?String format) -> String
950
+
951
+ # Returns a date object denoting the following day.
952
+ #
953
+ def succ: () -> Date
954
+
955
+ # Returns true if the date is Sunday.
956
+ #
957
+ def sunday?: () -> bool
958
+
959
+ # Returns true if the date is Thursday.
960
+ #
961
+ def thursday?: () -> bool
962
+
963
+ # Returns self.
964
+ #
965
+ def to_date: () -> Date
966
+
967
+ # Returns a DateTime object which denotes self.
968
+ #
969
+ def to_datetime: () -> DateTime
970
+
971
+ # Returns a string in an ISO 8601 format. (This method doesn't use the expanded
972
+ # representations.)
973
+ #
974
+ # Date.new(2001,2,3).to_s #=> "2001-02-03"
975
+ #
976
+ def to_s: () -> String
977
+
978
+ # Returns a Time object which denotes self. If self is a julian date, convert it
979
+ # to a gregorian date before converting it to Time.
980
+ #
981
+ def to_time: () -> Time
982
+
983
+ # Returns true if the date is Tuesday.
984
+ #
985
+ def tuesday?: () -> bool
986
+
987
+ # This method is equivalent to step(max, 1){|date| ...}.
988
+ #
989
+ def upto: (Date max) { (Date) -> untyped } -> Date
990
+ | (Date max) -> ::Enumerator[Date, Date]
991
+
992
+ # Returns the day of week (0-6, Sunday is zero).
993
+ #
994
+ # Date.new(2001,2,3).wday #=> 6
995
+ #
996
+ def wday: () -> Integer
997
+
998
+ # Returns true if the date is Wednesday.
999
+ #
1000
+ def wednesday?: () -> bool
1001
+
1002
+ # This method is equivalent to strftime('%F').
1003
+ #
1004
+ def xmlschema: () -> String
1005
+
1006
+ # Returns the day of the year (1-366).
1007
+ #
1008
+ # Date.new(2001,2,3).yday #=> 34
1009
+ #
1010
+ def yday: () -> Integer
1011
+
1012
+ # Returns the year.
1013
+ #
1014
+ # Date.new(2001,2,3).year #=> 2001
1015
+ # (Date.new(1,1,1) - 1).year #=> 0
1016
+ #
1017
+ def year: () -> Integer
1018
+ end
1019
+
1020
+ # An array of strings of abbreviated day names in English. The first is "Sun".
1021
+ #
1022
+ Date::ABBR_DAYNAMES: Array[String]
1023
+
1024
+ # An array of strings of abbreviated month names in English. The first element
1025
+ # is nil.
1026
+ #
1027
+ Date::ABBR_MONTHNAMES: Array[String?]
1028
+
1029
+ # An array of strings of the full names of days of the week in English. The
1030
+ # first is "Sunday".
1031
+ #
1032
+ Date::DAYNAMES: Array[String]
1033
+
1034
+ # The Julian day number of the day of calendar reform for England and her
1035
+ # colonies.
1036
+ #
1037
+ Date::ENGLAND: Integer
1038
+
1039
+ # The Julian day number of the day of calendar reform for the proleptic
1040
+ # Gregorian calendar.
1041
+ #
1042
+ Date::GREGORIAN: Integer
1043
+
1044
+ # The Julian day number of the day of calendar reform for Italy and some
1045
+ # catholic countries.
1046
+ #
1047
+ Date::ITALY: Integer
1048
+
1049
+ # The Julian day number of the day of calendar reform for the proleptic Julian
1050
+ # calendar.
1051
+ #
1052
+ Date::JULIAN: Integer
1053
+
1054
+ # An array of strings of full month names in English. The first element is nil.
1055
+ #
1056
+ Date::MONTHNAMES: Array[String?]