SQLite time zone?

Posted on
Fri Oct 05, 2012 6:12 pm
gabbas offline
Posts: 39
Joined: Jun 22, 2008

SQLite time zone?

I just enabled the SQL Logger Plugin in SQLite mode, and mostly it looks really straightforward. I noticed something interesting though: the event log and device history tables seem to be in different time zones. Is this intentional? Is there a way to get them to use the same time zone? (Besides telling my Mac to pretend it's in London. :-)) For instance, my event log says this:

18|2012-10-05 16:59:43|False|11|Sent INSTEON|"Deck Plants" on to 100

but the corresponding entry in the device history is this:

3|2012-10-05 23:59:44|100|True

Notice the 7 hour time difference (I live in California). Suggestions please?

Posted on
Fri Oct 05, 2012 8:22 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: SQLite time zone?

This definitely looks like a bug. Consistency would be nice. ;-)

Despite the way it might appear, the device history table is correct and the event history table is wrong. We store timestamps in UTC, which PostgreSQL handles automatically but when using SQLite you need to select 'ts' as 'datetime(ts,'localtime')'. Doing so should show the time you expect for the device table.

The next version of Indigo 5.1 will include an updated SQL Logger plugin (v1.1.2) that stores the event log times correctly for SQLite. Note, unfortunately, you'll need to delete your SQLite database file and let the plugin recreate it (the fix required a tweak to the table definition itself).

Image

Posted on
Sat Oct 06, 2012 1:57 pm
gabbas offline
Posts: 39
Joined: Jun 22, 2008

Re: SQLite time zone?

Okay cool. Thanks Matt!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests