aboutsummaryrefslogtreecommitdiffstats
path: root/todolist/todo_item.go
diff options
context:
space:
mode:
authorGrant Ammons <gammons@gmail.com>2016-05-01 19:17:54 -0400
committerGrant Ammons <gammons@gmail.com>2016-05-01 19:17:54 -0400
commitb1fc3359eb7498236621d1aa6a9ff18f8cce73c0 (patch)
tree7422852d05743e195171c8006deca46a19e19e82 /todolist/todo_item.go
parent0905a863f50d9631e6c44488b952622e75d79785 (diff)
Sort todos by due date by default
Diffstat (limited to 'todolist/todo_item.go')
-rw-r--r--todolist/todo_item.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/todolist/todo_item.go b/todolist/todo_item.go
index cc06615..6b820b1 100644
--- a/todolist/todo_item.go
+++ b/todolist/todo_item.go
@@ -1,5 +1,7 @@
package todolist
+import "time"
+
type Todo struct {
Id int `json:"id"`
Subject string `json:"subject"`
@@ -17,3 +19,13 @@ func NewTodo() *Todo {
func (t Todo) Valid() bool {
return (t.Subject != "")
}
+
+func (t Todo) CalculateDueTime() time.Time {
+ if t.Due != "" {
+ parsedTime, _ := time.Parse("2006-01-02", t.Due)
+ return parsedTime
+ } else {
+ parsedTime, _ := time.Parse("2006-01-02", "1900-01-01")
+ return parsedTime
+ }
+}