diff options
author | Vincent Ambo <tazjin@tvl.su> | 2024-05-07T11·39+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-05-08T13·26+0000 |
commit | 4bac58e10a500680a1f3e69dbb25e014c5065b7c (patch) | |
tree | decc5d35151d2420142b0fa1ada8a3b9faa8f816 /tools | |
parent | 51ce40c599de42f652a8b15e7574d4fc71563d11 (diff) |
feat(tools/when): try to parse input as one segment first r/8092
Before getting clever about durations & stuff, try to parse the whole thing at once. This is useful for plain timestamps that contain spaces, like `2024-01-01 15:00:01` for example. Change-Id: I50b0ee8488c153b4e6db75abaea409d55c0b92d6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11600 Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
Diffstat (limited to 'tools')
-rw-r--r-- | tools/when/when.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/when/when.go b/tools/when/when.go index 3102328fe9e0..316f021913ab 100644 --- a/tools/when/when.go +++ b/tools/when/when.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "strconv" + "strings" "time" ) @@ -107,6 +108,13 @@ func main() { var err error var haveTime, haveDuration bool + // Try to parse entire input as one full thing, before getting more + // clever. + if t, err = parseTime(strings.Join(os.Args[1:], " ")); err == nil { + printTime(t) + return + } + for _, arg := range os.Args[1:] { if !haveTime { if t, err = parseTime(arg); err == nil { |