var dates = structNew(); var selectedYear = arguments.theYear; var selectedMonth = arguments.theMonth; var selectedDay = arguments.theDay; // initialize "Date" variables var selectedDate = ""; // initialize "Week" variables var firstOfThisWeek = ""; var lastOfThisWeek = ""; var firstOfLastWeek = ""; var firstOfNextWeek = ""; // initialize "Month" variables var lastDayofSelectedMonth = ""; // calculate the last day of the selected month lastDayofSelectedMonth = DaysInMonth(createDate(selectedYear, selectedMonth, 1)); if ( selectedDay GT lastDayofSelectedMonth ) selectedDay = lastDayofSelectedMonth; // Create Date from values passed in accounting for non-valid dates selectedDate = createDate(selectedYear, selectedMonth, selectedDay); // Create surround week dates firstOfThisWeek = application.ptCalendar2.date.firstDayOfWeek(selectedDate); lastOfThisWeek = dateAdd("d", 6, firstOfThisWeek); firstOfLastWeek = dateAdd("d", -7, firstOfThisWeek); firstOfNextWeek = dateAdd("d", 7, firstOfThisWeek); dates["thisDay"] = selectedDay; dates["thisMonth"] = selectedMonth; dates["thisYear"] = selectedYear; dates["fullDate"] = selectedDate; dates["formattedDate"] = dateFormat(selectedDate, "dddd, mmm dd, yyyy"); dates["yesterday"] = dateAdd('d', -1, selectedDate); dates["tomorrow"] = dateAdd('d', 1, selectedDate); // set the next and previous weeks dates["firstOfThisWeek"] = firstOfThisWeek; dates["lastOfThisWeek"] = lastOfThisWeek; dates["firstOfLastWeek"] = firstOfLastWeek; dates["firstOfNextWeek"] = firstOfNextWeek; dates["formattedThisWeek"] = dateFormat(firstOfThisWeek, 'mmmm dd, yyyy'); dates["formattedLastWeek"] = dateFormat(firstOfLastWeek, 'mmmm dd'); dates["formattedNextWeek"] = dateFormat(firstOfNextWeek, 'mmmm dd'); return dates;