Fix parsing todoist reminder dates

This commit is contained in:
kolaente 2020-07-05 20:49:29 +02:00
parent ec3fa9300b
commit 78791f31a4
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 20 additions and 12 deletions

View file

@ -283,7 +283,7 @@ func convertTodoistToVikunja(sync *sync) (fullVikunjaHierachie []*models.Namespa
// Put the due date together
if i.Due != nil {
dueDate, err := time.Parse("2006-01-02T15:04:05Z", i.Due.Date)
dueDate, err := time.Parse("2006-01-02", i.Due.Date)
if err != nil {
return nil, err
}
@ -368,7 +368,15 @@ func convertTodoistToVikunja(sync *sync) (fullVikunjaHierachie []*models.Namespa
continue
}
date, err := time.Parse("2006-01-02", r.Due.Date)
var err error
var date time.Time
date, err = time.Parse("2006-01-02T15:04:05Z", r.Due.Date)
if err != nil {
date, err = time.Parse("2006-01-02T15:04:05", r.Due.Date)
}
if err != nil {
date, err = time.Parse("2006-01-02", r.Due.Date)
}
if err != nil {
return nil, err
}

View file

@ -274,7 +274,7 @@ func TestConvertTodoistToVikunja(t *testing.T) {
ID: 103001,
ItemID: 400000000,
Due: &dueDate{
Date: "2020-06-16",
Date: "2020-06-16T07:00:00",
IsRecurring: false,
},
},
@ -282,7 +282,7 @@ func TestConvertTodoistToVikunja(t *testing.T) {
ID: 103002,
ItemID: 400000002,
Due: &dueDate{
Date: "2020-07-15",
Date: "2020-07-15T07:00:00Z",
IsRecurring: true,
},
},
@ -290,7 +290,7 @@ func TestConvertTodoistToVikunja(t *testing.T) {
ID: 103003,
ItemID: 400000003,
Due: &dueDate{
Date: "2020-06-15",
Date: "2020-06-15T07:00:00",
IsRecurring: false,
},
},
@ -298,7 +298,7 @@ func TestConvertTodoistToVikunja(t *testing.T) {
ID: 103004,
ItemID: 400000005,
Due: &dueDate{
Date: "2020-06-15",
Date: "2020-06-15T07:00:00",
IsRecurring: false,
},
},
@ -306,7 +306,7 @@ func TestConvertTodoistToVikunja(t *testing.T) {
ID: 103006,
ItemID: 400000009,
Due: &dueDate{
Date: "2020-06-15",
Date: "2020-06-15T07:00:00",
IsRecurring: false,
},
},
@ -350,7 +350,7 @@ func TestConvertTodoistToVikunja(t *testing.T) {
Created: time1,
Reminders: []time.Time{
time.Date(2020, time.June, 15, 0, 0, 0, 0, time.UTC).In(config.GetTimeZone()),
time.Date(2020, time.June, 16, 0, 0, 0, 0, time.UTC).In(config.GetTimeZone()),
time.Date(2020, time.June, 16, 7, 0, 0, 0, time.UTC).In(config.GetTimeZone()),
},
},
{
@ -364,7 +364,7 @@ func TestConvertTodoistToVikunja(t *testing.T) {
Done: false,
Created: time1,
Reminders: []time.Time{
time.Date(2020, time.July, 15, 0, 0, 0, 0, time.UTC).In(config.GetTimeZone()),
time.Date(2020, time.July, 15, 7, 0, 0, 0, time.UTC).In(config.GetTimeZone()),
},
},
{
@ -376,7 +376,7 @@ func TestConvertTodoistToVikunja(t *testing.T) {
DoneAt: time3,
Labels: vikunjaLabels,
Reminders: []time.Time{
time.Date(2020, time.June, 15, 0, 0, 0, 0, time.UTC).In(config.GetTimeZone()),
time.Date(2020, time.June, 15, 7, 0, 0, 0, time.UTC).In(config.GetTimeZone()),
},
},
{
@ -392,7 +392,7 @@ func TestConvertTodoistToVikunja(t *testing.T) {
Created: time1,
DoneAt: time3,
Reminders: []time.Time{
time.Date(2020, time.June, 15, 0, 0, 0, 0, time.UTC).In(config.GetTimeZone()),
time.Date(2020, time.June, 15, 7, 0, 0, 0, time.UTC).In(config.GetTimeZone()),
},
},
{
@ -470,7 +470,7 @@ func TestConvertTodoistToVikunja(t *testing.T) {
Done: false,
Created: time1,
Reminders: []time.Time{
time.Date(2020, time.June, 15, 0, 0, 0, 0, time.UTC).In(config.GetTimeZone()),
time.Date(2020, time.June, 15, 7, 0, 0, 0, time.UTC).In(config.GetTimeZone()),
},
},
{