aboutsummaryrefslogtreecommitdiffstats
path: root/timetask/time_entry.go
diff options
context:
space:
mode:
Diffstat (limited to 'timetask/time_entry.go')
-rw-r--r--timetask/time_entry.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/timetask/time_entry.go b/timetask/time_entry.go
new file mode 100644
index 0000000..6dfb787
--- /dev/null
+++ b/timetask/time_entry.go
@@ -0,0 +1,46 @@
+package timetask
+
+import "time"
+
+type TimeEntry struct {
+ Client string
+ Project string
+ Task string
+ WorkType string `yaml:"work_type"`
+ Date time.Time
+ 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
+ Task string
+ WorkType string `yaml:"work_type"`
+ Date string
+ Billable bool
+ Description string
+ }
+
+ err := unmarshal(&auxiliary)
+ if err != nil {
+ return err
+ }
+
+ date, err := time.Parse("2006-01-02", auxiliary.Date)
+ if err != nil {
+ return err
+ }
+
+ te.Client = auxiliary.Client
+ te.Project = auxiliary.Project
+ te.Task = auxiliary.Task
+ te.WorkType = auxiliary.WorkType
+ te.Date = date
+ te.Billable = auxiliary.Billable
+ te.Description = auxiliary.Description
+
+ return nil
+}