From a2d10713e922e9e5b7bfc7f7a2c20290b4013d80 Mon Sep 17 00:00:00 2001 From: Spiegel Date: Sat, 12 Jun 2021 20:56:05 +0900 Subject: [PATCH] Support another forecast data --- entity/entity.go | 2 +- fetch/import.go | 3 ++- values/date/date.go | 1 + values/date/date_test.go | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/entity/entity.go b/entity/entity.go index 06b9036..d9a8ed1 100644 --- a/entity/entity.go +++ b/entity/entity.go @@ -45,7 +45,7 @@ type Entity struct { } func Decode(elements []string) (*Entity, error) { - if len(elements) != CSVCols { + if len(elements) < CSVCols { return nil, errs.Wrap(ecode.ErrInvalidRecord) } return &Entity{ diff --git a/fetch/import.go b/fetch/import.go index c97c2a9..88d6d9f 100644 --- a/fetch/import.go +++ b/fetch/import.go @@ -12,7 +12,8 @@ import ( //Import function returns slice of entity.Entity func Import(r io.Reader, f *filter.Filter) ([]*entity.Entity, error) { list := entity.NewList(nil) - cr := csvdata.New(r, true).WithFieldsPerRecord(entity.CSVCols) + //cr := csvdata.New(r, true).WithFieldsPerRecord(entity.CSVCols) + cr := csvdata.New(r, true) for { if err := cr.Next(); err != nil { if errs.Is(err, io.EOF) { diff --git a/values/date/date.go b/values/date/date.go index 98212e0..f19183f 100644 --- a/values/date/date.go +++ b/values/date/date.go @@ -15,6 +15,7 @@ var ( defaultDateForm = "2006-01-02" timeTemplate = []string{ defaultDateForm, + "2006-01-02 15:04:05 MST", time.RFC3339, } Zero = FromTime(time.Time{}) //Zero value of Date diff --git a/values/date/date_test.go b/values/date/date_test.go index 31b99b3..a7ba386 100644 --- a/values/date/date_test.go +++ b/values/date/date_test.go @@ -17,6 +17,7 @@ func TestUnmarshal(t *testing.T) { str string jsn string }{ + {s: `{"date_taken": "2005-03-26 00:00:00 UTC"}`, str: "2005-03-26", jsn: `{"date_taken":"2005-03-26"}`}, {s: `{"date_taken": "2005-03-26T00:00:00+09:00"}`, str: "2005-03-26", jsn: `{"date_taken":"2005-03-26"}`}, {s: `{"date_taken": "2005-03-26"}`, str: "2005-03-26", jsn: `{"date_taken":"2005-03-26"}`}, {s: `{"date_taken": ""}`, str: "", jsn: `{"date_taken":""}`},