首次提交:初始化项目代码

This commit is contained in:
sunct
2026-07-31 15:18:32 +08:00
commit d6393266b0
193 changed files with 14287 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
package main
import (
"fmt"
"time"
)
func main() {
now := time.Now()
fmt.Println("本地时间:", now)
// UTC 时区
utcLoc, _ := time.LoadLocation("UTC")
utcTime := now.In(utcLoc)
fmt.Println("UTC时间:", utcTime)
// 纽约时区
nyLoc, _ := time.LoadLocation("America/New_York")
nyTime := now.In(nyLoc)
fmt.Println("纽约时间:", nyTime)
// 时区偏移
_, offset := now.Zone()
fmt.Printf("本地时区偏移: %d 小时\n", offset/3600)
// 固定偏移时区(不依赖IANA数据)
estLoc := time.FixedZone("EST", -5*3600)
estTime := now.In(estLoc)
fmt.Println("EST时间 (FixedZone):", estTime)
}