Merge pull request #26 from 30x/XAPID-1016
[XAPID-1016] fix unsupported timestamp format
diff --git a/api.go b/api.go
index 98a7c01..287d782 100644
--- a/api.go
+++ b/api.go
@@ -49,6 +49,7 @@
sqlTimeFormat = "2006-01-02 15:04:05.999 -0700 MST"
iso8601 = "2006-01-02T15:04:05.999Z07:00"
sqliteTimeFormat = "2006-01-02 15:04:05.999-07:00"
+ changeTimeFormat = "2006-01-02 15:04:05.999"
)
type deploymentsResult struct {
@@ -407,13 +408,13 @@
if t == "" {
return ""
}
- formats := []string{sqliteTimeFormat, sqlTimeFormat, iso8601, time.RFC3339}
+ formats := []string{sqliteTimeFormat, sqlTimeFormat, iso8601, time.RFC3339, changeTimeFormat}
for _, f := range formats {
timestamp, err := time.Parse(f, t)
if err == nil {
return timestamp.Format(iso8601)
}
}
- log.Panic("convertTime: Unsupported time format: " + t)
- return ""
+ log.Error("convertTime: Unsupported time format: " + t)
+ return t
}
diff --git a/api_test.go b/api_test.go
index fb86a65..c725129 100644
--- a/api_test.go
+++ b/api_test.go
@@ -378,8 +378,8 @@
})
It("should get iso8601 time", func() {
- testTimes := []string{"", "2017-04-05 04:47:36.462 +0000 UTC", "2017-04-05 04:47:36.462-07:00", "2017-04-05T04:47:36.462Z", "2017-04-05 23:23:38.162+00:00"}
- isoTime := []string{"", "2017-04-05T04:47:36.462Z", "2017-04-05T04:47:36.462-07:00", "2017-04-05T04:47:36.462Z", "2017-04-05T23:23:38.162Z"}
+ testTimes := []string{"", "2017-04-05 04:47:36.462 +0000 UTC", "2017-04-05 04:47:36.462-07:00", "2017-04-05T04:47:36.462Z", "2017-04-05 23:23:38.162+00:00", "2017-06-22 16:41:02.334"}
+ isoTime := []string{"", "2017-04-05T04:47:36.462Z", "2017-04-05T04:47:36.462-07:00", "2017-04-05T04:47:36.462Z", "2017-04-05T23:23:38.162Z", "2017-06-22T16:41:02.334Z"}
for i, t := range testTimes {
log.Debug("insert deployment with timestamp: " + t)
deploymentID := "api_time_iso8601_" + strconv.Itoa(i)
diff --git a/data.go b/data.go
index 8820f6a..d30c757 100644
--- a/data.go
+++ b/data.go
@@ -125,7 +125,7 @@
for _, query := range queries {
_, err := db.Exec(query)
if err != nil {
- if strings.Contains(err.Error(), "duplicate column name") {
+ if strings.Contains(err.Error(), "duplicate column name") {
log.Warnf("AlterTable warning: %s", err)
} else {
return err