MCPcopy Index your code
hub / github.com/yuin/gopher-lua / strftime

Function strftime

utils.go:107–131  ·  view source on GitHub ↗
(t time.Time, cfmt string)

Source from the content-addressed store, hash-verified

105 'x': "15/04/05", 'X': "15:04:05", 'y': "06", 'Y': "2006", 'z': "-0700", 'Z': "MST"}
106
107func strftime(t time.Time, cfmt string) string {
108 sc := newFlagScanner('%', "", "", cfmt)
109 for c, eos := sc.Next(); !eos; c, eos = sc.Next() {
110 if !sc.ChangeFlag {
111 if sc.HasFlag {
112 if v, ok := cDateFlagToGo[c]; ok {
113 sc.AppendString(t.Format(v))
114 } else {
115 switch c {
116 case 'w':
117 sc.AppendString(fmt.Sprint(int(t.Weekday())))
118 default:
119 sc.AppendChar('%')
120 sc.AppendChar(c)
121 }
122 }
123 sc.HasFlag = false
124 } else {
125 sc.AppendChar(c)
126 }
127 }
128 }
129
130 return sc.String()
131}
132
133func isInteger(v LNumber) bool {
134 return float64(v) == float64(int64(v))

Callers 1

osDateFunction · 0.85

Calls 6

newFlagScannerFunction · 0.85
AppendStringMethod · 0.80
AppendCharMethod · 0.80
StringMethod · 0.65
NextMethod · 0.45
FormatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…