diff options
| author | Teddy Wing | 2017-06-04 02:07:50 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-06-04 02:07:50 +0200 | 
| commit | 02e4fb5d0d95b8c5c5442ee0a97b960f1296c236 (patch) | |
| tree | 4cf323694692322036b80d2d921ff966096c6c36 /timetask/time_entry.go | |
| parent | 055301ca09d57b759b290d897bbb7560460251ca (diff) | |
| parent | 9b6a6543e351308939bd420243507368b0669e63 (diff) | |
| download | timetasker-02e4fb5d0d95b8c5c5442ee0a97b960f1296c236.tar.bz2 | |
Merge branch 'timetasker-daily'
Diffstat (limited to 'timetask/time_entry.go')
| -rw-r--r-- | timetask/time_entry.go | 65 | 
1 files changed, 25 insertions, 40 deletions
| diff --git a/timetask/time_entry.go b/timetask/time_entry.go index 17a8e0c..bb7a741 100644 --- a/timetask/time_entry.go +++ b/timetask/time_entry.go @@ -3,50 +3,35 @@ package timetask  import "time"  type TimeEntry struct { -	Client      string -	Project     string -	Module      string -	Task        string -	WorkType    string `yaml:"work_type"` +	PersonID    int +	Client      int +	Project     int +	Module      int +	Task        int +	WorkType    int  	Date        time.Time -	Time        int +	Time        float64  	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 +func NewTimeEntry( +	profile Profile, +	project Project, +	date time.Time, +	time float64, +	description string, +) TimeEntry { +	return TimeEntry{ +		PersonID:    profile.PersonID, +		Client:      project.Client, +		Project:     project.Project, +		Module:      project.Module, +		Task:        project.Task, +		WorkType:    project.WorkType, +		Date:        date, +		Time:        time, +		Billable:    project.Billable, +		Description: description,  	} - -	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  } | 
