Skip to content

Commit 9c9ee70

Browse files
authored
refactor: Enhance calendar event comparison for migration (#287)
Enhances calendar events comparison for migration by ignoring seconds, and milliseconds improving compatibility with the new codebase. Previously, seconds and milliseconds were not considered. Now, both calendar events and course date blocks have seconds and milliseconds set to zero for precise matching, ensuring a smooth transition. Fixes: LEARNER-9924
1 parent 756925d commit 9c9ee70

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

course/src/main/java/org/openedx/course/presentation/calendarsync/CalendarManager.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,18 @@ class CalendarManager(
294294
}
295295

296296
matchedDate?.let { unit ->
297-
if (unit.date.toCalendar().timeInMillis == dueDateInMillis) {
297+
val dueDateCalendar = Calendar.getInstance().apply {
298+
timeInMillis = dueDateInMillis
299+
set(Calendar.SECOND, 0)
300+
set(Calendar.MILLISECOND, 0)
301+
}
302+
303+
val unitDateCalendar = unit.date.toCalendar().apply {
304+
set(Calendar.SECOND, 0)
305+
set(Calendar.MILLISECOND, 0)
306+
}
307+
308+
if (dueDateCalendar == unitDateCalendar) {
298309
datesList.remove(unit)
299310
} else {
300311
// If any single value isn't matched, return false

0 commit comments

Comments
 (0)