Use UTC timezone when creating all day events

Related issues:
https://github.com/SimpleMobileTools/Simple-Calendar/issues/1539

https://github.com/SimpleMobileTools/Simple-Calendar/issues/1480
This commit is contained in:
Naveen 2022-10-20 23:43:42 +05:30
parent 4aa78bfb0b
commit c444c476b3
2 changed files with 18 additions and 6 deletions

View File

@ -224,9 +224,14 @@ class EventActivity : SimpleActivity() {
updateTextColors(event_scrollview)
updateIconColors()
refreshMenuItems()
event_time_zone_divider.beVisibleIf(config.allowChangingTimeZones)
event_time_zone_image.beVisibleIf(config.allowChangingTimeZones)
event_time_zone.beVisibleIf(config.allowChangingTimeZones)
showOrHideTimeZone()
}
private fun showOrHideTimeZone() {
val allowChangingTimeZones = config.allowChangingTimeZones && !event_all_day.isChecked
event_time_zone_divider.beVisibleIf(allowChangingTimeZones)
event_time_zone_image.beVisibleIf(allowChangingTimeZones)
event_time_zone.beVisibleIf(allowChangingTimeZones)
}
private fun refreshMenuItems() {
@ -998,6 +1003,9 @@ class EventActivity : SimpleActivity() {
hideKeyboard()
event_start_time.beGoneIf(isChecked)
event_end_time.beGoneIf(isChecked)
mEvent.timeZone = if (isChecked) DateTimeZone.UTC.id else DateTimeZone.getDefault().id
updateTimeZoneText()
showOrHideTimeZone()
resetTime()
}
@ -1149,7 +1157,11 @@ class EventActivity : SimpleActivity() {
reminder3Type = mReminder3Type
repeatInterval = mRepeatInterval
importId = newImportId
timeZone = if (mEvent.timeZone.isEmpty()) TimeZone.getDefault().id else timeZone
timeZone = when {
mIsAllDayEvent -> DateTimeZone.UTC.id
timeZone.isEmpty() -> DateTimeZone.getDefault().id
else -> timeZone
}
flags = mEvent.flags.addBitIf(event_all_day.isChecked, FLAG_ALL_DAY)
repeatLimit = if (repeatInterval == 0) 0 else mRepeatLimit
repeatRule = mRepeatRule

View File

@ -228,8 +228,8 @@ class CalDAVHelper(val context: Context) {
val event = Event(
null, startTS, endTS, title, location, description, reminder1?.minutes ?: REMINDER_OFF,
reminder2?.minutes ?: REMINDER_OFF, reminder3?.minutes ?: REMINDER_OFF, reminder1?.type
?: REMINDER_NOTIFICATION, reminder2?.type ?: REMINDER_NOTIFICATION, reminder3?.type
?: REMINDER_NOTIFICATION, repeatRule.repeatInterval, repeatRule.repeatRule,
?: REMINDER_NOTIFICATION, reminder2?.type ?: REMINDER_NOTIFICATION, reminder3?.type
?: REMINDER_NOTIFICATION, repeatRule.repeatInterval, repeatRule.repeatRule,
repeatRule.repeatLimit, ArrayList(), attendees, importId, eventTimeZone, allDay, eventTypeId, source = source, availability = availability
)