georgiev / rubyfb

ruby/rails Firebird db access library
Other
16 stars 5 forks source link

Automatic conversion of TIMESTAMP to time with regard to DST #21

Open mingan opened 10 years ago

mingan commented 10 years ago

In a project, I use rubyfb for importing data from an external FB database. The records have a field with datatype TIMESTAMP. Records are spaced in 15 minute intervals are meant to represent times in CET.

When looking at the data via IB SQL tool I see records with times from the first column.

IB SQL rubyfb expected
2013-03-31 01:30 2013-03-31 01:30 CET 2013-03-31 01:30 CET
2013-03-31 01:45 2013-03-31 01:30 CET 2013-03-31 01:30 CET
2013-03-31 02:00 2013-03-31 03:00 CEST 2013-03-31 03:00 CEST
2013-03-31 02:15 2013-03-31 03:15 CEST 2013-03-31 03:15 CEST
2013-03-31 02:30 2013-03-31 03:30 CEST 2013-03-31 03:30 CEST
2013-03-31 02:45 2013-03-31 03:45 CEST 2013-03-31 03:45 CEST
2013-03-31 03:00 2013-03-31 03:00 CEST 2013-03-31 04:00 CEST
2013-03-31 03:15 2013-03-31 03:15 CEST 2013-03-31 04:15 CEST
2013-03-31 03:30 2013-03-31 03:30 CEST 2013-03-31 04:30 CEST
2013-03-31 03:45 2013-03-31 03:45 CEST 2013-03-31 04:45 CEST
2013-03-31 04:00 2013-03-31 04:00 CEST 2013-03-31 05:00 CEST
2013-03-31 04:15 2013-03-31 04:15 CEST 2013-03-31 05:15 CEST
2013-03-31 04:30 2013-03-31 04:30 CEST 2013-03-31 05:30 CEST
2013-03-31 04:45 2013-03-31 04:45 CEST 2013-03-31 05:45 CEST

But when I queries with rubyfb the records have values from the middle column, i.e. 03:00 CEST to 03:59 CEST is repeated twice and all summer hours are one hour behind the expected time even though they have the CEST TZ. That is the regular time is handled correctly, the shift to DST is correct but the whole DST is one hour off.

(For clarification, CET is +01:00 and CEST is +02:00. In 2013 the switch occurred at 2013-03-31 changing from 01:59 CET to 03:00 CEST.)

I don't have access to the server running the FB database and don't know what is the setting of the server time or if it has any significance. I can tell that the database itself returns correct current time in CEST when queried during CEST.

As a workaround I CAST the column to VARCHAR and then parse the returned value with explicitly specifying CET as a timezone.