447 Commits
Author SHA1 Message Date
Hiroshi SHIBATAandClaude Opus 5.5 65911e4910 Use rb_len_t for String lengths and Array indices in date
It falls back to long on Ruby versions that do not define HAVE_RB_LEN_T, so the change also builds there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 08:10:53 +09:00
youdie006 a9d3eadfc8 [ruby/date] Deprecate lenient RFC 3339 date time separators
RFC 3339 allows only "T", and by convention a space, between the date
and the time, but Date._rfc3339 also accepts \t, \n, \v, \f and \r.
Warn on those under Warning[:deprecated] before they become an error.

The separator is now captured so rfc3339_cb can inspect it, which
shifts the remaining group indices.

https://github.com/ruby/date/commit/ffb9d45105
2026-10-09 22:45:03 +00:00
Hiroshi SHIBATA 5794f9a280 [ruby/date] v3.6.0
https://github.com/ruby/date/commit/0cd525c52f
2026-10-08 03:19:00 +00:00
Jean Boussier 46e53809f5 [ruby/date] Implement compaction and embedded structs
Currently dates are allocated in a 40B slot plus a 32B (simple)
or 48B (complex) external struct.

Once embedded they entirely fit into a 80B slot.

https://github.com/ruby/date/commit/e8a1442c60
2026-08-28 16:30:09 +00:00
sjh9714 c84cb4d4f3 [ruby/date] Range-check the integral Rational offset
Every branch of offset_to_sec range-checks the resulting number of
seconds except one path through the Rational branch: when the day
fraction is an integral Rational, n is assigned inside the if arm and
reaches *rof without passing the guard that sits in the else arm.

DateTime.new(2024, 1, 1, 0, 0, 0, Rational(2, 1)) therefore produced a
48-hour offset, while the equivalent Integer 2 is rejected and falls
back to +00:00. Rational(49710, 1) is 4_294_944_000 seconds, over
INT_MAX, so the (int) narrowing turned a large positive offset into a
negative one.

Move the check below the if/else so it covers both arms. That also
bounds n before the narrowing. Rational(1, 1) is exactly
DAY_IN_SECONDS and the guard is inclusive, so in-range values are
unaffected.

https://github.com/ruby/date/commit/7524d7c41f
2026-08-28 16:00:02 +00:00
Nobuyoshi Nakada 2084db2eab [ruby/date] Validate the commercial week range before conversion
Reject week numbers outside -53..-1 and 1..53 before conversion so
integer overflow cannot make invalid input appear valid.

Fixes https://github.com/ruby/date/pull/180.

https://github.com/ruby/date/commit/e9c07010c7
2026-08-28 15:58:42 +00:00
Nobuyoshi Nakada b95de2b9a4 [ruby/date] Preserve input encoding when parsing time zones
Pass the input encoding through `date__strptime` so non-ASCII trailing
data is treated as a parse failure instead of raising an encoding error.

Fixes https://github.com/ruby/date/pull/179.

https://github.com/ruby/date/commit/edf7cf016c
2026-08-28 15:58:33 +00:00
Nobuyoshi Nakada 7af1270680 [ruby/date] Suppress warnings by clang 21
https://bugs.ruby-lang.org/issues/21629

https://github.com/ruby/date/commit/214024627a
2026-08-28 10:53:00 +00:00
Nobuyoshi Nakada 7d4461e162 [Misc #22206] Generate dependencies without compiler builds
Replace `tool/update-deps` with a Ruby source scanner so dependency
updates no longer require GNU make, a configured build, or compiler
preprocessor output.

Keep compact source mappings and scanner declarations in dependency
files, and expand complete rules into the build directory.  Avoid the
temporary fixture headers required by the compiler-driven prototype.

Use the generated rules from GNU make, BSD make, and NMake builds.
Support out-of-tree and read-only source trees, and retain expanded
dependencies shipped in release archives when baseruby is unavailable.
2026-07-23 00:04:47 +09:00
Nobuyoshi Nakada 4b6f5f299e [ruby/date] Avoid NUL-terminated ISO 8601 component checks
https://github.com/ruby/date/commit/98c72c840b
2026-07-15 10:30:50 +00:00
Jean Boussier 0fd945f3de Stop including onigmo.h in rregexp.h
Followup: https://github.com/ruby/ruby/pull/17671

[Bug #22184]

`onigmo.h` contains a lot of declarations that can easily
conflict with third party code, hence it's better to keep
it opaque. That however requires a few hacks.
2026-07-07 09:21:13 +02:00
Jean Boussier b58a6024a0 Make T_REGEXP embedded
When embeddeding `struct re_pattern_buffer`, `RRegexp` end up
488B large, which result in a rather minimal 24B waste in 512B slots.

This however requires a few changes:
  - Stop relying on `RREGEXP_PTR == NULL` to check for initialization.
  - `reg_copy` requires a new `onig_reg_copy_body` API.
2026-07-06 11:56:40 +02:00
Nobuyoshi Nakada 5d72b7cb46 [ruby/date] Verify all argument classes first
https://github.com/ruby/date/commit/c98d85dfd3
2026-05-29 04:21:36 +00:00
Nobuyoshi Nakada 55a7404c06 [ruby/date] Check if failed fist
If the parse fails, `leftover` will not be used either.

https://github.com/ruby/date/commit/fa1dd0b52d
2026-05-29 04:21:36 +00:00
Nobuyoshi Nakada a650fc469b [ruby/date] Do not use C99 style comment [ci skip]
The minimum required ruby version of this library is still 2.6.
C99 has been adopted since ruby 2.7.

https://github.com/ruby/date/commit/b9162f3e77
2026-05-29 04:21:36 +00:00
USAMI Kenta 2e6929c5e0 [ruby/date] Fix stray bracket in Date#new_start call-seq
https://github.com/ruby/date/commit/390c91dbb3
2026-05-25 02:29:40 +00:00
Burdette Lamar e9c4825828 [ruby/date] [DOC] Fix link (https://github.com/ruby/date/pull/160)
https://github.com/ruby/date/commit/54974fe8e5
2026-03-19 23:31:17 +00:00
Maciej Mensfeld 8024245854 [ruby/date] remove conditional for uint64_t
https://github.com/ruby/date/commit/47778c32d8
2025-12-26 11:00:51 +09:00
Maciej Mensfeld 5960fb9fa0 [ruby/date] remove redundant code
https://github.com/ruby/date/commit/5e6a458179
2025-12-26 11:00:51 +09:00
Maciej Mensfeld bcaa127ecd [ruby/date] code remarks, macros and r2.6 support
https://github.com/ruby/date/commit/2682dc79c0
2025-12-26 11:00:51 +09:00
Maciej Mensfeld ea03f263b5 [ruby/date] improve styling
https://github.com/ruby/date/commit/cd7a329dfd
2025-12-26 11:00:51 +09:00
Maciej Mensfeld f09e35ee4a [ruby/date] [ruby/date] Optimize Gregorian date conversions with Neri-Schneider algorithm
Replace floating-point arithmetic and iterative loops with pure integer
operations for ~40% faster Date operations. Date.ordinal and Date.commercial
are ~2x faster due to O(1) first-day-of-year calculation.

Reference: https://arxiv.org/abs/2102.06959

https://github.com/ruby/date/commit/cc639549d6
2025-12-26 11:00:51 +09:00
Hiroshi SHIBATA 4523a90532 [ruby/date] v3.5.1
https://github.com/ruby/date/commit/1d0aadc295
2025-12-10 05:28:49 +00:00
Peter Zhu 1f0d41aa4d [ruby/date] Call rb_gc_register_mark_object after object allocation
It's possible that both half_days_in_day and day_in_nanoseconds are Ruby
objects, which means that creating day_in_nanoseconds may trigger GC.
Since half_days_in_day is not registered as a mark object until after
day_in_nanoseconds is allocated, the GC may reclaim half_days_in_day.

We can see this crash:

    ruby(rb_print_backtrace+0xb) [0x63a373c0] vm_dump.c:1105
    ruby(rb_vm_bugreport) vm_dump.c:1450
    ruby(rb_assert_failure_detail+0xdb) [0x6371d3a2] error.c:1216
    ruby(RB_FL_TEST_RAW+0x0) [0x6371d3d5] error.c:1192
    ruby(rb_assert_failure) (null):0
    ruby(rb_gc_impl_writebarrier+0xb4) [0x636f01e4] gc/default/default.c:6103
    ruby(pin_array_list_append+0x72) [0x638f9787] include/ruby/internal/gc.h:788
    ruby(rb_vm_register_global_object) vm.c:4713
    ruby(rb_gc_register_mark_object+0x3a) [0x6374144a] gc.c:3449
    .ext/i686-linux-gnu/date_core.so(Init_date_core+0x204) [0xdbec86c4] ext/date/date_core.c:9511
    .ext/i686-linux-gnu/date_core.so(Init_date_core) (null):0
    ruby(dln_load_and_init+0x71) [0x6392c541] dln.c:521
    ruby(dln_load_feature+0xd2) [0x6392c7d2] dln.c:566
    ruby(load_ext+0xc3) [0x637931b3] load.c:1210
    ruby(rb_vm_pop_frame+0x0) [0x638f80cd] vm.c:3120
    ruby(rb_vm_call_cfunc_in_box) vm.c:3122
    ruby(rb_long2num_inline+0x0) [0x637956f8] load.c:1353
    ruby(require_internal) load.c:1354
    ruby(rb_require_string_internal+0x60) [0x63795fa1] load.c:1457
    ruby(rb_require_string) load.c:1443

https://github.com/ruby/date/commit/cbec5948e0
2025-12-06 17:13:32 +00:00
Stan Lo 4cd6661e18 Reorganize page documentations (#15154)
Re-organize page docs
2025-11-27 20:12:24 +00:00
Hiroshi SHIBATA 337c4bc163 [ruby/date] v3.5.0
https://github.com/ruby/date/commit/d535f7e85f
2025-10-29 07:08:01 +00:00
Nobuyoshi Nakada e6188c45e1 [ruby/date] Date._parse does not accept nil
https://github.com/ruby/date/commit/545066ca28
2025-10-06 14:22:03 +09:00
Nobuyoshi Nakada f13e68e252 [ruby/date] Do not repeat conversions to string
https://github.com/ruby/date/commit/159e1ebb7f
https://github.com/ruby/date/commit/4f7b6c9b42
2025-10-06 13:16:56 +09:00
Nobuyoshi Nakada 6d2f93f170 [ruby/date] Suppress maybe-uninitialized warning by gcc-13
https://github.com/ruby/date/commit/afaa4a997b
2025-09-15 08:02:07 +00:00
Jeremy Evans 0b23a8db60 Update dependencies for addition of set.h to public headers 2025-07-11 15:24:23 +09:00
Dmitry Dygalo 022c18b60d [ruby/date] [Bug #21436] check for fixnum lower bound in m_ajd
Issue - https://bugs.ruby-lang.org/issues/21436

Apparently, the lower bound check is missing, which results in overflow & wrapping later on in RB_INT2FIX

Signed-off-by: Dmitry Dygalo <dmitry.dygalo@workato.com>

https://github.com/ruby/date/commit/67d75e8423
2025-06-15 16:12:45 +00:00
Dmitry Dygalo c1877d431e [ruby/date] [Bug #21437] Date#hash for large years
Addresses https://bugs.ruby-lang.org/issues/21437

Signed-off-by: Dmitry Dygalo <dmitry.dygalo@workato.com>

https://github.com/ruby/date/commit/31f07bc576
2025-06-15 16:11:06 +00:00
Jean Boussier fb0dbbc0e6 [ruby/date] d_lite_marshal_load: copy ivars in the right order
https://github.com/ruby/date/commit/dbf4e957dc
2025-06-13 17:46:10 +00:00
Jean Boussier 99a72df16d [ruby/date] Remove references to FL_EXIVAR
This flag isn't really meant to be public, it's an implementation
detail of Ruby.

And checking it before calling `rb_copy_generic_ivar` only save
a function call.

https://github.com/ruby/date/commit/8175252653
2025-06-13 17:40:43 +00:00
Nobuyoshi Nakada f45aa1505f [ruby/date] Update zonetab.h at 2025-06-11
https://github.com/ruby/date/commit/b28617cde0
2025-06-11 10:05:39 +00:00
Nobuyoshi Nakada 998e5791c5 [ruby/date] Suppress warnings by gcc-13 with -Og
https://github.com/ruby/date/commit/6dd7969a64
2025-06-05 14:18:38 +00:00
Susan van den Broek 76aaf8ddf4 [ruby/date] Add license files (COPYING, BSDL) to gem files
https://github.com/ruby/date/commit/a3d85e0be5
2025-03-18 07:28:50 +00:00
Nobuyoshi Nakada 384e6945ac [ruby/date] Enclose dangling else in braces and fix -Wmisleading-indentation
```
date_strptime.c:253:324: warning: misleading indentation;
      statement is not part of the previous 'if' [-Wmisleading-indentation]
  253 |   ...((VALUE)RUBY_Qtrue)); return 0; } while (0); si += l; } while (0);
      |                                                   ^
date_strptime.c:252:7: note: previous statement is here
  252 |       else
      |       ^
```

https://github.com/ruby/date/commit/41aed5b746
2025-01-13 03:12:28 +00:00
Ryan Bigg 778e73b2b3 [ruby/date] Simplify description of this library
https://github.com/ruby/date/commit/904d4b9607
2024-12-26 10:27:24 +09:00
Stan Lo 6d00dee30a [ruby/date] Fix broken rdoc-ref to the calendar page
https://github.com/ruby/date/commit/cb52e64be1
2024-12-15 06:20:10 +00:00
Hiroshi SHIBATA 229592f175 [ruby/date] Bump up 3.4.1
https://github.com/ruby/date/commit/a3295ad262
2024-12-02 07:51:06 +00:00
Nobuyoshi Nakada 43dd9c721f [ruby/date] Fix mixed declarations and code
This still support ruby 2.6 which does not require C99.

https://github.com/ruby/date/commit/61d849758f
2024-11-29 02:48:10 +00:00
Nobuyoshi Nakada b910de641b [ruby/date] Suppress compound-token-split-by-macro warnings
It was used intentionally.

https://github.com/ruby/date/commit/291b40f939
2024-11-29 02:48:09 +00:00
Nobuyoshi Nakada 511954dd5c [ruby/date] Extract Julian calendar epoch literals
https://github.com/ruby/date/commit/e677e99a86
2024-11-05 04:19:40 +00:00
Nobuyoshi Nakada c51feedbfd [ruby/date] Update argc by rb_scan_args not to contain keywords
https://github.com/ruby/date/commit/f277463439
2024-11-05 04:19:39 +00:00
Dmitrii Zudin ee4599dbe7 [ruby/date] Fix incorrect argc2 decrement in datetime_s_iso8601 function
Replace the decrement (argc2--) with an increment (argc2++) for
the correct number of arguments when opt is provided.

https://github.com/ruby/date/commit/b6974b00d8
2024-11-05 03:38:13 +00:00
Hiroshi SHIBATA bb5f28c8f7 [ruby/date] Bump up v3.4.0
https://github.com/ruby/date/commit/94f8e51e65
2024-11-01 13:42:16 +09:00
d25b74b32c Resize arrays in rb_ary_freeze and use it for freezing arrays
While working on a separate issue we found that in some cases
`ary_heap_realloc` was being called on frozen arrays. To fix this, this
change does the following:

1) Updates `rb_ary_freeze` to assert the type is an array, return if
already frozen, and shrink the capacity if it is not embedded, shared
or a shared root.
2) Replaces `rb_obj_freeze` with `rb_ary_freeze` when the object is
always an array.
3) In `ary_heap_realloc`, ensure the new capa is set with
`ARY_SET_CAPA`. Previously the change in capa was not set.
4) Adds an assertion to `ary_heap_realloc` that the array is not frozen.

Some of this work was originally done in
https://github.com/ruby/ruby/pull/2640, referencing this issue
https://bugs.ruby-lang.org/issues/16291. There didn't appear to be any
objections to this PR, it appears to have simply lost traction.

The original PR made changes to arrays and strings at the same time,
this PR only does arrays. Also it was old enough that rather than revive
that branch I've made a new one. I added Lourens as co-author in addtion
to Aaron who helped me with this patch.

The original PR made this change for performance reasons, and while
that's still true for this PR, the goal of this PR is to avoid
calling `ary_heap_realloc` on frozen arrays. The capacity should be
shrunk _before_ the array is frozen, not after.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
Co-Authored-By: methodmissing <lourens@methodmissing.com>
2024-07-02 10:34:23 -07:00
Nobuyoshi Nakada 04c86a63cd [ruby/date] Update zonetab.h at 2024-06-26
https://github.com/ruby/date/commit/ef5a0dac5b
2024-06-26 10:01:21 +00:00
Nobuyoshi Nakada 865a2027a1 [ruby/date] Use locale insensitive casecmp
https://github.com/ruby/date/commit/cfbd6a6b13
2024-06-24 15:36:56 +00:00