From 7154288ccdad7e208809b42c09a735fdeadf8c9a Mon Sep 17 00:00:00 2001 From: Bowei Xu Date: Thu, 7 Jun 2018 13:17:00 -0700 Subject: [PATCH] Fix CLI parseTime for listworkflow (#824) --- tools/cli/app_test.go | 6 ++++++ tools/cli/commands.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/cli/app_test.go b/tools/cli/app_test.go index 30ab88d1a5a..903f4e462b9 100644 --- a/tools/cli/app_test.go +++ b/tools/cli/app_test.go @@ -441,3 +441,9 @@ func (s *cliAppSuite) TestObserveWorkflowWithID() { err = s.app.Run([]string{"", "--do", domainName, "workflow", "observeid", "wid", "-sd"}) s.Nil(err) } + +func (s *cliAppSuite) TestParseTime() { + s.Equal(int64(100), parseTime("", 100)) + s.Equal(int64(1528383845000000000), parseTime("2018-06-07T15:04:05+00:00", 0)) + s.Equal(int64(1528383845000000000), parseTime("1528383845000000000", 0)) +} diff --git a/tools/cli/commands.go b/tools/cli/commands.go index cfeea639127..1983b8fbac4 100644 --- a/tools/cli/commands.go +++ b/tools/cli/commands.go @@ -1109,7 +1109,7 @@ func parseTime(timeStr string, defaultValue int64) int64 { } // try to parse - parsedTime, err := time.Parse(defaultTimeFormat, timeStr) + parsedTime, err := time.Parse(defaultDateTimeFormat, timeStr) if err == nil { return parsedTime.UnixNano() }