Fix post `created` date in SQLite
We store times in UTC in all other places, but the post.Created logic when creating a post meant that dates were being stored in a user's local timezone. This fixes that. Ref T529
This commit is contained in:
parent
6f4c004e8c
commit
daaa4564bb
|
@ -574,11 +574,19 @@ func (db *datastore) CreatePost(userID, collID int64, post *SubmittedPost) (*Pos
|
||||||
}
|
}
|
||||||
|
|
||||||
created := time.Now()
|
created := time.Now()
|
||||||
|
if db.driverName == driverSQLite {
|
||||||
|
// SQLite stores datetimes in UTC, so convert time.Now() to it here
|
||||||
|
created = created.UTC()
|
||||||
|
}
|
||||||
if post.Created != nil {
|
if post.Created != nil {
|
||||||
created, err = time.Parse("2006-01-02T15:04:05Z", *post.Created)
|
created, err = time.Parse("2006-01-02T15:04:05Z", *post.Created)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Unable to parse Created time '%s': %v", *post.Created, err)
|
log.Error("Unable to parse Created time '%s': %v", *post.Created, err)
|
||||||
created = time.Now()
|
created = time.Now()
|
||||||
|
if db.driverName == driverSQLite {
|
||||||
|
// SQLite stores datetimes in UTC, so convert time.Now() to it here
|
||||||
|
created = created.UTC()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue