From f5d08e07bbed6aba141fa6268904f099bfa28108 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Fri, 30 Nov 2018 11:14:15 +0000 Subject: [PATCH] Event invites: add timezone information to email summary. --- .../syncadapter/CalendarSyncManager.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.java b/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.java index c51e4fe7..2e6bec90 100644 --- a/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.java +++ b/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.java @@ -46,6 +46,7 @@ import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Locale; +import java.util.TimeZone; import at.bitfire.ical4android.CalendarStorageException; import at.bitfire.ical4android.Event; @@ -221,13 +222,17 @@ public class CalendarSyncManager extends SyncManager { } private static String formatEventDates(Event event) { + final Locale locale = Locale.US; final String dateFormatString = event.isAllDay() ? "EEEE, MMM dd" : "EEEE, MMM dd @ hh:mm a"; final DateFormat dateFormat = - new SimpleDateFormat(dateFormatString, - Locale.US); + new SimpleDateFormat(dateFormatString, locale); + final TimeZone timezone = event.dtStart.getTimeZone(); Date startDate = event.dtStart.getDate(); Date endDate = event.getEndDate(true).getDate(); + final String tzName = (timezone != null) ? + timezone.getDisplayName(timezone.inDaylightTime(startDate), TimeZone.SHORT) + : "UTC"; Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); cal1.setTime(startDate); @@ -238,10 +243,11 @@ public class CalendarSyncManager extends SyncManager { return dateFormat.format(startDate); } return sameDay ? - String.format("%s - %s", + String.format("%s - %s (%s)", dateFormat.format(startDate), - new SimpleDateFormat("hh:mm a", Locale.US).format(endDate)) : - String.format("%s - %s", dateFormat.format(startDate), dateFormat.format(endDate)); + new SimpleDateFormat("hh:mm a", Locale.US).format(endDate), + tzName) : + String.format("%s - %s (%s)", dateFormat.format(startDate), dateFormat.format(endDate), tzName); } private Uri createAttachmentFromString(Context context, String name, String content) {