date 3.4.0 → 3.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 663deb4b7503aa59db5242f38e54b0e00072a41715555d584171f1b49423d898
4
- data.tar.gz: 7c59321afa979e6823fe7e5ee93dd4a558822a4b9fb2406d8c0c440a7db3d869
3
+ metadata.gz: a4bfc8d13122968d3e8be9e00abdcac1308a4b86f699d5747e492ee80d97ed13
4
+ data.tar.gz: 579ae53dacefba07eabb2e2a6b9cada3c377efd0348d3290e4a6b392059f9883
5
5
  SHA512:
6
- metadata.gz: 28d17ce123b257d3b5983104040709f96d6c0abeb5e431678e83a3e41148630857d96e130451fd6ecf77a3d9a19bd7dac08479ca3d5350c0157adfc009b4b48d
7
- data.tar.gz: 6f1ae004dd42e1e566e59371009b128ada23a76fd2dafa0384cb50fffeb84be0791f1d1e06916eebd31c1708d9d4026bc987f94cc5bb5e895c9200bf7e7c1907
6
+ metadata.gz: f75049bebd6c5c9acd3ed8290be91514f20cd275348e4c6d1887175ccac2c88890f0b07e8236d24bb37cab3223d7d1038e02726f880ec7c186a1ce300c196fe5
7
+ data.tar.gz: c1d74e9cb222d4eb2f3b5715d6aa68a411b6b92ca05cc47babcee05343e455ba218a15b9c12f25d925887ea7a7dac0a203011a2e5e783269a2f16de921143fba
data/BSDL ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions
5
+ are met:
6
+ 1. Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ 2. Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
+ SUCH DAMAGE.
data/COPYING ADDED
@@ -0,0 +1,56 @@
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a. place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b. use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c. give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d. make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a. distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b. accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c. give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d. make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # `Date`
2
2
 
3
- A subclass of `Object` that includes the `Comparable` module and easily handles date.
3
+ The official date library for Ruby.
4
4
 
5
5
  ## Installation
6
6
 
data/ext/date/date_core.c CHANGED
@@ -248,6 +248,11 @@ f_negative_p(VALUE x)
248
248
  #define date_sg_t double
249
249
  #endif
250
250
 
251
+ #define JULIAN_EPOCH_DATE "-4712-01-01"
252
+ #define JULIAN_EPOCH_DATETIME JULIAN_EPOCH_DATE "T00:00:00+00:00"
253
+ #define JULIAN_EPOCH_DATETIME_RFC3339 "Mon, 1 Jan -4712 00:00:00 +0000"
254
+ #define JULIAN_EPOCH_DATETIME_HTTPDATE "Mon, 01 Jan -4712 00:00:00 GMT"
255
+
251
256
  /* A set of nth, jd, df and sf denote ajd + 1/2. Each ajd begin at
252
257
  * noon of GMT (assume equal to UTC). However, this begins at
253
258
  * midnight.
@@ -1594,7 +1599,7 @@ m_ajd(union DateData *x)
1594
1599
 
1595
1600
  if (simple_dat_p(x)) {
1596
1601
  r = m_real_jd(x);
1597
- if (FIXNUM_P(r) && FIX2LONG(r) <= (FIXNUM_MAX / 2)) {
1602
+ if (FIXNUM_P(r) && FIX2LONG(r) <= (FIXNUM_MAX / 2) && FIX2LONG(r) >= (FIXNUM_MIN + 1) / 2) {
1598
1603
  long ir = FIX2LONG(r);
1599
1604
  ir = ir * 2 - 1;
1600
1605
  return rb_rational_new2(LONG2FIX(ir), INT2FIX(2));
@@ -2493,7 +2498,7 @@ date_s__valid_jd_p(int argc, VALUE *argv, VALUE klass)
2493
2498
  *
2494
2499
  * Date.valid_jd?(2451944) # => true
2495
2500
  *
2496
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
2501
+ * See argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
2497
2502
  *
2498
2503
  * Related: Date.jd.
2499
2504
  */
@@ -2587,7 +2592,7 @@ date_s__valid_civil_p(int argc, VALUE *argv, VALUE klass)
2587
2592
  * Date.valid_date?(2001, 2, 29) # => false
2588
2593
  * Date.valid_date?(2001, 2, -1) # => true
2589
2594
  *
2590
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
2595
+ * See argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
2591
2596
  *
2592
2597
  * Related: Date.jd, Date.new.
2593
2598
  */
@@ -2675,7 +2680,7 @@ date_s__valid_ordinal_p(int argc, VALUE *argv, VALUE klass)
2675
2680
  * Date.valid_ordinal?(2001, 34) # => true
2676
2681
  * Date.valid_ordinal?(2001, 366) # => false
2677
2682
  *
2678
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
2683
+ * See argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
2679
2684
  *
2680
2685
  * Related: Date.jd, Date.ordinal.
2681
2686
  */
@@ -2765,7 +2770,7 @@ date_s__valid_commercial_p(int argc, VALUE *argv, VALUE klass)
2765
2770
  *
2766
2771
  * See Date.commercial.
2767
2772
  *
2768
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
2773
+ * See argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
2769
2774
  *
2770
2775
  * Related: Date.jd, Date.commercial.
2771
2776
  */
@@ -3345,7 +3350,7 @@ static VALUE d_lite_plus(VALUE, VALUE);
3345
3350
  *
3346
3351
  * Date.jd(Date::ITALY - 1).julian? # => true
3347
3352
  *
3348
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
3353
+ * See argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
3349
3354
  *
3350
3355
  * Related: Date.new.
3351
3356
  */
@@ -3410,7 +3415,7 @@ date_s_jd(int argc, VALUE *argv, VALUE klass)
3410
3415
  *
3411
3416
  * Raises an exception if +yday+ is zero or out of range.
3412
3417
  *
3413
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
3418
+ * See argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
3414
3419
  *
3415
3420
  * Related: Date.jd, Date.new.
3416
3421
  */
@@ -3487,7 +3492,7 @@ date_s_civil(int argc, VALUE *argv, VALUE klass)
3487
3492
  * where +n+ is the number of days in the month;
3488
3493
  * when the argument is negative, counts backward from the end of the month.
3489
3494
  *
3490
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
3495
+ * See argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
3491
3496
  *
3492
3497
  * Related: Date.jd.
3493
3498
  */
@@ -3593,7 +3598,7 @@ date_initialize(int argc, VALUE *argv, VALUE self)
3593
3598
  * Date.commercial(2020, 1, 1).to_s # => "2019-12-30"
3594
3599
  Date.commercial(2020, 1, 7).to_s # => "2020-01-05"
3595
3600
  *
3596
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
3601
+ * See argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
3597
3602
  *
3598
3603
  * Related: Date.jd, Date.new, Date.ordinal.
3599
3604
  */
@@ -3778,7 +3783,7 @@ static void set_sg(union DateData *, double);
3778
3783
  *
3779
3784
  * Date.today.to_s # => "2022-07-06"
3780
3785
  *
3781
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
3786
+ * See argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
3782
3787
  *
3783
3788
  */
3784
3789
  static VALUE
@@ -3873,7 +3878,6 @@ static VALUE
3873
3878
  rt_complete_frags(VALUE klass, VALUE hash)
3874
3879
  {
3875
3880
  static VALUE tab = Qnil;
3876
- int g;
3877
3881
  long e;
3878
3882
  VALUE k, a, d;
3879
3883
 
@@ -3970,9 +3974,13 @@ rt_complete_frags(VALUE klass, VALUE hash)
3970
3974
  rb_gc_register_mark_object(tab);
3971
3975
  }
3972
3976
 
3977
+ k = a = Qnil;
3978
+
3973
3979
  {
3974
- long i, eno = 0, idx = 0;
3980
+ long i, eno = 0;
3981
+ VALUE t = Qnil;
3975
3982
 
3983
+ e = 0;
3976
3984
  for (i = 0; i < RARRAY_LEN(tab); i++) {
3977
3985
  VALUE x, a;
3978
3986
 
@@ -3987,23 +3995,20 @@ rt_complete_frags(VALUE klass, VALUE hash)
3987
3995
  n++;
3988
3996
  if (n > eno) {
3989
3997
  eno = n;
3990
- idx = i;
3998
+ t = x;
3991
3999
  }
3992
4000
  }
3993
4001
  }
3994
- if (eno == 0)
3995
- g = 0;
3996
- else {
3997
- g = 1;
3998
- k = RARRAY_AREF(RARRAY_AREF(tab, idx), 0);
3999
- a = RARRAY_AREF(RARRAY_AREF(tab, idx), 1);
4000
- e = eno;
4002
+ if (eno > 0) {
4003
+ k = RARRAY_AREF(t, 0);
4004
+ a = RARRAY_AREF(t, 1);
4001
4005
  }
4006
+ e = eno;
4002
4007
  }
4003
4008
 
4004
4009
  d = Qnil;
4005
4010
 
4006
- if (g && !NIL_P(k) && (RARRAY_LEN(a) - e)) {
4011
+ if (!NIL_P(k) && (RARRAY_LEN(a) > e)) {
4007
4012
  if (k == sym("ordinal")) {
4008
4013
  if (NIL_P(ref_hash("year"))) {
4009
4014
  if (NIL_P(d))
@@ -4090,7 +4095,7 @@ rt_complete_frags(VALUE klass, VALUE hash)
4090
4095
  }
4091
4096
  }
4092
4097
 
4093
- if (g && k == sym("time")) {
4098
+ if (k == sym("time")) {
4094
4099
  if (f_le_p(klass, cDateTime)) {
4095
4100
  if (NIL_P(d))
4096
4101
  d = date_s_today(0, (VALUE *)0, cDate);
@@ -4410,7 +4415,7 @@ date_s__strptime(int argc, VALUE *argv, VALUE klass)
4410
4415
  * {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html].
4411
4416
  * (Unlike Date.strftime, does not support flags and width.)
4412
4417
  *
4413
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
4418
+ * See argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
4414
4419
  *
4415
4420
  * See also {strptime(3)}[https://man7.org/linux/man-pages/man3/strptime.3.html].
4416
4421
  *
@@ -4425,7 +4430,7 @@ date_s_strptime(int argc, VALUE *argv, VALUE klass)
4425
4430
 
4426
4431
  switch (argc) {
4427
4432
  case 0:
4428
- str = rb_str_new2("-4712-01-01");
4433
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
4429
4434
  case 1:
4430
4435
  fmt = rb_str_new2("%F");
4431
4436
  case 2:
@@ -4459,11 +4464,10 @@ get_limit(VALUE opt)
4459
4464
  #define rb_category_warn(category, fmt) rb_warn(fmt)
4460
4465
  #endif
4461
4466
 
4462
- static void
4467
+ static VALUE
4463
4468
  check_limit(VALUE str, VALUE opt)
4464
4469
  {
4465
4470
  size_t slen, limit;
4466
- if (NIL_P(str)) return;
4467
4471
  StringValue(str);
4468
4472
  slen = RSTRING_LEN(str);
4469
4473
  limit = get_limit(opt);
@@ -4471,6 +4475,7 @@ check_limit(VALUE str, VALUE opt)
4471
4475
  rb_raise(rb_eArgError,
4472
4476
  "string length (%"PRI_SIZE_PREFIX"u) exceeds the limit %"PRI_SIZE_PREFIX"u", slen, limit);
4473
4477
  }
4478
+ return str;
4474
4479
  }
4475
4480
 
4476
4481
  static VALUE
@@ -4478,10 +4483,8 @@ date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
4478
4483
  {
4479
4484
  VALUE vstr, vcomp, hash, opt;
4480
4485
 
4481
- rb_scan_args(argc, argv, "11:", &vstr, &vcomp, &opt);
4482
- if (!NIL_P(opt)) argc--;
4483
- check_limit(vstr, opt);
4484
- StringValue(vstr);
4486
+ argc = rb_scan_args(argc, argv, "11:", &vstr, &vcomp, &opt);
4487
+ vstr = check_limit(vstr, opt);
4485
4488
  if (!rb_enc_str_asciicompat_p(vstr))
4486
4489
  rb_raise(rb_eArgError,
4487
4490
  "string should have ASCII compatible encoding");
@@ -4556,7 +4559,7 @@ date_s__parse(int argc, VALUE *argv, VALUE klass)
4556
4559
  *
4557
4560
  * See:
4558
4561
  *
4559
- * - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
4562
+ * - Argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
4560
4563
  * - Argument {limit}[rdoc-ref:Date@Argument+limit].
4561
4564
  *
4562
4565
  * Related: Date._parse (returns a hash).
@@ -4566,12 +4569,11 @@ date_s_parse(int argc, VALUE *argv, VALUE klass)
4566
4569
  {
4567
4570
  VALUE str, comp, sg, opt;
4568
4571
 
4569
- rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
4570
- if (!NIL_P(opt)) argc--;
4572
+ argc = rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
4571
4573
 
4572
4574
  switch (argc) {
4573
4575
  case 0:
4574
- str = rb_str_new2("-4712-01-01");
4576
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
4575
4577
  case 1:
4576
4578
  comp = Qtrue;
4577
4579
  case 2:
@@ -4617,7 +4619,7 @@ date_s__iso8601(int argc, VALUE *argv, VALUE klass)
4617
4619
  VALUE str, opt;
4618
4620
 
4619
4621
  rb_scan_args(argc, argv, "1:", &str, &opt);
4620
- check_limit(str, opt);
4622
+ if (!NIL_P(str)) str = check_limit(str, opt);
4621
4623
 
4622
4624
  return date__iso8601(str);
4623
4625
  }
@@ -4636,7 +4638,7 @@ date_s__iso8601(int argc, VALUE *argv, VALUE klass)
4636
4638
  *
4637
4639
  * See:
4638
4640
  *
4639
- * - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
4641
+ * - Argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
4640
4642
  * - Argument {limit}[rdoc-ref:Date@Argument+limit].
4641
4643
  *
4642
4644
  * Related: Date._iso8601 (returns a hash).
@@ -4646,12 +4648,11 @@ date_s_iso8601(int argc, VALUE *argv, VALUE klass)
4646
4648
  {
4647
4649
  VALUE str, sg, opt;
4648
4650
 
4649
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4650
- if (!NIL_P(opt)) argc--;
4651
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4651
4652
 
4652
4653
  switch (argc) {
4653
4654
  case 0:
4654
- str = rb_str_new2("-4712-01-01");
4655
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
4655
4656
  case 1:
4656
4657
  sg = INT2FIX(DEFAULT_SG);
4657
4658
  }
@@ -4688,7 +4689,7 @@ date_s__rfc3339(int argc, VALUE *argv, VALUE klass)
4688
4689
  VALUE str, opt;
4689
4690
 
4690
4691
  rb_scan_args(argc, argv, "1:", &str, &opt);
4691
- check_limit(str, opt);
4692
+ if (!NIL_P(str)) str = check_limit(str, opt);
4692
4693
 
4693
4694
  return date__rfc3339(str);
4694
4695
  }
@@ -4707,7 +4708,7 @@ date_s__rfc3339(int argc, VALUE *argv, VALUE klass)
4707
4708
  *
4708
4709
  * See:
4709
4710
  *
4710
- * - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
4711
+ * - Argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
4711
4712
  * - Argument {limit}[rdoc-ref:Date@Argument+limit].
4712
4713
  *
4713
4714
  * Related: Date._rfc3339 (returns a hash).
@@ -4717,12 +4718,11 @@ date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
4717
4718
  {
4718
4719
  VALUE str, sg, opt;
4719
4720
 
4720
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4721
- if (!NIL_P(opt)) argc--;
4721
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4722
4722
 
4723
4723
  switch (argc) {
4724
4724
  case 0:
4725
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
4725
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
4726
4726
  case 1:
4727
4727
  sg = INT2FIX(DEFAULT_SG);
4728
4728
  }
@@ -4758,7 +4758,7 @@ date_s__xmlschema(int argc, VALUE *argv, VALUE klass)
4758
4758
  VALUE str, opt;
4759
4759
 
4760
4760
  rb_scan_args(argc, argv, "1:", &str, &opt);
4761
- check_limit(str, opt);
4761
+ if (!NIL_P(str)) str = check_limit(str, opt);
4762
4762
 
4763
4763
  return date__xmlschema(str);
4764
4764
  }
@@ -4776,7 +4776,7 @@ date_s__xmlschema(int argc, VALUE *argv, VALUE klass)
4776
4776
  *
4777
4777
  * See:
4778
4778
  *
4779
- * - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
4779
+ * - Argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
4780
4780
  * - Argument {limit}[rdoc-ref:Date@Argument+limit].
4781
4781
  *
4782
4782
  * Related: Date._xmlschema (returns a hash).
@@ -4786,12 +4786,11 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
4786
4786
  {
4787
4787
  VALUE str, sg, opt;
4788
4788
 
4789
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4790
- if (!NIL_P(opt)) argc--;
4789
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4791
4790
 
4792
4791
  switch (argc) {
4793
4792
  case 0:
4794
- str = rb_str_new2("-4712-01-01");
4793
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
4795
4794
  case 1:
4796
4795
  sg = INT2FIX(DEFAULT_SG);
4797
4796
  }
@@ -4828,7 +4827,7 @@ date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
4828
4827
  VALUE str, opt;
4829
4828
 
4830
4829
  rb_scan_args(argc, argv, "1:", &str, &opt);
4831
- check_limit(str, opt);
4830
+ if (!NIL_P(str)) str = check_limit(str, opt);
4832
4831
 
4833
4832
  return date__rfc2822(str);
4834
4833
  }
@@ -4847,7 +4846,7 @@ date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
4847
4846
  *
4848
4847
  * See:
4849
4848
  *
4850
- * - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
4849
+ * - Argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
4851
4850
  * - Argument {limit}[rdoc-ref:Date@Argument+limit].
4852
4851
  *
4853
4852
  * Related: Date._rfc2822 (returns a hash).
@@ -4857,11 +4856,11 @@ date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
4857
4856
  {
4858
4857
  VALUE str, sg, opt;
4859
4858
 
4860
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4859
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4861
4860
 
4862
4861
  switch (argc) {
4863
4862
  case 0:
4864
- str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000");
4863
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_RFC3339);
4865
4864
  case 1:
4866
4865
  sg = INT2FIX(DEFAULT_SG);
4867
4866
  }
@@ -4896,7 +4895,7 @@ date_s__httpdate(int argc, VALUE *argv, VALUE klass)
4896
4895
  VALUE str, opt;
4897
4896
 
4898
4897
  rb_scan_args(argc, argv, "1:", &str, &opt);
4899
- check_limit(str, opt);
4898
+ if (!NIL_P(str)) str = check_limit(str, opt);
4900
4899
 
4901
4900
  return date__httpdate(str);
4902
4901
  }
@@ -4915,7 +4914,7 @@ date_s__httpdate(int argc, VALUE *argv, VALUE klass)
4915
4914
  *
4916
4915
  * See:
4917
4916
  *
4918
- * - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
4917
+ * - Argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
4919
4918
  * - Argument {limit}[rdoc-ref:Date@Argument+limit].
4920
4919
  *
4921
4920
  * Related: Date._httpdate (returns a hash).
@@ -4925,11 +4924,11 @@ date_s_httpdate(int argc, VALUE *argv, VALUE klass)
4925
4924
  {
4926
4925
  VALUE str, sg, opt;
4927
4926
 
4928
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4927
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4929
4928
 
4930
4929
  switch (argc) {
4931
4930
  case 0:
4932
- str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT");
4931
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_HTTPDATE);
4933
4932
  case 1:
4934
4933
  sg = INT2FIX(DEFAULT_SG);
4935
4934
  }
@@ -4965,7 +4964,7 @@ date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
4965
4964
  VALUE str, opt;
4966
4965
 
4967
4966
  rb_scan_args(argc, argv, "1:", &str, &opt);
4968
- check_limit(str, opt);
4967
+ if (!NIL_P(str)) str = check_limit(str, opt);
4969
4968
 
4970
4969
  return date__jisx0301(str);
4971
4970
  }
@@ -4987,7 +4986,7 @@ date_s__jisx0301(int argc, VALUE *argv, VALUE klass)
4987
4986
  *
4988
4987
  * See:
4989
4988
  *
4990
- * - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
4989
+ * - Argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
4991
4990
  * - Argument {limit}[rdoc-ref:Date@Argument+limit].
4992
4991
  *
4993
4992
  * Related: Date._jisx0301 (returns a hash).
@@ -4997,12 +4996,11 @@ date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
4997
4996
  {
4998
4997
  VALUE str, sg, opt;
4999
4998
 
5000
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
5001
- if (!NIL_P(opt)) argc--;
4999
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
5002
5000
 
5003
5001
  switch (argc) {
5004
5002
  case 0:
5005
- str = rb_str_new2("-4712-01-01");
5003
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
5006
5004
  case 1:
5007
5005
  sg = INT2FIX(DEFAULT_SG);
5008
5006
  }
@@ -5746,7 +5744,7 @@ d_lite_leap_p(VALUE self)
5746
5744
  * Date.new(2001, 2, 3, Date::GREGORIAN).start # => -Infinity
5747
5745
  * Date.new(2001, 2, 3, Date::JULIAN).start # => Infinity
5748
5746
  *
5749
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
5747
+ * See argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
5750
5748
  *
5751
5749
  */
5752
5750
  static VALUE
@@ -5821,7 +5819,7 @@ dup_obj_with_new_start(VALUE obj, double sg)
5821
5819
  * d1 = d0.new_start(Date::JULIAN)
5822
5820
  * d1.julian? # => true
5823
5821
  *
5824
- * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
5822
+ * See argument {start}[rdoc-ref:date/calendars.rdoc@Argument+start].
5825
5823
  *
5826
5824
  */
5827
5825
  static VALUE
@@ -6937,13 +6935,24 @@ d_lite_eql_p(VALUE self, VALUE other)
6937
6935
  static VALUE
6938
6936
  d_lite_hash(VALUE self)
6939
6937
  {
6940
- st_index_t v, h[4];
6938
+ st_index_t v, h[5];
6939
+ VALUE nth;
6941
6940
 
6942
6941
  get_d1(self);
6943
- h[0] = m_nth(dat);
6944
- h[1] = m_jd(dat);
6945
- h[2] = m_df(dat);
6946
- h[3] = m_sf(dat);
6942
+ nth = m_nth(dat);
6943
+
6944
+ if (FIXNUM_P(nth)) {
6945
+ h[0] = 0;
6946
+ h[1] = (st_index_t)nth;
6947
+ } else {
6948
+ h[0] = 1;
6949
+ h[1] = (st_index_t)FIX2LONG(rb_hash(nth));
6950
+ }
6951
+
6952
+ h[2] = m_jd(dat);
6953
+ h[3] = m_df(dat);
6954
+ h[4] = m_sf(dat);
6955
+
6947
6956
  v = rb_memhash(h, sizeof(h));
6948
6957
  return ST2FIX(v);
6949
6958
  }
@@ -7518,10 +7527,7 @@ d_lite_marshal_dump_old(VALUE self)
7518
7527
  m_of_in_day(dat),
7519
7528
  DBL2NUM(m_sg(dat)));
7520
7529
 
7521
- if (FL_TEST(self, FL_EXIVAR)) {
7522
- rb_copy_generic_ivar(a, self);
7523
- FL_SET(a, FL_EXIVAR);
7524
- }
7530
+ rb_copy_generic_ivar(a, self);
7525
7531
 
7526
7532
  return a;
7527
7533
  }
@@ -7543,10 +7549,8 @@ d_lite_marshal_dump(VALUE self)
7543
7549
  INT2FIX(m_of(dat)),
7544
7550
  DBL2NUM(m_sg(dat)));
7545
7551
 
7546
- if (FL_TEST(self, FL_EXIVAR)) {
7547
- rb_copy_generic_ivar(a, self);
7548
- FL_SET(a, FL_EXIVAR);
7549
- }
7552
+
7553
+ rb_copy_generic_ivar(a, self);
7550
7554
 
7551
7555
  return a;
7552
7556
  }
@@ -7619,10 +7623,7 @@ d_lite_marshal_load(VALUE self, VALUE a)
7619
7623
  HAVE_JD | HAVE_DF);
7620
7624
  }
7621
7625
 
7622
- if (FL_TEST(a, FL_EXIVAR)) {
7623
- rb_copy_generic_ivar(self, a);
7624
- FL_SET(self, FL_EXIVAR);
7625
- }
7626
+ rb_copy_generic_ivar(self, a);
7626
7627
 
7627
7628
  return self;
7628
7629
  }
@@ -8375,7 +8376,7 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
8375
8376
 
8376
8377
  switch (argc) {
8377
8378
  case 0:
8378
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8379
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8379
8380
  case 1:
8380
8381
  fmt = rb_str_new2("%FT%T%z");
8381
8382
  case 2:
@@ -8423,12 +8424,11 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
8423
8424
  {
8424
8425
  VALUE str, comp, sg, opt;
8425
8426
 
8426
- rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
8427
- if (!NIL_P(opt)) argc--;
8427
+ argc = rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
8428
8428
 
8429
8429
  switch (argc) {
8430
8430
  case 0:
8431
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8431
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8432
8432
  case 1:
8433
8433
  comp = Qtrue;
8434
8434
  case 2:
@@ -8470,12 +8470,11 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
8470
8470
  {
8471
8471
  VALUE str, sg, opt;
8472
8472
 
8473
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8474
- if (!NIL_P(opt)) argc--;
8473
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8475
8474
 
8476
8475
  switch (argc) {
8477
8476
  case 0:
8478
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8477
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8479
8478
  case 1:
8480
8479
  sg = INT2FIX(DEFAULT_SG);
8481
8480
  }
@@ -8485,7 +8484,7 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
8485
8484
  VALUE argv2[2], hash;
8486
8485
  argv2[0] = str;
8487
8486
  argv2[1] = opt;
8488
- if (!NIL_P(opt)) argc2--;
8487
+ if (!NIL_P(opt)) argc2++;
8489
8488
  hash = date_s__iso8601(argc2, argv2, klass);
8490
8489
  return dt_new_by_frags(klass, hash, sg);
8491
8490
  }
@@ -8510,12 +8509,11 @@ datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
8510
8509
  {
8511
8510
  VALUE str, sg, opt;
8512
8511
 
8513
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8514
- if (!NIL_P(opt)) argc--;
8512
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8515
8513
 
8516
8514
  switch (argc) {
8517
8515
  case 0:
8518
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8516
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8519
8517
  case 1:
8520
8518
  sg = INT2FIX(DEFAULT_SG);
8521
8519
  }
@@ -8550,12 +8548,11 @@ datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
8550
8548
  {
8551
8549
  VALUE str, sg, opt;
8552
8550
 
8553
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8554
- if (!NIL_P(opt)) argc--;
8551
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8555
8552
 
8556
8553
  switch (argc) {
8557
8554
  case 0:
8558
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8555
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8559
8556
  case 1:
8560
8557
  sg = INT2FIX(DEFAULT_SG);
8561
8558
  }
@@ -8591,12 +8588,11 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
8591
8588
  {
8592
8589
  VALUE str, sg, opt;
8593
8590
 
8594
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8595
- if (!NIL_P(opt)) argc--;
8591
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8596
8592
 
8597
8593
  switch (argc) {
8598
8594
  case 0:
8599
- str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000");
8595
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_RFC3339);
8600
8596
  case 1:
8601
8597
  sg = INT2FIX(DEFAULT_SG);
8602
8598
  }
@@ -8631,12 +8627,11 @@ datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
8631
8627
  {
8632
8628
  VALUE str, sg, opt;
8633
8629
 
8634
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8635
- if (!NIL_P(opt)) argc--;
8630
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8636
8631
 
8637
8632
  switch (argc) {
8638
8633
  case 0:
8639
- str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT");
8634
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_HTTPDATE);
8640
8635
  case 1:
8641
8636
  sg = INT2FIX(DEFAULT_SG);
8642
8637
  }
@@ -8676,12 +8671,11 @@ datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
8676
8671
  {
8677
8672
  VALUE str, sg, opt;
8678
8673
 
8679
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8680
- if (!NIL_P(opt)) argc--;
8674
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8681
8675
 
8682
8676
  switch (argc) {
8683
8677
  case 0:
8684
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8678
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8685
8679
  case 1:
8686
8680
  sg = INT2FIX(DEFAULT_SG);
8687
8681
  }
@@ -8962,9 +8956,10 @@ date_to_time(VALUE self)
8962
8956
  get_d1a(self);
8963
8957
 
8964
8958
  if (m_julian_p(adat)) {
8965
- self = d_lite_gregorian(self);
8966
- get_d1b(self);
8959
+ VALUE g = d_lite_gregorian(self);
8960
+ get_d1b(g);
8967
8961
  adat = bdat;
8962
+ self = g;
8968
8963
  }
8969
8964
 
8970
8965
  t = f_local3(rb_cTime,
@@ -9042,9 +9037,10 @@ datetime_to_time(VALUE self)
9042
9037
  get_d1(self);
9043
9038
 
9044
9039
  if (m_julian_p(dat)) {
9045
- self = d_lite_gregorian(self);
9046
- get_d1a(self);
9040
+ VALUE g = d_lite_gregorian(self);
9041
+ get_d1a(g);
9047
9042
  dat = adat;
9043
+ self = g;
9048
9044
  }
9049
9045
 
9050
9046
  {
@@ -9528,7 +9524,7 @@ Init_date_core(void)
9528
9524
  *
9529
9525
  * - You need both dates and times; \Date handles only dates.
9530
9526
  * - You need only Gregorian dates (and not Julian dates);
9531
- * see {Julian and Gregorian Calendars}[rdoc-ref:calendars.rdoc].
9527
+ * see {Julian and Gregorian Calendars}[rdoc-ref:date/calendars.rdoc].
9532
9528
  *
9533
9529
  * A \Date object, once created, is immutable, and cannot be modified.
9534
9530
  *
@@ -122,8 +122,9 @@ do { \
122
122
  do { \
123
123
  size_t l; \
124
124
  l = read_digits(&str[si], slen - si, &n, w); \
125
- if (l == 0) \
125
+ if (l == 0) { \
126
126
  fail(); \
127
+ } \
127
128
  si += l; \
128
129
  } while (0)
129
130
 
data/ext/date/extconf.rb CHANGED
@@ -3,6 +3,7 @@ require 'mkmf'
3
3
 
4
4
  config_string("strict_warnflags") {|w| $warnflags += " #{w}"}
5
5
 
6
+ append_cflags("-Wno-compound-token-split-by-macro") if RUBY_VERSION < "2.7."
6
7
  have_func("rb_category_warn")
7
8
  with_werror("", {:werror => true}) do |opt, |
8
9
  have_var("timezone", "time.h", opt)
data/lib/date.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  require 'date_core'
5
5
 
6
6
  class Date
7
- VERSION = "3.4.0" # :nodoc:
7
+ VERSION = "3.5.0" # :nodoc:
8
8
 
9
9
  # call-seq:
10
10
  # infinite? -> false
metadata CHANGED
@@ -1,23 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: date
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.5.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: 2024-11-01 00:00:00.000000000 Z
11
+ date: 2025-10-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: A subclass of Object includes Comparable module for handling dates.
13
+ description: The official date library for Ruby.
14
14
  email:
15
- -
15
+ -
16
16
  executables: []
17
17
  extensions:
18
18
  - ext/date/extconf.rb
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - BSDL
22
+ - COPYING
21
23
  - README.md
22
24
  - ext/date/date_core.c
23
25
  - ext/date/date_parse.c
@@ -35,7 +37,7 @@ licenses:
35
37
  - BSD-2-Clause
36
38
  metadata:
37
39
  changelog_uri: https://github.com/ruby/date/releases
38
- post_install_message:
40
+ post_install_message:
39
41
  rdoc_options: []
40
42
  require_paths:
41
43
  - lib
@@ -50,8 +52,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
52
  - !ruby/object:Gem::Version
51
53
  version: '0'
52
54
  requirements: []
53
- rubygems_version: 3.5.11
54
- signing_key:
55
+ rubygems_version: 3.5.22
56
+ signing_key:
55
57
  specification_version: 4
56
- summary: A subclass of Object includes Comparable module for handling dates.
58
+ summary: The official date library for Ruby.
57
59
  test_files: []