date 3.3.4 → 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: c21f55b2cc18baf941cd4774c226c424d7f987bee9239e0b732a0d9fb4f0e6fd
4
- data.tar.gz: 2acbe62f992812810d0efd5f09801fcec3669d1ba4df7afc20b95a10a13093a9
3
+ metadata.gz: 9b82de0c3b7d4685d8aa478af5ce4d919808d79d83b71012b0f61052c37a1506
4
+ data.tar.gz: 6a1adeb0b3d43f3afdc9edb06c1b2bfd081f726e3b91dff9d5d482e77cf87d11
5
5
  SHA512:
6
- metadata.gz: 13082c47b2973af41fc9064501b16db82f900a3e8c8f4d470370f8f424cf89752e49193595329e37029007a5086d83725321f836efe949012f7df43cff26d401
7
- data.tar.gz: 1500c8d72b88fabb2645cbd67da24447f9a11be934a20cad3557b8b261bfa788e9a7d9f699891c1c93a39fd92c3427c9672d0d84815390b57337727d77665153
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.
@@ -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:
@@ -4464,12 +4469,6 @@ check_limit(VALUE str, VALUE opt)
4464
4469
  {
4465
4470
  size_t slen, limit;
4466
4471
  if (NIL_P(str)) return;
4467
- if (SYMBOL_P(str)) {
4468
- rb_category_warn(RB_WARN_CATEGORY_DEPRECATED,
4469
- "The ability to parse Symbol is an unintentional bug and is deprecated");
4470
- str = rb_sym2str(str);
4471
- }
4472
-
4473
4472
  StringValue(str);
4474
4473
  slen = RSTRING_LEN(str);
4475
4474
  limit = get_limit(opt);
@@ -4484,8 +4483,7 @@ date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
4484
4483
  {
4485
4484
  VALUE vstr, vcomp, hash, opt;
4486
4485
 
4487
- rb_scan_args(argc, argv, "11:", &vstr, &vcomp, &opt);
4488
- if (!NIL_P(opt)) argc--;
4486
+ argc = rb_scan_args(argc, argv, "11:", &vstr, &vcomp, &opt);
4489
4487
  check_limit(vstr, opt);
4490
4488
  StringValue(vstr);
4491
4489
  if (!rb_enc_str_asciicompat_p(vstr))
@@ -4572,12 +4570,11 @@ date_s_parse(int argc, VALUE *argv, VALUE klass)
4572
4570
  {
4573
4571
  VALUE str, comp, sg, opt;
4574
4572
 
4575
- rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
4576
- if (!NIL_P(opt)) argc--;
4573
+ argc = rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
4577
4574
 
4578
4575
  switch (argc) {
4579
4576
  case 0:
4580
- str = rb_str_new2("-4712-01-01");
4577
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
4581
4578
  case 1:
4582
4579
  comp = Qtrue;
4583
4580
  case 2:
@@ -4652,12 +4649,11 @@ date_s_iso8601(int argc, VALUE *argv, VALUE klass)
4652
4649
  {
4653
4650
  VALUE str, sg, opt;
4654
4651
 
4655
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4656
- if (!NIL_P(opt)) argc--;
4652
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4657
4653
 
4658
4654
  switch (argc) {
4659
4655
  case 0:
4660
- str = rb_str_new2("-4712-01-01");
4656
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
4661
4657
  case 1:
4662
4658
  sg = INT2FIX(DEFAULT_SG);
4663
4659
  }
@@ -4723,12 +4719,11 @@ date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
4723
4719
  {
4724
4720
  VALUE str, sg, opt;
4725
4721
 
4726
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4727
- if (!NIL_P(opt)) argc--;
4722
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4728
4723
 
4729
4724
  switch (argc) {
4730
4725
  case 0:
4731
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
4726
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
4732
4727
  case 1:
4733
4728
  sg = INT2FIX(DEFAULT_SG);
4734
4729
  }
@@ -4792,12 +4787,11 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
4792
4787
  {
4793
4788
  VALUE str, sg, opt;
4794
4789
 
4795
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4796
- if (!NIL_P(opt)) argc--;
4790
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4797
4791
 
4798
4792
  switch (argc) {
4799
4793
  case 0:
4800
- str = rb_str_new2("-4712-01-01");
4794
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
4801
4795
  case 1:
4802
4796
  sg = INT2FIX(DEFAULT_SG);
4803
4797
  }
@@ -4863,11 +4857,11 @@ date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
4863
4857
  {
4864
4858
  VALUE str, sg, opt;
4865
4859
 
4866
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4860
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4867
4861
 
4868
4862
  switch (argc) {
4869
4863
  case 0:
4870
- str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000");
4864
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_RFC3339);
4871
4865
  case 1:
4872
4866
  sg = INT2FIX(DEFAULT_SG);
4873
4867
  }
@@ -4931,11 +4925,11 @@ date_s_httpdate(int argc, VALUE *argv, VALUE klass)
4931
4925
  {
4932
4926
  VALUE str, sg, opt;
4933
4927
 
4934
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4928
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
4935
4929
 
4936
4930
  switch (argc) {
4937
4931
  case 0:
4938
- str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT");
4932
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_HTTPDATE);
4939
4933
  case 1:
4940
4934
  sg = INT2FIX(DEFAULT_SG);
4941
4935
  }
@@ -5003,12 +4997,11 @@ date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
5003
4997
  {
5004
4998
  VALUE str, sg, opt;
5005
4999
 
5006
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
5007
- if (!NIL_P(opt)) argc--;
5000
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
5008
5001
 
5009
5002
  switch (argc) {
5010
5003
  case 0:
5011
- str = rb_str_new2("-4712-01-01");
5004
+ str = rb_str_new2(JULIAN_EPOCH_DATE);
5012
5005
  case 1:
5013
5006
  sg = INT2FIX(DEFAULT_SG);
5014
5007
  }
@@ -6332,9 +6325,11 @@ minus_dd(VALUE self, VALUE other)
6332
6325
  * call-seq:
6333
6326
  * d - other -> date or rational
6334
6327
  *
6335
- * Returns the difference between the two dates if the other is a date
6336
- * object. If the other is a numeric value, returns a date object
6337
- * 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,
6338
6333
  * assumes its precision is at most nanosecond.
6339
6334
  *
6340
6335
  * Date.new(2001,2,3) - 1 #=> #<Date: 2001-02-02 ...>
@@ -8379,7 +8374,7 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
8379
8374
 
8380
8375
  switch (argc) {
8381
8376
  case 0:
8382
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8377
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8383
8378
  case 1:
8384
8379
  fmt = rb_str_new2("%FT%T%z");
8385
8380
  case 2:
@@ -8427,12 +8422,11 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
8427
8422
  {
8428
8423
  VALUE str, comp, sg, opt;
8429
8424
 
8430
- rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
8431
- if (!NIL_P(opt)) argc--;
8425
+ argc = rb_scan_args(argc, argv, "03:", &str, &comp, &sg, &opt);
8432
8426
 
8433
8427
  switch (argc) {
8434
8428
  case 0:
8435
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8429
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8436
8430
  case 1:
8437
8431
  comp = Qtrue;
8438
8432
  case 2:
@@ -8474,12 +8468,11 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
8474
8468
  {
8475
8469
  VALUE str, sg, opt;
8476
8470
 
8477
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8478
- if (!NIL_P(opt)) argc--;
8471
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8479
8472
 
8480
8473
  switch (argc) {
8481
8474
  case 0:
8482
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8475
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8483
8476
  case 1:
8484
8477
  sg = INT2FIX(DEFAULT_SG);
8485
8478
  }
@@ -8489,7 +8482,7 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
8489
8482
  VALUE argv2[2], hash;
8490
8483
  argv2[0] = str;
8491
8484
  argv2[1] = opt;
8492
- if (!NIL_P(opt)) argc2--;
8485
+ if (!NIL_P(opt)) argc2++;
8493
8486
  hash = date_s__iso8601(argc2, argv2, klass);
8494
8487
  return dt_new_by_frags(klass, hash, sg);
8495
8488
  }
@@ -8514,12 +8507,11 @@ datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
8514
8507
  {
8515
8508
  VALUE str, sg, opt;
8516
8509
 
8517
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8518
- if (!NIL_P(opt)) argc--;
8510
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8519
8511
 
8520
8512
  switch (argc) {
8521
8513
  case 0:
8522
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8514
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8523
8515
  case 1:
8524
8516
  sg = INT2FIX(DEFAULT_SG);
8525
8517
  }
@@ -8554,12 +8546,11 @@ datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
8554
8546
  {
8555
8547
  VALUE str, sg, opt;
8556
8548
 
8557
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8558
- if (!NIL_P(opt)) argc--;
8549
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8559
8550
 
8560
8551
  switch (argc) {
8561
8552
  case 0:
8562
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8553
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8563
8554
  case 1:
8564
8555
  sg = INT2FIX(DEFAULT_SG);
8565
8556
  }
@@ -8595,12 +8586,11 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
8595
8586
  {
8596
8587
  VALUE str, sg, opt;
8597
8588
 
8598
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8599
- if (!NIL_P(opt)) argc--;
8589
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8600
8590
 
8601
8591
  switch (argc) {
8602
8592
  case 0:
8603
- str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000");
8593
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_RFC3339);
8604
8594
  case 1:
8605
8595
  sg = INT2FIX(DEFAULT_SG);
8606
8596
  }
@@ -8635,12 +8625,11 @@ datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
8635
8625
  {
8636
8626
  VALUE str, sg, opt;
8637
8627
 
8638
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8639
- if (!NIL_P(opt)) argc--;
8628
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8640
8629
 
8641
8630
  switch (argc) {
8642
8631
  case 0:
8643
- str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT");
8632
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME_HTTPDATE);
8644
8633
  case 1:
8645
8634
  sg = INT2FIX(DEFAULT_SG);
8646
8635
  }
@@ -8680,12 +8669,11 @@ datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
8680
8669
  {
8681
8670
  VALUE str, sg, opt;
8682
8671
 
8683
- rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8684
- if (!NIL_P(opt)) argc--;
8672
+ argc = rb_scan_args(argc, argv, "02:", &str, &sg, &opt);
8685
8673
 
8686
8674
  switch (argc) {
8687
8675
  case 0:
8688
- str = rb_str_new2("-4712-01-01T00:00:00+00:00");
8676
+ str = rb_str_new2(JULIAN_EPOCH_DATETIME);
8689
8677
  case 1:
8690
8678
  sg = INT2FIX(DEFAULT_SG);
8691
8679
  }
@@ -8961,18 +8949,23 @@ time_to_datetime(VALUE self)
8961
8949
  static VALUE
8962
8950
  date_to_time(VALUE self)
8963
8951
  {
8952
+ VALUE t;
8953
+
8964
8954
  get_d1a(self);
8965
8955
 
8966
8956
  if (m_julian_p(adat)) {
8967
- VALUE tmp = d_lite_gregorian(self);
8968
- get_d1b(tmp);
8957
+ VALUE g = d_lite_gregorian(self);
8958
+ get_d1b(g);
8969
8959
  adat = bdat;
8960
+ self = g;
8970
8961
  }
8971
8962
 
8972
- return f_local3(rb_cTime,
8963
+ t = f_local3(rb_cTime,
8973
8964
  m_real_year(adat),
8974
8965
  INT2FIX(m_mon(adat)),
8975
8966
  INT2FIX(m_mday(adat)));
8967
+ RB_GC_GUARD(self); /* may be the converted gregorian */
8968
+ return t;
8976
8969
  }
8977
8970
 
8978
8971
  /*
@@ -9042,9 +9035,10 @@ datetime_to_time(VALUE self)
9042
9035
  get_d1(self);
9043
9036
 
9044
9037
  if (m_julian_p(dat)) {
9045
- self = d_lite_gregorian(self);
9046
- get_d1a(self);
9038
+ VALUE g = d_lite_gregorian(self);
9039
+ get_d1a(g);
9047
9040
  dat = adat;
9041
+ self = g;
9048
9042
  }
9049
9043
 
9050
9044
  {
@@ -9061,6 +9055,7 @@ datetime_to_time(VALUE self)
9061
9055
  f_add(INT2FIX(m_sec(dat)),
9062
9056
  m_sf_in_sec(dat)),
9063
9057
  INT2FIX(m_of(dat)));
9058
+ RB_GC_GUARD(self); /* may be the converted gregorian */
9064
9059
  return t;
9065
9060
  }
9066
9061
  }
@@ -9465,7 +9460,7 @@ mk_ary_of_str(long len, const char *a[])
9465
9460
  }
9466
9461
  rb_ary_push(o, e);
9467
9462
  }
9468
- rb_obj_freeze(o);
9463
+ rb_ary_freeze(o);
9469
9464
  return o;
9470
9465
  }
9471
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