-
Notifications
You must be signed in to change notification settings - Fork 66
Description
Describe the bug
On a server set to the UTC timezone as the location, the format (with RFC3339) will output "Z", rather than "-00:00".
For both datetime and timestamp field types, MySQL will report an "incorrect datetime value".
The "Z"output is a known golang feature.
Steps to Reproduce
Table with
createdAt DATETIME DEFAULT NULL
'updatedAt' TIMESTAMP DEFAULT NULL
Go struct with
CreatedAt strfmt.DateTime json:"createdAt,omitempty" db:"createdAt"
UpdatedAt *strfmt.DateTime json:"updatedAt,omitempty" db:"updatedAt"
Try using the following in sql code
nowFmt := strfmt.DateTime(time.Now())
testCommentInsert := &mod.TestComment {
Comment: StringPtr("Need help"),
CreatedAt: nowFmt,
UpdatedAt: &nowFmt,
}
The issue does not occur when using time.Time
Switching from strfmt.DateTime to time.Time fixes the problem
CreatedAt time.Time json:"createdAt,omitempty" db:"createdAt"
UpdatedAt *time.Time json:"updatedAt,omitempty" db:"updatedAt"
Expected behavior
strfmt.DateTime to properly handle UTC with go.
Environment
Unix base MySQL running UTC.