如何使用civil.Date类型从civil.Date获取一周中的某一天。
date := civil.Date{
Year: 2021,
Month: time.May,
Day: 1}我正在寻找等同于'time‘包的Weekday()函数。
任何替代方式也是受欢迎的。
发布于 2021-09-05 09:26:54
怎么样
package main
import (
"fmt"
"os"
"time"
"cloud.google.com/go/civil"
)
func main() {
date := civil.Date{
Year: 2021,
Month: time.September,
Day: 5,
}
t, err := time.Parse(time.RFC3339, date.String()+"T00:00:00Z")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(t.Weekday().String())
}https://stackoverflow.com/questions/69061622
复制相似问题