On Wednesday, June 3, 2020 at 5:14:26 PM UTC-7, Stephen Weil wrote: > > 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. >
I don't see any issues with this, but changing the behavior could potentially cause problems for users who are relying on the current behavior. This should be fairly easy to override using a Database extension, though. I'd be OK shipping such a Database extension with Sequel, if you are interesting in working on it. Thanks, Jeremy -- 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/8deb5d8f-87cf-4166-ac08-8d4a8d436440%40googlegroups.com.
