diff options
| author | Grant Ammons <gammons@gmail.com> | 2017-04-12 08:54:19 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-12 08:54:19 -0400 |
| commit | e118736cf7df17dc10822fab36af7407c7e110a6 (patch) | |
| tree | 651dfc58c6c144bd1349dfe6a74c9aed477cf13f /todolist/todo_item.go | |
| parent | 146f19e1dc8143096bca6bfd0adf2e1f8d9be7b7 (diff) | |
| parent | 8badae37312c70bc9ae68c7c6c0792033fb0dbd1 (diff) | |
Merge pull request #53 from ingorichter/ingo/completion-date
Add `CompletedDate` to todo item
Diffstat (limited to 'todolist/todo_item.go')
| -rw-r--r-- | todolist/todo_item.go | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/todolist/todo_item.go b/todolist/todo_item.go index 273df8d..859e946 100644 --- a/todolist/todo_item.go +++ b/todolist/todo_item.go @@ -2,15 +2,19 @@ package todolist import "time" +// Timestamp format to include date, time with timezone support. Easy to parse +const ISO8601_TIMESTAMP_FORMAT = "2006-01-02T15:04:05Z07:00" + type Todo struct { - Id int `json:"id"` - Subject string `json:"subject"` - Projects []string `json:"projects"` - Contexts []string `json:"contexts"` - Due string `json:"due"` - Completed bool `json:"completed"` - Archived bool `json:"archived"` - IsPriority bool `json:"isPriority"` + Id int `json:"id"` + Subject string `json:"subject"` + Projects []string `json:"projects"` + Contexts []string `json:"contexts"` + Due string `json:"due"` + Completed bool `json:"completed"` + CompletedDate string `json:"completedDate"` + Archived bool `json:"archived"` + IsPriority bool `json:"isPriority"` } func NewTodo() *Todo { @@ -30,3 +34,13 @@ func (t Todo) CalculateDueTime() time.Time { return parsedTime } } + +func (t *Todo) Complete() { + t.Completed = true + t.CompletedDate = timestamp(time.Now()).Format(ISO8601_TIMESTAMP_FORMAT) +} + +func (t *Todo) Uncomplete() { + t.Completed = false + t.CompletedDate = "" +}
\ No newline at end of file |
