date 3.4.1 → 3.6.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.
@@ -2325,6 +2325,16 @@ sec_fraction(VALUE f)
2325
2325
 
2326
2326
  #define SNUM 14
2327
2327
 
2328
+ #ifndef rb_streql_lit
2329
+ static inline int
2330
+ rb_streql_cstr(VALUE str, const char *lit, size_t len)
2331
+ {
2332
+ if ((size_t)RSTRING_LEN(str) != len) return 0;
2333
+ return memcmp(RSTRING_PTR(str), lit, len) == 0;
2334
+ }
2335
+ #define rb_streql_lit(str, lit) rb_streql_cstr(str, lit, sizeof(lit "") - 1)
2336
+ #endif
2337
+
2328
2338
  static int
2329
2339
  iso8601_ext_datetime_cb(VALUE m, VALUE hash)
2330
2340
  {
@@ -2339,14 +2349,14 @@ iso8601_ext_datetime_cb(VALUE m, VALUE hash)
2339
2349
 
2340
2350
  if (!NIL_P(s[1])) {
2341
2351
  if (!NIL_P(s[3])) set_hash("mday", str2num(s[3]));
2342
- if (strcmp(RSTRING_PTR(s[1]), "-") != 0) {
2352
+ if (!rb_streql_lit(s[1], "-")) {
2343
2353
  y = str2num(s[1]);
2344
2354
  if (RSTRING_LEN(s[1]) < 4)
2345
2355
  y = comp_year69(y);
2346
2356
  set_hash("year", y);
2347
2357
  }
2348
2358
  if (NIL_P(s[2])) {
2349
- if (strcmp(RSTRING_PTR(s[1]), "-") != 0)
2359
+ if (!rb_streql_lit(s[1], "-"))
2350
2360
  return 0;
2351
2361
  }
2352
2362
  else
@@ -2425,14 +2435,14 @@ iso8601_bas_datetime_cb(VALUE m, VALUE hash)
2425
2435
 
2426
2436
  if (!NIL_P(s[3])) {
2427
2437
  set_hash("mday", str2num(s[3]));
2428
- if (strcmp(RSTRING_PTR(s[1]), "--") != 0) {
2438
+ if (!rb_streql_lit(s[1], "--")) {
2429
2439
  y = str2num(s[1]);
2430
2440
  if (RSTRING_LEN(s[1]) < 4)
2431
2441
  y = comp_year69(y);
2432
2442
  set_hash("year", y);
2433
2443
  }
2434
2444
  if (*RSTRING_PTR(s[2]) == '-') {
2435
- if (strcmp(RSTRING_PTR(s[1]), "--") != 0)
2445
+ if (!rb_streql_lit(s[1], "--"))
2436
2446
  return 0;
2437
2447
  }
2438
2448
  else
@@ -41,7 +41,6 @@ static const int ABBREVIATED_MONTH_NAME_LENGTH = 3;
41
41
 
42
42
  #define f_match(r,s) rb_funcall(r, rb_intern("match"), 1, s)
43
43
  #define f_aref(o,i) rb_funcall(o, rb_intern("[]"), 1, i)
44
- #define f_end(o,i) rb_funcall(o, rb_intern("end"), 1, i)
45
44
 
46
45
  #define issign(c) ((c) == '-' || (c) == '+')
47
46
 
@@ -122,8 +121,9 @@ do { \
122
121
  do { \
123
122
  size_t l; \
124
123
  l = read_digits(&str[si], slen - si, &n, w); \
125
- if (l == 0) \
124
+ if (l == 0) { \
126
125
  fail(); \
126
+ } \
127
127
  si += l; \
128
128
  } while (0)
129
129
 
@@ -143,7 +143,7 @@ valid_range_p(VALUE v, int a, int b)
143
143
  do { \
144
144
  size_t l; \
145
145
  l = date__strptime_internal(&str[si], slen - si, \
146
- fmt, sizeof fmt - 1, hash); \
146
+ fmt, sizeof fmt - 1, hash, enc); \
147
147
  if (fail_p()) \
148
148
  return 0; \
149
149
  si += l; \
@@ -159,7 +159,8 @@ head_match_p(size_t len, const char *name, const char *str, size_t slen, size_t
159
159
 
160
160
  static size_t
161
161
  date__strptime_internal(const char *str, size_t slen,
162
- const char *fmt, size_t flen, VALUE hash)
162
+ const char *fmt, size_t flen,
163
+ VALUE hash, rb_encoding *enc)
163
164
  {
164
165
  size_t si, fi;
165
166
  int c;
@@ -596,15 +597,14 @@ date__strptime_internal(const char *str, size_t slen,
596
597
 
597
598
  b = rb_backref_get();
598
599
  rb_match_busy(b);
599
- m = f_match(pat, rb_usascii_str_new(&str[si], slen - si));
600
+ m = f_match(pat, rb_enc_str_new(&str[si], slen - si, enc));
600
601
 
601
602
  if (!NIL_P(m)) {
602
- VALUE s, l, o;
603
+ VALUE s, o;
603
604
 
604
605
  s = rb_reg_nth_match(1, m);
605
- l = f_end(m, INT2FIX(0));
606
606
  o = date_zone_to_diff(s);
607
- si += NUM2LONG(l);
607
+ si += RSTRING_LEN(s);
608
608
  set_hash("zone", s);
609
609
  set_hash("offset", o);
610
610
  rb_backref_set(b);
@@ -653,23 +653,24 @@ date__strptime_internal(const char *str, size_t slen,
653
653
 
654
654
  VALUE
655
655
  date__strptime(const char *str, size_t slen,
656
- const char *fmt, size_t flen, VALUE hash)
656
+ const char *fmt, size_t flen,
657
+ VALUE hash, rb_encoding *enc)
657
658
  {
658
659
  size_t si;
659
660
  VALUE cent, merid;
660
661
 
661
- si = date__strptime_internal(str, slen, fmt, flen, hash);
662
+ si = date__strptime_internal(str, slen, fmt, flen, hash, enc);
663
+
664
+ if (fail_p())
665
+ return Qnil;
662
666
 
663
667
  if (slen > si) {
664
668
  VALUE s;
665
669
 
666
- s = rb_usascii_str_new(&str[si], slen - si);
670
+ s = rb_enc_str_new(&str[si], slen - si, enc);
667
671
  set_hash("leftover", s);
668
672
  }
669
673
 
670
- if (fail_p())
671
- return Qnil;
672
-
673
674
  cent = del_hash("_cent");
674
675
  if (!NIL_P(cent)) {
675
676
  VALUE year;
data/ext/date/extconf.rb CHANGED
@@ -3,6 +3,9 @@ require 'mkmf'
3
3
 
4
4
  config_string("strict_warnflags") {|w| $warnflags += " #{w}"}
5
5
 
6
+ unless try_compile("", "", werror: true)
7
+ append_cflags("-Wno-default-const-init-field-unsafe")
8
+ end
6
9
  append_cflags("-Wno-compound-token-split-by-macro") if RUBY_VERSION < "2.7."
7
10
  have_func("rb_category_warn")
8
11
  with_werror("", {:werror => true}) do |opt, |
@@ -10,4 +13,7 @@ with_werror("", {:werror => true}) do |opt, |
10
13
  have_var("altzone", "time.h", opt)
11
14
  end
12
15
 
16
+ have_func("rb_gc_mark_movable", "ruby.h") # RUBY_VERSION >= 2.7
17
+ have_const("RUBY_TYPED_EMBEDDABLE", "ruby.h") # RUBY_VERSION >= 3.3
18
+
13
19
  create_makefile('date_core')
data/lib/date.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  require 'date_core'
5
5
 
6
6
  class Date
7
- VERSION = "3.4.1" # :nodoc:
7
+ VERSION = "3.6.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.1
4
+ version: 3.6.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-12-02 00:00:00.000000000 Z
11
+ date: 2026-10-08 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: []