AddModTime adds file's Mod Time to output
(timeFormat string)
| 2236 | |
| 2237 | // AddModTime adds file's Mod Time to output |
| 2238 | func (l *ListFormat) AddModTime(timeFormat string) { |
| 2239 | switch timeFormat { |
| 2240 | case "": |
| 2241 | l.AppendOutput(func(entry *ListJSONItem) string { |
| 2242 | return entry.ModTime.When.Local().Format("2006-01-02 15:04:05") |
| 2243 | }) |
| 2244 | case "unix": |
| 2245 | l.AppendOutput(func(entry *ListJSONItem) string { |
| 2246 | return fmt.Sprint(entry.ModTime.When.Unix()) |
| 2247 | }) |
| 2248 | case "unixnano": |
| 2249 | l.AppendOutput(func(entry *ListJSONItem) string { |
| 2250 | return fmt.Sprint(entry.ModTime.When.UnixNano()) |
| 2251 | }) |
| 2252 | default: |
| 2253 | timeFormat = transform.TimeFormat(timeFormat) |
| 2254 | l.AppendOutput(func(entry *ListJSONItem) string { |
| 2255 | return entry.ModTime.When.Local().Format(timeFormat) |
| 2256 | }) |
| 2257 | } |
| 2258 | } |
| 2259 | |
| 2260 | // AddSize adds file's size to output |
| 2261 | func (l *ListFormat) AddSize() { |