diff --git a/utils/coreutils.go b/utils/coreutils.go index da988fb2c..62756e5fd 100644 --- a/utils/coreutils.go +++ b/utils/coreutils.go @@ -144,6 +144,7 @@ func ParseTimeDetectLayout(tmStr string, timezone string) (time.Time, error) { oneLineTimestampRule := regexp.MustCompile(`^\d{14}$`) oneSpaceTimestampRule := regexp.MustCompile(`^\d{2}\.\d{2}.\d{4}\s{1}\d{2}:\d{2}:\d{2}$`) eamonTimestampRule := regexp.MustCompile(`^\d{2}/\d{2}/\d{4}\s{1}\d{2}:\d{2}:\d{2}$`) + broadsoftTimestampRule := regexp.MustCompile(`^\d{14}\.\d{3}`) switch { case rfc3339Rule.MatchString(tmStr): return time.Parse(time.RFC3339, tmStr) @@ -171,6 +172,8 @@ func ParseTimeDetectLayout(tmStr string, timezone string) (time.Time, error) { return time.ParseInLocation("02.01.2006 15:04:05", tmStr, loc) case eamonTimestampRule.MatchString(tmStr): return time.ParseInLocation("02/01/2006 15:04:05", tmStr, loc) + case broadsoftTimestampRule.MatchString(tmStr): + return time.ParseInLocation("20060102150405.999", tmStr, loc) case tmStr == "*now": return time.Now(), nil } diff --git a/utils/utils_test.go b/utils/utils_test.go index da96f7b39..e2bf8762a 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -259,6 +259,14 @@ func TestParseTimeDetectLayout(t *testing.T) { } else if !eamonTmS.Equal(expectedTime) { t.Errorf("Unexpected time parsed: %v, expecting: %v", eamonTmS, expectedTime) } + broadSoftTmStr := "20160419210007.037" + broadTmS, err := ParseTimeDetectLayout(broadSoftTmStr, "") + expectedTime = time.Date(2016, 4, 19, 21, 0, 7, 37000000, time.UTC) + if err != nil { + t.Error(err) + } else if !broadTmS.Equal(expectedTime) { + t.Errorf("Expecting: %v, received: %v", expectedTime, broadTmS) + } } func TestParseDateUnix(t *testing.T) {