date 3.0.1 → 3.1.2
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 +362 -132
- data/ext/date/date_parse.c +1 -0
- data/ext/date/date_strptime.c +1 -0
- data/ext/date/prereq.mk +1 -1
- data/ext/date/zonetab.list +7 -7
- data/lib/date.rb +0 -2
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33ef20bebc298ad26d350db0e6511f2dbc084402c0d118e5f70f5f77230df222
|
4
|
+
data.tar.gz: d6ad174792f8032aab382cb21c10cc0cdbcc77e6f32c4105ff51736251eea43f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e7b5ac465831a3fc501d72d1ef576a8b3d4791553047a0516c1e6dc7190eb418acb65521afda41a0ff6fe5ca3f09011e04ba27f3b30b2d511bffb177704306c
|
7
|
+
data.tar.gz: 8c020832fac18b494a6d2ec7de441fd8d3cc90ffa44cc33196ef2fa0ad1e1ee1ff8af63c183250c39d10ccde9a478246303500d53c61483319d0f62c502d8c4b
|
data/ext/date/date_core.c
CHANGED
@@ -53,6 +53,8 @@ static double positive_inf, negative_inf;
|
|
53
53
|
#define f_add3(x,y,z) f_add(f_add(x, y), z)
|
54
54
|
#define f_sub3(x,y,z) f_sub(f_sub(x, y), z)
|
55
55
|
|
56
|
+
#define f_frozen_ary(...) rb_obj_freeze(rb_ary_new3(__VA_ARGS__))
|
57
|
+
|
56
58
|
static VALUE date_initialize(int argc, VALUE *argv, VALUE self);
|
57
59
|
static VALUE datetime_initialize(int argc, VALUE *argv, VALUE self);
|
58
60
|
|
@@ -2971,11 +2973,15 @@ d_lite_memsize(const void *ptr)
|
|
2971
2973
|
return complex_dat_p(dat) ? sizeof(struct ComplexDateData) : sizeof(struct SimpleDateData);
|
2972
2974
|
}
|
2973
2975
|
|
2976
|
+
#ifndef HAVE_RB_EXT_RACTOR_SAFE
|
2977
|
+
# define RUBY_TYPED_FROZEN_SHAREABLE 0
|
2978
|
+
#endif
|
2979
|
+
|
2974
2980
|
static const rb_data_type_t d_lite_type = {
|
2975
2981
|
"Date",
|
2976
2982
|
{d_lite_gc_mark, RUBY_TYPED_DEFAULT_FREE, d_lite_memsize,},
|
2977
2983
|
0, 0,
|
2978
|
-
RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED,
|
2984
|
+
RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED|RUBY_TYPED_FROZEN_SHAREABLE,
|
2979
2985
|
};
|
2980
2986
|
|
2981
2987
|
inline static VALUE
|
@@ -3767,89 +3773,89 @@ rt_complete_frags(VALUE klass, VALUE hash)
|
|
3767
3773
|
VALUE k, a, d;
|
3768
3774
|
|
3769
3775
|
if (NIL_P(tab)) {
|
3770
|
-
tab =
|
3771
|
-
|
3776
|
+
tab = f_frozen_ary(11,
|
3777
|
+
f_frozen_ary(2,
|
3772
3778
|
sym("time"),
|
3773
|
-
|
3779
|
+
f_frozen_ary(3,
|
3774
3780
|
sym("hour"),
|
3775
3781
|
sym("min"),
|
3776
3782
|
sym("sec"))),
|
3777
|
-
|
3783
|
+
f_frozen_ary(2,
|
3778
3784
|
Qnil,
|
3779
|
-
|
3785
|
+
f_frozen_ary(1,
|
3780
3786
|
sym("jd"))),
|
3781
|
-
|
3787
|
+
f_frozen_ary(2,
|
3782
3788
|
sym("ordinal"),
|
3783
|
-
|
3789
|
+
f_frozen_ary(5,
|
3784
3790
|
sym("year"),
|
3785
3791
|
sym("yday"),
|
3786
3792
|
sym("hour"),
|
3787
3793
|
sym("min"),
|
3788
3794
|
sym("sec"))),
|
3789
|
-
|
3795
|
+
f_frozen_ary(2,
|
3790
3796
|
sym("civil"),
|
3791
|
-
|
3797
|
+
f_frozen_ary(6,
|
3792
3798
|
sym("year"),
|
3793
3799
|
sym("mon"),
|
3794
3800
|
sym("mday"),
|
3795
3801
|
sym("hour"),
|
3796
3802
|
sym("min"),
|
3797
3803
|
sym("sec"))),
|
3798
|
-
|
3804
|
+
f_frozen_ary(2,
|
3799
3805
|
sym("commercial"),
|
3800
|
-
|
3806
|
+
f_frozen_ary(6,
|
3801
3807
|
sym("cwyear"),
|
3802
3808
|
sym("cweek"),
|
3803
3809
|
sym("cwday"),
|
3804
3810
|
sym("hour"),
|
3805
3811
|
sym("min"),
|
3806
3812
|
sym("sec"))),
|
3807
|
-
|
3813
|
+
f_frozen_ary(2,
|
3808
3814
|
sym("wday"),
|
3809
|
-
|
3815
|
+
f_frozen_ary(4,
|
3810
3816
|
sym("wday"),
|
3811
3817
|
sym("hour"),
|
3812
3818
|
sym("min"),
|
3813
3819
|
sym("sec"))),
|
3814
|
-
|
3820
|
+
f_frozen_ary(2,
|
3815
3821
|
sym("wnum0"),
|
3816
|
-
|
3822
|
+
f_frozen_ary(6,
|
3817
3823
|
sym("year"),
|
3818
3824
|
sym("wnum0"),
|
3819
3825
|
sym("wday"),
|
3820
3826
|
sym("hour"),
|
3821
3827
|
sym("min"),
|
3822
3828
|
sym("sec"))),
|
3823
|
-
|
3829
|
+
f_frozen_ary(2,
|
3824
3830
|
sym("wnum1"),
|
3825
|
-
|
3831
|
+
f_frozen_ary(6,
|
3826
3832
|
sym("year"),
|
3827
3833
|
sym("wnum1"),
|
3828
3834
|
sym("wday"),
|
3829
3835
|
sym("hour"),
|
3830
3836
|
sym("min"),
|
3831
3837
|
sym("sec"))),
|
3832
|
-
|
3838
|
+
f_frozen_ary(2,
|
3833
3839
|
Qnil,
|
3834
|
-
|
3840
|
+
f_frozen_ary(6,
|
3835
3841
|
sym("cwyear"),
|
3836
3842
|
sym("cweek"),
|
3837
3843
|
sym("wday"),
|
3838
3844
|
sym("hour"),
|
3839
3845
|
sym("min"),
|
3840
3846
|
sym("sec"))),
|
3841
|
-
|
3847
|
+
f_frozen_ary(2,
|
3842
3848
|
Qnil,
|
3843
|
-
|
3849
|
+
f_frozen_ary(6,
|
3844
3850
|
sym("year"),
|
3845
3851
|
sym("wnum0"),
|
3846
3852
|
sym("cwday"),
|
3847
3853
|
sym("hour"),
|
3848
3854
|
sym("min"),
|
3849
3855
|
sym("sec"))),
|
3850
|
-
|
3856
|
+
f_frozen_ary(2,
|
3851
3857
|
Qnil,
|
3852
|
-
|
3858
|
+
f_frozen_ary(6,
|
3853
3859
|
sym("year"),
|
3854
3860
|
sym("wnum1"),
|
3855
3861
|
sym("cwday"),
|
@@ -4322,12 +4328,37 @@ date_s_strptime(int argc, VALUE *argv, VALUE klass)
|
|
4322
4328
|
|
4323
4329
|
VALUE date__parse(VALUE str, VALUE comp);
|
4324
4330
|
|
4331
|
+
static size_t
|
4332
|
+
get_limit(VALUE opt)
|
4333
|
+
{
|
4334
|
+
if (!NIL_P(opt)) {
|
4335
|
+
VALUE limit = rb_hash_aref(opt, ID2SYM(rb_intern("limit")));
|
4336
|
+
if (NIL_P(limit)) return SIZE_MAX;
|
4337
|
+
return NUM2SIZET(limit);
|
4338
|
+
}
|
4339
|
+
return 128;
|
4340
|
+
}
|
4341
|
+
|
4342
|
+
static void
|
4343
|
+
check_limit(VALUE str, VALUE opt)
|
4344
|
+
{
|
4345
|
+
StringValue(str);
|
4346
|
+
size_t slen = RSTRING_LEN(str);
|
4347
|
+
size_t limit = get_limit(opt);
|
4348
|
+
if (slen > limit) {
|
4349
|
+
rb_raise(rb_eArgError,
|
4350
|
+
"string length (%"PRI_SIZE_PREFIX"u) exceeds the limit %"PRI_SIZE_PREFIX"u", slen, limit);
|
4351
|
+
}
|
4352
|
+
}
|
4353
|
+
|
4325
4354
|
static VALUE
|
4326
4355
|
date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
|
4327
4356
|
{
|
4328
|
-
VALUE vstr, vcomp, hash;
|
4357
|
+
VALUE vstr, vcomp, hash, opt;
|
4329
4358
|
|
4330
|
-
rb_scan_args(argc, argv, "11", &vstr, &vcomp);
|
4359
|
+
rb_scan_args(argc, argv, "11:", &vstr, &vcomp, &opt);
|
4360
|
+
if (!NIL_P(opt)) argc--;
|
4361
|
+
check_limit(vstr, opt);
|
4331
4362
|
StringValue(vstr);
|
4332
4363
|
if (!rb_enc_str_asciicompat_p(vstr))
|
4333
4364
|
rb_raise(rb_eArgError,
|
@@ -4342,17 +4373,25 @@ date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
|
|
4342
4373
|
|
4343
4374
|
/*
|
4344
4375
|
* call-seq:
|
4345
|
-
* Date._parse(string[, comp=true]) -> hash
|
4376
|
+
* Date._parse(string[, comp=true], limit: 128) -> hash
|
4346
4377
|
*
|
4347
4378
|
* Parses the given representation of date and time, and returns a
|
4348
|
-
* hash of parsed elements.
|
4349
|
-
*
|
4379
|
+
* hash of parsed elements.
|
4380
|
+
*
|
4381
|
+
* This method **does not** function as a validator. If the input
|
4382
|
+
* string does not match valid formats strictly, you may get a cryptic
|
4383
|
+
* result. Should consider to use `Date._strptime` or
|
4384
|
+
* `DateTime._strptime` instead of this method as possible.
|
4350
4385
|
*
|
4351
4386
|
* If the optional second argument is true and the detected year is in
|
4352
4387
|
* the range "00" to "99", considers the year a 2-digit form and makes
|
4353
4388
|
* it full.
|
4354
4389
|
*
|
4355
4390
|
* Date._parse('2001-02-03') #=> {:year=>2001, :mon=>2, :mday=>3}
|
4391
|
+
*
|
4392
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4393
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4394
|
+
* it may take a long time to parse.
|
4356
4395
|
*/
|
4357
4396
|
static VALUE
|
4358
4397
|
date_s__parse(int argc, VALUE *argv, VALUE klass)
|
@@ -4362,10 +4401,15 @@ date_s__parse(int argc, VALUE *argv, VALUE klass)
|
|
4362
4401
|
|
4363
4402
|
/*
|
4364
4403
|
* call-seq:
|
4365
|
-
* Date.parse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]]) -> date
|
4404
|
+
* Date.parse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]], limit: 128) -> date
|
4366
4405
|
*
|
4367
4406
|
* Parses the given representation of date and time, and creates a
|
4368
|
-
* date object.
|
4407
|
+
* date object.
|
4408
|
+
*
|
4409
|
+
* This method **does not** function as a validator. If the input
|
4410
|
+
* string does not match valid formats strictly, you may get a cryptic
|
4411
|
+
* result. Should consider to use `Date.strptime` instead of this
|
4412
|
+
* method as possible.
|
4369
4413
|
*
|
4370
4414
|
* If the optional second argument is true and the detected year is in
|
4371
4415
|
* the range "00" to "99", considers the year a 2-digit form and makes
|
@@ -4374,13 +4418,18 @@ date_s__parse(int argc, VALUE *argv, VALUE klass)
|
|
4374
4418
|
* Date.parse('2001-02-03') #=> #<Date: 2001-02-03 ...>
|
4375
4419
|
* Date.parse('20010203') #=> #<Date: 2001-02-03 ...>
|
4376
4420
|
* Date.parse('3rd Feb 2001') #=> #<Date: 2001-02-03 ...>
|
4421
|
+
*
|
4422
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4423
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4424
|
+
* it may take a long time to parse.
|
4377
4425
|
*/
|
4378
4426
|
static VALUE
|
4379
4427
|
date_s_parse(int argc, VALUE *argv, VALUE klass)
|
4380
4428
|
{
|
4381
|
-
VALUE str, comp, sg;
|
4429
|
+
VALUE str, comp, sg, opt;
|
4382
4430
|
|
4383
|
-
rb_scan_args(argc, argv, "03", &str, &comp, &sg);
|
4431
|
+
rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
|
4432
|
+
if (!NIL_P(opt)) argc--;
|
4384
4433
|
|
4385
4434
|
switch (argc) {
|
4386
4435
|
case 0:
|
@@ -4392,11 +4441,12 @@ date_s_parse(int argc, VALUE *argv, VALUE klass)
|
|
4392
4441
|
}
|
4393
4442
|
|
4394
4443
|
{
|
4395
|
-
|
4396
|
-
|
4397
|
-
|
4398
|
-
|
4399
|
-
|
4444
|
+
int argc2 = 2;
|
4445
|
+
VALUE argv2[3];
|
4446
|
+
argv2[0] = str;
|
4447
|
+
argv2[1] = comp;
|
4448
|
+
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
4449
|
+
VALUE hash = date_s__parse(argc2, argv2, klass);
|
4400
4450
|
return d_new_by_frags(klass, hash, sg);
|
4401
4451
|
}
|
4402
4452
|
}
|
@@ -4410,19 +4460,28 @@ VALUE date__jisx0301(VALUE);
|
|
4410
4460
|
|
4411
4461
|
/*
|
4412
4462
|
* call-seq:
|
4413
|
-
* Date._iso8601(string) -> hash
|
4463
|
+
* Date._iso8601(string, limit: 128) -> hash
|
4414
4464
|
*
|
4415
4465
|
* Returns a hash of parsed elements.
|
4466
|
+
*
|
4467
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4468
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4469
|
+
* it may take a long time to parse.
|
4416
4470
|
*/
|
4417
4471
|
static VALUE
|
4418
|
-
date_s__iso8601(VALUE
|
4472
|
+
date_s__iso8601(int argc, VALUE *argv, VALUE klass)
|
4419
4473
|
{
|
4474
|
+
VALUE str, opt;
|
4475
|
+
|
4476
|
+
rb_scan_args(argc, argv, "1:", &str, &opt);
|
4477
|
+
check_limit(str, opt);
|
4478
|
+
|
4420
4479
|
return date__iso8601(str);
|
4421
4480
|
}
|
4422
4481
|
|
4423
4482
|
/*
|
4424
4483
|
* call-seq:
|
4425
|
-
* Date.iso8601(string='-4712-01-01'[, start=Date::ITALY]) -> date
|
4484
|
+
* Date.iso8601(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
|
4426
4485
|
*
|
4427
4486
|
* Creates a new Date object by parsing from a string according to
|
4428
4487
|
* some typical ISO 8601 formats.
|
@@ -4430,13 +4489,18 @@ date_s__iso8601(VALUE klass, VALUE str)
|
|
4430
4489
|
* Date.iso8601('2001-02-03') #=> #<Date: 2001-02-03 ...>
|
4431
4490
|
* Date.iso8601('20010203') #=> #<Date: 2001-02-03 ...>
|
4432
4491
|
* Date.iso8601('2001-W05-6') #=> #<Date: 2001-02-03 ...>
|
4492
|
+
*
|
4493
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4494
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4495
|
+
* it may take a long time to parse.
|
4433
4496
|
*/
|
4434
4497
|
static VALUE
|
4435
4498
|
date_s_iso8601(int argc, VALUE *argv, VALUE klass)
|
4436
4499
|
{
|
4437
|
-
VALUE str, sg;
|
4500
|
+
VALUE str, sg, opt;
|
4438
4501
|
|
4439
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
4502
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
4503
|
+
if (!NIL_P(opt)) argc--;
|
4440
4504
|
|
4441
4505
|
switch (argc) {
|
4442
4506
|
case 0:
|
@@ -4446,38 +4510,56 @@ date_s_iso8601(int argc, VALUE *argv, VALUE klass)
|
|
4446
4510
|
}
|
4447
4511
|
|
4448
4512
|
{
|
4449
|
-
|
4513
|
+
int argc2 = 1;
|
4514
|
+
VALUE argv2[2];
|
4515
|
+
argv2[0] = str;
|
4516
|
+
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
4517
|
+
VALUE hash = date_s__iso8601(argc2, argv2, klass);
|
4450
4518
|
return d_new_by_frags(klass, hash, sg);
|
4451
4519
|
}
|
4452
4520
|
}
|
4453
4521
|
|
4454
4522
|
/*
|
4455
4523
|
* call-seq:
|
4456
|
-
* Date._rfc3339(string) -> hash
|
4524
|
+
* Date._rfc3339(string, limit: 128) -> hash
|
4457
4525
|
*
|
4458
4526
|
* Returns a hash of parsed elements.
|
4527
|
+
*
|
4528
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4529
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4530
|
+
* it may take a long time to parse.
|
4459
4531
|
*/
|
4460
4532
|
static VALUE
|
4461
|
-
date_s__rfc3339(VALUE
|
4533
|
+
date_s__rfc3339(int argc, VALUE *argv, VALUE klass)
|
4462
4534
|
{
|
4535
|
+
VALUE str, opt;
|
4536
|
+
|
4537
|
+
rb_scan_args(argc, argv, "1:", &str, &opt);
|
4538
|
+
check_limit(str, opt);
|
4539
|
+
|
4463
4540
|
return date__rfc3339(str);
|
4464
4541
|
}
|
4465
4542
|
|
4466
4543
|
/*
|
4467
4544
|
* call-seq:
|
4468
|
-
* Date.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> date
|
4545
|
+
* Date.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> date
|
4469
4546
|
*
|
4470
4547
|
* Creates a new Date object by parsing from a string according to
|
4471
4548
|
* some typical RFC 3339 formats.
|
4472
4549
|
*
|
4473
4550
|
* Date.rfc3339('2001-02-03T04:05:06+07:00') #=> #<Date: 2001-02-03 ...>
|
4551
|
+
*
|
4552
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4553
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4554
|
+
* it may take a long time to parse.
|
4474
4555
|
*/
|
4475
4556
|
static VALUE
|
4476
4557
|
date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
|
4477
4558
|
{
|
4478
|
-
VALUE str, sg;
|
4559
|
+
VALUE str, sg, opt;
|
4479
4560
|
|
4480
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
4561
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
4562
|
+
if (!NIL_P(opt)) argc--;
|
4481
4563
|
|
4482
4564
|
switch (argc) {
|
4483
4565
|
case 0:
|
@@ -4487,38 +4569,56 @@ date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
|
|
4487
4569
|
}
|
4488
4570
|
|
4489
4571
|
{
|
4490
|
-
|
4572
|
+
int argc2 = 1;
|
4573
|
+
VALUE argv2[2];
|
4574
|
+
argv2[0] = str;
|
4575
|
+
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
4576
|
+
VALUE hash = date_s__rfc3339(argc2, argv2, klass);
|
4491
4577
|
return d_new_by_frags(klass, hash, sg);
|
4492
4578
|
}
|
4493
4579
|
}
|
4494
4580
|
|
4495
4581
|
/*
|
4496
4582
|
* call-seq:
|
4497
|
-
* Date._xmlschema(string) -> hash
|
4583
|
+
* Date._xmlschema(string, limit: 128) -> hash
|
4498
4584
|
*
|
4499
4585
|
* Returns a hash of parsed elements.
|
4586
|
+
*
|
4587
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4588
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4589
|
+
* it may take a long time to parse.
|
4500
4590
|
*/
|
4501
4591
|
static VALUE
|
4502
|
-
date_s__xmlschema(VALUE
|
4592
|
+
date_s__xmlschema(int argc, VALUE *argv, VALUE klass)
|
4503
4593
|
{
|
4594
|
+
VALUE str, opt;
|
4595
|
+
|
4596
|
+
rb_scan_args(argc, argv, "1:", &str, &opt);
|
4597
|
+
check_limit(str, opt);
|
4598
|
+
|
4504
4599
|
return date__xmlschema(str);
|
4505
4600
|
}
|
4506
4601
|
|
4507
4602
|
/*
|
4508
4603
|
* call-seq:
|
4509
|
-
* Date.xmlschema(string='-4712-01-01'[, start=Date::ITALY]) -> date
|
4604
|
+
* Date.xmlschema(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
|
4510
4605
|
*
|
4511
4606
|
* Creates a new Date object by parsing from a string according to
|
4512
4607
|
* some typical XML Schema formats.
|
4513
4608
|
*
|
4514
4609
|
* Date.xmlschema('2001-02-03') #=> #<Date: 2001-02-03 ...>
|
4610
|
+
*
|
4611
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4612
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4613
|
+
* it may take a long time to parse.
|
4515
4614
|
*/
|
4516
4615
|
static VALUE
|
4517
4616
|
date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
4518
4617
|
{
|
4519
|
-
VALUE str, sg;
|
4618
|
+
VALUE str, sg, opt;
|
4520
4619
|
|
4521
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
4620
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
4621
|
+
if (!NIL_P(opt)) argc--;
|
4522
4622
|
|
4523
4623
|
switch (argc) {
|
4524
4624
|
case 0:
|
@@ -4528,41 +4628,58 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
|
4528
4628
|
}
|
4529
4629
|
|
4530
4630
|
{
|
4531
|
-
|
4631
|
+
int argc2 = 1;
|
4632
|
+
VALUE argv2[2];
|
4633
|
+
argv2[0] = str;
|
4634
|
+
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
4635
|
+
VALUE hash = date_s__xmlschema(argc2, argv2, klass);
|
4532
4636
|
return d_new_by_frags(klass, hash, sg);
|
4533
4637
|
}
|
4534
4638
|
}
|
4535
4639
|
|
4536
4640
|
/*
|
4537
4641
|
* call-seq:
|
4538
|
-
* Date._rfc2822(string) -> hash
|
4539
|
-
* Date._rfc822(string) -> hash
|
4642
|
+
* Date._rfc2822(string, limit: 128) -> hash
|
4643
|
+
* Date._rfc822(string, limit: 128) -> hash
|
4540
4644
|
*
|
4541
4645
|
* Returns a hash of parsed elements.
|
4646
|
+
*
|
4647
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4648
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4649
|
+
* it may take a long time to parse.
|
4542
4650
|
*/
|
4543
4651
|
static VALUE
|
4544
|
-
date_s__rfc2822(VALUE
|
4652
|
+
date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
|
4545
4653
|
{
|
4654
|
+
VALUE str, opt;
|
4655
|
+
|
4656
|
+
rb_scan_args(argc, argv, "1:", &str, &opt);
|
4657
|
+
check_limit(str, opt);
|
4658
|
+
|
4546
4659
|
return date__rfc2822(str);
|
4547
4660
|
}
|
4548
4661
|
|
4549
4662
|
/*
|
4550
4663
|
* call-seq:
|
4551
|
-
* Date.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> date
|
4552
|
-
* Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> date
|
4664
|
+
* Date.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> date
|
4665
|
+
* Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> date
|
4553
4666
|
*
|
4554
4667
|
* Creates a new Date object by parsing from a string according to
|
4555
4668
|
* some typical RFC 2822 formats.
|
4556
4669
|
*
|
4557
4670
|
* Date.rfc2822('Sat, 3 Feb 2001 00:00:00 +0000')
|
4558
4671
|
* #=> #<Date: 2001-02-03 ...>
|
4672
|
+
*
|
4673
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4674
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4675
|
+
* it may take a long time to parse.
|
4559
4676
|
*/
|
4560
4677
|
static VALUE
|
4561
4678
|
date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
4562
4679
|
{
|
4563
|
-
VALUE str, sg;
|
4680
|
+
VALUE str, sg, opt;
|
4564
4681
|
|
4565
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
4682
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
4566
4683
|
|
4567
4684
|
switch (argc) {
|
4568
4685
|
case 0:
|
@@ -4572,39 +4689,56 @@ date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
|
4572
4689
|
}
|
4573
4690
|
|
4574
4691
|
{
|
4575
|
-
|
4692
|
+
int argc2 = 1;
|
4693
|
+
VALUE argv2[2];
|
4694
|
+
argv2[0] = str;
|
4695
|
+
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
4696
|
+
VALUE hash = date_s__rfc2822(argc2, argv2, klass);
|
4576
4697
|
return d_new_by_frags(klass, hash, sg);
|
4577
4698
|
}
|
4578
4699
|
}
|
4579
4700
|
|
4580
4701
|
/*
|
4581
4702
|
* call-seq:
|
4582
|
-
* Date._httpdate(string) -> hash
|
4703
|
+
* Date._httpdate(string, limit: 128) -> hash
|
4583
4704
|
*
|
4584
4705
|
* Returns a hash of parsed elements.
|
4706
|
+
*
|
4707
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4708
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4709
|
+
* it may take a long time to parse.
|
4585
4710
|
*/
|
4586
4711
|
static VALUE
|
4587
|
-
date_s__httpdate(VALUE
|
4712
|
+
date_s__httpdate(int argc, VALUE *argv, VALUE klass)
|
4588
4713
|
{
|
4714
|
+
VALUE str, opt;
|
4715
|
+
|
4716
|
+
rb_scan_args(argc, argv, "1:", &str, &opt);
|
4717
|
+
check_limit(str, opt);
|
4718
|
+
|
4589
4719
|
return date__httpdate(str);
|
4590
4720
|
}
|
4591
4721
|
|
4592
4722
|
/*
|
4593
4723
|
* call-seq:
|
4594
|
-
* Date.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY]) -> date
|
4724
|
+
* Date.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY], limit: 128) -> date
|
4595
4725
|
*
|
4596
4726
|
* Creates a new Date object by parsing from a string according to
|
4597
4727
|
* some RFC 2616 format.
|
4598
4728
|
*
|
4599
4729
|
* Date.httpdate('Sat, 03 Feb 2001 00:00:00 GMT')
|
4600
4730
|
* #=> #<Date: 2001-02-03 ...>
|
4731
|
+
*
|
4732
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4733
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4734
|
+
* it may take a long time to parse.
|
4601
4735
|
*/
|
4602
4736
|
static VALUE
|
4603
4737
|
date_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
4604
4738
|
{
|
4605
|
-
VALUE str, sg;
|
4739
|
+
VALUE str, sg, opt;
|
4606
4740
|
|
4607
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
4741
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
4608
4742
|
|
4609
4743
|
switch (argc) {
|
4610
4744
|
case 0:
|
@@ -4614,26 +4748,39 @@ date_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
|
4614
4748
|
}
|
4615
4749
|
|
4616
4750
|
{
|
4617
|
-
|
4751
|
+
int argc2 = 1;
|
4752
|
+
VALUE argv2[2];
|
4753
|
+
argv2[0] = str;
|
4754
|
+
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
4755
|
+
VALUE hash = date_s__httpdate(argc2, argv2, klass);
|
4618
4756
|
return d_new_by_frags(klass, hash, sg);
|
4619
4757
|
}
|
4620
4758
|
}
|
4621
4759
|
|
4622
4760
|
/*
|
4623
4761
|
* call-seq:
|
4624
|
-
* Date._jisx0301(string) -> hash
|
4762
|
+
* Date._jisx0301(string, limit: 128) -> hash
|
4625
4763
|
*
|
4626
4764
|
* Returns a hash of parsed elements.
|
4765
|
+
*
|
4766
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4767
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4768
|
+
* it may take a long time to parse.
|
4627
4769
|
*/
|
4628
4770
|
static VALUE
|
4629
|
-
date_s__jisx0301(VALUE
|
4771
|
+
date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
|
4630
4772
|
{
|
4773
|
+
VALUE str, opt;
|
4774
|
+
|
4775
|
+
rb_scan_args(argc, argv, "1:", &str, &opt);
|
4776
|
+
check_limit(str, opt);
|
4777
|
+
|
4631
4778
|
return date__jisx0301(str);
|
4632
4779
|
}
|
4633
4780
|
|
4634
4781
|
/*
|
4635
4782
|
* call-seq:
|
4636
|
-
* Date.jisx0301(string='-4712-01-01'[, start=Date::ITALY]) -> date
|
4783
|
+
* Date.jisx0301(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
|
4637
4784
|
*
|
4638
4785
|
* Creates a new Date object by parsing from a string according to
|
4639
4786
|
* some typical JIS X 0301 formats.
|
@@ -4643,13 +4790,18 @@ date_s__jisx0301(VALUE klass, VALUE str)
|
|
4643
4790
|
* For no-era year, legacy format, Heisei is assumed.
|
4644
4791
|
*
|
4645
4792
|
* Date.jisx0301('13.02.03') #=> #<Date: 2001-02-03 ...>
|
4793
|
+
*
|
4794
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
4795
|
+
* You can stop this check by passing `limit: nil`, but note that
|
4796
|
+
* it may take a long time to parse.
|
4646
4797
|
*/
|
4647
4798
|
static VALUE
|
4648
4799
|
date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
|
4649
4800
|
{
|
4650
|
-
VALUE str, sg;
|
4801
|
+
VALUE str, sg, opt;
|
4651
4802
|
|
4652
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
4803
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
4804
|
+
if (!NIL_P(opt)) argc--;
|
4653
4805
|
|
4654
4806
|
switch (argc) {
|
4655
4807
|
case 0:
|
@@ -4659,7 +4811,11 @@ date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
|
|
4659
4811
|
}
|
4660
4812
|
|
4661
4813
|
{
|
4662
|
-
|
4814
|
+
int argc2 = 1;
|
4815
|
+
VALUE argv2[2];
|
4816
|
+
argv2[0] = str;
|
4817
|
+
if (!NIL_P(opt)) argv2[argc2++] = opt;
|
4818
|
+
VALUE hash = date_s__jisx0301(argc2, argv2, klass);
|
4663
4819
|
return d_new_by_frags(klass, hash, sg);
|
4664
4820
|
}
|
4665
4821
|
}
|
@@ -7998,10 +8154,15 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
|
|
7998
8154
|
|
7999
8155
|
/*
|
8000
8156
|
* call-seq:
|
8001
|
-
* DateTime.parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]]) -> datetime
|
8157
|
+
* DateTime.parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]], limit: 128) -> datetime
|
8002
8158
|
*
|
8003
8159
|
* Parses the given representation of date and time, and creates a
|
8004
|
-
* DateTime object.
|
8160
|
+
* DateTime object.
|
8161
|
+
*
|
8162
|
+
* This method **does not** function as a validator. If the input
|
8163
|
+
* string does not match valid formats strictly, you may get a cryptic
|
8164
|
+
* result. Should consider to use `DateTime.strptime` instead of this
|
8165
|
+
* method as possible.
|
8005
8166
|
*
|
8006
8167
|
* If the optional second argument is true and the detected year is in
|
8007
8168
|
* the range "00" to "99", makes it full.
|
@@ -8012,13 +8173,18 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
|
|
8012
8173
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
8013
8174
|
* DateTime.parse('3rd Feb 2001 04:05:06 PM')
|
8014
8175
|
* #=> #<DateTime: 2001-02-03T16:05:06+00:00 ...>
|
8176
|
+
*
|
8177
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
8178
|
+
* You can stop this check by passing `limit: nil`, but note that
|
8179
|
+
* it may take a long time to parse.
|
8015
8180
|
*/
|
8016
8181
|
static VALUE
|
8017
8182
|
datetime_s_parse(int argc, VALUE *argv, VALUE klass)
|
8018
8183
|
{
|
8019
|
-
VALUE str, comp, sg;
|
8184
|
+
VALUE str, comp, sg, opt;
|
8020
8185
|
|
8021
|
-
rb_scan_args(argc, argv, "03", &str, &comp, &sg);
|
8186
|
+
rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
|
8187
|
+
if (!NIL_P(opt)) argc--;
|
8022
8188
|
|
8023
8189
|
switch (argc) {
|
8024
8190
|
case 0:
|
@@ -8030,18 +8196,20 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
|
|
8030
8196
|
}
|
8031
8197
|
|
8032
8198
|
{
|
8033
|
-
|
8034
|
-
|
8035
|
-
|
8036
|
-
|
8037
|
-
|
8199
|
+
int argc2 = 2;
|
8200
|
+
VALUE argv2[3];
|
8201
|
+
argv2[0] = str;
|
8202
|
+
argv2[1] = comp;
|
8203
|
+
argv2[2] = opt;
|
8204
|
+
if (!NIL_P(opt)) argc2++;
|
8205
|
+
VALUE hash = date_s__parse(argc2, argv2, klass);
|
8038
8206
|
return dt_new_by_frags(klass, hash, sg);
|
8039
8207
|
}
|
8040
8208
|
}
|
8041
8209
|
|
8042
8210
|
/*
|
8043
8211
|
* call-seq:
|
8044
|
-
* DateTime.iso8601(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
|
8212
|
+
* DateTime.iso8601(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
|
8045
8213
|
*
|
8046
8214
|
* Creates a new DateTime object by parsing from a string according to
|
8047
8215
|
* some typical ISO 8601 formats.
|
@@ -8052,13 +8220,18 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
|
|
8052
8220
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
8053
8221
|
* DateTime.iso8601('2001-W05-6T04:05:06+07:00')
|
8054
8222
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
8223
|
+
*
|
8224
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
8225
|
+
* You can stop this check by passing `limit: nil`, but note that
|
8226
|
+
* it may take a long time to parse.
|
8055
8227
|
*/
|
8056
8228
|
static VALUE
|
8057
8229
|
datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
|
8058
8230
|
{
|
8059
|
-
VALUE str, sg;
|
8231
|
+
VALUE str, sg, opt;
|
8060
8232
|
|
8061
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
8233
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
8234
|
+
if (!NIL_P(opt)) argc--;
|
8062
8235
|
|
8063
8236
|
switch (argc) {
|
8064
8237
|
case 0:
|
@@ -8068,27 +8241,37 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
|
|
8068
8241
|
}
|
8069
8242
|
|
8070
8243
|
{
|
8071
|
-
|
8244
|
+
int argc2 = 1;
|
8245
|
+
VALUE argv2[2];
|
8246
|
+
argv2[0] = str;
|
8247
|
+
argv2[1] = opt;
|
8248
|
+
if (!NIL_P(opt)) argc2--;
|
8249
|
+
VALUE hash = date_s__iso8601(argc2, argv2, klass);
|
8072
8250
|
return dt_new_by_frags(klass, hash, sg);
|
8073
8251
|
}
|
8074
8252
|
}
|
8075
8253
|
|
8076
8254
|
/*
|
8077
8255
|
* call-seq:
|
8078
|
-
* DateTime.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
|
8256
|
+
* DateTime.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
|
8079
8257
|
*
|
8080
8258
|
* Creates a new DateTime object by parsing from a string according to
|
8081
8259
|
* some typical RFC 3339 formats.
|
8082
8260
|
*
|
8083
8261
|
* DateTime.rfc3339('2001-02-03T04:05:06+07:00')
|
8084
8262
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
8263
|
+
*
|
8264
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
8265
|
+
* You can stop this check by passing `limit: nil`, but note that
|
8266
|
+
* it may take a long time to parse.
|
8085
8267
|
*/
|
8086
8268
|
static VALUE
|
8087
8269
|
datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
|
8088
8270
|
{
|
8089
|
-
VALUE str, sg;
|
8271
|
+
VALUE str, sg, opt;
|
8090
8272
|
|
8091
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
8273
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
8274
|
+
if (!NIL_P(opt)) argc--;
|
8092
8275
|
|
8093
8276
|
switch (argc) {
|
8094
8277
|
case 0:
|
@@ -8098,27 +8281,37 @@ datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
|
|
8098
8281
|
}
|
8099
8282
|
|
8100
8283
|
{
|
8101
|
-
|
8284
|
+
int argc2 = 1;
|
8285
|
+
VALUE argv2[2];
|
8286
|
+
argv2[0] = str;
|
8287
|
+
argv2[1] = opt;
|
8288
|
+
if (!NIL_P(opt)) argc2++;
|
8289
|
+
VALUE hash = date_s__rfc3339(argc2, argv2, klass);
|
8102
8290
|
return dt_new_by_frags(klass, hash, sg);
|
8103
8291
|
}
|
8104
8292
|
}
|
8105
8293
|
|
8106
8294
|
/*
|
8107
8295
|
* call-seq:
|
8108
|
-
* DateTime.xmlschema(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
|
8296
|
+
* DateTime.xmlschema(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
|
8109
8297
|
*
|
8110
8298
|
* Creates a new DateTime object by parsing from a string according to
|
8111
8299
|
* some typical XML Schema formats.
|
8112
8300
|
*
|
8113
8301
|
* DateTime.xmlschema('2001-02-03T04:05:06+07:00')
|
8114
8302
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
8303
|
+
*
|
8304
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
8305
|
+
* You can stop this check by passing `limit: nil`, but note that
|
8306
|
+
* it may take a long time to parse.
|
8115
8307
|
*/
|
8116
8308
|
static VALUE
|
8117
8309
|
datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
8118
8310
|
{
|
8119
|
-
VALUE str, sg;
|
8311
|
+
VALUE str, sg, opt;
|
8120
8312
|
|
8121
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
8313
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
8314
|
+
if (!NIL_P(opt)) argc--;
|
8122
8315
|
|
8123
8316
|
switch (argc) {
|
8124
8317
|
case 0:
|
@@ -8128,28 +8321,38 @@ datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
|
|
8128
8321
|
}
|
8129
8322
|
|
8130
8323
|
{
|
8131
|
-
|
8324
|
+
int argc2 = 1;
|
8325
|
+
VALUE argv2[2];
|
8326
|
+
argv2[0] = str;
|
8327
|
+
argv2[1] = opt;
|
8328
|
+
if (!NIL_P(opt)) argc2++;
|
8329
|
+
VALUE hash = date_s__xmlschema(argc2, argv2, klass);
|
8132
8330
|
return dt_new_by_frags(klass, hash, sg);
|
8133
8331
|
}
|
8134
8332
|
}
|
8135
8333
|
|
8136
8334
|
/*
|
8137
8335
|
* call-seq:
|
8138
|
-
* DateTime.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> datetime
|
8139
|
-
* DateTime.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> datetime
|
8336
|
+
* DateTime.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> datetime
|
8337
|
+
* DateTime.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> datetime
|
8140
8338
|
*
|
8141
8339
|
* Creates a new DateTime object by parsing from a string according to
|
8142
8340
|
* some typical RFC 2822 formats.
|
8143
8341
|
*
|
8144
8342
|
* DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700')
|
8145
8343
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
8344
|
+
*
|
8345
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
8346
|
+
* You can stop this check by passing `limit: nil`, but note that
|
8347
|
+
* it may take a long time to parse.
|
8146
8348
|
*/
|
8147
8349
|
static VALUE
|
8148
8350
|
datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
8149
8351
|
{
|
8150
|
-
VALUE str, sg;
|
8352
|
+
VALUE str, sg, opt;
|
8151
8353
|
|
8152
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
8354
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
8355
|
+
if (!NIL_P(opt)) argc--;
|
8153
8356
|
|
8154
8357
|
switch (argc) {
|
8155
8358
|
case 0:
|
@@ -8159,7 +8362,12 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
|
8159
8362
|
}
|
8160
8363
|
|
8161
8364
|
{
|
8162
|
-
|
8365
|
+
int argc2 = 1;
|
8366
|
+
VALUE argv2[2];
|
8367
|
+
argv2[0] = str;
|
8368
|
+
argv2[1] = opt;
|
8369
|
+
if (!NIL_P(opt)) argc2++;
|
8370
|
+
VALUE hash = date_s__rfc2822(argc2, argv2, klass);
|
8163
8371
|
return dt_new_by_frags(klass, hash, sg);
|
8164
8372
|
}
|
8165
8373
|
}
|
@@ -8173,13 +8381,18 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
|
|
8173
8381
|
*
|
8174
8382
|
* DateTime.httpdate('Sat, 03 Feb 2001 04:05:06 GMT')
|
8175
8383
|
* #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>
|
8384
|
+
*
|
8385
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
8386
|
+
* You can stop this check by passing `limit: nil`, but note that
|
8387
|
+
* it may take a long time to parse.
|
8176
8388
|
*/
|
8177
8389
|
static VALUE
|
8178
8390
|
datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
8179
8391
|
{
|
8180
|
-
VALUE str, sg;
|
8392
|
+
VALUE str, sg, opt;
|
8181
8393
|
|
8182
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
8394
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
8395
|
+
if (!NIL_P(opt)) argc--;
|
8183
8396
|
|
8184
8397
|
switch (argc) {
|
8185
8398
|
case 0:
|
@@ -8189,14 +8402,19 @@ datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
|
8189
8402
|
}
|
8190
8403
|
|
8191
8404
|
{
|
8192
|
-
|
8405
|
+
int argc2 = 1;
|
8406
|
+
VALUE argv2[2];
|
8407
|
+
argv2[0] = str;
|
8408
|
+
argv2[1] = opt;
|
8409
|
+
if (!NIL_P(opt)) argc2++;
|
8410
|
+
VALUE hash = date_s__httpdate(argc2, argv2, klass);
|
8193
8411
|
return dt_new_by_frags(klass, hash, sg);
|
8194
8412
|
}
|
8195
8413
|
}
|
8196
8414
|
|
8197
8415
|
/*
|
8198
8416
|
* call-seq:
|
8199
|
-
* DateTime.jisx0301(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
|
8417
|
+
* DateTime.jisx0301(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
|
8200
8418
|
*
|
8201
8419
|
* Creates a new DateTime object by parsing from a string according to
|
8202
8420
|
* some typical JIS X 0301 formats.
|
@@ -8208,13 +8426,18 @@ datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
|
|
8208
8426
|
*
|
8209
8427
|
* DateTime.jisx0301('13.02.03T04:05:06+07:00')
|
8210
8428
|
* #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
|
8429
|
+
*
|
8430
|
+
* Raise an ArgumentError when the string length is longer than _limit_.
|
8431
|
+
* You can stop this check by passing `limit: nil`, but note that
|
8432
|
+
* it may take a long time to parse.
|
8211
8433
|
*/
|
8212
8434
|
static VALUE
|
8213
8435
|
datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
|
8214
8436
|
{
|
8215
|
-
VALUE str, sg;
|
8437
|
+
VALUE str, sg, opt;
|
8216
8438
|
|
8217
|
-
rb_scan_args(argc, argv, "02", &str, &sg);
|
8439
|
+
rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
|
8440
|
+
if (!NIL_P(opt)) argc--;
|
8218
8441
|
|
8219
8442
|
switch (argc) {
|
8220
8443
|
case 0:
|
@@ -8224,7 +8447,12 @@ datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
|
|
8224
8447
|
}
|
8225
8448
|
|
8226
8449
|
{
|
8227
|
-
|
8450
|
+
int argc2 = 1;
|
8451
|
+
VALUE argv2[2];
|
8452
|
+
argv2[0] = str;
|
8453
|
+
argv2[1] = opt;
|
8454
|
+
if (!NIL_P(opt)) argc2++;
|
8455
|
+
VALUE hash = date_s__jisx0301(argc2, argv2, klass);
|
8228
8456
|
return dt_new_by_frags(klass, hash, sg);
|
8229
8457
|
}
|
8230
8458
|
}
|
@@ -9102,13 +9330,13 @@ d_lite_zero(VALUE x)
|
|
9102
9330
|
void
|
9103
9331
|
Init_date_core(void)
|
9104
9332
|
{
|
9105
|
-
#
|
9106
|
-
|
9107
|
-
|
9108
|
-
id_cmp =
|
9109
|
-
id_le_p =
|
9110
|
-
id_ge_p =
|
9111
|
-
id_eqeq_p =
|
9333
|
+
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
9334
|
+
RB_EXT_RACTOR_SAFE(true);
|
9335
|
+
#endif
|
9336
|
+
id_cmp = rb_intern_const("<=>");
|
9337
|
+
id_le_p = rb_intern_const("<=");
|
9338
|
+
id_ge_p = rb_intern_const(">=");
|
9339
|
+
id_eqeq_p = rb_intern_const("==");
|
9112
9340
|
|
9113
9341
|
half_days_in_day = rb_rational_new2(INT2FIX(1), INT2FIX(2));
|
9114
9342
|
|
@@ -9383,19 +9611,19 @@ Init_date_core(void)
|
|
9383
9611
|
rb_define_singleton_method(cDate, "strptime", date_s_strptime, -1);
|
9384
9612
|
rb_define_singleton_method(cDate, "_parse", date_s__parse, -1);
|
9385
9613
|
rb_define_singleton_method(cDate, "parse", date_s_parse, -1);
|
9386
|
-
rb_define_singleton_method(cDate, "_iso8601", date_s__iso8601, 1);
|
9614
|
+
rb_define_singleton_method(cDate, "_iso8601", date_s__iso8601, -1);
|
9387
9615
|
rb_define_singleton_method(cDate, "iso8601", date_s_iso8601, -1);
|
9388
|
-
rb_define_singleton_method(cDate, "_rfc3339", date_s__rfc3339, 1);
|
9616
|
+
rb_define_singleton_method(cDate, "_rfc3339", date_s__rfc3339, -1);
|
9389
9617
|
rb_define_singleton_method(cDate, "rfc3339", date_s_rfc3339, -1);
|
9390
|
-
rb_define_singleton_method(cDate, "_xmlschema", date_s__xmlschema, 1);
|
9618
|
+
rb_define_singleton_method(cDate, "_xmlschema", date_s__xmlschema, -1);
|
9391
9619
|
rb_define_singleton_method(cDate, "xmlschema", date_s_xmlschema, -1);
|
9392
|
-
rb_define_singleton_method(cDate, "_rfc2822", date_s__rfc2822, 1);
|
9393
|
-
rb_define_singleton_method(cDate, "_rfc822", date_s__rfc2822, 1);
|
9620
|
+
rb_define_singleton_method(cDate, "_rfc2822", date_s__rfc2822, -1);
|
9621
|
+
rb_define_singleton_method(cDate, "_rfc822", date_s__rfc2822, -1);
|
9394
9622
|
rb_define_singleton_method(cDate, "rfc2822", date_s_rfc2822, -1);
|
9395
9623
|
rb_define_singleton_method(cDate, "rfc822", date_s_rfc2822, -1);
|
9396
|
-
rb_define_singleton_method(cDate, "_httpdate", date_s__httpdate, 1);
|
9624
|
+
rb_define_singleton_method(cDate, "_httpdate", date_s__httpdate, -1);
|
9397
9625
|
rb_define_singleton_method(cDate, "httpdate", date_s_httpdate, -1);
|
9398
|
-
rb_define_singleton_method(cDate, "_jisx0301", date_s__jisx0301, 1);
|
9626
|
+
rb_define_singleton_method(cDate, "_jisx0301", date_s__jisx0301, -1);
|
9399
9627
|
rb_define_singleton_method(cDate, "jisx0301", date_s_jisx0301, -1);
|
9400
9628
|
|
9401
9629
|
rb_define_method(cDate, "initialize", date_initialize, -1);
|
@@ -9515,6 +9743,8 @@ Init_date_core(void)
|
|
9515
9743
|
* A subclass of Date that easily handles date, hour, minute, second,
|
9516
9744
|
* and offset.
|
9517
9745
|
*
|
9746
|
+
* DateTime class is considered deprecated. Use Time class.
|
9747
|
+
*
|
9518
9748
|
* DateTime does not consider any leap seconds, does not track
|
9519
9749
|
* any summer time rules.
|
9520
9750
|
*
|
@@ -9575,18 +9805,18 @@ Init_date_core(void)
|
|
9575
9805
|
* === When should you use DateTime and when should you use Time?
|
9576
9806
|
*
|
9577
9807
|
* It's a common misconception that
|
9578
|
-
* {William Shakespeare}[
|
9808
|
+
* {William Shakespeare}[https://en.wikipedia.org/wiki/William_Shakespeare]
|
9579
9809
|
* and
|
9580
|
-
* {Miguel de Cervantes}[
|
9810
|
+
* {Miguel de Cervantes}[https://en.wikipedia.org/wiki/Miguel_de_Cervantes]
|
9581
9811
|
* died on the same day in history -
|
9582
9812
|
* so much so that UNESCO named April 23 as
|
9583
|
-
* {World Book Day because of this fact}[
|
9813
|
+
* {World Book Day because of this fact}[https://en.wikipedia.org/wiki/World_Book_Day].
|
9584
9814
|
* However, because England hadn't yet adopted the
|
9585
|
-
* {Gregorian Calendar Reform}[
|
9586
|
-
* (and wouldn't until {1752}[
|
9815
|
+
* {Gregorian Calendar Reform}[https://en.wikipedia.org/wiki/Gregorian_calendar#Gregorian_reform]
|
9816
|
+
* (and wouldn't until {1752}[https://en.wikipedia.org/wiki/Calendar_(New_Style)_Act_1750])
|
9587
9817
|
* their deaths are actually 10 days apart.
|
9588
9818
|
* Since Ruby's Time class implements a
|
9589
|
-
* {proleptic Gregorian calendar}[
|
9819
|
+
* {proleptic Gregorian calendar}[https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar]
|
9590
9820
|
* and has no concept of calendar reform there's no way
|
9591
9821
|
* to express this with Time objects. This is where DateTime steps in:
|
9592
9822
|
*
|
@@ -9630,7 +9860,7 @@ Init_date_core(void)
|
|
9630
9860
|
* #=> Fri, 04 May 1753 00:00:00 +0000
|
9631
9861
|
*
|
9632
9862
|
* As you can see, if we're accurately tracking the number of
|
9633
|
-
* {solar years}[
|
9863
|
+
* {solar years}[https://en.wikipedia.org/wiki/Tropical_year]
|
9634
9864
|
* since Shakespeare's birthday then the correct anniversary date
|
9635
9865
|
* would be the 4th May and not the 23rd April.
|
9636
9866
|
*
|
@@ -9642,10 +9872,10 @@ Init_date_core(void)
|
|
9642
9872
|
* making the same mistakes as UNESCO. If you also have to deal
|
9643
9873
|
* with timezones then best of luck - just bear in mind that
|
9644
9874
|
* you'll probably be dealing with
|
9645
|
-
* {local solar times}[
|
9875
|
+
* {local solar times}[https://en.wikipedia.org/wiki/Solar_time],
|
9646
9876
|
* since it wasn't until the 19th century that the introduction
|
9647
9877
|
* of the railways necessitated the need for
|
9648
|
-
* {Standard Time}[
|
9878
|
+
* {Standard Time}[https://en.wikipedia.org/wiki/Standard_time#Great_Britain]
|
9649
9879
|
* and eventually timezones.
|
9650
9880
|
*/
|
9651
9881
|
|
data/ext/date/date_parse.c
CHANGED
data/ext/date/date_strptime.c
CHANGED
data/ext/date/prereq.mk
CHANGED
data/ext/date/zonetab.list
CHANGED
@@ -47,12 +47,12 @@ utc, 0*3600
|
|
47
47
|
wet, 0*3600
|
48
48
|
at, -2*3600
|
49
49
|
brst,-2*3600
|
50
|
-
ndt, -(
|
50
|
+
ndt, -(1*3600+1800)
|
51
51
|
art, -3*3600
|
52
52
|
adt, -3*3600
|
53
53
|
brt, -3*3600
|
54
54
|
clst,-3*3600
|
55
|
-
nst, -(
|
55
|
+
nst, -(2*3600+1800)
|
56
56
|
ast, -4*3600
|
57
57
|
clt, -4*3600
|
58
58
|
akdt,-8*3600
|
@@ -62,7 +62,7 @@ hadt,-9*3600
|
|
62
62
|
hdt, -9*3600
|
63
63
|
yst, -9*3600
|
64
64
|
ahst,-10*3600
|
65
|
-
cat
|
65
|
+
cat,2*3600
|
66
66
|
hast,-10*3600
|
67
67
|
hst,-10*3600
|
68
68
|
nt, -11*3600
|
@@ -82,7 +82,7 @@ fst, 2*3600
|
|
82
82
|
mest, 2*3600
|
83
83
|
mesz, 2*3600
|
84
84
|
sast, 2*3600
|
85
|
-
sst,
|
85
|
+
sst, -11*3600
|
86
86
|
bt, 3*3600
|
87
87
|
eat, 3*3600
|
88
88
|
eest, 3*3600
|
@@ -92,13 +92,13 @@ zp4, 4*3600
|
|
92
92
|
zp5, 5*3600
|
93
93
|
ist, (5*3600+1800)
|
94
94
|
zp6, 6*3600
|
95
|
-
wast,
|
96
|
-
cct,
|
95
|
+
wast, 2*3600
|
96
|
+
cct, (6*3600+1800)
|
97
97
|
sgt, 8*3600
|
98
98
|
wadt, 8*3600
|
99
99
|
jst, 9*3600
|
100
100
|
kst, 9*3600
|
101
|
-
east
|
101
|
+
east,-6*3600
|
102
102
|
gst, 10*3600
|
103
103
|
eadt,11*3600
|
104
104
|
idle,12*3600
|
data/lib/date.rb
CHANGED
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: date
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tadayoshi Funaba
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A subclass of Object includes Comparable module for handling dates.
|
14
14
|
email:
|
15
|
-
-
|
15
|
+
-
|
16
16
|
executables: []
|
17
17
|
extensions:
|
18
18
|
- ext/date/extconf.rb
|
@@ -30,9 +30,10 @@ files:
|
|
30
30
|
- lib/date.rb
|
31
31
|
homepage: https://github.com/ruby/date
|
32
32
|
licenses:
|
33
|
+
- Ruby
|
33
34
|
- BSD-2-Clause
|
34
35
|
metadata: {}
|
35
|
-
post_install_message:
|
36
|
+
post_install_message:
|
36
37
|
rdoc_options: []
|
37
38
|
require_paths:
|
38
39
|
- lib
|
@@ -47,8 +48,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
48
|
- !ruby/object:Gem::Version
|
48
49
|
version: '0'
|
49
50
|
requirements: []
|
50
|
-
rubygems_version: 3.
|
51
|
-
signing_key:
|
51
|
+
rubygems_version: 3.1.4
|
52
|
+
signing_key:
|
52
53
|
specification_version: 4
|
53
54
|
summary: A subclass of Object includes Comparable module for handling dates.
|
54
55
|
test_files: []
|