tracker issue : CF-4204933

select a category, or use search below
(searches all categories and all time range)
Title:

cfexchangecalendar changing timezone on recurring events

| View in Tracker

Status/Resolution/Reason: Open//

Reporter/Name(from Bugbase): Roberto A. / ()

Created: 08/05/2019

Components: CFExchange, Calendar

Versions: 2018

Failure Type: Data Corruption

Found In Build/Fixed In Build: ColdFusion 11 and ColdFusion 2018. /

Priority/Frequency: Normal / Some users will encounter

Locale/System: English / Win 2016

Vote Count: 1

When using cfexchangecalendar to setup a new recurring event, the timezone changes to (UTC+00:00) Monrovia, Reykjavik (and the event time is therefore incorrect). This issue does not occur if the event is not recurring.

Sample setup:

<cfset local.event.Message = "Event Message">
<cfset local.event.Subject = "Event Subject">
<cfset local.event.AllDayEvent = "no">
<cfset local.event.StartTime = createDateTime(2019, 7, 26, 0, 0, 0)>
<cfset local.event.EndTime = createDateTime(2019, 7, 27, 0, 0, 0)>
<cfset local.event.IsRecurring = "yes">
<cfset local.event.RecurrenceType = "WEEKLY">
<cfset local.event.RecurrenceEndDate = createDateTime(2019, 12, 31, 0, 0, 0)>
<cfset local.event.RecurrenceDays = "MON">

Also tried using dateConvert("utc2local", dateObj) function to set the dates to UTC, but that did not fix the issue.

Attachments:

Comments:

dateConvert("utc2local", dateObj) and dateConvert("local2utc", dateObj) are crucial conversion functions
Vote by A. B.
31126 | August 18, 2019 02:59:08 PM GMT
For the time being, you might like to use the following functions: <cfscript> string function convertUTCToLocal (date utcDatetime, string timezone) { var utcFormat=createobject("java","java.text.SimpleDateFormat").init("yyyy-MM-dd HH:mm:ss"); var utcTimezone=createobject("java","java.util.TimeZone").getTimezone("UTC"); utcFormat.setTimeZone(utcTimezone); var utcDatetimeString=datetimeFormat(arguments.utcDatetime, "yyyy-MM-dd HH:nn:ss"); var utcDatetimeFormatted=utcFormat.parse(utcDatetimeString); var localFormat=createobject("java","java.text.SimpleDateFormat").init("yyyy-MM-dd HH:mm:ss"); var localTimezone=createobject("java","java.util.TimeZone").getTimezone(arguments.timezone); localFormat.setTimeZone(localTimezone); var localDatetime=localFormat.format(utcDatetimeFormatted) return localDatetime.toString(); } string function convertLocalToUTC (date localDatetime, string timezone) { var localFormat=createobject("java","java.text.SimpleDateFormat").init("yyyy-MM-dd HH:mm:ss"); var localTimezone=createobject("java","java.util.TimeZone").getTimezone(arguments.timezone); localFormat.setTimeZone(localTimezone); var localDatetimeString=datetimeFormat(arguments.localDatetime, "yyyy-MM-dd HH:nn:ss"); var localDatetimeFormatted=localFormat.parse(localDatetimeString); var utcFormat=createobject("java","java.text.SimpleDateFormat").init("yyyy-MM-dd HH:mm:ss"); var utcTimezone=createobject("java","java.util.TimeZone").getTimezone("UTC"); utcFormat.setTimeZone(utcTimezone); var utcDatetime=utcFormat.format(localDatetimeFormatted); return utcDatetime.toString(); } /***** Example of conversion from local datetime to UTC *****/ myLocalTimezone="Europe/Amsterdam"; myLocaldatetime=createdatetime(2019,08,18,16,21,05); utcDate=convertLocalToUTC(myLocaldatetime, myLocalTimezone); writeoutput("UTC datetime: " & utcDate) /***** Example of conversion from UTC to local datetime *****/ /*myLocalTimezone="Asia/Shanghai"; utcDatetime=createdatetime(2019,8,18,13,56,37); localDatetime=convertUTCToLocal(utcDatetime, myLocalTimezone); writeoutput("Local datetime: " & localDatetime)*/ </cfscript>
Comment by A. B.
31125 | August 18, 2019 03:00:43 PM GMT
Thank you for your help. I tried using your convertLocalToUTC function but unfortunately the times still get changed.
Comment by Roberto A.
31130 | August 19, 2019 03:08:07 PM GMT
Let's then apply the code I gave you: <cfscript> string function convertLocalToUTC (date localDatetime, string timezone) { var localFormat=createobject("java","java.text.SimpleDateFormat").init("yyyy-MM-dd HH:mm:ss"); var localTimezone=createobject("java","java.util.TimeZone").getTimezone(arguments.timezone); localFormat.setTimeZone(localTimezone); var localDatetimeString=datetimeFormat(arguments.localDatetime, "yyyy-MM-dd HH:nn:ss"); var localDatetimeFormatted=localFormat.parse(localDatetimeString); var utcFormat=createobject("java","java.text.SimpleDateFormat").init("yyyy-MM-dd HH:mm:ss"); var utcTimezone=createobject("java","java.util.TimeZone").getTimezone("UTC"); utcFormat.setTimeZone(utcTimezone); var utcDatetime=utcFormat.format(localDatetimeFormatted); return utcDatetime.toString(); } myLocalStartDatetime=createdatetime(2019,08,19,22,0,0); myLocalEndDatetime=createdatetime(2019,08,20,22,0,0); utcStartDateTime=convertLocalToUTC(myLocalStartDatetime, "Europe/Madrid"); utcEndDateTime=convertLocalToUTC(myLocalEndDatetime, "Europe/Madrid"); writeoutput("Start datetime converted to UTC: " & utcStartDateTime); writeoutput("<br>"); writeoutput("End datetime converted to UTC: " & utcEndDateTime); </cfscript> The above code gives me the expected result, namely: Start datetime converted to UTC: 2019-08-19 20:00:00 End datetime converted to UTC: 2019-08-20 20:00:00
Comment by A. B.
31131 | August 19, 2019 04:03:13 PM GMT
The code that you supplied is not the issue. The issue is that the cfexchangecalendar tag is not working as expected. When an event is not setup as a "Recurring Event", the timezone is fine. When set as a "Recurring Event", the timezone switches and even if I use the functions you provided, the times are always out of sync.
Comment by Roberto A.
31132 | August 19, 2019 10:23:57 PM GMT