fox/xtime/constant.go
2025-05-25 20:02:15 +08:00

43 lines
927 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package xtime
import (
"github.com/golang-module/carbon/v2"
"time"
)
type TimezoneOffset = int
// 系统时区偏移量,也就是默认时区偏移量
var sysTimezoneOffset = SaoPauloTimezoneOffset
var nowOffset int
const (
// SaoPauloTimezoneOffset 南美/圣保罗 西三区时间UTC-3
SaoPauloTimezoneOffset TimezoneOffset = -3 * 3600
// ShangHaiTimezoneOffset 亚洲/上海 东八区时间UTC+3
ShangHaiTimezoneOffset TimezoneOffset = 8 * 3600
)
const (
// 每周起始日
WeekStartsAt = carbon.Monday
// 时间间隔
NoDuration = time.Duration(0)
Day = time.Hour * 24
Week = 7 * Day
Month = 30 * Day
)
// SetSysTimezoneOffset 设置系统时区偏移量,影响所有默认行为
func SetSysTimezoneOffset(offset int) {
sysTimezoneOffset = offset
}
// SetNowTimeOffset 设置当前时间偏移影响Now的结果
func SetNowTimeOffset(offset int) {
nowOffset = offset
}