Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove no longer existing all_day JSON field #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion completed.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ func CompletedList(c *cli.Context) error {
if !r == true {
continue
}
date, _ := item.DateTime()
writer.Write([]string{
IdFormat(item),
CompletedDateFormat(item.DateTime()),
CompletedDateFormat(date),
ProjectFormat(item.ProjectID, client.Store, projectColorHash, c),
ContentFormat(item),
})
Expand Down
6 changes: 3 additions & 3 deletions filter_eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ func Eval(e Expression, item todoist.AbstractItem, projects todoist.Projects, la
}
case DateExpr:
e := e.(DateExpr)
return EvalDate(e, item.DateTime()), err
dateTime, allDay := item.DateTime()
return EvalDate(e, dateTime, allDay), err
case NotOpExpr:
e := e.(NotOpExpr)
r, err := Eval(e.expr, item, projects, labels)
Expand All @@ -57,14 +58,13 @@ func Eval(e Expression, item todoist.AbstractItem, projects todoist.Projects, la
return
}

func EvalDate(e DateExpr, itemDate time.Time) (result bool) {
func EvalDate(e DateExpr, itemDate time.Time, allDay bool) (result bool) {
if (itemDate == time.Time{}) {
if e.operation == NO_DUE_DATE {
return true
}
return false
}
allDay := e.allDay
dueDate := e.datetime
switch e.operation {
case DUE_ON:
Expand Down
15 changes: 9 additions & 6 deletions lib/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ type CompletedItem struct {
TaskID int `json:"task_id"`
}

func (item CompletedItem) DateTime() time.Time {
func (item CompletedItem) DateTime() (time.Time, bool) {
t, _ := time.Parse(time.RFC3339, item.CompletedData)
return t
return t, true
}

func (item CompletedItem) GetProjectID() int {
Expand All @@ -63,7 +63,6 @@ type Item struct {
HaveIndent
ChildItem *Item `json:"-"`
BrotherItem *Item `json:"-"`
AllDay bool `json:"all_day"`
AssignedByUID int `json:"assigned_by_uid"`
Checked int `json:"checked"`
Collapsed int `json:"collapsed"`
Expand Down Expand Up @@ -92,8 +91,9 @@ func (a Items) Less(i, j int) bool { return a[i].ID < a[j].ID }

func (a Items) At(i int) IDCarrier { return a[i] }

func (item Item) DateTime() time.Time {
func (item Item) DateTime() (time.Time, bool) {
var date string
var allDay bool

if item.Due == nil {
date = ""
Expand All @@ -102,10 +102,13 @@ func (item Item) DateTime() time.Time {
}

t, err := time.ParseInLocation(RFC3339DateTime, date, time.Local)
allDay = false

if err != nil {
t, _ = time.ParseInLocation(RFC3339Date, date, time.Local)
allDay = true
}
return t
return t, allDay
}

func (item Item) GetProjectID() int {
Expand All @@ -118,7 +121,7 @@ func (item Item) GetLabelIDs() []int {

// interface for Eval actions
type AbstractItem interface {
DateTime() time.Time
DateTime() (time.Time, bool)
GetProjectID() int
GetLabelIDs() []int
}
Expand Down
3 changes: 2 additions & 1 deletion list.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ func List(c *cli.Context) error {
if !r || item.Checked == 1 {
return
}
dateTime, allDay := item.DateTime()
itemList = append(itemList, []string{
IdFormat(item),
PriorityFormat(item.Priority),
DueDateFormat(item.DateTime(), item.AllDay),
DueDateFormat(dateTime, allDay),
ProjectFormat(item.ProjectID, client.Store, projectColorHash, c),
item.LabelsString(client.Store),
ContentPrefix(client.Store, item, depth, c) + ContentFormat(item),
Expand Down
4 changes: 3 additions & 1 deletion show.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ func Show(c *cli.Context) error {
}
projectColorHash := GenerateColorHash(projectIds, colorList)

dateTime, allDay := item.DateTime()

records := [][]string{
[]string{"ID", IdFormat(item)},
[]string{"Content", ContentFormat(item)},
[]string{"Project", ProjectFormat(item.ProjectID, client.Store, projectColorHash, c)},
[]string{"Labels", item.LabelsString(client.Store)},
[]string{"Priority", PriorityFormat(item.Priority)},
[]string{"DueDate", DueDateFormat(item.DateTime(), item.AllDay)},
[]string{"DueDate", DueDateFormat(dateTime, allDay)},
[]string{"URL", todoist.GetContentURL(item)},
}
defer writer.Flush()
Expand Down