mirror of
https://github.com/ruby/ruby.git
synced 2025-09-16 17:14:01 +02:00
merge revision(s) d3279a0c11
: [Backport #20327]
[Bug #20327] Do not count subsecond to calculate UTC offset Assume that there will never be any time zones with UTC offsets that are subseconds. Historically, UTC offset has only been used down to the second. --- test/ruby/test_time_tz.rb | 8 ++++++++ time.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-)
This commit is contained in:
parent
baa5bc16c1
commit
e6bf38a6e7
3 changed files with 10 additions and 2 deletions
|
@ -695,6 +695,13 @@ module TestTimeTZ::WithTZ
|
||||||
assert_equal(t.dst?, t2.dst?)
|
assert_equal(t.dst?, t2.dst?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def subtest_fractional_second(time_class, tz, tzarg, tzname, abbr, utc_offset)
|
||||||
|
t = time_class.new(2024, 1, 1, 23, 59, 59.9r, tzarg)
|
||||||
|
assert_equal(utc_offset[t.dst? ? 1 : 0], t.utc_offset)
|
||||||
|
t = time_class.new(2024, 7, 1, 23, 59, 59.9r, tzarg)
|
||||||
|
assert_equal(utc_offset[t.dst? ? 1 : 0], t.utc_offset)
|
||||||
|
end
|
||||||
|
|
||||||
def test_invalid_zone
|
def test_invalid_zone
|
||||||
make_timezone("INVALID", "INV", 0)
|
make_timezone("INVALID", "INV", 0)
|
||||||
rescue => e
|
rescue => e
|
||||||
|
@ -719,6 +726,7 @@ module TestTimeTZ::WithTZ
|
||||||
"Asia/Tokyo" => ["JST", +9*3600],
|
"Asia/Tokyo" => ["JST", +9*3600],
|
||||||
"America/Los_Angeles" => ["PST", -8*3600, "PDT", -7*3600],
|
"America/Los_Angeles" => ["PST", -8*3600, "PDT", -7*3600],
|
||||||
"Africa/Ndjamena" => ["WAT", +1*3600],
|
"Africa/Ndjamena" => ["WAT", +1*3600],
|
||||||
|
"Etc/UTC" => ["UTC", 0],
|
||||||
}
|
}
|
||||||
|
|
||||||
def make_timezone(tzname, abbr, utc_offset, abbr2 = nil, utc_offset2 = nil)
|
def make_timezone(tzname, abbr, utc_offset, abbr2 = nil, utc_offset2 = nil)
|
||||||
|
|
2
time.c
2
time.c
|
@ -2322,7 +2322,7 @@ zone_timelocal(VALUE zone, VALUE time)
|
||||||
struct time_object *tobj = DATA_PTR(time);
|
struct time_object *tobj = DATA_PTR(time);
|
||||||
wideval_t t, s;
|
wideval_t t, s;
|
||||||
|
|
||||||
t = rb_time_unmagnify(tobj->timew);
|
split_second(tobj->timew, &t, &s);
|
||||||
tm = tm_from_time(rb_cTimeTM, time);
|
tm = tm_from_time(rb_cTimeTM, time);
|
||||||
utc = rb_check_funcall(zone, id_local_to_utc, 1, &tm);
|
utc = rb_check_funcall(zone, id_local_to_utc, 1, &tm);
|
||||||
if (UNDEF_P(utc)) return 0;
|
if (UNDEF_P(utc)) return 0;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
||||||
#define RUBY_VERSION_TEENY 3
|
#define RUBY_VERSION_TEENY 3
|
||||||
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
||||||
#define RUBY_PATCHLEVEL 166
|
#define RUBY_PATCHLEVEL 167
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
#include "ruby/internal/abi.h"
|
#include "ruby/internal/abi.h"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue