Project

General

Profile

Actions

Bug #4291

closed

rb_time_new with negative values (pre-epoch dates) on Windows

Added by banker (Kyle Banker) about 13 years ago. Updated almost 13 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2p136 (2010-12-25) [i386-mingw32]
Backport:
[ruby-core:34558]

Description

=begin
rb_time_new does not handle negative values (and thus pre-epoch dates) on windows. It seems like it should given that Time.at does.

ruby 1.9.2p136 (2010-12-25) [i386-mingw32]

Pure ruby does work:
irb(main):005:0> sec = Time.utc(1600).to_f
=> -11676096000.0
irb(main):012:0> Time.at(sec).utc
=> 1600-01-01 00:00:00 UTC

But in a C extension, it does not work:
value = rb_time_new(-11676096000, 0);
value = rb_funcall(value, utc_method, 0);

This results in a Time object with this value:
2008-04-21 19:24:48 UTC (12884901888.0)

Where we wanted 1600-01-01

Note that the problem in on Windows only. Other platforms work fine.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0