Project

General

Profile

Actions

Bug #8454

closed

Date and Time compatibility

Added by jonys (Jonatan Hejzlar) almost 11 years ago. Updated almost 11 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
2.0.0p195
[ruby-core:55172]

Description

Time.to_datetime creates a DateTime object with the local timezone
Date.to_datetime creates a DateTime object with the +0000 timezone

As a result, Date.to_time.to_datetime gives a different result than Date.to_datetime.

Updated by tadf (tadayoshi funaba) almost 11 years ago

  • Status changed from Open to Rejected

it's the current spec.
see [ruby-dev:24250].

i think you are interested in the following case too.

Time.parse('2001-02-03')
#=> 2001-02-03 00:00:00 +0900

Date.parse('2001-02-03')
#=> #<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>

DateTime.parse('2001-02-03')
#=> #<DateTime: 2001-02-03T00:00:00+00:00 ((2451944j,0s,0n),+0s,2299161j)>

i honestly don't like this feature.
but i think i just provided what users want in this case.

Actions

Also available in: Atom PDF

Like0
Like0