On Thu, Dec 3, 2020 at 11:03 AM J. Lewis Muir <[email protected]> wrote:

> On Thursday, December 3, 2020 at 12:00:20 AM UTC-6 Jeremy Evans wrote:
>
>> If you can use Ruby 2.0, you should be able to easily use the mysql gem.
>> Current Sequel runs fine on Ruby 2.0.  You will have to switch to
>> Sequel.datetime_class = DateTime, though, because timezone support was not
>> added to Time until Ruby 2.6.
>>
>
> I understand that time zone support was only added to Time in Ruby 2.6,
> but for Ruby 2.0, I don't understand how DateTime is able to handle time
> zones any better than Time.  I don't see any support for named time zones
> in Time nor DateTime as of Ruby 2.0; I just see support for a UTC offset.
> So, I'm not understanding the need for Sequel.datetime_class = DateTime.
> Could you explain?
>

Before Ruby 2.6, Time didn't handle timezones, and you can't take an
existing Time instance and convert it to a new timezone offset (unlike with
DateTime).  You could only convert it from local to utc or vice versa.

Before Ruby 2.2, Time cannot even deal with parsed times not in the local
zone:

$ruby21  -rtime -e 'p Time.parse("2020-10-20 10:20:30-03:00")'
2020-10-20 06:20:30 -0700
$ ruby22  -rtime -e 'p Time.parse("2020-10-20 10:20:30-03:00")'
2020-10-20 10:20:30 -0300

DateTime itself doesn't handle timezones in any version, but Sequel can use
TZInfo to figure out the correct offset, and use DateTime's offset support
to set the offset correctly.  Sequel can't do that with Time, since Time
doesn't have support for 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/CADGZSSdUQGd%2B7j%2BzYLv9%2Bq6T8Dtg4jPgZn5%3Dnd5AE5OpqdatgA%40mail.gmail.com.

Reply via email to