Store timestamps in DB in Unix time, and display them in the Local time for consistent TZs in displays, and to ensure ordering is correct

This fixes a bug where entries could be out of order if they were recorded on machines in different TZs (e.g. if one machine had the TZ set to UTC). Admittedly, this commit isn't a perfect fix since
it doesn't change all the existing hishtory entries to be stored in UTC, but this just means that the ordering bug will continue to exist for historical entries, but be fixed for new entries. And
for our purposes, that is good enough. :)

 # Please enter the commit message for your changes. Lines starting
This commit is contained in:
David Dworken
2023-09-09 12:28:01 -07:00
parent 223598c8f2
commit 2ccbb8d587
6 changed files with 101 additions and 52 deletions

View File

@ -311,8 +311,8 @@ func MakeFakeHistoryEntry(command string) data.HistoryEntry {
CurrentWorkingDirectory: "/tmp/",
HomeDirectory: "/home/david/",
ExitCode: 2,
StartTime: time.Unix(fakeHistoryTimestamp, 0),
EndTime: time.Unix(fakeHistoryTimestamp+3, 0),
StartTime: time.Unix(fakeHistoryTimestamp, 0).UTC(),
EndTime: time.Unix(fakeHistoryTimestamp+3, 0).UTC(),
}
}