mirror of
https://github.com/ruby/ruby.git
synced 2025-09-18 18:13:58 +02:00
merge revision(s) 99a9c3fe2e
: [Backport #17024]
Fixed yday and wday with timezone [Bug #17024]
This commit is contained in:
parent
13d2ab0d88
commit
4be9bf1f67
4 changed files with 17 additions and 6 deletions
|
@ -121,7 +121,7 @@ describe "Time.new with a utc_offset argument" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.6" do
|
||||
ruby_version_is "2.7" do
|
||||
describe "Time.new with a timezone argument" do
|
||||
it "returns a Time in the timezone" do
|
||||
zone = TimeSpecs::Timezone.new(offset: (5*3600+30*60))
|
||||
|
@ -129,6 +129,10 @@ ruby_version_is "2.6" do
|
|||
|
||||
time.zone.should == zone
|
||||
time.utc_offset.should == 5*3600+30*60
|
||||
ruby_version_is "2.7" do
|
||||
time.wday.should == 6
|
||||
time.yday.should == 1
|
||||
end
|
||||
end
|
||||
|
||||
it "accepts timezone argument that must have #local_to_utc and #utc_to_local methods" do
|
||||
|
|
|
@ -608,6 +608,8 @@ module TestTimeTZ::WithTZ
|
|||
assert_equal([2018, 9, 1, 12, 0, 0, tz], [t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.zone])
|
||||
h, m = (-utc_offset / 60).divmod(60)
|
||||
assert_equal(time_class.utc(2018, 9, 1, 12+h, m, 0).to_i, t.to_i)
|
||||
assert_equal(6, t.wday)
|
||||
assert_equal(244, t.yday)
|
||||
end
|
||||
|
||||
def subtest_now(time_class, tz, tzarg, tzname, abbr, utc_offset)
|
||||
|
|
13
time.c
13
time.c
|
@ -4558,14 +4558,15 @@ time_wday(VALUE time)
|
|||
|
||||
GetTimeval(time, tobj);
|
||||
MAKE_TM(time, tobj);
|
||||
if (tobj->vtm.wday == VTM_WDAY_INITVAL) {
|
||||
VALUE zone = tobj->vtm.zone;
|
||||
if (!NIL_P(zone)) zone_localtime(zone, time);
|
||||
}
|
||||
return INT2FIX((int)tobj->vtm.wday);
|
||||
}
|
||||
|
||||
#define wday_p(n) {\
|
||||
struct time_object *tobj;\
|
||||
GetTimeval(time, tobj);\
|
||||
MAKE_TM(time, tobj);\
|
||||
return (tobj->vtm.wday == (n)) ? Qtrue : Qfalse;\
|
||||
return (time_wday(time) == INT2FIX(n)) ? Qtrue : Qfalse; \
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4697,6 +4698,10 @@ time_yday(VALUE time)
|
|||
|
||||
GetTimeval(time, tobj);
|
||||
MAKE_TM(time, tobj);
|
||||
if (tobj->vtm.yday == 0) {
|
||||
VALUE zone = tobj->vtm.zone;
|
||||
if (!NIL_P(zone)) zone_localtime(zone, time);
|
||||
}
|
||||
return INT2FIX(tobj->vtm.yday);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
||||
#define RUBY_VERSION_TEENY 1
|
||||
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
||||
#define RUBY_PATCHLEVEL 99
|
||||
#define RUBY_PATCHLEVEL 100
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2020
|
||||
#define RUBY_RELEASE_MONTH 7
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue