前端之家收集整理的这篇文章主要介绍了
golang 通过ISOWeek翻转得到周的日期时间,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
func firstDayOfISOWeek(year int,week int,timezone *time.Location) time.Time {
date := time.Date(year,0,timezone)
isoYear,isoWeek := date.ISOWeek()
for date.Weekday() != time.Monday {
date = date.AddDate(0,-1)
isoYear,isoWeek = date.ISOWeek()
}
for isoYear < year {
date = date.AddDate(0,1)
isoYear,isoWeek = date.ISOWeek()
}
for isoWeek < week {
date = date.AddDate(0,isoWeek = date.ISOWeek()
}
return date
}
原文链接:https://www.f2er.com/go/188826.html