Goで time.Time の IsZero() がずれる
code:go
package main
import (
"fmt"
"time"
)
func main() {
var t1 time.Time
fmt.Printf("t: %v, isZero: %t\n", t1, t1.IsZero())
tz, _ := time.LoadLocation("Asia/Tokyo")
t2 := time.Time{}.In(tz)
fmt.Printf("t: %v, isZero: %t\n", t2, t2.IsZero())
t3, _ := time.Parse(time.RFC3339, time.Time{}.In(tz).Format(time.RFC3339))
fmt.Printf("t: %v, isZero: %t\n", t3, t3.IsZero())
}
code:sh
t: 0001-01-01 00:00:00 +0000 UTC, isZero: true
t: 0001-01-01 09:18:59 +0918 LMT, isZero: true
t: 0001-01-01 09:18:59 +0918 +0918, isZero: false
ref