diff options
Diffstat (limited to 'internal/task')
| -rw-r--r-- | internal/task/stats.go | 2 | ||||
| -rw-r--r-- | internal/task/task.go | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/internal/task/stats.go b/internal/task/stats.go index c516249..b306687 100644 --- a/internal/task/stats.go +++ b/internal/task/stats.go @@ -28,7 +28,7 @@ func DueTasks(tasks []Task, now time.Time) int { if t.Status == "completed" || t.Due == "" { continue } - ts, err := time.Parse("20060102T150405Z", t.Due) + ts, err := time.Parse(DateFormat, t.Due) if err != nil { continue } diff --git a/internal/task/task.go b/internal/task/task.go index 2c7f8e8..8eadd18 100644 --- a/internal/task/task.go +++ b/internal/task/task.go @@ -16,6 +16,11 @@ import ( "github.com/google/shlex" ) +// DateFormat is the date format used by Taskwarrior in all date fields +// (e.g. Entry, Due, Start). All date parsing and formatting in this +// package uses this constant. +const DateFormat = "20060102T150405Z" + // Task represents a taskwarrior task as returned by `task export`. type Annotation struct { Entry string `json:"entry"` @@ -421,7 +426,7 @@ func SortTasks(tasks []Task) { if s == "" { return time.Time{}, false } - t, err := time.Parse("20060102T150405Z", s) + t, err := time.Parse(DateFormat, s) if err != nil { return time.Time{}, false } |
