mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/date/date_core.c (datetime_to_time): preserve timezone info
[Bug #12189] [Fix GH-1295] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f8e79c84a9
commit
5f11a6eb6c
3 changed files with 15 additions and 9 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Fri Mar 18 10:24:12 2016 Naotoshi Seo <sonots@gmail.com>
|
||||||
|
|
||||||
|
* ext/date/date_core.c (datetime_to_time): preserve timezone info
|
||||||
|
[Bug #12189] [Fix GH-1295]
|
||||||
|
|
||||||
Fri Mar 18 10:17:00 2016 Kenta Murata <mrkn@mrkn.jp>
|
Fri Mar 18 10:17:00 2016 Kenta Murata <mrkn@mrkn.jp>
|
||||||
|
|
||||||
* bignum.c (rb_big_hash): make it public function to be available in
|
* bignum.c (rb_big_hash): make it public function to be available in
|
||||||
|
|
|
@ -8587,21 +8587,24 @@ date_to_datetime(VALUE self)
|
||||||
static VALUE
|
static VALUE
|
||||||
datetime_to_time(VALUE self)
|
datetime_to_time(VALUE self)
|
||||||
{
|
{
|
||||||
volatile VALUE dup = dup_obj_with_new_offset(self, 0);
|
volatile VALUE dup = dup_obj(self);
|
||||||
{
|
{
|
||||||
VALUE t;
|
VALUE t;
|
||||||
|
|
||||||
get_d1(dup);
|
get_d1(dup);
|
||||||
|
|
||||||
t = f_utc6(rb_cTime,
|
t = rb_funcall(rb_cTime,
|
||||||
|
rb_intern("new"),
|
||||||
|
7,
|
||||||
m_real_year(dat),
|
m_real_year(dat),
|
||||||
INT2FIX(m_mon(dat)),
|
INT2FIX(m_mon(dat)),
|
||||||
INT2FIX(m_mday(dat)),
|
INT2FIX(m_mday(dat)),
|
||||||
INT2FIX(m_hour(dat)),
|
INT2FIX(m_hour(dat)),
|
||||||
INT2FIX(m_min(dat)),
|
INT2FIX(m_min(dat)),
|
||||||
f_add(INT2FIX(m_sec(dat)),
|
f_add(INT2FIX(m_sec(dat)),
|
||||||
m_sf_in_sec(dat)));
|
m_sf_in_sec(dat)),
|
||||||
return f_getlocal(t);
|
INT2FIX(m_of(dat)));
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,10 @@ class TestDateConv < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_to_time__from_datetime
|
def test_to_time__from_datetime
|
||||||
d = DateTime.new(2004, 9, 19, 1, 2, 3, 9.to_r/24) + 456789.to_r/86400000000
|
d = DateTime.new(2004, 9, 19, 1, 2, 3, 8.to_r/24) + 456789.to_r/86400000000
|
||||||
t = d.to_time
|
t = d.to_time
|
||||||
if t.utc_offset == 9*60*60
|
assert_equal([2004, 9, 19, 1, 2, 3, 456789, 8*60*60],
|
||||||
assert_equal([2004, 9, 19, 1, 2, 3, 456789],
|
[t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.usec, t.utc_offset])
|
||||||
[t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.usec])
|
|
||||||
end
|
|
||||||
|
|
||||||
d = DateTime.new(2004, 9, 19, 1, 2, 3, 0) + 456789.to_r/86400000000
|
d = DateTime.new(2004, 9, 19, 1, 2, 3, 0) + 456789.to_r/86400000000
|
||||||
t = d.to_time.utc
|
t = d.to_time.utc
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue