blob: 17a8e0c8d789a637b851676fd06e1dda8089673f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package timetask
import "time"
type TimeEntry struct {
Client string
Project string
Module string
Task string
WorkType string `yaml:"work_type"`
Date time.Time
Time int
Billable bool
Description string
}
// Parse date string into a real date
func (te *TimeEntry) UnmarshalYAML(unmarshal func(interface{}) error) error {
var auxiliary struct {
Client string
Project string
Module string
Task string
WorkType string `yaml:"work_type"`
Date string
Time int
Billable bool
Description string
}
err := unmarshal(&auxiliary)
if err != nil {
return err
}
date, err := time.Parse("2006-01-02", auxiliary.Date)
if auxiliary.Date != "" && err != nil {
return err
}
te.Client = auxiliary.Client
te.Project = auxiliary.Project
te.Module = auxiliary.Module
te.Task = auxiliary.Task
te.WorkType = auxiliary.WorkType
te.Date = date
te.Time = auxiliary.Time
te.Billable = auxiliary.Billable
te.Description = auxiliary.Description
return nil
}
|