Skip to main content
Inspiring
July 26, 2019
Question

cfexchangecalendar changing timezone on recurring events

  • July 26, 2019
  • 2 replies
  • 1207 views

Hello,

I am not sure if this is a bug or if I am not using the tag correctly. The following occurs in ColdFusion 2018 release.

If I setup a new event with cfexchangecalendar, using the following event parameters, the timezone changes to (UTC+00:00) Monrovia, Reykjavik (and the event time is therefore incorrect):

<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">

Any assistance would be appreciated.

Thank you,

Robert

This topic has been closed for replies.

2 replies

Legend
August 19, 2019

We saw the same behavior on all events...not just recurring...after updating to CF2018.  Everything switched to UTC time.

Did you post a bug to Adobe?  I will vote it up, if so.

Inspiring
August 19, 2019

Yes, the bug post can be found here:

https://tracker.adobe.com/#/view/CF-4204933

BKBK
Community Expert
Community Expert
July 27, 2019

Does this help?

<cfset local.event.StartTime = dateConvert("utc2local", createDateTime(2019, 7, 26, 0, 0, 0))>

<cfset local.event.EndTime = dateConvert("utc2local", createDateTime(2019, 7, 27, 0, 0, 0))>

<cfset local.event.RecurrenceEndDate = dateConvert("utc2local", createDateTime(2019, 12, 31, 0, 0, 0))>

Inspiring
July 30, 2019

That was a really good suggestion, but unfortunately, the result is the same. The time gets changed to UTC 0 even though I pass all time events through the dateConvert "utc2local" function.

It is odd, because if I do not set a recurring event everything is ok. As soon as I specify that it is a recurring event, the times get changed.

Inspiring
August 19, 2019

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>


Thank you for your help. I tried using your convertLocalToUTC function but unfortunately the times still get changed.