35 Star 428 Fork 70

GVPdromara/carbon

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
default.go 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
kuafuRace 提交于 1个月前 . v2.6.3
package carbon
var (
// DefaultLayout default layout
// 默认布局模板
DefaultLayout = DateTimeLayout
// DefaultTimezone default timezone
// 默认时区
DefaultTimezone = UTC
// DefaultLocale default language locale
// 默认语言区域
DefaultLocale = "en"
// DefaultWeekStartsAt default start date of the week
// 默认一周开始日期
DefaultWeekStartsAt = Monday
// DefaultWeekendDays default weekend days of the week
// 默认周末日期
DefaultWeekendDays = []Weekday{
Saturday, Sunday,
}
)
// Default defines a Default struct.
// 定义 Default 结构体
type Default struct {
Layout string
Timezone string
Locale string
WeekStartsAt Weekday
WeekendDays []Weekday
}
// SetDefault sets default.
// 设置全局默认值
func SetDefault(d Default) {
if d.Layout != "" {
DefaultLayout = d.Layout
}
if d.Timezone != "" {
DefaultTimezone = d.Timezone
}
if d.Locale != "" {
DefaultLocale = d.Locale
}
if d.WeekStartsAt.String() != "" {
DefaultWeekStartsAt = d.WeekStartsAt
}
if len(d.WeekendDays) > 0 {
DefaultWeekendDays = d.WeekendDays
}
}
// ResetDefault resets default.
// 重置全局默认值
func ResetDefault() {
DefaultLayout = DateTimeLayout
DefaultTimezone = UTC
DefaultLocale = "en"
DefaultWeekStartsAt = Monday
DefaultWeekendDays = []Weekday{
Saturday, Sunday,
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/dromara/carbon.git
git@gitee.com:dromara/carbon.git
dromara
carbon
carbon
v2.6.4

搜索帮助