-
-
Notifications
You must be signed in to change notification settings - Fork 261
Closed
Labels
BugReport a reproducible bug or regressionReport a reproducible bug or regression
Description
Hello,
I encountered an issue with the following code:
func Demo(t time.Time) {
fmt.Println(t.Location())
tt := carbon.CreateFromStdTime(t).
SetLocation(t.Location()).
StartOfHour().
StdTime()
fmt.Println(tt)
fmt.Println(time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), 0, 0, 0, t.Location()))
}
func Test_demo2(t *testing.T) {
loc, _ := time.LoadLocation("Asia/Shanghai")
Demo(time.Date(2024, 3, 15, 14, 30, 45, 123456789, loc))
}golang version: go version go1.23.4 darwin/amd64
carbon version: v2.6.1
time zone: Asia/Shanghai
I expected to get:
Asia/Shanghai
2024-03-15 14:00:00 +0800 CST
2024-03-15 14:00:00 +0800 CST
But I actually get:
Asia/Shanghai
2024-03-15 14:00:00 +0000 UTC -- error, timezone not right
2024-03-15 14:00:00 +0800 CST
Thanks!
Metadata
Metadata
Assignees
Labels
BugReport a reproducible bug or regressionReport a reproducible bug or regression