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?
For example:
----
$ timedatectl
Local time: Thu 2020-12-03 10:49:52 PST
Universal time: Thu 2020-12-03 18:49:52 UTC
RTC time: Thu 2020-12-03 18:49:52
Time zone: America/Los_Angeles (PST, -0800)
NTP enabled: no
NTP synchronized: yes
RTC in local TZ: no
DST active: no
Last DST change: DST ended at
Sun 2020-11-01 01:59:59 PDT
Sun 2020-11-01 01:00:00 PST
Next DST change: DST begins (the clock jumps one hour forward) at
Sun 2021-03-14 01:59:59 PST
Sun 2021-03-14 03:00:00 PDT
$ irb
irb(main):001:0> RUBY_VERSION
=> "2.0.0"
irb(main):002:0> require 'time'
=> true
irb(main):003:0> t = Time.parse('2020-12-01 08:00:00 -06:00')
=> 2020-12-01 06:00:00 -0800
irb(main):004:0> t.utc_offset
=> -28800
irb(main):005:0> t.zone
=> "PST"
irb(main):006:0> require 'date'
=> false
irb(main):007:0> dt = DateTime.parse('2020-12-01 08:00:00 -06:00')
=> #<DateTime: 2020-12-01T08:00:00-06:00
((2459185j,50400s,0n),-21600s,2299161j)>
irb(main):008:0> dtt = dt.to_time
=> 2020-12-01 06:00:00 -0800
irb(main):009:0> dtt.utc_offset
=> -28800
irb(main):010:0> dtt.zone
=> "PST"
irb(main):011:0>
----
Thank you!
Lewis
--
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/ccef0479-f81f-4bbb-91b8-c749061f04e0n%40googlegroups.com.