I insert dates into a database, the column type is DateTime, and dates being inserted are strings with just date values (no time values and no timezone). I confirm in the database that the date values are correct and have no timezones. When I select the date fields all dates have 00:00:00 for the time as expected but some dates come back in CST and other dates come back in MST. This happens in mssql, tinytds, access, and sqlite.
When debugging this in sqlite, I see Time.localtime() being called with the correct date and time values and no timezone, however each Time value comes back randomly with CST or MST for the timezone. I was expecting dates all to comeback as MST which is my local timezone. Here are my questions: 1. is this a bug in Time.localtime? 2. why does it sometimes pick CST and other times pick MST? The timezones seem to be consistent across databases and across runs so this does not appear to be random. 3. can I control what happens when DateTime or Time values are read in as a string and converted to a Time value? 4. can I set the timezone to something specific? 5. can I disable the DateTime conversion all together? Setting Sequel.default_timezone = :local does not change the outcome. I prefer to just circumvent the DateTime conversions and let the values come back as Strings. Is that possible? I could not see an easy way to do then debugging through the issue. Here is some sample data from the Northwind database: Here is the database from SSMS immediately after inserting: ID LastName FirstName BirthDate HireDate 1 Davolio Nancy 1948-12-08 00:00:00.000 1992-05-01 00:00:00.000 2 Fuller Andrew 1952-02-19 00:00:00.000 1992-08-14 00:00:00.000 3 Leverling Janet 1963-08-30 00:00:00.000 1992-04-01 00:00:00.000 4 Peacock Margaret 1937-09-19 00:00:00.000 1993-05-03 00:00:00.000 5 Buchanan Steven 1955-03-04 00:00:00.000 1993-10-17 00:00:00.000 6 Suyama Michael 1963-07-02 00:00:00.000 1993-10-17 00:00:00.000 7 King Robert 1960-05-29 00:00:00.000 1994-01-02 00:00:00.000 8 Callahan Laura 1958-01-09 00:00:00.000 1994-03-05 00:00:00.000 9 Dodsworth Anne 1966-01-27 00:00:00.000 1994-11-15 00:00:00.000 Here is the data I selected from the database using Sequel ID LastName FirstName BirthDate HireDate 1 Davolio, Nancy, 1948-12-08 00:00:00 -0700,1992-05-01 00:00:00 -0600 2 Fuller, Andrew, 1952-02-19 00:00:00 -0700,1992-08-14 00:00:00 -0600 3 Leverling, Janet, 1963-08-30 00:00:00 -0600,1992-04-01 00:00:00 -0600 4 Peacock, Margaret, 1937-09-19 00:00:00 -0600,1993-05-03 00:00:00 -0600 5 Buchanan, Steven, 1955-03-04 00:00:00 -0700,1993-10-17 00:00:00 -0600 8 Callahan, Laura, 1958-01-09 00:00:00 -0700,1994-03-05 00:00:00 -0700 6 Suyama, Michael, 1963-07-02 00:00:00 -0600,1993-10-17 00:00:00 -0600 7 King, Robert, 1960-05-29 00:00:00 -0600,1994-01-02 00:00:00 -0700 9 Dodsworth Anne, 1966-01-27 00:00:00 -0700,1994-11-15 00:00:00 -0700 Thanks, Michael -- 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/67e32743-129b-4b90-a0e4-d866e3a7d5fdn%40googlegroups.com.
