George,

DM does nothing particular with timezones, so basically, like you
said, the TZ on your server is used. One way to force everything to be
considered UTC is to do ENV['TZ] = 'utc' before you start your
program. Also, you could try out Daniel's brandnew ZonedTypes [1] and
see if they work for you. I know the project is very young, so it
might not yet be fully there.

cheers
snusnu

[1] http://github.com/hassox/dm-zone-types

On Mon, Jul 5, 2010 at 13:52, George <[email protected]> wrote:
> Also tried the same test with a Time property. The same thing
> happened.
>
>
> On Jul 5, 12:01 pm, George <[email protected]> wrote:
>> After setting and saving a DateTime property, it is always returned
>> with +01 hour offset.
>>
>> Is this by design? It makes comparison of datetime fields rather
>> tiresome.
>> (The +1 hour does match the timezone offset of the server but it is
>> not the time I asked datamapper to store!)
>> How should I handle datetimes better so I don't hit this problem?
>>
>> Here's an example:
>>   trip.start_date = DateTime::civil( 2010, 5, 1, 13, 15, 0, 0 )
>>   trip.start_date.to_s.should == "2010-05-01T13:15:00+00:00" # PASS
>>   trip.save.should be_true # PASS
>>   trip.reload
>>   trip.start_date.to_s.should == "2010-05-01T13:15:00+00:00" # FAIL
>>
>>   expected: "2010-05-01T13:15:00+00:00",
>>   got: "2010-05-01T13:15:00+01:00"
>>
>> Incidentally the value that is stored in the database does exclude the
>> offset, so it seems to be added my DM when reading the data.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "DataMapper" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/datamapper?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to