Mercurial > gemma
diff pkg/models/sr.go @ 1900:6a67cd819e93
To prepare stretch import made some model data types re-usable.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 18 Jan 2019 15:04:53 +0100 |
parents | 056a86b24be2 |
children | df6383831ad3 |
line wrap: on
line diff
--- a/pkg/models/sr.go Fri Jan 18 14:58:34 2019 +0100 +++ b/pkg/models/sr.go Fri Jan 18 15:04:53 2019 +0100 @@ -21,19 +21,14 @@ "errors" "fmt" "io" - "time" ) -const SoundingResultDateFormat = "2006-01-02" - type ( - SoundingResultDate struct{ time.Time } - SoundingResultMeta struct { - Date SoundingResultDate `json:"date"` - Bottleneck string `json:"bottleneck"` - EPSG uint `json:"epsg"` - DepthReference string `json:"depth-reference"` + Date Date `json:"date"` + Bottleneck string `json:"bottleneck"` + EPSG uint `json:"epsg"` + DepthReference string `json:"depth-reference"` } ) @@ -50,22 +45,6 @@ WHERE bn.objnam = $1 AND sr.date_info = $2` ) -func (srd SoundingResultDate) MarshalJSON() ([]byte, error) { - return json.Marshal(srd.Format(SoundingResultDateFormat)) -} - -func (srd *SoundingResultDate) UnmarshalJSON(data []byte) error { - var s string - if err := json.Unmarshal(data, &s); err != nil { - return err - } - d, err := time.Parse(SoundingResultDateFormat, s) - if err == nil { - *srd = SoundingResultDate{d} - } - return err -} - func (m *SoundingResultMeta) Decode(r io.Reader) error { err := json.NewDecoder(r).Decode(m) if err == nil && m.EPSG == 0 {