date 3.3.3 → 3.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ccf42407789dcdf94598ab68332e1860f4f2b5f5820d7b2b2bd8ae283088160
4
- data.tar.gz: 988c7bded5cb20a4b68283216eeaaddf874a15765705919fe372bdeaf58d1c2a
3
+ metadata.gz: 9b82de0c3b7d4685d8aa478af5ce4d919808d79d83b71012b0f61052c37a1506
4
+ data.tar.gz: 6a1adeb0b3d43f3afdc9edb06c1b2bfd081f726e3b91dff9d5d482e77cf87d11
5
5
  SHA512:
6
- metadata.gz: f99b7157afc55d925ffe6ea0f786ce4dc377a30786bb8045b71019db65cd056c83edbd4a979925060ed0daaae2f0cc71f19c04d0b89df53b6a39c70ad6005457
7
- data.tar.gz: d4d955554151f00b3e0db05cf684d5e7c47655654fd3174aa3e1c67b14a9fa8696092219eac5e540ae9d9abe8c05b06e13bb4ff74c754c33b7e075e9b5498597
6
+ metadata.gz: 69bc90e06d9f020e5c391732c6b95c8fabe8abe705be5760b5f303980b90ffda96ae55c0ad837a23c8c6701b63783a0a7c16bd2e13f82f7903c1c47089312645
7
+ data.tar.gz: 7c0aff9c2c9a43f3ac6b1f53a9530805792c7941c45074f5bb58cb90b24890efc641b374cbee7fd36ac8124426a748da92a67d148bb07329b62a90f14bfb9194
data/ext/date/date_core.c CHANGED
@@ -57,7 +57,7 @@ static VALUE sym_hour, sym_min, sym_sec, sym_sec_fraction, sym_zone;
57
57
  #define f_add3(x,y,z) f_add(f_add(x, y), z)
58
58
  #define f_sub3(x,y,z) f_sub(f_sub(x, y), z)
59
59
 
60
- #define f_frozen_ary(...) rb_obj_freeze(rb_ary_new3(__VA_ARGS__))
60
+ #define f_frozen_ary(...) rb_ary_freeze(rb_ary_new3(__VA_ARGS__))
61
61
 
62
62
  static VALUE date_initialize(int argc, VALUE *argv, VALUE self);
63
63
  static VALUE datetime_initialize(int argc, VALUE *argv, VALUE self);
@@ -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.
@@ -2589,8 +2594,6 @@ date_s__valid_civil_p(int argc, VALUE *argv, VALUE klass)
2589
2594
  *
2590
2595
  * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
2591
2596
  *
2592
- * Date.valid_date? is an alias for Date.valid_civil?.
2593
- *
2594
2597
  * Related: Date.jd, Date.new.
2595
2598
  */
2596
2599
  static VALUE
@@ -2986,8 +2989,6 @@ date_s_julian_leap_p(VALUE klass, VALUE y)
2986
2989
  * Date.gregorian_leap?(2000) # => true
2987
2990
  * Date.gregorian_leap?(2001) # => false
2988
2991
  *
2989
- * Date.leap? is an alias for Date.gregorian_leap?.
2990
- *
2991
2992
  * Related: Date.julian_leap?.
2992
2993
  */
2993
2994
  static VALUE
@@ -3493,8 +3494,6 @@ date_s_civil(int argc, VALUE *argv, VALUE klass)
3493
3494
  *
3494
3495
  * See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
3495
3496
  *
3496
- * Date.civil is an alias for Date.new.
3497
- *
3498
3497
  * Related: Date.jd.
3499
3498
  */
3500
3499
  static VALUE
@@ -4431,7 +4430,7 @@ date_s_strptime(int argc, VALUE *argv, VALUE klass)
4431
4430
 
4432
4431
  switch (argc) {
4433
4432
  case 0:
4434
- str = rb_str_new2("-4712-01-01");
4433
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
4435
4434
  case 1:
4436
4435
  fmt = rb_str_new2("%F");
4437
4436
  case 2:
@@ -4470,12 +4469,6 @@ check_limit(VALUE str, VALUE opt)
4470
4469
  {
4471
4470
  size_t slen, limit;
4472
4471
  if (NIL_P(str)) return;
4473
- if (SYMBOL_P(str)) {
4474
- rb_category_warn(RB_WARN_CATEGORY_DEPRECATED,
4475
- "The ability to parse Symbol is an unintentional bug and is deprecated");
4476
- str = rb_sym2str(str);
4477
- }
4478
-
4479
4472
  StringValue(str);
4480
4473
  slen = RSTRING_LEN(str);
4481
4474
  limit = get_limit(opt);
@@ -4490,8 +4483,7 @@ date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
4490
4483
  {
4491
4484
  VALUE vstr, vcomp, hash, opt;
4492
4485
 
4493
- rb_scan_args(argc, argv, "11:", &vstr, &vcomp, &opt);
4494
- if (!NIL_P(opt)) argc--;
4486
+ argc = rb_scan_args(argc, argv, "11:", &vstr, &vcomp, &opt);
4495
4487
  check_limit(vstr, opt);
4496
4488
  StringValue(vstr);
4497
4489
  if (!rb_enc_str_asciicompat_p(vstr))
@@ -4578,12 +4570,11 @@ date_s_parse(int argc, VALUE *argv, VALUE klass)
4578
4570
  {
4579
4571
  VALUE str, comp, sg, opt;
4580
4572
 
4581
- rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
4582
- if (!NIL_P(opt)) argc--;
4573
+ argc = rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
4583
4574
 
4584
4575
  switch (argc) {
4585
4576
  case 0:
4586
- str = rb_str_new2("-4712-01-01");
4577
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
4587
4578
  case 1:
4588
4579
  comp = Qtrue;
4589
4580
  case 2:
@@ -4658,12 +4649,11 @@ date_s_iso8601(int argc, VALUE *argv, VALUE klass)
4658
4649
  {
4659
4650
  VALUE str, sg, opt;
4660
4651
 
4661
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4662
- if (!NIL_P(opt)) argc--;
4652
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4663
4653
 
4664
4654
  switch (argc) {
4665
4655
  case 0:
4666
- str = rb_str_new2("-4712-01-01");
4656
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
4667
4657
  case 1:
4668
4658
  sg = INT2FIX(DEFAULT_SG);
4669
4659
  }
@@ -4729,12 +4719,11 @@ date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
4729
4719
  {
4730
4720
  VALUE str, sg, opt;
4731
4721
 
4732
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4733
- if (!NIL_P(opt)) argc--;
4722
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4734
4723
 
4735
4724
  switch (argc) {
4736
4725
  case 0:
4737
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
4726
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
4738
4727
  case 1:
4739
4728
  sg = INT2FIX(DEFAULT_SG);
4740
4729
  }
@@ -4798,12 +4787,11 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
4798
4787
  {
4799
4788
  VALUE str, sg, opt;
4800
4789
 
4801
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4802
- if (!NIL_P(opt)) argc--;
4790
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4803
4791
 
4804
4792
  switch (argc) {
4805
4793
  case 0:
4806
- str = rb_str_new2("-4712-01-01");
4794
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
4807
4795
  case 1:
4808
4796
  sg = INT2FIX(DEFAULT_SG);
4809
4797
  }
@@ -4832,8 +4820,6 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
4832
4820
  *
4833
4821
  * See argument {limit}[rdoc-ref:Date@Argument+limit].
4834
4822
  *
4835
- * Date._rfc822 is an alias for Date._rfc2822.
4836
- *
4837
4823
  * Related: Date.rfc2822 (returns a \Date object).
4838
4824
  */
4839
4825
  static VALUE
@@ -4864,8 +4850,6 @@ date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
4864
4850
  * - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
4865
4851
  * - Argument {limit}[rdoc-ref:Date@Argument+limit].
4866
4852
  *
4867
- * Date.rfc822 is an alias for Date.rfc2822.
4868
- *
4869
4853
  * Related: Date._rfc2822 (returns a hash).
4870
4854
  */
4871
4855
  static VALUE
@@ -4873,11 +4857,11 @@ date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
4873
4857
  {
4874
4858
  VALUE str, sg, opt;
4875
4859
 
4876
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4860
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4877
4861
 
4878
4862
  switch (argc) {
4879
4863
  case 0:
4880
- str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000");
4864
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_RFC3339);
4881
4865
  case 1:
4882
4866
  sg = INT2FIX(DEFAULT_SG);
4883
4867
  }
@@ -4941,11 +4925,11 @@ date_s_httpdate(int argc, VALUE *argv, VALUE klass)
4941
4925
  {
4942
4926
  VALUE str, sg, opt;
4943
4927
 
4944
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4928
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4945
4929
 
4946
4930
  switch (argc) {
4947
4931
  case 0:
4948
- str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT");
4932
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_HTTPDATE);
4949
4933
  case 1:
4950
4934
  sg = INT2FIX(DEFAULT_SG);
4951
4935
  }
@@ -5013,12 +4997,11 @@ date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
5013
4997
  {
5014
4998
  VALUE str, sg, opt;
5015
4999
 
5016
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
5017
- if (!NIL_P(opt)) argc--;
5000
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
5018
5001
 
5019
5002
  switch (argc) {
5020
5003
  case 0:
5021
- str = rb_str_new2("-4712-01-01");
5004
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
5022
5005
  case 1:
5023
5006
  sg = INT2FIX(DEFAULT_SG);
5024
5007
  }
@@ -5346,7 +5329,6 @@ d_lite_yday(VALUE self)
5346
5329
  *
5347
5330
  * Date.new(2001, 2, 3).mon # => 2
5348
5331
  *
5349
- * Date#month is an alias for Date#mon.
5350
5332
  */
5351
5333
  static VALUE
5352
5334
  d_lite_mon(VALUE self)
@@ -5363,7 +5345,6 @@ d_lite_mon(VALUE self)
5363
5345
  *
5364
5346
  * Date.new(2001, 2, 3).mday # => 3
5365
5347
  *
5366
- * Date#day is an alias for Date#mday.
5367
5348
  */
5368
5349
  static VALUE
5369
5350
  d_lite_mday(VALUE self)
@@ -5613,7 +5594,6 @@ d_lite_hour(VALUE self)
5613
5594
  *
5614
5595
  * DateTime.new(2001, 2, 3, 4, 5, 6).min # => 5
5615
5596
  *
5616
- * Date#minute is an alias for Date#min.
5617
5597
  */
5618
5598
  static VALUE
5619
5599
  d_lite_min(VALUE self)
@@ -5630,7 +5610,6 @@ d_lite_min(VALUE self)
5630
5610
  *
5631
5611
  * DateTime.new(2001, 2, 3, 4, 5, 6).sec # => 6
5632
5612
  *
5633
- * Date#second is an alias for Date#sec.
5634
5613
  */
5635
5614
  static VALUE
5636
5615
  d_lite_sec(VALUE self)
@@ -5648,7 +5627,6 @@ d_lite_sec(VALUE self)
5648
5627
  *
5649
5628
  * DateTime.new(2001, 2, 3, 4, 5, 6.5).sec_fraction # => (1/2)
5650
5629
  *
5651
- * Date#second_fraction is an alias for Date#sec_fraction.
5652
5630
  */
5653
5631
  static VALUE
5654
5632
  d_lite_sec_fraction(VALUE self)
@@ -6347,9 +6325,11 @@ minus_dd(VALUE self, VALUE other)
6347
6325
  * call-seq:
6348
6326
  * d - other -> date or rational
6349
6327
  *
6350
- * Returns the difference between the two dates if the other is a date
6351
- * object. If the other is a numeric value, returns a date object
6352
- * pointing +other+ days before self. If the other is a fractional number,
6328
+ * If the other is a date object, returns a Rational
6329
+ * whose value is the difference between the two dates in days.
6330
+ * If the other is a numeric value, returns a date object
6331
+ * pointing +other+ days before self.
6332
+ * If the other is a fractional number,
6353
6333
  * assumes its precision is at most nanosecond.
6354
6334
  *
6355
6335
  * Date.new(2001,2,3) - 1 #=> #<Date: 2001-02-02 ...>
@@ -6424,7 +6404,6 @@ d_lite_prev_day(int argc, VALUE *argv, VALUE self)
6424
6404
  * d.to_s # => "2001-02-03"
6425
6405
  * d.next.to_s # => "2001-02-04"
6426
6406
  *
6427
- * Date#succ is an alias for Date#next.
6428
6407
  */
6429
6408
  static VALUE
6430
6409
  d_lite_next(VALUE self)
@@ -7298,7 +7277,6 @@ strftimev(const char *fmt, VALUE self,
7298
7277
  *
7299
7278
  * See {asctime}[https://linux.die.net/man/3/asctime].
7300
7279
  *
7301
- * Date#ctime is an alias for Date#asctime.
7302
7280
  */
7303
7281
  static VALUE
7304
7282
  d_lite_asctime(VALUE self)
@@ -7316,7 +7294,6 @@ d_lite_asctime(VALUE self)
7316
7294
  *
7317
7295
  * Date.new(2001, 2, 3).iso8601 # => "2001-02-03"
7318
7296
  *
7319
- * Date#xmlschema is an alias for Date#iso8601.
7320
7297
  */
7321
7298
  static VALUE
7322
7299
  d_lite_iso8601(VALUE self)
@@ -7349,7 +7326,6 @@ d_lite_rfc3339(VALUE self)
7349
7326
  *
7350
7327
  * Date.new(2001, 2, 3).rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
7351
7328
  *
7352
- * Date#rfc822 is an alias for Date#rfc2822.
7353
7329
  */
7354
7330
  static VALUE
7355
7331
  d_lite_rfc2822(VALUE self)
@@ -8398,7 +8374,7 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
8398
8374
 
8399
8375
  switch (argc) {
8400
8376
  case 0:
8401
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8377
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8402
8378
  case 1:
8403
8379
  fmt = rb_str_new2("%FT%T%z");
8404
8380
  case 2:
@@ -8446,12 +8422,11 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
8446
8422
  {
8447
8423
  VALUE str, comp, sg, opt;
8448
8424
 
8449
- rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
8450
- if (!NIL_P(opt)) argc--;
8425
+ argc = rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
8451
8426
 
8452
8427
  switch (argc) {
8453
8428
  case 0:
8454
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8429
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8455
8430
  case 1:
8456
8431
  comp = Qtrue;
8457
8432
  case 2:
@@ -8493,12 +8468,11 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
8493
8468
  {
8494
8469
  VALUE str, sg, opt;
8495
8470
 
8496
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8497
- if (!NIL_P(opt)) argc--;
8471
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8498
8472
 
8499
8473
  switch (argc) {
8500
8474
  case 0:
8501
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8475
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8502
8476
  case 1:
8503
8477
  sg = INT2FIX(DEFAULT_SG);
8504
8478
  }
@@ -8508,7 +8482,7 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
8508
8482
  VALUE argv2[2], hash;
8509
8483
  argv2[0] = str;
8510
8484
  argv2[1] = opt;
8511
- if (!NIL_P(opt)) argc2--;
8485
+ if (!NIL_P(opt)) argc2++;
8512
8486
  hash = date_s__iso8601(argc2, argv2, klass);
8513
8487
  return dt_new_by_frags(klass, hash, sg);
8514
8488
  }
@@ -8533,12 +8507,11 @@ datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
8533
8507
  {
8534
8508
  VALUE str, sg, opt;
8535
8509
 
8536
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8537
- if (!NIL_P(opt)) argc--;
8510
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8538
8511
 
8539
8512
  switch (argc) {
8540
8513
  case 0:
8541
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8514
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8542
8515
  case 1:
8543
8516
  sg = INT2FIX(DEFAULT_SG);
8544
8517
  }
@@ -8573,12 +8546,11 @@ datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
8573
8546
  {
8574
8547
  VALUE str, sg, opt;
8575
8548
 
8576
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8577
- if (!NIL_P(opt)) argc--;
8549
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8578
8550
 
8579
8551
  switch (argc) {
8580
8552
  case 0:
8581
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8553
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8582
8554
  case 1:
8583
8555
  sg = INT2FIX(DEFAULT_SG);
8584
8556
  }
@@ -8614,12 +8586,11 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
8614
8586
  {
8615
8587
  VALUE str, sg, opt;
8616
8588
 
8617
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8618
- if (!NIL_P(opt)) argc--;
8589
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8619
8590
 
8620
8591
  switch (argc) {
8621
8592
  case 0:
8622
- str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000");
8593
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_RFC3339);
8623
8594
  case 1:
8624
8595
  sg = INT2FIX(DEFAULT_SG);
8625
8596
  }
@@ -8654,12 +8625,11 @@ datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
8654
8625
  {
8655
8626
  VALUE str, sg, opt;
8656
8627
 
8657
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8658
- if (!NIL_P(opt)) argc--;
8628
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8659
8629
 
8660
8630
  switch (argc) {
8661
8631
  case 0:
8662
- str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT");
8632
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_HTTPDATE);
8663
8633
  case 1:
8664
8634
  sg = INT2FIX(DEFAULT_SG);
8665
8635
  }
@@ -8699,12 +8669,11 @@ datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
8699
8669
  {
8700
8670
  VALUE str, sg, opt;
8701
8671
 
8702
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8703
- if (!NIL_P(opt)) argc--;
8672
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8704
8673
 
8705
8674
  switch (argc) {
8706
8675
  case 0:
8707
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8676
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8708
8677
  case 1:
8709
8678
  sg = INT2FIX(DEFAULT_SG);
8710
8679
  }
@@ -8745,8 +8714,8 @@ dt_lite_to_s(VALUE self)
8745
8714
  *
8746
8715
  * DateTime.now.strftime # => "2022-07-01T11:03:19-05:00"
8747
8716
  *
8748
- * For other formats, see
8749
- * {Formats for Dates and Times}[doc/strftime_formatting.rdoc].
8717
+ * For other formats,
8718
+ * see {Formats for Dates and Times}[https://docs.ruby-lang.org/en/master/strftime_formatting_rdoc.html]:
8750
8719
  *
8751
8720
  */
8752
8721
  static VALUE
@@ -8980,18 +8949,23 @@ time_to_datetime(VALUE self)
8980
8949
  static VALUE
8981
8950
  date_to_time(VALUE self)
8982
8951
  {
8952
+ VALUE t;
8953
+
8983
8954
  get_d1a(self);
8984
8955
 
8985
8956
  if (m_julian_p(adat)) {
8986
- VALUE tmp = d_lite_gregorian(self);
8987
- get_d1b(tmp);
8957
+ VALUE g = d_lite_gregorian(self);
8958
+ get_d1b(g);
8988
8959
  adat = bdat;
8960
+ self = g;
8989
8961
  }
8990
8962
 
8991
- return f_local3(rb_cTime,
8963
+ t = f_local3(rb_cTime,
8992
8964
  m_real_year(adat),
8993
8965
  INT2FIX(m_mon(adat)),
8994
8966
  INT2FIX(m_mday(adat)));
8967
+ RB_GC_GUARD(self); /* may be the converted gregorian */
8968
+ return t;
8995
8969
  }
8996
8970
 
8997
8971
  /*
@@ -9061,9 +9035,10 @@ datetime_to_time(VALUE self)
9061
9035
  get_d1(self);
9062
9036
 
9063
9037
  if (m_julian_p(dat)) {
9064
- self = d_lite_gregorian(self);
9065
- get_d1a(self);
9038
+ VALUE g = d_lite_gregorian(self);
9039
+ get_d1a(g);
9066
9040
  dat = adat;
9041
+ self = g;
9067
9042
  }
9068
9043
 
9069
9044
  {
@@ -9080,6 +9055,7 @@ datetime_to_time(VALUE self)
9080
9055
  f_add(INT2FIX(m_sec(dat)),
9081
9056
  m_sf_in_sec(dat)),
9082
9057
  INT2FIX(m_of(dat)));
9058
+ RB_GC_GUARD(self); /* may be the converted gregorian */
9083
9059
  return t;
9084
9060
  }
9085
9061
  }
@@ -9484,7 +9460,7 @@ mk_ary_of_str(long len, const char *a[])
9484
9460
  }
9485
9461
  rb_ary_push(o, e);
9486
9462
  }
9487
- rb_obj_freeze(o);
9463
+ rb_ary_freeze(o);
9488
9464
  return o;
9489
9465
  }
9490
9466
 
@@ -7,6 +7,9 @@
7
7
  #include "ruby/re.h"
8
8
  #include <ctype.h>
9
9
 
10
+ #undef strncasecmp
11
+ #define strncasecmp STRNCASECMP
12
+
10
13
  RUBY_EXTERN VALUE rb_int_positive_pow(long x, unsigned long y);
11
14
  RUBY_EXTERN unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, size_t *retlen, int *overflow);
12
15
 
@@ -7,6 +7,9 @@
7
7
  #include "ruby/re.h"
8
8
  #include <ctype.h>
9
9
 
10
+ #undef strncasecmp
11
+ #define strncasecmp STRNCASECMP
12
+
10
13
  static const char *day_names[] = {
11
14
  "Sunday", "Monday", "Tuesday", "Wednesday",
12
15
  "Thursday", "Friday", "Saturday",
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/ext/date/prereq.mk CHANGED
@@ -1,7 +1,7 @@
1
1
  .SUFFIXES: .list
2
2
 
3
3
  .list.h:
4
- gperf --ignore-case -C -c -P -p -j1 -i 1 -g -o -t -N $(*F) $< \
4
+ gperf --ignore-case -L ANSI-C -C -c -P -p -j1 -i 1 -g -o -t -N $(*F) $< \
5
5
  | sed -f $(top_srcdir)/tool/gperf.sed \
6
6
  > $(@F)
7
7