parent
86480ad969
commit
fd0d462bf4
2 changed files with 11 additions and 2 deletions
|
@ -241,6 +241,15 @@ func (m *Migration) AuthURL() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseDate(dateString string) (date time.Time, err error) {
|
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)
|
date, err = time.Parse("2006-01-02T15:04:05Z", dateString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
date, err = time.Parse("2006-01-02T15:04:05", dateString)
|
date, err = time.Parse("2006-01-02T15:04:05", dateString)
|
||||||
|
|
|
@ -39,7 +39,7 @@ func TestConvertTodoistToVikunja(t *testing.T) {
|
||||||
time3, err := time.Parse(time.RFC3339Nano, "2014-10-21T08:25:05Z")
|
time3, err := time.Parse(time.RFC3339Nano, "2014-10-21T08:25:05Z")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
time3 = time3.In(config.GetTimeZone())
|
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)
|
assert.NoError(t, err)
|
||||||
dueTime = dueTime.In(config.GetTimeZone())
|
dueTime = dueTime.In(config.GetTimeZone())
|
||||||
dueTimeWithTime, err := time.Parse(time.RFC3339Nano, "2021-01-31T19:00:00Z")
|
dueTimeWithTime, err := time.Parse(time.RFC3339Nano, "2021-01-31T19:00:00Z")
|
||||||
|
@ -401,7 +401,7 @@ func TestConvertTodoistToVikunja(t *testing.T) {
|
||||||
Done: false,
|
Done: false,
|
||||||
Created: time1,
|
Created: time1,
|
||||||
Reminders: []time.Time{
|
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()),
|
time.Date(2020, time.June, 16, 7, 0, 0, 0, time.UTC).In(config.GetTimeZone()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue