cfexchangecalendar changing timezone on recurring events

Explorer ,
Jul 26, 2019 Jul 26, 2019

Copy link to clipboard

Copied

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

Views

493

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 27, 2019 Jul 27, 2019

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 30, 2019 Jul 30, 2019

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 04, 2019 Aug 04, 2019

Copy link to clipboard

Copied

If the function dateConvert("utc2local", dateObj) isn't working as expected, then there is probably a bug. You should report it in Tracker

In the meantime, let's look for a workaround.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 05, 2019 Aug 05, 2019

Copy link to clipboard

Copied

Will do. Thank you.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 18, 2019 Aug 18, 2019

Copy link to clipboard

Copied

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>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 19, 2019 Aug 19, 2019

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 19, 2019 Aug 19, 2019

Copy link to clipboard

Copied

rob_cyberdyne  wrote

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

This now confuses me. What are the

  • local datetime
  • local timezone

that you wish to convert to UTC?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 19, 2019 Aug 19, 2019

Copy link to clipboard

Copied

If I put today's date, with a weekly Monday occurrence, I get a series of calendar events that start on Monday at 22:00 and end on Tuesday at 22:00.

I pass the start and end date as below:

myLocaldatetime=createdatetime(2019,08,19,0,0,0);

convertLocalToUTC(myLocaldatetime, "Europe/Madrid")

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 19, 2019 Aug 19, 2019

Copy link to clipboard

Copied

rob_cyberdyne  wrote

If I put today's date, with a weekly Monday occurrence, I get a series of calendar events that start on Monday at 22:00 and end on Tuesday at 22:00.

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 19, 2019 Aug 19, 2019

Copy link to clipboard

Copied

LATEST

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 19, 2019 Aug 19, 2019

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 19, 2019 Aug 19, 2019

Copy link to clipboard

Copied

Yes, the bug post can be found here:

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines