feat(tools/when): try to parse input as one segment first
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
This commit is contained in:
parent
51ce40c599
commit
4bac58e10a
1 changed files with 8 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue