// Set page as dynamic for now
request.element.isStatic = 0;
WriteDump(var=request.params,expand=false,label="request.params");
WriteDump(var=request.page,expand=false,label="request.page");
WriteDump(var=request.element,expand=false,label="request.element");
WriteDump(var=request.user,expand=false,label="request.user");
/* csmode = "";
if ( StructKeyExists(request,"renderstate") AND StructKeyExists(request.renderstate,"rendermode") )
csmode = request.renderstate.rendermode; */
/* if ( csmode IS "edit" OR csmode IS "author" )
{
// Set Search Results as Dynamic
request.element.isStatic = 0;
WriteOutput("Important: You are currently in #csmode# mode!");
}*/
resetConfig = true;
if ( StructKeyExists(request,'params') AND StructKeyExists(request.params,'resetConfig') )
resetConfig = ( IsBoolean(request.params.resetConfig) ) ? request.params.resetConfig : false;
configItem = {};
curPageID = request.page.id;
curElementID = request.element.id;
// Get the items from the Display Properties Custom Element
items = attributes.elementInfo.elementData.propertyValues;
//WriteDump(items);
if ( ArrayLen(items) )
configItem = items[1].values;
//WriteDump(var=configItem,label="configItem",expand=false);
if ( NOT StructKeyExists(Application,'ptCalendar') )
{
WriteOutput('The PT Calendar App must be installed to use this render handler!
');
exit;
}
//WriteOutput('resetConfig: #YesNoFormat(resetConfig)#!
');
if ( NOT StructKeyExists(Application.ptCalendar,'jsonFeedConfig') )
Application.ptCalendar.jsonFeedConfig = {};
if ( NOT StructKeyExists(Application.ptCalendar.jsonFeedConfig,curPageID) OR resetConfig )
Application.ptCalendar.jsonFeedConfig[curPageID] = configItem;
//WriteDump(var=Application.ptCalendar.jsonFeedConfig,label="jsonFeedConfig",expand=false);
lock scope="session" timeout="10" type ="exclusive" {
if ( NOT StructKeyExists(session,'ptCalendar') )
session.ptCalendar = {};
if ( NOT StructKeyExists(session.ptCalendar,'userFeedSpecs') )
session.ptCalendar.userFeedSpecs = {};
session.ptCalendar.userFeedSpecs.PageId = request.page.id;
session.ptCalendar.userFeedSpecs.GroupList = request.user.GroupList;
WriteDump(var=session.ptCalendar.userFeedSpecs,label="userFeedSpecs",expand=false);
}
tzInfo = GetTimeZoneInfo();
tzOffset = NumberFormat(tzInfo.utcHourOffset,'00') & ":" & NumberFormat(tzInfo.utcMinuteOffset,'00');
//WriteDump(tzInfo);
//WriteOutput('
tzOffset: #tzOffset#');
start = '2025-03-15T00:00:00-#tzOffset#'; //05:00
if ( StructKeyExists(request.params,'start') AND TRIM(request.params.start) NEQ '' )
{
start = request.params.start;
// WriteOutput('
start: #start#');
start = convertDateTimeStrToUTC(dtStr=start);
// WriteOutput('
start (convert): #start#');
}
if ( NOT IsDate(start) )
{
// Use NOW() for the start date
startDT = Now();
start = convertDateTimeStrToUTC(dtStr=startDT);
// WriteOutput('
start (convert 2): #start#');
}
end = ''; //2025-04-16T00:00:00-04:00
if ( StructKeyExists(request.params,'end') AND TRIM(request.params.end) NEQ '' )
{
end = request.params.end;
WriteOutput('
end: #end#');
end = convertDateTimeStrToUTC(dtStr=end);
WriteOutput('
end (convert 1): #end#');
}
if ( NOT IsDate(end) )
{
// Convert the start date and add 1 month
startDT = parseDateTime(start);
//startDT = dateConvert("utc2local", start);
//WriteOutput('
startDT: #startDT#');
endDT = DateAdd('m',1,startDT);
//WriteOutput('
endDT: #endDT#');
// Convert endDT back to UTC time string
//endDT = dateConvert("local2Utc", endDT);
//WriteOutput('
endDT (UTC): #endDT#');
end = convertDateTimeStrToUTC(dtStr=endDT);
//WriteOutput('
end (convert 2): #end#');
}
useCache = true;
if ( StructKeyExists(request.params,'cache') AND IsBoolean(request.params.cache) )
useCache = request.params.cache;
//start = '2025-02-15T00:00:00-05:00';
//end = '2025-04-16T00:00:00-04:00';
WriteOutput('
start: #start# - end: #end#');
WriteOutput('
Cache Enabled: #useCache#');
WriteOutput('
getEventsData()');
data = application.ptCalendar.calEventsAPI.getEventsData(start=start,end=end,useCache=useCache);
WriteOutput('
Records: #ArrayLen(data.events)#');
writedump(data);
var retStr = arguments.dtStr;
var tzInfo = GetTimeZoneInfo();
var tzOffset = NumberFormat(tzInfo.utcHourOffset,'00') & ":" & NumberFormat(tzInfo.utcMinuteOffset,'00');
if ( IsDate(retStr) )
{
retStr = parseDateTime(retStr);
retStr = "#DateFormat(retStr,'yyyy-mm-dd')#T#TimeFormat(retStr,'HH:mm:ss')#-#tzOffset#";
}
return retStr;