For our application, we have a database with values stored in PST, but
handle all dates at the application level in UTC. We have used the named
timezones extension, and set:

Sequel.database_timezone = 'America/Los Angeles'
Sequel.application_timezone = :utc

This works fine for any DateTime field. For Date fields, this will not
convert from UTC to PST, so 2020-06-04 00:55:49 UTC will get saved
as 2020-06-04 instead of 2020-06-03.

I don't know if this is really a "bug" per se. Given that these are date
fields, the application should really be passing a Date and not a DateTime,
and could handle the TZ logic itself. I did observe however that
Database#typecast_value_date does explicitly handle DateTime and Time
objects. In that method, adding:

value = from_application_timestamp(value)

inside the case condition for DateTime/Time handles the conversion
gracefully. Do you see any other potential issues with this change? It does
not appear to break any tests.

Best,

Stephen

-- 
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/CANba2HMm%2BXUq1M2u90ewwK%3Dj8H%2B%2B0keSXX5ZKw%2BhmLV2CkK1VA%40mail.gmail.com.

Reply via email to