As explained in issue https://github.com/jeremyevans/sequel/issues/1652 
default behaviour of Sequel on MySQL can result in incorrect conversion of 
times and dates.

The problem is that MySQL does not handle timezones in timestamps. As it 
does not, Sequel cannot include the timezone in the timestamp. If you don't 
specify what timezone the database is in (using DB.timezone or 
Sequel.default_timezone), Sequel's default behavior is just to omit the 
timezone when literalizing the DateTime/Time instance.

Unfortunately, that means that any time which is NOT in database timezone 
will be used incorrectly. Even worse, on older ruby (older than 2.4), 
conversion from DateTime to Time changes timezone to local (converting the 
time correctly), which means same time is transformed differently based on 
which class is used.

It is possible to query the database and determine if it's in UTC. Finding 
out if it's in local time might not work correctly, as the server and 
application ideas of timezone may have different daylight saving time 
changes. By default, UTC and local are only two timezones sequel can work 
with (extension is required to support more).

Still, considering the default behaviour being surprising, I would propose 
to at least look for the UTC case and set the database timezone to :utc if 
it's detected. I think I'm not only person who set the servers to UTC 
exactly in hope that it would reduce number of timezone-related problems I 
will need to face.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/c0161461-f3f2-4928-a934-576255982355%40googlegroups.com.

Reply via email to