accept timezone for timestamps

This commit is contained in:
Balazs Nagy
2022-07-09 13:43:14 +02:00
parent d29120f08b
commit 1335a7022a
6 changed files with 53 additions and 1 deletions

View File

@@ -1413,6 +1413,19 @@ In this example the flag could be used like this:
$ myapp --meeting 2019-08-12T15:04:05
```
When the layout doesn't contain timezones, timestamp will render with UTC. To
change behavior, a default timezone can be provided with flag definition:
```go
app := &cli.App{
Flags: []cli.Flag{
&cli.TimestampFlag{Name: "meeting", Layout: "2006-01-02T15:04:05", Timezone: time.Local},
},
}
```
(time.Local contains the system's local time zone.)
Side note: quotes may be necessary around the date depending on your layout (if
you have spaces for instance)