From f017c462593496efbc0810ec2603da49a2e3d9d8 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 3 Jun 2017 13:02:03 +0200 Subject: Add `NewTimeEntry()` A new function that creates a `TimeEntry` build from a `Profile`, `Project`, and a few other parameters. Makes it a bit easier to create `TimeEntry`ies. Additionally, add a `PersonID` field to `TimeEntry` so we can pass it around as a self-contained thing without worrying about having to pass a `Profile` along with it. --- timetask/time_entry.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'timetask/time_entry.go') diff --git a/timetask/time_entry.go b/timetask/time_entry.go index 1cc4203..161de3e 100644 --- a/timetask/time_entry.go +++ b/timetask/time_entry.go @@ -3,6 +3,7 @@ package timetask import "time" type TimeEntry struct { + PersonID int Client int Project int Module int @@ -13,3 +14,24 @@ type TimeEntry struct { Billable bool Description string } + +func NewTimeEntry( + profile Profile, + project Project, + date time.Time, + time int, + 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, + } +} -- cgit v1.2.3