The UFZ services GitLab and Mattermost will be unavailable on Monday, December 06 from 06:00 AM to 08:00 AM due to maintenance work.

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) {
return json.Marshal(val)
}
// NOTE:
// I wonder if embedding would solve the problem of missing
// methods like `Format` and `Equal`
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 {
str := strings.Trim(string(text), "\"")
t, err := time.Parse(s.DATE_FORMAT, str)
......@@ -64,6 +76,10 @@ func (d UploadDate) Format() string {
return t.Format(s.DATE_FORMAT)
}
func (d UploadDate) Equal(other UploadDate) bool {
return time.Time(d).Equal(time.Time(other))
}
type Boolean bool
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