go-sqlite3 icon indicating copy to clipboard operation
go-sqlite3 copied to clipboard

Document that "Z" is trimmed when parsing time

Open emersion opened this issue 2 years ago • 1 comments

emersion avatar Jan 26 '23 13:01 emersion

@mattn The current behavior is actually pretty strange. Right now this library doesn't even support timezones (other than Z) for any format other than the first two.

Probably we should remove the part where it chops off Z and fix the list of formats to:

var SQLiteTimestampFormats = []string{
	"2006-01-02 15:04:05.999999999Z07:00",
	"2006-01-02 15:04:05.999999999",
	"2006-01-02T15:04:05.999999999Z07:00",
	"2006-01-02T15:04:05.999999999",
	"2006-01-02 15:04:05Z07:00",
	"2006-01-02 15:04:05",
	"2006-01-02T15:04:05Z07:00",
	"2006-01-02T15:04:05",
	"2006-01-02 15:04Z07:00",
	"2006-01-02 15:04",
	"2006-01-02T15:04Z07:00",
	"2006-01-02T15:04",
	"2006-01-02Z07:00",
	"2006-01-02",
}

However, that could get into some interesting questions wrt backwards compatibility.

It would also be worth mentioning that if the parsed timestamp does not include time zone information it will assume UTC (and not local).

rittneje avatar Jan 26 '23 23:01 rittneje