package tfelem import ( "time" ) const ( GFL_ISO8601Date = "2006-01-02" GFL_ISO8601Time = "15:04:05" GFL_ISO8601Full = "2006-01-02T15:04:05-0700" GFL_CommonDatetime = "2006-01-02 15:04:05" GFL_NginxDefault = "02/Jan/2006:15:04:05 -0700" ) type GoFormatElement struct { GoFmtLayout string } func (this *GoFormatElement) ExpectedSize() int { return len(this.GoFmtLayout) } func (this *GoFormatElement) PrintElement(t time.Time) string { return t.Format(this.GoFmtLayout) } func NewGoFormatElement(layout string) *GoFormatElement { return &GoFormatElement{ GoFmtLayout: layout, } } func NewISO8601DateElement() *GoFormatElement { return &GoFormatElement{ GoFmtLayout: GFL_ISO8601Date, } } func NewISO8601TimeElement() *GoFormatElement { return &GoFormatElement{ GoFmtLayout: GFL_ISO8601Time, } } func NewISO8601FullElement() *GoFormatElement { return &GoFormatElement{ GoFmtLayout: GFL_ISO8601Full, } } func NewCommonDatetimeElement() *GoFormatElement { return &GoFormatElement{ GoFmtLayout: GFL_CommonDatetime, } } func NewRFC3339Element() *GoFormatElement { return &GoFormatElement{ GoFmtLayout: time.RFC3339, } } func NewRFC3339NanoElement() *GoFormatElement { return &GoFormatElement{ GoFmtLayout: time.RFC3339Nano, } } func NewNginxDefaultElement() *GoFormatElement { return &GoFormatElement{ GoFmtLayout: GFL_NginxDefault, } }