diff options
| author | Teddy Wing | 2017-06-03 11:47:26 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-06-03 11:47:26 +0200 | 
| commit | 302fbc3a9db675c24e3ca2cb0c99d1ae5b88180e (patch) | |
| tree | f9099bdb355562cd27eee3a6a7021cc77022e086 | |
| parent | c0576d6d96656f4a83e8bdff7cb0a09f455a0b10 (diff) | |
| download | timetasker-302fbc3a9db675c24e3ca2cb0c99d1ae5b88180e.tar.bz2 | |
time_entry.go: Rewrite `TimeEntry` type for the new era
Change [Client, Project, Module, Task, WorkType] fields to `int`s
instead of strings.
In the new era, with config2.toml, these fields will be populated
directly with the proper int IDs from TimeTask. Thus these fields need
to be `int`s.
Get rid of the `UnmarshalYAML` function as in the new era we won't be
submitting time entries by YAML file. Instead they will be submitted
directly via command line arguments (plus the IDs coming from the config
file).
| -rw-r--r-- | timetask/time_entry.go | 47 | 
1 files changed, 5 insertions, 42 deletions
| diff --git a/timetask/time_entry.go b/timetask/time_entry.go index 17a8e0c..1cc4203 100644 --- a/timetask/time_entry.go +++ b/timetask/time_entry.go @@ -3,50 +3,13 @@ package timetask  import "time"  type TimeEntry struct { -	Client      string -	Project     string -	Module      string -	Task        string -	WorkType    string `yaml:"work_type"` +	Client      int +	Project     int +	Module      int +	Task        int +	WorkType    int  	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 -} | 
