datamapper / do

DataObjects
147 stars 74 forks source link

The .utc_offset method returns the offset in seconds between the #85

Closed Daniel-ltw closed 8 years ago

Daniel-ltw commented 9 years ago

timezone of the object and UTC.

The offset argument to DateTime.new is the offset from UTC as a fraction of a day.

Depending on the type of object provided, this offset will be adjusted again,internally within the DateTime class:

https://github.com/ruby/ruby/blob/37055f9da04ad4d8f8d2b303fbf0c947e4661868/ext/date/date_core.c#L2328

If the offset is provided in seconds, and passed as a T_FIXNUM or T_FLOAT type to DateTime.new, it will be multiplied by DAY_IN_SECONDS, resulting in an unexpected timezone offset.

This change passes the timezone as a string to DateTime.new instead of the gmt_offset.