-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(os/gtime): fix gtime.StrToTime("00:00:00") is not zero time instant #3694
Conversation
If Perhaps should update Lines 18 to 28 in ba322ba
// Value is the interface providing the Value method for package database/sql/driver
// for retrieving value from golang variable to database.
func (t *Time) Value() (driver.Value, error) {
if t == nil {
return nil, nil
}
if t.IsZero() {
return nil, nil
}
if t.Year() == 0 {
// Only time.
return t.Format("15:04:05"), nil
}
return t.Time, nil
} |
|
The ci failed. I think this change is ok: // Value is the interface providing the Value method for package database/sql/driver
// for retrieving value from golang variable to database.
func (t *Time) Value() (driver.Value, error) {
if t == nil {
return nil, nil
}
if t.IsZero() {
return nil, nil
}
if t.Year() == 0 {
// Only time.
return t.Format("15:04:05"), nil
}
return t.Time, nil
} |
Thanks for suggestion, I make a new pr #3714 |
updated on 2024-07-27
in stdlib,
so, is is ok that
gtime.StrToTime("00:00:00")
is not zero time instant.origin
gtime.StrToTime
parse stringh:m:s
like00:00:00
,the return is not zero time instant.for example:
and in std, zero time instant is :
time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)
nottime.Date(0, 1, 1, 0, 0, 0, 0, time.UTC)
so, I think it is a bug.
the pr will Fixes #2012 , and make