Commit graph

135 commits

Author SHA1 Message Date
Andrew Konchin
8adc96b5ca [ruby/date] Skip tests failing on TruffleRuby
d019ac8186
2025-01-10 15:59:25 +00:00
Nobuyoshi Nakada
e4f5fd8e5f [ruby/date] Refine assertions
1970b740d0
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
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
zverok
1859784422 [ruby/date] Implement Date#deconstruct_keys and DateTime#deconstruct_keys
6bb6d3a810
2022-12-13 19:52:06 +00:00
Nobuyoshi Nakada
1b7c5c394f [ruby/date] Fix misplaced time zone offset checks
d21c69450a
2022-10-07 14:41:31 +09:00
Nobuyoshi Nakada
cb16dcb184 [ruby/date] The shrunk words to be copied is limited
Th buffer size is small enough and no need to allocate dynamically.

f62bf0a01d
2022-09-29 14:56:39 +09:00
Nobuyoshi Nakada
5a8aaedaff [ruby/date] Narrow ALLOCV region for shrunk words
f51b038074
2022-09-29 14:06:36 +09:00
Nobuyoshi Nakada
d12fce7af3 [ruby/date] Check time zone offset elements
Too big parts of fractional hour time zone offset can cause assertion
failures.

06bcfb2729
2022-09-28 21:07:00 +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
Jeremy Evans
ab3cb29bd9 Avoid defining the same test class in multiple files
Should fix issues with parallel testing sometimes not running all
tests.

This should be viewed skipping whitespace changes.

Fixes [Bug #18731]
2022-04-22 15:00:16 -07:00
Yusuke Endoh
ddd83e8462 test/date/test_date_parse.rb: relax the time limit
The timeout was very strict for weak CI machines like qemu-riscv.
Due to the additional overhead for Regexp.timeout=, it started failing
on such machines.

20220330T200018Z.fail.html.gz
```
  1) Error:
TestDateParse#test__parse_too_long_year:
Timeout::Error: execution expired
```
2022-03-31 12:52:16 +09:00
Nobuyoshi Nakada
8780f15fd7 [ruby/date] Use assert_deprecated_warn
c55004715a
2022-02-25 20:39:47 +09:00
Nobuyoshi Nakada
bb22bc76b0 [ruby/date] Deprecate the unintentional ability to parse Symbol
d57818f3b3
2022-02-25 19:57:50 +09:00
Nobuyoshi Nakada
d4f32b6b7b [ruby/date] Scale timeouts
2889698e2f
2022-02-25 19:52:33 +09:00
Nobuyoshi Nakada
4933d7fe56 [ruby/date] Update tests
5a138afce9
2022-02-25 19:52:32 +09:00
Nobuyoshi Nakada
b5c2a0840f [ruby/date] Anchor at beginning of numbers
https://hackerone.com/reports/1254844

2f7814cc22
2022-02-25 19:52:31 +09:00
Nobuyoshi Nakada
1758eade57 [ruby/date] Anchor at beginning of numbers
https://hackerone.com/reports/1254844

7ffe25e458
2022-02-25 19:52:31 +09:00
Hiroshi SHIBATA
7f5e06601b [ruby/date] Use omit instead of skip for test-unit
537f3f681e
2022-01-12 10:53:34 +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
Jeremy Evans
f9f7f3a75e [ruby/date] Make %v strftime flag use uppercase month
%v is supposed to be the VMS date, and VMS date format uses an
uppercase month.

Ruby 1.8 used an uppercase month for %v, but the behavior was
changed without explanation in r31672.

Time#strftime still uses an uppercase month for %v, so this change
makes Date#strftime consistent with Time#strftime.

Fixes [Bug #13810]

56c489fd7e
2021-09-28 17:34:26 +09:00
Jeremy Evans
8065670cfb [ruby/date] Fix comparison with Float::INFINITY
Fixes [Bug #17945]

953d907238
2021-07-11 20:28:21 +09:00
Marc-Andre Lafortune
f2f00e24fa [ruby/date] Make Ractor-compatible 2020-12-22 03:12:51 -05:00
Jeremy Evans
ad156f7e2c
[ruby/date] Fix cannot load complex into simple error when loading marshal dump (Fixes #20)
This problem exists because Marshal.load calls Date.allocate, which
uses a SimpleDateData.  There doesn't seem to be any support for
taking an existing Date instance and converting it from SimpleDateData
to ComplexDateData.  Work around this issue by making Date.allocate
use a ComplexDateData.  This causes problems in Date#initialize,
so remove the Date#initialize method (keeping the date_initialize
function, used internally for Date.civil). Alias Date.new to
Date.civil, since they do the same thing.

6bb8d8fa0f
2020-06-20 18:35:03 +09:00
Nobuyoshi Nakada
e68999c82c
Fixed misspellings
Fixed misspellings reported at [Bug #16437], for default gems.
2019-12-20 12:19:45 +09:00
Jeremy Evans
469545307f [ruby/date] Add more timezone abbreviations
This gets the time zone abbreviations from
https://www.timeanddate.com/time/zones/, and adds unambiguous time
zones not already present in zonetab.list.  See bin/update-abbr
for the program used.

This regenerates zonetab.h using prereq.mk (requires gperf).

Only one test line is added, just to make sure a new time zone
abbreviation is picked up.

Fixes Ruby Bug 16286

702e8b3033
2019-11-01 17:30:14 +09:00
Jeremy Evans
3895e548bd [ruby/date] Revert "Simplify #inspect"
This reverts commit af01edd7d8575f544f647dbe8cde5b6ae535d459.

Revert requested by Yui Naruse.

875d563557
2019-10-31 15:51:30 +09:00
glaszig
fce940aac7 [ruby/date] introduce Date::Error, raise Date::Error for every
"invalid <anything>" type of exception

3e55c09ba4
2019-10-31 15:51:25 +09:00
Jeremy Evans
5fe8943fda Fix typo causing Date.new(year, month) to fail
Add a test for this case.
2019-10-24 12:34:51 -07:00
zverok
913807bd6c
[ruby/date] Simplify #inspect
af01edd7d8
2019-10-24 18:39:04 +09:00
Jeremy Evans
2e37c1960a
[ruby/date] Remove taint support
Ruby 2.7 deprecates taint and it no longer has an effect.
The lack of taint support should not cause a problem in
previous versions.

519470dc3b
2019-10-24 18:39:04 +09:00
Jeremy Evans
fc0e8d00bc
[ruby/date] Support -Float::INFINITY...date ranges
Fixes Ruby Bug 12961

7f533c2552
2019-10-24 18:39:04 +09:00
Jeremy Evans
4e40ca301c
[ruby/date] Check for numeric arguments in constructors
Previously, the type of these arguments were not checked, leading to
NoMethodErrors in some cases, and TypeErrors in other cases, but not
showing what field was having the problems.  This change makes it so
the field with the problem is included in the error message.

For the valid_*? methods, this changes them to return false if one
of the arguments that should be numeric is not.

Fixes Ruby Bug 11935
Fixes Ruby Misc 15298

a2f4b665f8
2019-10-24 18:39:04 +09:00
Jeremy Evans
9eb798a3f1
[ruby/date] Make julian dates roundtrip through to_time.to_date
Previously, julian dates would not round trip through to_time.to_date,
because Time is always considered gregorian.  This converts the Date
instance from julian to gregorian before converting to Time, ensuring
that an equal date object will be returned if converting that Time
back to Date.

This does result in julian Date objects showing different day values
if converting to Time.

Fixes Ruby Bug 8428.

d8df64555e
2019-10-24 18:39:04 +09:00
Nobuyoshi Nakada
d96feee37c
date_parse.c: avoid copying
* ext/date/date_parse.c (date_zone_to_diff): get rid of copying
  the whole argument string.
2019-08-12 20:41:11 +09:00
Nobuyoshi Nakada
1bf796c69d
Fix Date#step test
The document states that "the limit should be a date object".
2019-08-07 09:43:11 +09:00
Nobuyoshi Nakada
afea8db8c7
Test invalid offset warnings 2019-07-24 01:42:45 +09:00
Nobuyoshi Nakada
75fb0a9afa
Allow mday in Date.iso8601 to be omitted
[Bug #12285]
2019-07-16 09:41:23 +09:00
Nobuyoshi Nakada
9e472e18d2
suppress marshal warnings 2019-06-04 19:00:48 +09:00
nobu
320c98b436 date: support for Reiwa, new Japanese era
[Feature #15742]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-09 01:27:36 +00:00
nobu
1329c7cdca date: make zone a substring to copy encoding and taintedness
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-03 10:56:36 +00:00
nobu
321d72bdd6 Added tests for end of Heisei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-01 05:58:31 +00:00
nobu
8c69f7ec44 test/date: removed unnecessaruy __send__
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-11 05:09:35 +00:00
nobu
b572705486 date_core.c: moved some methods to DateTime
* ext/date/date_core.c (Init_date_core): moved methods which make
  sense only for DateTime to that class, instead of defining
  private methods in Date and making them public in DateTime.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-11 04:35:13 +00:00
nobu
0fa71d44d5 date_core.c: respect COMPLEX_DAT bit
* ext/date/date_core.c (d_lite_marshal_load): respect COMPLEX_DAT
  bit in the pre-allocated structure.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-13 04:29:31 +00:00
nobu
8655d0735f date_core.c: keep COMPLEX_DAT bit
* ext/date/date_core.c (d_lite_initialize_copy): do not change
  COMPLEX_DAT bit, as the structure does not change.  initialize
  member-wise instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-13 04:29:30 +00:00
hsbt
1380aa04a6 Support old versions of Ruby with FrozenError.
They should work separatedly from Ruby core repository.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-07 12:47:11 +00:00
mame
c80339d05f test/date/test_date_base.rb: removed
It depends upon calendar.so which is not bundled.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-17 08:18:56 +00:00