aboutsummaryrefslogtreecommitdiffstats
path: root/todolist/todo_item.go
diff options
context:
space:
mode:
Diffstat (limited to 'todolist/todo_item.go')
-rw-r--r--todolist/todo_item.go30
1 files changed, 22 insertions, 8 deletions
diff --git a/todolist/todo_item.go b/todolist/todo_item.go
index 273df8d..c208f9f 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 = bod(time.Now()).Format(ISO8601_TIMESTAMP_FORMAT)
+}
+
+func (t *Todo) Uncomplete() {
+ t.Completed = false
+ t.CompletedDate = ""
+} \ No newline at end of file