date 3.3.2 → 3.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/date/date_core.c +10 -25
- data/ext/date/date_strptime.c +51 -54
- data/lib/date.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c21f55b2cc18baf941cd4774c226c424d7f987bee9239e0b732a0d9fb4f0e6fd
|
|
4
|
+
data.tar.gz: 2acbe62f992812810d0efd5f09801fcec3669d1ba4df7afc20b95a10a13093a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 13082c47b2973af41fc9064501b16db82f900a3e8c8f4d470370f8f424cf89752e49193595329e37029007a5086d83725321f836efe949012f7df43cff26d401
|
|
7
|
+
data.tar.gz: 1500c8d72b88fabb2645cbd67da24447f9a11be934a20cad3557b8b261bfa788e9a7d9f699891c1c93a39fd92c3427c9672d0d84815390b57337727d77665153
|
data/ext/date/date_core.c
CHANGED
|
@@ -64,7 +64,8 @@ static VALUE datetime_initialize(int argc, VALUE *argv, VALUE self);
|
|
|
64
64
|
|
|
65
65
|
#define RETURN_FALSE_UNLESS_NUMERIC(obj) if(!RTEST(rb_obj_is_kind_of((obj), rb_cNumeric))) return Qfalse
|
|
66
66
|
inline static void
|
|
67
|
-
check_numeric(VALUE obj, const char* field)
|
|
67
|
+
check_numeric(VALUE obj, const char* field)
|
|
68
|
+
{
|
|
68
69
|
if(!RTEST(rb_obj_is_kind_of(obj, rb_cNumeric))) {
|
|
69
70
|
rb_raise(rb_eTypeError, "invalid %s (not numeric)", field);
|
|
70
71
|
}
|
|
@@ -2588,8 +2589,6 @@ date_s__valid_civil_p(int argc, VALUE *argv, VALUE klass)
|
|
|
2588
2589
|
*
|
|
2589
2590
|
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
2590
2591
|
*
|
|
2591
|
-
* Date.valid_date? is an alias for Date.valid_civil?.
|
|
2592
|
-
*
|
|
2593
2592
|
* Related: Date.jd, Date.new.
|
|
2594
2593
|
*/
|
|
2595
2594
|
static VALUE
|
|
@@ -2985,8 +2984,6 @@ date_s_julian_leap_p(VALUE klass, VALUE y)
|
|
|
2985
2984
|
* Date.gregorian_leap?(2000) # => true
|
|
2986
2985
|
* Date.gregorian_leap?(2001) # => false
|
|
2987
2986
|
*
|
|
2988
|
-
* Date.leap? is an alias for Date.gregorian_leap?.
|
|
2989
|
-
*
|
|
2990
2987
|
* Related: Date.julian_leap?.
|
|
2991
2988
|
*/
|
|
2992
2989
|
static VALUE
|
|
@@ -3492,8 +3489,6 @@ date_s_civil(int argc, VALUE *argv, VALUE klass)
|
|
|
3492
3489
|
*
|
|
3493
3490
|
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
3494
3491
|
*
|
|
3495
|
-
* Date.civil is an alias for Date.new.
|
|
3496
|
-
*
|
|
3497
3492
|
* Related: Date.jd.
|
|
3498
3493
|
*/
|
|
3499
3494
|
static VALUE
|
|
@@ -4831,8 +4826,6 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
|
|
4831
4826
|
*
|
|
4832
4827
|
* See argument {limit}[rdoc-ref:Date@Argument+limit].
|
|
4833
4828
|
*
|
|
4834
|
-
* Date._rfc822 is an alias for Date._rfc2822.
|
|
4835
|
-
*
|
|
4836
4829
|
* Related: Date.rfc2822 (returns a \Date object).
|
|
4837
4830
|
*/
|
|
4838
4831
|
static VALUE
|
|
@@ -4863,8 +4856,6 @@ date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
|
|
|
4863
4856
|
* - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
|
|
4864
4857
|
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
|
|
4865
4858
|
*
|
|
4866
|
-
* Date.rfc822 is an alias for Date.rfc2822.
|
|
4867
|
-
*
|
|
4868
4859
|
* Related: Date._rfc2822 (returns a hash).
|
|
4869
4860
|
*/
|
|
4870
4861
|
static VALUE
|
|
@@ -5345,7 +5336,6 @@ d_lite_yday(VALUE self)
|
|
|
5345
5336
|
*
|
|
5346
5337
|
* Date.new(2001, 2, 3).mon # => 2
|
|
5347
5338
|
*
|
|
5348
|
-
* Date#month is an alias for Date#mon.
|
|
5349
5339
|
*/
|
|
5350
5340
|
static VALUE
|
|
5351
5341
|
d_lite_mon(VALUE self)
|
|
@@ -5362,7 +5352,6 @@ d_lite_mon(VALUE self)
|
|
|
5362
5352
|
*
|
|
5363
5353
|
* Date.new(2001, 2, 3).mday # => 3
|
|
5364
5354
|
*
|
|
5365
|
-
* Date#day is an alias for Date#mday.
|
|
5366
5355
|
*/
|
|
5367
5356
|
static VALUE
|
|
5368
5357
|
d_lite_mday(VALUE self)
|
|
@@ -5612,7 +5601,6 @@ d_lite_hour(VALUE self)
|
|
|
5612
5601
|
*
|
|
5613
5602
|
* DateTime.new(2001, 2, 3, 4, 5, 6).min # => 5
|
|
5614
5603
|
*
|
|
5615
|
-
* Date#minute is an alias for Date#min.
|
|
5616
5604
|
*/
|
|
5617
5605
|
static VALUE
|
|
5618
5606
|
d_lite_min(VALUE self)
|
|
@@ -5629,7 +5617,6 @@ d_lite_min(VALUE self)
|
|
|
5629
5617
|
*
|
|
5630
5618
|
* DateTime.new(2001, 2, 3, 4, 5, 6).sec # => 6
|
|
5631
5619
|
*
|
|
5632
|
-
* Date#second is an alias for Date#sec.
|
|
5633
5620
|
*/
|
|
5634
5621
|
static VALUE
|
|
5635
5622
|
d_lite_sec(VALUE self)
|
|
@@ -5647,7 +5634,6 @@ d_lite_sec(VALUE self)
|
|
|
5647
5634
|
*
|
|
5648
5635
|
* DateTime.new(2001, 2, 3, 4, 5, 6.5).sec_fraction # => (1/2)
|
|
5649
5636
|
*
|
|
5650
|
-
* Date#second_fraction is an alias for Date#sec_fraction.
|
|
5651
5637
|
*/
|
|
5652
5638
|
static VALUE
|
|
5653
5639
|
d_lite_sec_fraction(VALUE self)
|
|
@@ -6423,7 +6409,6 @@ d_lite_prev_day(int argc, VALUE *argv, VALUE self)
|
|
|
6423
6409
|
* d.to_s # => "2001-02-03"
|
|
6424
6410
|
* d.next.to_s # => "2001-02-04"
|
|
6425
6411
|
*
|
|
6426
|
-
* Date#succ is an alias for Date#next.
|
|
6427
6412
|
*/
|
|
6428
6413
|
static VALUE
|
|
6429
6414
|
d_lite_next(VALUE self)
|
|
@@ -7297,7 +7282,6 @@ strftimev(const char *fmt, VALUE self,
|
|
|
7297
7282
|
*
|
|
7298
7283
|
* See {asctime}[https://linux.die.net/man/3/asctime].
|
|
7299
7284
|
*
|
|
7300
|
-
* Date#ctime is an alias for Date#asctime.
|
|
7301
7285
|
*/
|
|
7302
7286
|
static VALUE
|
|
7303
7287
|
d_lite_asctime(VALUE self)
|
|
@@ -7315,7 +7299,6 @@ d_lite_asctime(VALUE self)
|
|
|
7315
7299
|
*
|
|
7316
7300
|
* Date.new(2001, 2, 3).iso8601 # => "2001-02-03"
|
|
7317
7301
|
*
|
|
7318
|
-
* Date#xmlschema is an alias for Date#iso8601.
|
|
7319
7302
|
*/
|
|
7320
7303
|
static VALUE
|
|
7321
7304
|
d_lite_iso8601(VALUE self)
|
|
@@ -7348,7 +7331,6 @@ d_lite_rfc3339(VALUE self)
|
|
|
7348
7331
|
*
|
|
7349
7332
|
* Date.new(2001, 2, 3).rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
|
|
7350
7333
|
*
|
|
7351
|
-
* Date#rfc822 is an alias for Date#rfc2822.
|
|
7352
7334
|
*/
|
|
7353
7335
|
static VALUE
|
|
7354
7336
|
d_lite_rfc2822(VALUE self)
|
|
@@ -7437,7 +7419,8 @@ d_lite_jisx0301(VALUE self)
|
|
|
7437
7419
|
}
|
|
7438
7420
|
|
|
7439
7421
|
static VALUE
|
|
7440
|
-
deconstruct_keys(VALUE self, VALUE keys, int is_datetime)
|
|
7422
|
+
deconstruct_keys(VALUE self, VALUE keys, int is_datetime)
|
|
7423
|
+
{
|
|
7441
7424
|
VALUE h = rb_hash_new();
|
|
7442
7425
|
long i;
|
|
7443
7426
|
|
|
@@ -7520,7 +7503,8 @@ deconstruct_keys(VALUE self, VALUE keys, int is_datetime) {
|
|
|
7520
7503
|
*
|
|
7521
7504
|
*/
|
|
7522
7505
|
static VALUE
|
|
7523
|
-
d_lite_deconstruct_keys(VALUE self, VALUE keys)
|
|
7506
|
+
d_lite_deconstruct_keys(VALUE self, VALUE keys)
|
|
7507
|
+
{
|
|
7524
7508
|
return deconstruct_keys(self, keys, /* is_datetime=false */ 0);
|
|
7525
7509
|
}
|
|
7526
7510
|
|
|
@@ -8742,8 +8726,8 @@ dt_lite_to_s(VALUE self)
|
|
|
8742
8726
|
*
|
|
8743
8727
|
* DateTime.now.strftime # => "2022-07-01T11:03:19-05:00"
|
|
8744
8728
|
*
|
|
8745
|
-
* For other formats,
|
|
8746
|
-
* {Formats for Dates and Times}[
|
|
8729
|
+
* For other formats,
|
|
8730
|
+
* see {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html]:
|
|
8747
8731
|
*
|
|
8748
8732
|
*/
|
|
8749
8733
|
static VALUE
|
|
@@ -8868,7 +8852,8 @@ dt_lite_jisx0301(int argc, VALUE *argv, VALUE self)
|
|
|
8868
8852
|
*
|
|
8869
8853
|
*/
|
|
8870
8854
|
static VALUE
|
|
8871
|
-
dt_lite_deconstruct_keys(VALUE self, VALUE keys)
|
|
8855
|
+
dt_lite_deconstruct_keys(VALUE self, VALUE keys)
|
|
8856
|
+
{
|
|
8872
8857
|
return deconstruct_keys(self, keys, /* is_datetime=true */ 1);
|
|
8873
8858
|
}
|
|
8874
8859
|
|
data/ext/date/date_strptime.c
CHANGED
|
@@ -10,28 +10,15 @@
|
|
|
10
10
|
static const char *day_names[] = {
|
|
11
11
|
"Sunday", "Monday", "Tuesday", "Wednesday",
|
|
12
12
|
"Thursday", "Friday", "Saturday",
|
|
13
|
-
"Sun", "Mon", "Tue", "Wed",
|
|
14
|
-
"Thu", "Fri", "Sat"
|
|
15
13
|
};
|
|
14
|
+
static const int ABBREVIATED_DAY_NAME_LENGTH = 3;
|
|
16
15
|
|
|
17
16
|
static const char *month_names[] = {
|
|
18
17
|
"January", "February", "March", "April",
|
|
19
18
|
"May", "June", "July", "August", "September",
|
|
20
19
|
"October", "November", "December",
|
|
21
|
-
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
|
22
|
-
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
static const char *merid_names[] = {
|
|
26
|
-
"am", "pm",
|
|
27
|
-
"a.m.", "p.m."
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
static const char *extz_pats[] = {
|
|
31
|
-
":z",
|
|
32
|
-
"::z",
|
|
33
|
-
":::z"
|
|
34
20
|
};
|
|
21
|
+
static const int ABBREVIATED_MONTH_NAME_LENGTH = 3;
|
|
35
22
|
|
|
36
23
|
#define sizeof_array(o) (sizeof o / sizeof o[0])
|
|
37
24
|
|
|
@@ -75,7 +62,7 @@ num_pattern_p(const char *s)
|
|
|
75
62
|
#define NUM_PATTERN_P() num_pattern_p(&fmt[fi + 1])
|
|
76
63
|
|
|
77
64
|
static long
|
|
78
|
-
read_digits(const char *s, VALUE *n, size_t width)
|
|
65
|
+
read_digits(const char *s, size_t slen, VALUE *n, size_t width)
|
|
79
66
|
{
|
|
80
67
|
size_t l;
|
|
81
68
|
|
|
@@ -83,7 +70,7 @@ read_digits(const char *s, VALUE *n, size_t width)
|
|
|
83
70
|
return 0;
|
|
84
71
|
|
|
85
72
|
l = 0;
|
|
86
|
-
while (ISDIGIT(s[l])) {
|
|
73
|
+
while (l < slen && ISDIGIT(s[l])) {
|
|
87
74
|
if (++l == width) break;
|
|
88
75
|
}
|
|
89
76
|
|
|
@@ -131,7 +118,7 @@ do { \
|
|
|
131
118
|
#define READ_DIGITS(n,w) \
|
|
132
119
|
do { \
|
|
133
120
|
size_t l; \
|
|
134
|
-
l = read_digits(&str[si], &n, w); \
|
|
121
|
+
l = read_digits(&str[si], slen - si, &n, w); \
|
|
135
122
|
if (l == 0) \
|
|
136
123
|
fail(); \
|
|
137
124
|
si += l; \
|
|
@@ -161,6 +148,12 @@ do { \
|
|
|
161
148
|
|
|
162
149
|
VALUE date_zone_to_diff(VALUE);
|
|
163
150
|
|
|
151
|
+
static inline int
|
|
152
|
+
head_match_p(size_t len, const char *name, const char *str, size_t slen, size_t si)
|
|
153
|
+
{
|
|
154
|
+
return slen - si >= len && strncasecmp(name, &str[si], len) == 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
164
157
|
static size_t
|
|
165
158
|
date__strptime_internal(const char *str, size_t slen,
|
|
166
159
|
const char *fmt, size_t flen, VALUE hash)
|
|
@@ -168,9 +161,18 @@ date__strptime_internal(const char *str, size_t slen,
|
|
|
168
161
|
size_t si, fi;
|
|
169
162
|
int c;
|
|
170
163
|
|
|
164
|
+
#define HEAD_MATCH_P(len, name) head_match_p(len, name, str, slen, si)
|
|
171
165
|
si = fi = 0;
|
|
172
166
|
|
|
173
167
|
while (fi < flen) {
|
|
168
|
+
if (isspace((unsigned char)fmt[fi])) {
|
|
169
|
+
while (si < slen && isspace((unsigned char)str[si]))
|
|
170
|
+
si++;
|
|
171
|
+
while (++fi < flen && isspace((unsigned char)fmt[fi]));
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (si >= slen) fail();
|
|
174
176
|
|
|
175
177
|
switch (fmt[fi]) {
|
|
176
178
|
case '%':
|
|
@@ -194,12 +196,11 @@ date__strptime_internal(const char *str, size_t slen,
|
|
|
194
196
|
{
|
|
195
197
|
int i;
|
|
196
198
|
|
|
197
|
-
for (i =
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
199
|
+
for (i = 1; i < 3 && fi + i < flen && fmt[fi+i] == ':'; ++i);
|
|
200
|
+
if (fmt[fi+i] == 'z') {
|
|
201
|
+
fi += i - 1;
|
|
202
|
+
goto again;
|
|
203
|
+
}
|
|
203
204
|
fail();
|
|
204
205
|
}
|
|
205
206
|
|
|
@@ -209,10 +210,12 @@ date__strptime_internal(const char *str, size_t slen,
|
|
|
209
210
|
int i;
|
|
210
211
|
|
|
211
212
|
for (i = 0; i < (int)sizeof_array(day_names); i++) {
|
|
212
|
-
|
|
213
|
-
|
|
213
|
+
const char *day_name = day_names[i];
|
|
214
|
+
size_t l = strlen(day_name);
|
|
215
|
+
if (HEAD_MATCH_P(l, day_name) ||
|
|
216
|
+
HEAD_MATCH_P(l = ABBREVIATED_DAY_NAME_LENGTH, day_name)) {
|
|
214
217
|
si += l;
|
|
215
|
-
set_hash("wday", INT2FIX(i
|
|
218
|
+
set_hash("wday", INT2FIX(i));
|
|
216
219
|
goto matched;
|
|
217
220
|
}
|
|
218
221
|
}
|
|
@@ -225,10 +228,12 @@ date__strptime_internal(const char *str, size_t slen,
|
|
|
225
228
|
int i;
|
|
226
229
|
|
|
227
230
|
for (i = 0; i < (int)sizeof_array(month_names); i++) {
|
|
228
|
-
|
|
229
|
-
|
|
231
|
+
const char *month_name = month_names[i];
|
|
232
|
+
size_t l = strlen(month_name);
|
|
233
|
+
if (HEAD_MATCH_P(l, month_name) ||
|
|
234
|
+
HEAD_MATCH_P(l = ABBREVIATED_MONTH_NAME_LENGTH, month_name)) {
|
|
230
235
|
si += l;
|
|
231
|
-
set_hash("mon", INT2FIX(
|
|
236
|
+
set_hash("mon", INT2FIX(i + 1));
|
|
232
237
|
goto matched;
|
|
233
238
|
}
|
|
234
239
|
}
|
|
@@ -402,18 +407,19 @@ date__strptime_internal(const char *str, size_t slen,
|
|
|
402
407
|
|
|
403
408
|
case 'P':
|
|
404
409
|
case 'p':
|
|
410
|
+
if (slen - si < 2) fail();
|
|
405
411
|
{
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
if (
|
|
411
|
-
|
|
412
|
-
set_hash("_merid", INT2FIX((i % 2) == 0 ? 0 : 12));
|
|
413
|
-
goto matched;
|
|
414
|
-
}
|
|
412
|
+
char c = str[si];
|
|
413
|
+
const int hour = (c == 'P' || c == 'p') ? 12 : 0;
|
|
414
|
+
if (!hour && !(c == 'A' || c == 'a')) fail();
|
|
415
|
+
if ((c = str[si+1]) == '.') {
|
|
416
|
+
if (slen - si < 4 || str[si+3] != '.') fail();
|
|
417
|
+
c = str[si += 2];
|
|
415
418
|
}
|
|
416
|
-
fail();
|
|
419
|
+
if (!(c == 'M' || c == 'm')) fail();
|
|
420
|
+
si += 2;
|
|
421
|
+
set_hash("_merid", INT2FIX(hour));
|
|
422
|
+
goto matched;
|
|
417
423
|
}
|
|
418
424
|
|
|
419
425
|
case 'Q':
|
|
@@ -587,7 +593,7 @@ date__strptime_internal(const char *str, size_t slen,
|
|
|
587
593
|
|
|
588
594
|
b = rb_backref_get();
|
|
589
595
|
rb_match_busy(b);
|
|
590
|
-
m = f_match(pat,
|
|
596
|
+
m = f_match(pat, rb_usascii_str_new(&str[si], slen - si));
|
|
591
597
|
|
|
592
598
|
if (!NIL_P(m)) {
|
|
593
599
|
VALUE s, l, o;
|
|
@@ -619,22 +625,13 @@ date__strptime_internal(const char *str, size_t slen,
|
|
|
619
625
|
if (str[si] != '%')
|
|
620
626
|
fail();
|
|
621
627
|
si++;
|
|
622
|
-
if (fi < flen)
|
|
623
|
-
if (str[si] != fmt[fi])
|
|
628
|
+
if (fi < flen) {
|
|
629
|
+
if (si >= slen || str[si] != fmt[fi])
|
|
624
630
|
fail();
|
|
625
|
-
|
|
631
|
+
si++;
|
|
632
|
+
}
|
|
626
633
|
goto matched;
|
|
627
634
|
}
|
|
628
|
-
case ' ':
|
|
629
|
-
case '\t':
|
|
630
|
-
case '\n':
|
|
631
|
-
case '\v':
|
|
632
|
-
case '\f':
|
|
633
|
-
case '\r':
|
|
634
|
-
while (isspace((unsigned char)str[si]))
|
|
635
|
-
si++;
|
|
636
|
-
fi++;
|
|
637
|
-
break;
|
|
638
635
|
default:
|
|
639
636
|
ordinal:
|
|
640
637
|
if (str[si] != fmt[fi])
|
data/lib/date.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: date
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.3.
|
|
4
|
+
version: 3.3.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tadayoshi Funaba
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-11-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A subclass of Object includes Comparable module for handling dates.
|
|
14
14
|
email:
|
|
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
49
49
|
- !ruby/object:Gem::Version
|
|
50
50
|
version: '0'
|
|
51
51
|
requirements: []
|
|
52
|
-
rubygems_version: 3.
|
|
52
|
+
rubygems_version: 3.5.0.dev
|
|
53
53
|
signing_key:
|
|
54
54
|
specification_version: 4
|
|
55
55
|
summary: A subclass of Object includes Comparable module for handling dates.
|