代码拉取完成,页面将自动刷新
package zone
import (
"time"
"gitee.com/pangxianfei/multiapp/config"
)
var location *time.Location
type Time = time.Time
type Duration = time.Duration
type Location = time.Location
type Timer = time.Timer
type Ticker = time.Ticker
type Month = time.Month
type Weekday = time.Weekday
const (
Sunday Weekday = iota
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
)
const (
Nanosecond Duration = 1
Microsecond = 1000 * Nanosecond
Millisecond = 1000 * Microsecond
Second = 1000 * Millisecond
Minute = 60 * Second
Hour = 60 * Minute
)
func Initialize() {
var err error
location, err = time.LoadLocation(config.GetString("app.timezone"))
if err != nil {
panic(err)
}
}
func Date(year int, month Month, day, hour, min, sec, nsec int) Time {
return time.Date(year, month, day, hour, min, sec, nsec, GetLocation())
}
func Until(t Time) Duration {
return time.Until(t.In(GetLocation()))
}
func AfterFunc(d Duration, f func()) *Timer {
return time.AfterFunc(d, f)
}
func After(d Duration) <-chan Time {
t := <-time.After(d)
t.In(GetLocation())
r := make(chan Time, 1)
r <- t
return r
}
func Since(t Time) Duration {
return time.Since(t)
}
func Now() Time {
return time.Now().In(GetLocation())
}
func NewTimer(d Duration) *Timer {
return time.NewTimer(d)
}
func NewTicker(d Duration) *Ticker {
return time.NewTicker(d)
}
func Tick(d Duration) <-chan Time {
t := <-time.Tick(d)
t.In(GetLocation())
r := make(chan Time, 1)
r <- t
return r
}
func ParseDuration(s string) (Duration, error) {
return time.ParseDuration(s)
}
func Sleep(d Duration) {
time.Sleep(d)
}
func Parse(layout string, value string) (Time, error) {
return time.ParseInLocation(layout, value, GetLocation())
}
func Unix(sec int64, nsec int64) Time {
return time.Unix(sec, nsec).In(GetLocation())
}
func GetLocation() *Location {
return location
}
func At(t Time) Time {
return t.In(location)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。