fix: importing tasks from todoist without a due time set
continuous-integration/drone/push Build is failing Details

Resolves #897
This commit is contained in:
kolaente 2021-11-23 22:29:53 +01:00
parent 86480ad969
commit fd0d462bf4
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 11 additions and 2 deletions

View File

@ -241,6 +241,15 @@ func (m *Migration) AuthURL() string {
}
func parseDate(dateString string) (date time.Time, err error) {
if len(dateString) == 10 {
// We're probably dealing with a date in the form of 2021-11-23 without a time
date, err = time.Parse("2006-01-02", dateString)
if err == nil {
// round the day to eod
return date.Add(time.Hour*23 + time.Minute*59), nil
}
}
date, err = time.Parse("2006-01-02T15:04:05Z", dateString)
if err != nil {
date, err = time.Parse("2006-01-02T15:04:05", dateString)

View File

@ -39,7 +39,7 @@ func TestConvertTodoistToVikunja(t *testing.T) {
time3, err := time.Parse(time.RFC3339Nano, "2014-10-21T08:25:05Z")
assert.NoError(t, err)
time3 = time3.In(config.GetTimeZone())
dueTime, err := time.Parse(time.RFC3339Nano, "2020-05-31T00:00:00Z")
dueTime, err := time.Parse(time.RFC3339Nano, "2020-05-31T23:59:00Z")
assert.NoError(t, err)
dueTime = dueTime.In(config.GetTimeZone())
dueTimeWithTime, err := time.Parse(time.RFC3339Nano, "2021-01-31T19:00:00Z")
@ -401,7 +401,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, 23, 59, 0, 0, time.UTC).In(config.GetTimeZone()),
time.Date(2020, time.June, 16, 7, 0, 0, 0, time.UTC).In(config.GetTimeZone()),
},
},