date 3.0.3 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of date might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 458212a8cf5ab21beadd0ddd281f41a7f3fa9dfe50fcb7f52a2594941b11477f
4
- data.tar.gz: 0a100c588376c5e886558cf9d2cc131d643e5387a483378b99d9ff371aad593c
3
+ metadata.gz: d4caa8f18343ab584fcbd5be80672d95d6b72574cc75690e2f591fc671f611aa
4
+ data.tar.gz: 0d70fbd67392cfdfa0d080d5626808a1c7fc4f834117da812369bf2910c90317
5
5
  SHA512:
6
- metadata.gz: fc7a13a9872d1c4b5b4f6495bdf3cb903b2d274dc06b3bd3d3b5a99f0be765e01bf449ae57bafb221fbf70dd3958ffbde9c76103c10971234a0724179c558b1f
7
- data.tar.gz: 63aacb8fc345a4dab53217a46f70a4dcdf7a0e7ace8d1450a36ef3b37e236f33d116a5228c44eefe45590f5bf8b608f0fe51d9d28c0f1f06915af113aaba7990
6
+ metadata.gz: 3b36c300a66f6dc671293c647e73014dff9c0460216c177a4cff0977973ca62029b3b9053b87d135a50d3885832edbbc36f0f37280008dca39da711d8070f5c6
7
+ data.tar.gz: a18e531345a4da23054d03e8480d76afdba97f97a12e56ca840a0dafd6467a1a5d1f9ec9b7e04b0fe6d9e088c1fec078042508aa9cd09e78d4941dc41701662d
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
 
@@ -2975,7 +2977,7 @@ static const rb_data_type_t d_lite_type = {
2975
2977
  "Date",
2976
2978
  {d_lite_gc_mark, RUBY_TYPED_DEFAULT_FREE, d_lite_memsize,},
2977
2979
  0, 0,
2978
- RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED,
2980
+ RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED|RUBY_TYPED_FROZEN_SHAREABLE,
2979
2981
  };
2980
2982
 
2981
2983
  inline static VALUE
@@ -3767,89 +3769,89 @@ rt_complete_frags(VALUE klass, VALUE hash)
3767
3769
  VALUE k, a, d;
3768
3770
 
3769
3771
  if (NIL_P(tab)) {
3770
- tab = rb_ary_new3(11,
3771
- rb_ary_new3(2,
3772
+ tab = f_frozen_ary(11,
3773
+ f_frozen_ary(2,
3772
3774
  sym("time"),
3773
- rb_ary_new3(3,
3775
+ f_frozen_ary(3,
3774
3776
  sym("hour"),
3775
3777
  sym("min"),
3776
3778
  sym("sec"))),
3777
- rb_ary_new3(2,
3779
+ f_frozen_ary(2,
3778
3780
  Qnil,
3779
- rb_ary_new3(1,
3781
+ f_frozen_ary(1,
3780
3782
  sym("jd"))),
3781
- rb_ary_new3(2,
3783
+ f_frozen_ary(2,
3782
3784
  sym("ordinal"),
3783
- rb_ary_new3(5,
3785
+ f_frozen_ary(5,
3784
3786
  sym("year"),
3785
3787
  sym("yday"),
3786
3788
  sym("hour"),
3787
3789
  sym("min"),
3788
3790
  sym("sec"))),
3789
- rb_ary_new3(2,
3791
+ f_frozen_ary(2,
3790
3792
  sym("civil"),
3791
- rb_ary_new3(6,
3793
+ f_frozen_ary(6,
3792
3794
  sym("year"),
3793
3795
  sym("mon"),
3794
3796
  sym("mday"),
3795
3797
  sym("hour"),
3796
3798
  sym("min"),
3797
3799
  sym("sec"))),
3798
- rb_ary_new3(2,
3800
+ f_frozen_ary(2,
3799
3801
  sym("commercial"),
3800
- rb_ary_new3(6,
3802
+ f_frozen_ary(6,
3801
3803
  sym("cwyear"),
3802
3804
  sym("cweek"),
3803
3805
  sym("cwday"),
3804
3806
  sym("hour"),
3805
3807
  sym("min"),
3806
3808
  sym("sec"))),
3807
- rb_ary_new3(2,
3809
+ f_frozen_ary(2,
3808
3810
  sym("wday"),
3809
- rb_ary_new3(4,
3811
+ f_frozen_ary(4,
3810
3812
  sym("wday"),
3811
3813
  sym("hour"),
3812
3814
  sym("min"),
3813
3815
  sym("sec"))),
3814
- rb_ary_new3(2,
3816
+ f_frozen_ary(2,
3815
3817
  sym("wnum0"),
3816
- rb_ary_new3(6,
3818
+ f_frozen_ary(6,
3817
3819
  sym("year"),
3818
3820
  sym("wnum0"),
3819
3821
  sym("wday"),
3820
3822
  sym("hour"),
3821
3823
  sym("min"),
3822
3824
  sym("sec"))),
3823
- rb_ary_new3(2,
3825
+ f_frozen_ary(2,
3824
3826
  sym("wnum1"),
3825
- rb_ary_new3(6,
3827
+ f_frozen_ary(6,
3826
3828
  sym("year"),
3827
3829
  sym("wnum1"),
3828
3830
  sym("wday"),
3829
3831
  sym("hour"),
3830
3832
  sym("min"),
3831
3833
  sym("sec"))),
3832
- rb_ary_new3(2,
3834
+ f_frozen_ary(2,
3833
3835
  Qnil,
3834
- rb_ary_new3(6,
3836
+ f_frozen_ary(6,
3835
3837
  sym("cwyear"),
3836
3838
  sym("cweek"),
3837
3839
  sym("wday"),
3838
3840
  sym("hour"),
3839
3841
  sym("min"),
3840
3842
  sym("sec"))),
3841
- rb_ary_new3(2,
3843
+ f_frozen_ary(2,
3842
3844
  Qnil,
3843
- rb_ary_new3(6,
3845
+ f_frozen_ary(6,
3844
3846
  sym("year"),
3845
3847
  sym("wnum0"),
3846
3848
  sym("cwday"),
3847
3849
  sym("hour"),
3848
3850
  sym("min"),
3849
3851
  sym("sec"))),
3850
- rb_ary_new3(2,
3852
+ f_frozen_ary(2,
3851
3853
  Qnil,
3852
- rb_ary_new3(6,
3854
+ f_frozen_ary(6,
3853
3855
  sym("year"),
3854
3856
  sym("wnum1"),
3855
3857
  sym("cwday"),
@@ -4322,40 +4324,12 @@ date_s_strptime(int argc, VALUE *argv, VALUE klass)
4322
4324
 
4323
4325
  VALUE date__parse(VALUE str, VALUE comp);
4324
4326
 
4325
- static size_t
4326
- get_limit(VALUE opt)
4327
- {
4328
- if (!NIL_P(opt)) {
4329
- VALUE limit = rb_hash_aref(opt, ID2SYM(rb_intern("limit")));
4330
- if (NIL_P(limit)) return SIZE_MAX;
4331
- return NUM2SIZET(limit);
4332
- }
4333
- return 128;
4334
- }
4335
-
4336
- static void
4337
- check_limit(VALUE str, VALUE opt)
4338
- {
4339
- if (NIL_P(str)) return;
4340
- if (SYMBOL_P(str)) str = rb_sym2str(str);
4341
-
4342
- StringValue(str);
4343
- size_t slen = RSTRING_LEN(str);
4344
- size_t limit = get_limit(opt);
4345
- if (slen > limit) {
4346
- rb_raise(rb_eArgError,
4347
- "string length (%"PRI_SIZE_PREFIX"u) exceeds the limit %"PRI_SIZE_PREFIX"u", slen, limit);
4348
- }
4349
- }
4350
-
4351
4327
  static VALUE
4352
4328
  date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
4353
4329
  {
4354
- VALUE vstr, vcomp, hash, opt;
4330
+ VALUE vstr, vcomp, hash;
4355
4331
 
4356
- rb_scan_args(argc, argv, "11:", &vstr, &vcomp, &opt);
4357
- if (!NIL_P(opt)) argc--;
4358
- check_limit(vstr, opt);
4332
+ rb_scan_args(argc, argv, "11", &vstr, &vcomp);
4359
4333
  StringValue(vstr);
4360
4334
  if (!rb_enc_str_asciicompat_p(vstr))
4361
4335
  rb_raise(rb_eArgError,
@@ -4370,21 +4344,21 @@ date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
4370
4344
 
4371
4345
  /*
4372
4346
  * call-seq:
4373
- * Date._parse(string[, comp=true], limit: 128) -> hash
4347
+ * Date._parse(string[, comp=true]) -> hash
4374
4348
  *
4375
4349
  * Parses the given representation of date and time, and returns a
4376
- * hash of parsed elements. This method does not function as a
4377
- * validator.
4350
+ * hash of parsed elements.
4351
+ *
4352
+ * This method **does not** function as a validator. If the input
4353
+ * string does not match valid formats strictly, you may get a cryptic
4354
+ * result. Should consider to use `Date._strptime` or
4355
+ * `DateTime._strptime` instead of this method as possible.
4378
4356
  *
4379
4357
  * If the optional second argument is true and the detected year is in
4380
4358
  * the range "00" to "99", considers the year a 2-digit form and makes
4381
4359
  * it full.
4382
4360
  *
4383
4361
  * Date._parse('2001-02-03') #=> {:year=>2001, :mon=>2, :mday=>3}
4384
- *
4385
- * Raise an ArgumentError when the string length is longer than _limit_.
4386
- * You can stop this check by passing `limit: nil`, but note that
4387
- * it may take a long time to parse.
4388
4362
  */
4389
4363
  static VALUE
4390
4364
  date_s__parse(int argc, VALUE *argv, VALUE klass)
@@ -4394,10 +4368,15 @@ date_s__parse(int argc, VALUE *argv, VALUE klass)
4394
4368
 
4395
4369
  /*
4396
4370
  * call-seq:
4397
- * Date.parse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]], limit: 128) -> date
4371
+ * Date.parse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]]) -> date
4398
4372
  *
4399
4373
  * Parses the given representation of date and time, and creates a
4400
- * date object. This method does not function as a validator.
4374
+ * date object.
4375
+ *
4376
+ * This method **does not** function as a validator. If the input
4377
+ * string does not match valid formats strictly, you may get a cryptic
4378
+ * result. Should consider to use `Date.strptime` instead of this
4379
+ * method as possible.
4401
4380
  *
4402
4381
  * If the optional second argument is true and the detected year is in
4403
4382
  * the range "00" to "99", considers the year a 2-digit form and makes
@@ -4406,18 +4385,13 @@ date_s__parse(int argc, VALUE *argv, VALUE klass)
4406
4385
  * Date.parse('2001-02-03') #=> #<Date: 2001-02-03 ...>
4407
4386
  * Date.parse('20010203') #=> #<Date: 2001-02-03 ...>
4408
4387
  * Date.parse('3rd Feb 2001') #=> #<Date: 2001-02-03 ...>
4409
- *
4410
- * Raise an ArgumentError when the string length is longer than _limit_.
4411
- * You can stop this check by passing `limit: nil`, but note that
4412
- * it may take a long time to parse.
4413
4388
  */
4414
4389
  static VALUE
4415
4390
  date_s_parse(int argc, VALUE *argv, VALUE klass)
4416
4391
  {
4417
- VALUE str, comp, sg, opt;
4392
+ VALUE str, comp, sg;
4418
4393
 
4419
- rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
4420
- if (!NIL_P(opt)) argc--;
4394
+ rb_scan_args(argc, argv, "03", &str, &comp, &sg);
4421
4395
 
4422
4396
  switch (argc) {
4423
4397
  case 0:
@@ -4429,12 +4403,11 @@ date_s_parse(int argc, VALUE *argv, VALUE klass)
4429
4403
  }
4430
4404
 
4431
4405
  {
4432
- int argc2 = 2;
4433
- VALUE argv2[3];
4434
- argv2[0] = str;
4435
- argv2[1] = comp;
4436
- if (!NIL_P(opt)) argv2[argc2++] = opt;
4437
- VALUE hash = date_s__parse(argc2, argv2, klass);
4406
+ VALUE argv2[2], hash;
4407
+
4408
+ argv2[0] = str;
4409
+ argv2[1] = comp;
4410
+ hash = date_s__parse(2, argv2, klass);
4438
4411
  return d_new_by_frags(klass, hash, sg);
4439
4412
  }
4440
4413
  }
@@ -4448,28 +4421,19 @@ VALUE date__jisx0301(VALUE);
4448
4421
 
4449
4422
  /*
4450
4423
  * call-seq:
4451
- * Date._iso8601(string, limit: 128) -> hash
4424
+ * Date._iso8601(string) -> hash
4452
4425
  *
4453
4426
  * Returns a hash of parsed elements.
4454
- *
4455
- * Raise an ArgumentError when the string length is longer than _limit_.
4456
- * You can stop this check by passing `limit: nil`, but note that
4457
- * it may take a long time to parse.
4458
4427
  */
4459
4428
  static VALUE
4460
- date_s__iso8601(int argc, VALUE *argv, VALUE klass)
4429
+ date_s__iso8601(VALUE klass, VALUE str)
4461
4430
  {
4462
- VALUE str, opt;
4463
-
4464
- rb_scan_args(argc, argv, "1:", &str, &opt);
4465
- check_limit(str, opt);
4466
-
4467
4431
  return date__iso8601(str);
4468
4432
  }
4469
4433
 
4470
4434
  /*
4471
4435
  * call-seq:
4472
- * Date.iso8601(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
4436
+ * Date.iso8601(string='-4712-01-01'[, start=Date::ITALY]) -> date
4473
4437
  *
4474
4438
  * Creates a new Date object by parsing from a string according to
4475
4439
  * some typical ISO 8601 formats.
@@ -4477,18 +4441,13 @@ date_s__iso8601(int argc, VALUE *argv, VALUE klass)
4477
4441
  * Date.iso8601('2001-02-03') #=> #<Date: 2001-02-03 ...>
4478
4442
  * Date.iso8601('20010203') #=> #<Date: 2001-02-03 ...>
4479
4443
  * Date.iso8601('2001-W05-6') #=> #<Date: 2001-02-03 ...>
4480
- *
4481
- * Raise an ArgumentError when the string length is longer than _limit_.
4482
- * You can stop this check by passing `limit: nil`, but note that
4483
- * it may take a long time to parse.
4484
4444
  */
4485
4445
  static VALUE
4486
4446
  date_s_iso8601(int argc, VALUE *argv, VALUE klass)
4487
4447
  {
4488
- VALUE str, sg, opt;
4448
+ VALUE str, sg;
4489
4449
 
4490
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4491
- if (!NIL_P(opt)) argc--;
4450
+ rb_scan_args(argc, argv, "02", &str, &sg);
4492
4451
 
4493
4452
  switch (argc) {
4494
4453
  case 0:
@@ -4498,56 +4457,38 @@ date_s_iso8601(int argc, VALUE *argv, VALUE klass)
4498
4457
  }
4499
4458
 
4500
4459
  {
4501
- int argc2 = 1;
4502
- VALUE argv2[2];
4503
- argv2[0] = str;
4504
- if (!NIL_P(opt)) argv2[argc2++] = opt;
4505
- VALUE hash = date_s__iso8601(argc2, argv2, klass);
4460
+ VALUE hash = date_s__iso8601(klass, str);
4506
4461
  return d_new_by_frags(klass, hash, sg);
4507
4462
  }
4508
4463
  }
4509
4464
 
4510
4465
  /*
4511
4466
  * call-seq:
4512
- * Date._rfc3339(string, limit: 128) -> hash
4467
+ * Date._rfc3339(string) -> hash
4513
4468
  *
4514
4469
  * Returns a hash of parsed elements.
4515
- *
4516
- * Raise an ArgumentError when the string length is longer than _limit_.
4517
- * You can stop this check by passing `limit: nil`, but note that
4518
- * it may take a long time to parse.
4519
4470
  */
4520
4471
  static VALUE
4521
- date_s__rfc3339(int argc, VALUE *argv, VALUE klass)
4472
+ date_s__rfc3339(VALUE klass, VALUE str)
4522
4473
  {
4523
- VALUE str, opt;
4524
-
4525
- rb_scan_args(argc, argv, "1:", &str, &opt);
4526
- check_limit(str, opt);
4527
-
4528
4474
  return date__rfc3339(str);
4529
4475
  }
4530
4476
 
4531
4477
  /*
4532
4478
  * call-seq:
4533
- * Date.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> date
4479
+ * Date.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> date
4534
4480
  *
4535
4481
  * Creates a new Date object by parsing from a string according to
4536
4482
  * some typical RFC 3339 formats.
4537
4483
  *
4538
4484
  * Date.rfc3339('2001-02-03T04:05:06+07:00') #=> #<Date: 2001-02-03 ...>
4539
- *
4540
- * Raise an ArgumentError when the string length is longer than _limit_.
4541
- * You can stop this check by passing `limit: nil`, but note that
4542
- * it may take a long time to parse.
4543
4485
  */
4544
4486
  static VALUE
4545
4487
  date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
4546
4488
  {
4547
- VALUE str, sg, opt;
4489
+ VALUE str, sg;
4548
4490
 
4549
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4550
- if (!NIL_P(opt)) argc--;
4491
+ rb_scan_args(argc, argv, "02", &str, &sg);
4551
4492
 
4552
4493
  switch (argc) {
4553
4494
  case 0:
@@ -4557,56 +4498,38 @@ date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
4557
4498
  }
4558
4499
 
4559
4500
  {
4560
- int argc2 = 1;
4561
- VALUE argv2[2];
4562
- argv2[0] = str;
4563
- if (!NIL_P(opt)) argv2[argc2++] = opt;
4564
- VALUE hash = date_s__rfc3339(argc2, argv2, klass);
4501
+ VALUE hash = date_s__rfc3339(klass, str);
4565
4502
  return d_new_by_frags(klass, hash, sg);
4566
4503
  }
4567
4504
  }
4568
4505
 
4569
4506
  /*
4570
4507
  * call-seq:
4571
- * Date._xmlschema(string, limit: 128) -> hash
4508
+ * Date._xmlschema(string) -> hash
4572
4509
  *
4573
4510
  * Returns a hash of parsed elements.
4574
- *
4575
- * Raise an ArgumentError when the string length is longer than _limit_.
4576
- * You can stop this check by passing `limit: nil`, but note that
4577
- * it may take a long time to parse.
4578
4511
  */
4579
4512
  static VALUE
4580
- date_s__xmlschema(int argc, VALUE *argv, VALUE klass)
4513
+ date_s__xmlschema(VALUE klass, VALUE str)
4581
4514
  {
4582
- VALUE str, opt;
4583
-
4584
- rb_scan_args(argc, argv, "1:", &str, &opt);
4585
- check_limit(str, opt);
4586
-
4587
4515
  return date__xmlschema(str);
4588
4516
  }
4589
4517
 
4590
4518
  /*
4591
4519
  * call-seq:
4592
- * Date.xmlschema(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
4520
+ * Date.xmlschema(string='-4712-01-01'[, start=Date::ITALY]) -> date
4593
4521
  *
4594
4522
  * Creates a new Date object by parsing from a string according to
4595
4523
  * some typical XML Schema formats.
4596
4524
  *
4597
4525
  * Date.xmlschema('2001-02-03') #=> #<Date: 2001-02-03 ...>
4598
- *
4599
- * Raise an ArgumentError when the string length is longer than _limit_.
4600
- * You can stop this check by passing `limit: nil`, but note that
4601
- * it may take a long time to parse.
4602
4526
  */
4603
4527
  static VALUE
4604
4528
  date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
4605
4529
  {
4606
- VALUE str, sg, opt;
4530
+ VALUE str, sg;
4607
4531
 
4608
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4609
- if (!NIL_P(opt)) argc--;
4532
+ rb_scan_args(argc, argv, "02", &str, &sg);
4610
4533
 
4611
4534
  switch (argc) {
4612
4535
  case 0:
@@ -4616,58 +4539,41 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
4616
4539
  }
4617
4540
 
4618
4541
  {
4619
- int argc2 = 1;
4620
- VALUE argv2[2];
4621
- argv2[0] = str;
4622
- if (!NIL_P(opt)) argv2[argc2++] = opt;
4623
- VALUE hash = date_s__xmlschema(argc2, argv2, klass);
4542
+ VALUE hash = date_s__xmlschema(klass, str);
4624
4543
  return d_new_by_frags(klass, hash, sg);
4625
4544
  }
4626
4545
  }
4627
4546
 
4628
4547
  /*
4629
4548
  * call-seq:
4630
- * Date._rfc2822(string, limit: 128) -> hash
4631
- * Date._rfc822(string, limit: 128) -> hash
4549
+ * Date._rfc2822(string) -> hash
4550
+ * Date._rfc822(string) -> hash
4632
4551
  *
4633
4552
  * Returns a hash of parsed elements.
4634
- *
4635
- * Raise an ArgumentError when the string length is longer than _limit_.
4636
- * You can stop this check by passing `limit: nil`, but note that
4637
- * it may take a long time to parse.
4638
4553
  */
4639
4554
  static VALUE
4640
- date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
4555
+ date_s__rfc2822(VALUE klass, VALUE str)
4641
4556
  {
4642
- VALUE str, opt;
4643
-
4644
- rb_scan_args(argc, argv, "1:", &str, &opt);
4645
- check_limit(str, opt);
4646
-
4647
4557
  return date__rfc2822(str);
4648
4558
  }
4649
4559
 
4650
4560
  /*
4651
4561
  * call-seq:
4652
- * Date.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> date
4653
- * Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> date
4562
+ * Date.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> date
4563
+ * Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> date
4654
4564
  *
4655
4565
  * Creates a new Date object by parsing from a string according to
4656
4566
  * some typical RFC 2822 formats.
4657
4567
  *
4658
4568
  * Date.rfc2822('Sat, 3 Feb 2001 00:00:00 +0000')
4659
4569
  * #=> #<Date: 2001-02-03 ...>
4660
- *
4661
- * Raise an ArgumentError when the string length is longer than _limit_.
4662
- * You can stop this check by passing `limit: nil`, but note that
4663
- * it may take a long time to parse.
4664
4570
  */
4665
4571
  static VALUE
4666
4572
  date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
4667
4573
  {
4668
- VALUE str, sg, opt;
4574
+ VALUE str, sg;
4669
4575
 
4670
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4576
+ rb_scan_args(argc, argv, "02", &str, &sg);
4671
4577
 
4672
4578
  switch (argc) {
4673
4579
  case 0:
@@ -4677,56 +4583,39 @@ date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
4677
4583
  }
4678
4584
 
4679
4585
  {
4680
- int argc2 = 1;
4681
- VALUE argv2[2];
4682
- argv2[0] = str;
4683
- if (!NIL_P(opt)) argv2[argc2++] = opt;
4684
- VALUE hash = date_s__rfc2822(argc2, argv2, klass);
4586
+ VALUE hash = date_s__rfc2822(klass, str);
4685
4587
  return d_new_by_frags(klass, hash, sg);
4686
4588
  }
4687
4589
  }
4688
4590
 
4689
4591
  /*
4690
4592
  * call-seq:
4691
- * Date._httpdate(string, limit: 128) -> hash
4593
+ * Date._httpdate(string) -> hash
4692
4594
  *
4693
4595
  * Returns a hash of parsed elements.
4694
- *
4695
- * Raise an ArgumentError when the string length is longer than _limit_.
4696
- * You can stop this check by passing `limit: nil`, but note that
4697
- * it may take a long time to parse.
4698
4596
  */
4699
4597
  static VALUE
4700
- date_s__httpdate(int argc, VALUE *argv, VALUE klass)
4598
+ date_s__httpdate(VALUE klass, VALUE str)
4701
4599
  {
4702
- VALUE str, opt;
4703
-
4704
- rb_scan_args(argc, argv, "1:", &str, &opt);
4705
- check_limit(str, opt);
4706
-
4707
4600
  return date__httpdate(str);
4708
4601
  }
4709
4602
 
4710
4603
  /*
4711
4604
  * call-seq:
4712
- * Date.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY], limit: 128) -> date
4605
+ * Date.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY]) -> date
4713
4606
  *
4714
4607
  * Creates a new Date object by parsing from a string according to
4715
4608
  * some RFC 2616 format.
4716
4609
  *
4717
4610
  * Date.httpdate('Sat, 03 Feb 2001 00:00:00 GMT')
4718
4611
  * #=> #<Date: 2001-02-03 ...>
4719
- *
4720
- * Raise an ArgumentError when the string length is longer than _limit_.
4721
- * You can stop this check by passing `limit: nil`, but note that
4722
- * it may take a long time to parse.
4723
4612
  */
4724
4613
  static VALUE
4725
4614
  date_s_httpdate(int argc, VALUE *argv, VALUE klass)
4726
4615
  {
4727
- VALUE str, sg, opt;
4616
+ VALUE str, sg;
4728
4617
 
4729
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4618
+ rb_scan_args(argc, argv, "02", &str, &sg);
4730
4619
 
4731
4620
  switch (argc) {
4732
4621
  case 0:
@@ -4736,39 +4625,26 @@ date_s_httpdate(int argc, VALUE *argv, VALUE klass)
4736
4625
  }
4737
4626
 
4738
4627
  {
4739
- int argc2 = 1;
4740
- VALUE argv2[2];
4741
- argv2[0] = str;
4742
- if (!NIL_P(opt)) argv2[argc2++] = opt;
4743
- VALUE hash = date_s__httpdate(argc2, argv2, klass);
4628
+ VALUE hash = date_s__httpdate(klass, str);
4744
4629
  return d_new_by_frags(klass, hash, sg);
4745
4630
  }
4746
4631
  }
4747
4632
 
4748
4633
  /*
4749
4634
  * call-seq:
4750
- * Date._jisx0301(string, limit: 128) -> hash
4635
+ * Date._jisx0301(string) -> hash
4751
4636
  *
4752
4637
  * Returns a hash of parsed elements.
4753
- *
4754
- * Raise an ArgumentError when the string length is longer than _limit_.
4755
- * You can stop this check by passing `limit: nil`, but note that
4756
- * it may take a long time to parse.
4757
4638
  */
4758
4639
  static VALUE
4759
- date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
4640
+ date_s__jisx0301(VALUE klass, VALUE str)
4760
4641
  {
4761
- VALUE str, opt;
4762
-
4763
- rb_scan_args(argc, argv, "1:", &str, &opt);
4764
- check_limit(str, opt);
4765
-
4766
4642
  return date__jisx0301(str);
4767
4643
  }
4768
4644
 
4769
4645
  /*
4770
4646
  * call-seq:
4771
- * Date.jisx0301(string='-4712-01-01'[, start=Date::ITALY], limit: 128) -> date
4647
+ * Date.jisx0301(string='-4712-01-01'[, start=Date::ITALY]) -> date
4772
4648
  *
4773
4649
  * Creates a new Date object by parsing from a string according to
4774
4650
  * some typical JIS X 0301 formats.
@@ -4778,18 +4654,13 @@ date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
4778
4654
  * For no-era year, legacy format, Heisei is assumed.
4779
4655
  *
4780
4656
  * Date.jisx0301('13.02.03') #=> #<Date: 2001-02-03 ...>
4781
- *
4782
- * Raise an ArgumentError when the string length is longer than _limit_.
4783
- * You can stop this check by passing `limit: nil`, but note that
4784
- * it may take a long time to parse.
4785
4657
  */
4786
4658
  static VALUE
4787
4659
  date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
4788
4660
  {
4789
- VALUE str, sg, opt;
4661
+ VALUE str, sg;
4790
4662
 
4791
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4792
- if (!NIL_P(opt)) argc--;
4663
+ rb_scan_args(argc, argv, "02", &str, &sg);
4793
4664
 
4794
4665
  switch (argc) {
4795
4666
  case 0:
@@ -4799,11 +4670,7 @@ date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
4799
4670
  }
4800
4671
 
4801
4672
  {
4802
- int argc2 = 1;
4803
- VALUE argv2[2];
4804
- argv2[0] = str;
4805
- if (!NIL_P(opt)) argv2[argc2++] = opt;
4806
- VALUE hash = date_s__jisx0301(argc2, argv2, klass);
4673
+ VALUE hash = date_s__jisx0301(klass, str);
4807
4674
  return d_new_by_frags(klass, hash, sg);
4808
4675
  }
4809
4676
  }
@@ -8142,10 +8009,15 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
8142
8009
 
8143
8010
  /*
8144
8011
  * call-seq:
8145
- * DateTime.parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]], limit: 128) -> datetime
8012
+ * DateTime.parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]]) -> datetime
8146
8013
  *
8147
8014
  * Parses the given representation of date and time, and creates a
8148
- * DateTime object. This method does not function as a validator.
8015
+ * DateTime object.
8016
+ *
8017
+ * This method **does not** function as a validator. If the input
8018
+ * string does not match valid formats strictly, you may get a cryptic
8019
+ * result. Should consider to use `DateTime.strptime` instead of this
8020
+ * method as possible.
8149
8021
  *
8150
8022
  * If the optional second argument is true and the detected year is in
8151
8023
  * the range "00" to "99", makes it full.
@@ -8156,18 +8028,13 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
8156
8028
  * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
8157
8029
  * DateTime.parse('3rd Feb 2001 04:05:06 PM')
8158
8030
  * #=> #<DateTime: 2001-02-03T16:05:06+00:00 ...>
8159
- *
8160
- * Raise an ArgumentError when the string length is longer than _limit_.
8161
- * You can stop this check by passing `limit: nil`, but note that
8162
- * it may take a long time to parse.
8163
8031
  */
8164
8032
  static VALUE
8165
8033
  datetime_s_parse(int argc, VALUE *argv, VALUE klass)
8166
8034
  {
8167
- VALUE str, comp, sg, opt;
8035
+ VALUE str, comp, sg;
8168
8036
 
8169
- rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
8170
- if (!NIL_P(opt)) argc--;
8037
+ rb_scan_args(argc, argv, "03", &str, &comp, &sg);
8171
8038
 
8172
8039
  switch (argc) {
8173
8040
  case 0:
@@ -8179,20 +8046,18 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
8179
8046
  }
8180
8047
 
8181
8048
  {
8182
- int argc2 = 2;
8183
- VALUE argv2[3];
8184
- argv2[0] = str;
8185
- argv2[1] = comp;
8186
- argv2[2] = opt;
8187
- if (!NIL_P(opt)) argc2++;
8188
- VALUE hash = date_s__parse(argc2, argv2, klass);
8049
+ VALUE argv2[2], hash;
8050
+
8051
+ argv2[0] = str;
8052
+ argv2[1] = comp;
8053
+ hash = date_s__parse(2, argv2, klass);
8189
8054
  return dt_new_by_frags(klass, hash, sg);
8190
8055
  }
8191
8056
  }
8192
8057
 
8193
8058
  /*
8194
8059
  * call-seq:
8195
- * DateTime.iso8601(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
8060
+ * DateTime.iso8601(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
8196
8061
  *
8197
8062
  * Creates a new DateTime object by parsing from a string according to
8198
8063
  * some typical ISO 8601 formats.
@@ -8203,18 +8068,13 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
8203
8068
  * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
8204
8069
  * DateTime.iso8601('2001-W05-6T04:05:06+07:00')
8205
8070
  * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
8206
- *
8207
- * Raise an ArgumentError when the string length is longer than _limit_.
8208
- * You can stop this check by passing `limit: nil`, but note that
8209
- * it may take a long time to parse.
8210
8071
  */
8211
8072
  static VALUE
8212
8073
  datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
8213
8074
  {
8214
- VALUE str, sg, opt;
8075
+ VALUE str, sg;
8215
8076
 
8216
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8217
- if (!NIL_P(opt)) argc--;
8077
+ rb_scan_args(argc, argv, "02", &str, &sg);
8218
8078
 
8219
8079
  switch (argc) {
8220
8080
  case 0:
@@ -8224,37 +8084,27 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
8224
8084
  }
8225
8085
 
8226
8086
  {
8227
- int argc2 = 1;
8228
- VALUE argv2[2];
8229
- argv2[0] = str;
8230
- argv2[1] = opt;
8231
- if (!NIL_P(opt)) argc2--;
8232
- VALUE hash = date_s__iso8601(argc2, argv2, klass);
8087
+ VALUE hash = date_s__iso8601(klass, str);
8233
8088
  return dt_new_by_frags(klass, hash, sg);
8234
8089
  }
8235
8090
  }
8236
8091
 
8237
8092
  /*
8238
8093
  * call-seq:
8239
- * DateTime.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
8094
+ * DateTime.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
8240
8095
  *
8241
8096
  * Creates a new DateTime object by parsing from a string according to
8242
8097
  * some typical RFC 3339 formats.
8243
8098
  *
8244
8099
  * DateTime.rfc3339('2001-02-03T04:05:06+07:00')
8245
8100
  * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
8246
- *
8247
- * Raise an ArgumentError when the string length is longer than _limit_.
8248
- * You can stop this check by passing `limit: nil`, but note that
8249
- * it may take a long time to parse.
8250
8101
  */
8251
8102
  static VALUE
8252
8103
  datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
8253
8104
  {
8254
- VALUE str, sg, opt;
8105
+ VALUE str, sg;
8255
8106
 
8256
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8257
- if (!NIL_P(opt)) argc--;
8107
+ rb_scan_args(argc, argv, "02", &str, &sg);
8258
8108
 
8259
8109
  switch (argc) {
8260
8110
  case 0:
@@ -8264,37 +8114,27 @@ datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
8264
8114
  }
8265
8115
 
8266
8116
  {
8267
- int argc2 = 1;
8268
- VALUE argv2[2];
8269
- argv2[0] = str;
8270
- argv2[1] = opt;
8271
- if (!NIL_P(opt)) argc2++;
8272
- VALUE hash = date_s__rfc3339(argc2, argv2, klass);
8117
+ VALUE hash = date_s__rfc3339(klass, str);
8273
8118
  return dt_new_by_frags(klass, hash, sg);
8274
8119
  }
8275
8120
  }
8276
8121
 
8277
8122
  /*
8278
8123
  * call-seq:
8279
- * DateTime.xmlschema(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
8124
+ * DateTime.xmlschema(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
8280
8125
  *
8281
8126
  * Creates a new DateTime object by parsing from a string according to
8282
8127
  * some typical XML Schema formats.
8283
8128
  *
8284
8129
  * DateTime.xmlschema('2001-02-03T04:05:06+07:00')
8285
8130
  * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
8286
- *
8287
- * Raise an ArgumentError when the string length is longer than _limit_.
8288
- * You can stop this check by passing `limit: nil`, but note that
8289
- * it may take a long time to parse.
8290
8131
  */
8291
8132
  static VALUE
8292
8133
  datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
8293
8134
  {
8294
- VALUE str, sg, opt;
8135
+ VALUE str, sg;
8295
8136
 
8296
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8297
- if (!NIL_P(opt)) argc--;
8137
+ rb_scan_args(argc, argv, "02", &str, &sg);
8298
8138
 
8299
8139
  switch (argc) {
8300
8140
  case 0:
@@ -8304,38 +8144,28 @@ datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
8304
8144
  }
8305
8145
 
8306
8146
  {
8307
- int argc2 = 1;
8308
- VALUE argv2[2];
8309
- argv2[0] = str;
8310
- argv2[1] = opt;
8311
- if (!NIL_P(opt)) argc2++;
8312
- VALUE hash = date_s__xmlschema(argc2, argv2, klass);
8147
+ VALUE hash = date_s__xmlschema(klass, str);
8313
8148
  return dt_new_by_frags(klass, hash, sg);
8314
8149
  }
8315
8150
  }
8316
8151
 
8317
8152
  /*
8318
8153
  * call-seq:
8319
- * DateTime.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> datetime
8320
- * DateTime.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY], limit: 128) -> datetime
8154
+ * DateTime.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> datetime
8155
+ * DateTime.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> datetime
8321
8156
  *
8322
8157
  * Creates a new DateTime object by parsing from a string according to
8323
8158
  * some typical RFC 2822 formats.
8324
8159
  *
8325
8160
  * DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700')
8326
8161
  * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
8327
- *
8328
- * Raise an ArgumentError when the string length is longer than _limit_.
8329
- * You can stop this check by passing `limit: nil`, but note that
8330
- * it may take a long time to parse.
8331
8162
  */
8332
8163
  static VALUE
8333
8164
  datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
8334
8165
  {
8335
- VALUE str, sg, opt;
8166
+ VALUE str, sg;
8336
8167
 
8337
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8338
- if (!NIL_P(opt)) argc--;
8168
+ rb_scan_args(argc, argv, "02", &str, &sg);
8339
8169
 
8340
8170
  switch (argc) {
8341
8171
  case 0:
@@ -8345,12 +8175,7 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
8345
8175
  }
8346
8176
 
8347
8177
  {
8348
- int argc2 = 1;
8349
- VALUE argv2[2];
8350
- argv2[0] = str;
8351
- argv2[1] = opt;
8352
- if (!NIL_P(opt)) argc2++;
8353
- VALUE hash = date_s__rfc2822(argc2, argv2, klass);
8178
+ VALUE hash = date_s__rfc2822(klass, str);
8354
8179
  return dt_new_by_frags(klass, hash, sg);
8355
8180
  }
8356
8181
  }
@@ -8364,18 +8189,13 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
8364
8189
  *
8365
8190
  * DateTime.httpdate('Sat, 03 Feb 2001 04:05:06 GMT')
8366
8191
  * #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>
8367
- *
8368
- * Raise an ArgumentError when the string length is longer than _limit_.
8369
- * You can stop this check by passing `limit: nil`, but note that
8370
- * it may take a long time to parse.
8371
8192
  */
8372
8193
  static VALUE
8373
8194
  datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
8374
8195
  {
8375
- VALUE str, sg, opt;
8196
+ VALUE str, sg;
8376
8197
 
8377
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8378
- if (!NIL_P(opt)) argc--;
8198
+ rb_scan_args(argc, argv, "02", &str, &sg);
8379
8199
 
8380
8200
  switch (argc) {
8381
8201
  case 0:
@@ -8385,19 +8205,14 @@ datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
8385
8205
  }
8386
8206
 
8387
8207
  {
8388
- int argc2 = 1;
8389
- VALUE argv2[2];
8390
- argv2[0] = str;
8391
- argv2[1] = opt;
8392
- if (!NIL_P(opt)) argc2++;
8393
- VALUE hash = date_s__httpdate(argc2, argv2, klass);
8208
+ VALUE hash = date_s__httpdate(klass, str);
8394
8209
  return dt_new_by_frags(klass, hash, sg);
8395
8210
  }
8396
8211
  }
8397
8212
 
8398
8213
  /*
8399
8214
  * call-seq:
8400
- * DateTime.jisx0301(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY], limit: 128) -> datetime
8215
+ * DateTime.jisx0301(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
8401
8216
  *
8402
8217
  * Creates a new DateTime object by parsing from a string according to
8403
8218
  * some typical JIS X 0301 formats.
@@ -8409,18 +8224,13 @@ datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
8409
8224
  *
8410
8225
  * DateTime.jisx0301('13.02.03T04:05:06+07:00')
8411
8226
  * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
8412
- *
8413
- * Raise an ArgumentError when the string length is longer than _limit_.
8414
- * You can stop this check by passing `limit: nil`, but note that
8415
- * it may take a long time to parse.
8416
8227
  */
8417
8228
  static VALUE
8418
8229
  datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
8419
8230
  {
8420
- VALUE str, sg, opt;
8231
+ VALUE str, sg;
8421
8232
 
8422
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8423
- if (!NIL_P(opt)) argc--;
8233
+ rb_scan_args(argc, argv, "02", &str, &sg);
8424
8234
 
8425
8235
  switch (argc) {
8426
8236
  case 0:
@@ -8430,12 +8240,7 @@ datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
8430
8240
  }
8431
8241
 
8432
8242
  {
8433
- int argc2 = 1;
8434
- VALUE argv2[2];
8435
- argv2[0] = str;
8436
- argv2[1] = opt;
8437
- if (!NIL_P(opt)) argc2++;
8438
- VALUE hash = date_s__jisx0301(argc2, argv2, klass);
8243
+ VALUE hash = date_s__jisx0301(klass, str);
8439
8244
  return dt_new_by_frags(klass, hash, sg);
8440
8245
  }
8441
8246
  }
@@ -9313,13 +9118,13 @@ d_lite_zero(VALUE x)
9313
9118
  void
9314
9119
  Init_date_core(void)
9315
9120
  {
9316
- #undef rb_intern
9317
- #define rb_intern(str) rb_intern_const(str)
9318
-
9319
- id_cmp = rb_intern("<=>");
9320
- id_le_p = rb_intern("<=");
9321
- id_ge_p = rb_intern(">=");
9322
- id_eqeq_p = rb_intern("==");
9121
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
9122
+ RB_EXT_RACTOR_SAFE(true);
9123
+ #endif
9124
+ id_cmp = rb_intern_const("<=>");
9125
+ id_le_p = rb_intern_const("<=");
9126
+ id_ge_p = rb_intern_const(">=");
9127
+ id_eqeq_p = rb_intern_const("==");
9323
9128
 
9324
9129
  half_days_in_day = rb_rational_new2(INT2FIX(1), INT2FIX(2));
9325
9130
 
@@ -9594,19 +9399,19 @@ Init_date_core(void)
9594
9399
  rb_define_singleton_method(cDate, "strptime", date_s_strptime, -1);
9595
9400
  rb_define_singleton_method(cDate, "_parse", date_s__parse, -1);
9596
9401
  rb_define_singleton_method(cDate, "parse", date_s_parse, -1);
9597
- rb_define_singleton_method(cDate, "_iso8601", date_s__iso8601, -1);
9402
+ rb_define_singleton_method(cDate, "_iso8601", date_s__iso8601, 1);
9598
9403
  rb_define_singleton_method(cDate, "iso8601", date_s_iso8601, -1);
9599
- rb_define_singleton_method(cDate, "_rfc3339", date_s__rfc3339, -1);
9404
+ rb_define_singleton_method(cDate, "_rfc3339", date_s__rfc3339, 1);
9600
9405
  rb_define_singleton_method(cDate, "rfc3339", date_s_rfc3339, -1);
9601
- rb_define_singleton_method(cDate, "_xmlschema", date_s__xmlschema, -1);
9406
+ rb_define_singleton_method(cDate, "_xmlschema", date_s__xmlschema, 1);
9602
9407
  rb_define_singleton_method(cDate, "xmlschema", date_s_xmlschema, -1);
9603
- rb_define_singleton_method(cDate, "_rfc2822", date_s__rfc2822, -1);
9604
- rb_define_singleton_method(cDate, "_rfc822", date_s__rfc2822, -1);
9408
+ rb_define_singleton_method(cDate, "_rfc2822", date_s__rfc2822, 1);
9409
+ rb_define_singleton_method(cDate, "_rfc822", date_s__rfc2822, 1);
9605
9410
  rb_define_singleton_method(cDate, "rfc2822", date_s_rfc2822, -1);
9606
9411
  rb_define_singleton_method(cDate, "rfc822", date_s_rfc2822, -1);
9607
- rb_define_singleton_method(cDate, "_httpdate", date_s__httpdate, -1);
9412
+ rb_define_singleton_method(cDate, "_httpdate", date_s__httpdate, 1);
9608
9413
  rb_define_singleton_method(cDate, "httpdate", date_s_httpdate, -1);
9609
- rb_define_singleton_method(cDate, "_jisx0301", date_s__jisx0301, -1);
9414
+ rb_define_singleton_method(cDate, "_jisx0301", date_s__jisx0301, 1);
9610
9415
  rb_define_singleton_method(cDate, "jisx0301", date_s_jisx0301, -1);
9611
9416
 
9612
9417
  rb_define_method(cDate, "initialize", date_initialize, -1);
@@ -9726,6 +9531,8 @@ Init_date_core(void)
9726
9531
  * A subclass of Date that easily handles date, hour, minute, second,
9727
9532
  * and offset.
9728
9533
  *
9534
+ * DateTime class is considered deprecated. Use Time class.
9535
+ *
9729
9536
  * DateTime does not consider any leap seconds, does not track
9730
9537
  * any summer time rules.
9731
9538
  *
@@ -9786,18 +9593,18 @@ Init_date_core(void)
9786
9593
  * === When should you use DateTime and when should you use Time?
9787
9594
  *
9788
9595
  * It's a common misconception that
9789
- * {William Shakespeare}[http://en.wikipedia.org/wiki/William_Shakespeare]
9596
+ * {William Shakespeare}[https://en.wikipedia.org/wiki/William_Shakespeare]
9790
9597
  * and
9791
- * {Miguel de Cervantes}[http://en.wikipedia.org/wiki/Miguel_de_Cervantes]
9598
+ * {Miguel de Cervantes}[https://en.wikipedia.org/wiki/Miguel_de_Cervantes]
9792
9599
  * died on the same day in history -
9793
9600
  * so much so that UNESCO named April 23 as
9794
- * {World Book Day because of this fact}[http://en.wikipedia.org/wiki/World_Book_Day].
9601
+ * {World Book Day because of this fact}[https://en.wikipedia.org/wiki/World_Book_Day].
9795
9602
  * However, because England hadn't yet adopted the
9796
- * {Gregorian Calendar Reform}[http://en.wikipedia.org/wiki/Gregorian_calendar#Gregorian_reform]
9797
- * (and wouldn't until {1752}[http://en.wikipedia.org/wiki/Calendar_(New_Style)_Act_1750])
9603
+ * {Gregorian Calendar Reform}[https://en.wikipedia.org/wiki/Gregorian_calendar#Gregorian_reform]
9604
+ * (and wouldn't until {1752}[https://en.wikipedia.org/wiki/Calendar_(New_Style)_Act_1750])
9798
9605
  * their deaths are actually 10 days apart.
9799
9606
  * Since Ruby's Time class implements a
9800
- * {proleptic Gregorian calendar}[http://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar]
9607
+ * {proleptic Gregorian calendar}[https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar]
9801
9608
  * and has no concept of calendar reform there's no way
9802
9609
  * to express this with Time objects. This is where DateTime steps in:
9803
9610
  *
@@ -9841,7 +9648,7 @@ Init_date_core(void)
9841
9648
  * #=> Fri, 04 May 1753 00:00:00 +0000
9842
9649
  *
9843
9650
  * As you can see, if we're accurately tracking the number of
9844
- * {solar years}[http://en.wikipedia.org/wiki/Tropical_year]
9651
+ * {solar years}[https://en.wikipedia.org/wiki/Tropical_year]
9845
9652
  * since Shakespeare's birthday then the correct anniversary date
9846
9653
  * would be the 4th May and not the 23rd April.
9847
9654
  *
@@ -9853,10 +9660,10 @@ Init_date_core(void)
9853
9660
  * making the same mistakes as UNESCO. If you also have to deal
9854
9661
  * with timezones then best of luck - just bear in mind that
9855
9662
  * you'll probably be dealing with
9856
- * {local solar times}[http://en.wikipedia.org/wiki/Solar_time],
9663
+ * {local solar times}[https://en.wikipedia.org/wiki/Solar_time],
9857
9664
  * since it wasn't until the 19th century that the introduction
9858
9665
  * of the railways necessitated the need for
9859
- * {Standard Time}[http://en.wikipedia.org/wiki/Standard_time#Great_Britain]
9666
+ * {Standard Time}[https://en.wikipedia.org/wiki/Standard_time#Great_Britain]
9860
9667
  * and eventually timezones.
9861
9668
  */
9862
9669
 
@@ -276,6 +276,7 @@ regcomp(const char *source, long len, int opt)
276
276
  VALUE pat;
277
277
 
278
278
  pat = rb_reg_new(source, len, opt);
279
+ rb_obj_freeze(pat);
279
280
  rb_gc_register_mark_object(pat);
280
281
  return pat;
281
282
  }
@@ -581,6 +581,7 @@ date__strptime_internal(const char *str, size_t slen,
581
581
  if (NIL_P(pat)) {
582
582
  pat = rb_reg_new(pat_source, sizeof pat_source - 1,
583
583
  ONIG_OPTION_IGNORECASE);
584
+ rb_obj_freeze(pat);
584
585
  rb_gc_register_mark_object(pat);
585
586
  }
586
587
 
data/ext/date/prereq.mk CHANGED
@@ -9,4 +9,4 @@ zonetab.h: zonetab.list
9
9
 
10
10
  .PHONY: update-zonetab
11
11
  update-zonetab:
12
- $(RUBY) -C $(srcdir) update-abbr.rb
12
+ $(RUBY) -C $(srcdir) update-abbr
@@ -47,12 +47,12 @@ utc, 0*3600
47
47
  wet, 0*3600
48
48
  at, -2*3600
49
49
  brst,-2*3600
50
- ndt, -(2*3600+1800)
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, -(3*3600+1800)
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,-10*3600
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, 2*3600
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, 7*3600
96
- cct, 8*3600
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,10*3600
101
+ east,-6*3600
102
102
  gst, 10*3600
103
103
  eadt,11*3600
104
104
  idle,12*3600
data/lib/date.rb CHANGED
@@ -4,7 +4,6 @@
4
4
  require 'date_core'
5
5
 
6
6
  class Date
7
- VERSION = '3.0.3' # :nodoc:
8
7
 
9
8
  def infinite?
10
9
  false
@@ -12,8 +11,6 @@ class Date
12
11
 
13
12
  class Infinity < Numeric # :nodoc:
14
13
 
15
- include Comparable
16
-
17
14
  def initialize(d=1) @d = d <=> 0 end
18
15
 
19
16
  def d() @d end
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.0.3
4
+ version: 3.1.0
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: 2021-11-18 00:00:00.000000000 Z
11
+ date: 2020-12-23 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.3.0.dev
51
- signing_key:
51
+ rubygems_version: 3.2.2
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: []