From June 06th, all CI Jobs will run on federated Helmholtz infrastructure by default. If you need UFZ-internal resources, add the tag "ufz-internal" to your CI configuration or use a custom GitLab Runner (e.g. EVE). If you have any questions, feel free to contact us!

Commit 87ada59e authored by David Schäfer's avatar David Schäfer
Browse files

added Scanner to Date type

parent 1f275ec1
...@@ -43,8 +43,20 @@ func (nf *NullFloat64) MarshalJSON() ([]byte, error) { ...@@ -43,8 +43,20 @@ func (nf *NullFloat64) MarshalJSON() ([]byte, error) {
return json.Marshal(val) return json.Marshal(val)
} }
// NOTE:
// I wonder if embedding would solve the problem of missing
// methods like `Format` and `Equal`
type UploadDate time.Time type UploadDate time.Time
func (d *UploadDate) Scan(value interface{}) error {
t, err := time.Parse(s.DATE_FORMAT, value.(string))
if err != nil {
return err
}
*d = UploadDate(t)
return nil
}
func (d *UploadDate) UnmarshalJSON(text []byte) error { func (d *UploadDate) UnmarshalJSON(text []byte) error {
str := strings.Trim(string(text), "\"") str := strings.Trim(string(text), "\"")
t, err := time.Parse(s.DATE_FORMAT, str) t, err := time.Parse(s.DATE_FORMAT, str)
...@@ -64,6 +76,10 @@ func (d UploadDate) Format() string { ...@@ -64,6 +76,10 @@ func (d UploadDate) Format() string {
return t.Format(s.DATE_FORMAT) return t.Format(s.DATE_FORMAT)
} }
func (d UploadDate) Equal(other UploadDate) bool {
return time.Time(d).Equal(time.Time(other))
}
type Boolean bool type Boolean bool
func (b *Boolean) Scan(value interface{}) error { func (b *Boolean) Scan(value interface{}) error {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment