From 049e4a932984d8f1b1738cdd32c7819c9f722ad7 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Fri, 17 Mar 2023 02:57:29 -0500 Subject: [PATCH] Set test timezone --- .../tasks/sync/microsoft/MicrosoftConverter.kt | 5 +++-- .../sync/microsoft/ConvertFromMicrosoftTests.kt | 16 ++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/tasks/sync/microsoft/MicrosoftConverter.kt b/app/src/main/java/org/tasks/sync/microsoft/MicrosoftConverter.kt index 6be350d67..2e1fac274 100644 --- a/app/src/main/java/org/tasks/sync/microsoft/MicrosoftConverter.kt +++ b/app/src/main/java/org/tasks/sync/microsoft/MicrosoftConverter.kt @@ -5,7 +5,8 @@ import org.tasks.data.CaldavTask import org.tasks.data.TagData import org.tasks.time.DateTime import java.text.SimpleDateFormat -import java.util.* +import java.util.Locale +import java.util.TimeZone object MicrosoftConverter { @@ -26,7 +27,7 @@ object MicrosoftConverter { completionDate = remote.completedDateTime ?.let { val tz = TimeZone.getTimeZone(it.timeZone) - SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.ssssss") + SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.ssssss", Locale.US) .apply { timeZone = tz } .parse(it.dateTime) ?.time diff --git a/app/src/test/java/org/tasks/sync/microsoft/ConvertFromMicrosoftTests.kt b/app/src/test/java/org/tasks/sync/microsoft/ConvertFromMicrosoftTests.kt index f71a113d8..09516df3b 100644 --- a/app/src/test/java/org/tasks/sync/microsoft/ConvertFromMicrosoftTests.kt +++ b/app/src/test/java/org/tasks/sync/microsoft/ConvertFromMicrosoftTests.kt @@ -3,8 +3,10 @@ package org.tasks.sync.microsoft import com.natpryce.makeiteasy.MakeItEasy import com.todoroo.astrid.data.Task import org.junit.Assert +import org.junit.Assert.assertEquals import org.junit.Test import org.tasks.TestUtilities +import org.tasks.TestUtilities.withTZ import org.tasks.makers.TaskMaker import org.tasks.time.DateTime @@ -12,7 +14,7 @@ class ConvertFromMicrosoftTests { @Test fun titleFromRemote() { val (local, _) = TestUtilities.mstodo("microsoft/basic_task.txt") - Assert.assertEquals("Basic task", local.title) + assertEquals("Basic task", local.title) } @Test @@ -28,7 +30,7 @@ class ConvertFromMicrosoftTests { task = TaskMaker.newTask(MakeItEasy.with(TaskMaker.PRIORITY, Task.Priority.MEDIUM)), defaultPriority = Task.Priority.LOW ) - Assert.assertEquals(Task.Priority.MEDIUM, local.priority) + assertEquals(Task.Priority.MEDIUM, local.priority) } @Test @@ -38,7 +40,7 @@ class ConvertFromMicrosoftTests { task = TaskMaker.newTask(MakeItEasy.with(TaskMaker.PRIORITY, Task.Priority.HIGH)), defaultPriority = Task.Priority.LOW ) - Assert.assertEquals(Task.Priority.LOW, local.priority) + assertEquals(Task.Priority.LOW, local.priority) } @Test @@ -48,18 +50,20 @@ class ConvertFromMicrosoftTests { task = TaskMaker.newTask(MakeItEasy.with(TaskMaker.PRIORITY, Task.Priority.HIGH)), defaultPriority = Task.Priority.HIGH ) - Assert.assertEquals(Task.Priority.NONE, local.priority) + assertEquals(Task.Priority.NONE, local.priority) } @Test fun noCompletionDate() { val (local, _) = TestUtilities.mstodo("microsoft/basic_task.txt") - Assert.assertEquals(0, local.completionDate) + assertEquals(0, local.completionDate) } @Test fun parseCompletionDate() { val (local, _) = TestUtilities.mstodo("microsoft/completed_task.txt") - Assert.assertEquals(DateTime(2022, 9, 18, 0, 0).millis, local.completionDate) + withTZ("America/Chicago") { + assertEquals(DateTime(2022, 9, 18, 0, 0).millis, local.completionDate) + } } } \ No newline at end of file