Commit graph

231 commits

Author SHA1 Message Date
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>

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>

31f07bc576
2025-06-15 16:11:06 +00:00
Jean Boussier
fb0dbbc0e6 [ruby/date] d_lite_marshal_load: copy ivars in the right order
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.

8175252653
2025-06-13 17:40:43 +00:00
Nobuyoshi Nakada
998e5791c5 [ruby/date] Suppress warnings by gcc-13 with -Og
6dd7969a64
2025-06-05 14:18:38 +00:00
Stan Lo
6d00dee30a [ruby/date] Fix broken rdoc-ref to the calendar page
cb52e64be1
2024-12-15 06:20:10 +00:00
Nobuyoshi Nakada
43dd9c721f [ruby/date] Fix mixed declarations and code
This still support ruby 2.6 which does not require C99.

61d849758f
2024-11-29 02:48:10 +00:00
Nobuyoshi Nakada
511954dd5c [ruby/date] Extract Julian calendar epoch literals
e677e99a86
2024-11-05 04:19:40 +00:00
Nobuyoshi Nakada
c51feedbfd [ruby/date] Update argc by rb_scan_args not to contain keywords
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.

b6974b00d8
2024-11-05 03:38:13 +00:00
eileencodes
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
p0pemaru
cb6dcc7746 [ruby/date] [DOC] specify the unit of return value for Date#-
b3a2c7611e
2024-06-03 05:24:18 +00:00
Nobuyoshi Nakada
77e5e06846 [ruby/date] Prevent converted gregorian date from GC
`m_sf_in_sec` calls `rb_rational_new` that can cause GC.

6de449ab6a
2024-06-03 05:23:44 +00:00
Nobuyoshi Nakada
2e6f8554f8 [ruby/date] Remove the unintentional ability to parse Symbol
It's been 2 years since ruby/date#49, so it's okay.

435dfec6c8
2024-02-21 16:04:52 +00:00
BurdetteLamar
7ffee5681f [ruby/date] [DOC] Fix link
2adb917487
2023-09-20 19:48:28 +00:00
Burdette Lamar
3d53827130 [ruby/date] Removed (newly unneeded) alias remarks
(https://github.com/ruby/date/pull/88)

cfa7e9868b
2023-02-19 22:24:39 +00:00
Nobuyoshi Nakada
c316a5f2f1 [ruby/date] Adjust format [ci skip]
71c35b4054
2022-12-18 03:03:54 +00:00
zverok
1859784422 [ruby/date] Implement Date#deconstruct_keys and DateTime#deconstruct_keys
6bb6d3a810
2022-12-13 19:52:06 +00:00
Nobuyoshi Nakada
739ad81ff1 [ruby/date] Check month range as civil 2022-10-27 05:36:11 +00:00
Nobuyoshi Nakada
3539da64fc
[DOC] Replace the external URIs to docs with rdoc-ref 2022-10-12 12:27:40 +09:00
Burdette Lamar
8d40ede2e0 [ruby/date] [DOC] Enhanced intro for Date (https://github.com/ruby/date/pull/72)
59a6673221
2022-08-15 22:16:23 +09:00
Nobuyoshi Nakada
e07d450dea [ruby/date] Fix Time#to_datetime before calendar reform
Time is always in the proleptic Gregorian calendar.
Also DateTime#to_time should convert to the Gregorian calendar first,
before extracting its components.

https://bugs.ruby-lang.org/issues/18946#change-98527

b2aee75248
2022-08-08 23:50:17 +09:00
Burdette Lamar
1607c6d281 [DOC] New doc about Julian/Gregorian (#70) 2022-08-07 20:42:31 -04:00
Burdette Lamar
eaf6189fe5 [ruby/date] Enhanced RDoc (https://github.com/ruby/date/pull/69)
Treats:
    ::_strptime
    ::strptime
Adds 'Related' entry to some methods' doc.

a6c2129273
2022-08-03 05:17:55 +09:00
Burdette Lamar
d8ea3a20fa [ruby/date] [DOC] Enhanced RDoc for parser methods (https://github.com/ruby/date/pull/68)
Treats:
    ::_httpdate
    ::_iso8601
    ::_jisx0301
    ::_parse
    ::_rfc2822
    ::_rfc3339
    ::_xmlschema
    ::httpdate
    ::iso8601
    ::jisx0301
    ::parse
    ::rfc2822
    ::rfc3339
    ::xmlschema

24bdab600a
2022-08-03 02:28:12 +09:00
Burdette Lamar
4efbeb1190 [ruby/date] Enhanced RDoc (https://github.com/ruby/date/pull/67)
Treats:
    ::httpdate
    #to_date
    #to_time
    #to_datetime
In behalf of ::httpdate, I've introduced section "Argument limit" that can be pointed to by various Date methods (similar to existing section "Argument start"). This will involve 8 already-enhanced methods plus 8 more not yet done.

00326ff99c
2022-07-31 03:18:45 +09:00
Burdette Lamar
53175643ef [ruby/date] [DOC] Enhanced RDoc (https://github.com/ruby/date/pull/66)
Treats:
    #===
    #to_s
    #inspect
    #strftme
    #asctime
    #iso3601
    #rfc3339
    #rfc2822
    #httpdate
    #jisx0301

aed66fedf6
2022-07-30 04:51:10 +09:00
Burdette Lamar
c348f5a91c [ruby/date] [DOC] Enhanced RDoc for <=> (https://github.com/ruby/date/pull/65)
0cdbaa92e9
2022-07-29 06:37:10 +09:00
Hiroshi SHIBATA
8154b176de
Manually sync with https://github.com/ruby/date/pull/64 2022-07-27 14:17:19 +09:00
Burdette Lamar
3aee94fb91 [ruby/date] [DOC] Enhanced RDoc (https://github.com/ruby/date/pull/63)
Treats:
    #next
    #<<
    #>>
    #next_month
    #prev_month
    #next_year
    #prev_year
    #step
    #upto
    #downto

4246441a35
2022-07-12 22:57:25 +09:00
Burdette Lamar
702d4d773f [ruby/date] [DOC] Enhanced RDoc (https://github.com/ruby/date/pull/62)
Minor edits to 11 methods' documentation.

00bb7f6648
2022-07-12 00:02:41 +09:00
Burdette Lamar
5137af633e [ruby/date] Enhanced RDoc (https://github.com/ruby/date/pull/61)
Omit private aliases from Rdoc.

48f9180663
2022-07-10 23:51:41 +09:00
Burdette Lamar
e9ec6893d2 [ruby/date] [DOC] Enhanced RDoc (https://github.com/ruby/date/pull/59)
Minor changes (mostly doc-guide compliance) to 18 or so of simpler methods (getters).

00e37ba2b4
2022-07-09 01:06:08 +09:00
Burdette Lamar
621e5c568a [ruby/date] Enhanced RDoc (https://github.com/ruby/date/pull/58)
Brings a dozen call-seq schemas into compliance with the doc guide.
    Adds links to section "Argument start" where needed.
    Revises (minorly) ::today.
    Otherwise, does not disturb existing text.

9aec11df50
2022-07-08 03:48:09 +09:00
Burdette Lamar
dbb23f29cb [ruby/date] [DOC] Enhanced RDoc (https://github.com/ruby/date/pull/57)
All things commercial.

9d3bc61728
2022-07-07 03:58:02 +09:00
Burdette Lamar
f64bb67d75 [ruby/date] Update ext/date/date_core.c
8eb1c780fb

Co-authored-by: Peter Zhu <peter@peterzhu.ca>
2022-07-05 04:12:50 +09:00
BurdetteLamar
5fe86666a5 [ruby/date] Enhanced RDoc
e36690f70e
2022-07-05 04:12:49 +09:00
BurdetteLamar
e323d8e6a2 [ruby/date] Enhanced RDoc
dcc0742623
2022-07-05 04:12:48 +09:00
BurdetteLamar
6317cf7de8 [ruby/date] Enhanced RDoc
91c632f156
2022-07-05 04:12:48 +09:00
BurdetteLamar
7212163e7c [ruby/date] Enhanced RDoc
5c18ec031e
2022-07-05 04:12:47 +09:00
BurdetteLamar
4ec14b6323 [ruby/date] Enhanced RDoc
fd3ae275c3
2022-07-05 04:12:46 +09:00
BurdetteLamar
24c80aea0e [ruby/date] Enhanced RDoc
ac25182c66
2022-07-05 04:12:45 +09:00
BurdetteLamar
c90110d146 [ruby/date] Enhanced RDoc
f9ecaad2ee
2022-07-05 04:12:44 +09:00
BurdetteLamar
6324aaf3d0 [ruby/date] Enhanced RDoc
e80fee4f30
2022-07-05 04:12:43 +09:00
Nobuyoshi Nakada
0db5ee5195 [ruby/date] Suppress declaration-after-statement warnings
60bd16009d
2022-02-25 20:01:06 +09:00
Nobuyoshi Nakada
bb22bc76b0 [ruby/date] Deprecate the unintentional ability to parse Symbol
d57818f3b3
2022-02-25 19:57:50 +09:00
Jean Boussier
a87c56f820 [ruby/date] check_limit: also handle symbols
376c65942b
2021-11-16 22:51:41 +09:00
Jean Boussier
fa674cf723 [ruby/date] Date._<format>(nil) should return an empty Hash
Fix: https://github.com/ruby/date/issues/39

This is how versions previous to 3.2.1 behaved and Active Support
currently rely on this behavior.

90357af080/activesupport/lib/active_support/values/time_zone.rb (L383-L384)

Any Rails application upgrading to date `3.2.1` might run into unexpected errors.

8f2d7a0c7e
2021-11-16 22:51:40 +09:00
Yusuke Endoh
489c8cebf5 [ruby/date] Add length limit option for methods that parses date strings
`Date.parse` now raises an ArgumentError when a given date string is
longer than 128. You can configure the limit by giving `limit` keyword
arguments like `Date.parse(str, limit: 1000)`. If you pass `limit: nil`,
the limit is disabled.

Not only `Date.parse` but also the following methods are changed.

* Date._parse
* Date.parse
* DateTime.parse
* Date._iso8601
* Date.iso8601
* DateTime.iso8601
* Date._rfc3339
* Date.rfc3339
* DateTime.rfc3339
* Date._xmlschema
* Date.xmlschema
* DateTime.xmlschema
* Date._rfc2822
* Date.rfc2822
* DateTime.rfc2822
* Date._rfc822
* Date.rfc822
* DateTime.rfc822
* Date._jisx0301
* Date.jisx0301
* DateTime.jisx0301

3959accef8
2021-11-16 20:56:56 +09:00
Rei Odaira
ceeae31901 Avoid using the altzone variable in AIX
In AIX, altzone exists in the standard library but is not declared
in time.h.  By 524513be39, have_var
and try_var in mkmf recognizes a variable that exists in a library
even when it is not declared.  As a result, in AIX, HAVE_ALTZONE
is defined, but compile fails due to the lack of the declaration.
2021-10-02 21:23:34 -05:00