Fetch the repository succeeded.
package dtfmt
import "time"
// ctx stores pre-computed time fields used by the formatter.
type ctx struct {
year int
month time.Month
day int
weekday time.Weekday
yearday int
isoWeek, isoYear int
hour, min, sec int
millis int
buf []byte
}
type ctxConfig struct {
date bool
clock bool
weekday bool
yearday bool
millis bool
iso bool
}
func (c *ctx) initTime(config *ctxConfig, t time.Time) {
if config.date {
c.year, c.month, c.day = t.Date()
}
if config.clock {
c.hour, c.min, c.sec = t.Clock()
}
if config.iso {
c.isoYear, c.isoWeek = t.ISOWeek()
}
if config.millis {
c.millis = t.Nanosecond() / 1000000
}
if config.yearday {
c.yearday = t.YearDay()
}
if config.weekday {
c.weekday = t.Weekday()
}
}
func (c *ctxConfig) enableDate() {
c.date = true
}
func (c *ctxConfig) enableClock() {
c.clock = true
}
func (c *ctxConfig) enableWeekday() {
c.weekday = true
}
func (c *ctxConfig) enableYearday() {
c.yearday = true
}
func (c *ctxConfig) enableISO() {
c.iso = true
}
func isLeap(year int) bool {
return year%4 == 0 && (year%100 != 0 || year%400 == 0)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。