Project

General

Profile

Bug #12271 ยป time.diff

yui-knk (Kaneko Yuichiro), 04/12/2016 09:34 AM

View differences:

ext/date/date_core.c
8406 8406
 * call-seq:
8407 8407
 *    t.to_time  ->  time
8408 8408
 *
8409
 * Returns a copy of self as local mode.
8409
 * Returns self.
8410 8410
 */
8411 8411
static VALUE
8412 8412
time_to_time(VALUE self)
8413 8413
{
8414
    return f_getlocal(self);
8414
    return self;
8415 8415
}
8416 8416

  
8417 8417
/*
test/date/test_date_conv.rb
3 3
require 'date'
4 4

  
5 5
class TestDateConv < Test::Unit::TestCase
6
  def with_tz(tz)
7
    old = ENV["TZ"]
8
    begin
9
      ENV["TZ"] = tz
10
      yield
11
    ensure
12
      ENV["TZ"] = old
13
    end
14
  end
6 15

  
7 16
  def test_to_class
8 17
    [Time.now, Date.today, DateTime.now].each do |o|
......
22 31
    t2 = t.to_time.utc
23 32
    assert_equal([2004, 9, 19, 1, 2, 3, 456789],
24 33
		 [t2.year, t2.mon, t2.mday, t2.hour, t2.min, t2.sec, t2.usec])
34

  
35
    t = Time.new(2004, 9, 19, 1, 2, 3, '+03:00')
36
    with_tz('Asia/Tokyo') do
37
      t2 = t.to_time
38
      assert_equal([2004, 9, 19, 1, 2, 3],
39
       [t2.year, t2.mon, t2.mday, t2.hour, t2.min, t2.sec])
40
      assert_equal(3 * 60 * 60, t2.gmt_offset)
41
    end
25 42
  end
26 43

  
27 44
  def test_to_time__from_date