I hate timezone but i have a query now
i have this function
public struct function isTimeInRange2(
required string timezone,
any startDate = "",
any endDate = "",
string expectedoutput = "PST"
) {
try {
// Create timezone objects for proper conversion
local.inputTZ = createObject("java", "java.util.TimeZone").getTimeZone(arguments.timezone);
local.outputTZ = createObject("java", "java.util.TimeZone").getTimeZone(arguments.expectedoutput);
local.shortTZ = local.inputTZ.getDisplayName(true, local.inputTZ.SHORT);
// Get current time in the expected output timezone
local.currentTime = lsParseDateTime(
date: NOW(),
timezone: arguments.expectedoutput
);
// For start and end dates, since they're already in AEST,
// we should parse them without timezone conversion
if (!isNull(arguments.startDate) && len(trim(arguments.startDate))) {
local.startTime = parseDateTime(arguments.startDate);
} else {
local.startTime = "";
}
if (!isNull(arguments.endDate) && len(trim(arguments.endDate))) {
local.endTime = parseDateTime(arguments.endDate);
} else {
local.endTime = "";
}
// Calculate if current time is in range
local.isInRange = (
(local.startTime == "" || local.currentTime >= local.startTime) &&
(local.endTime == "" || local.currentTime <= local.endTime)
);
// Format times for output
local.currentTimeFormatted = lsDateTimeFormat(
date: local.currentTime,
timezone: arguments.expectedoutput,
mask: "mm/dd/yyyy HHnnss z"
);
local.startTimeFormatted = (local.startTime != "") ?
dateTimeFormat(
local.startTime,
"mm/dd/yyyy HHnnss"
) & " " & local.shortTZ : "";
local.startTimeFormattedNoZone = (local.startTime != "") ?
dateTimeFormat(
local.startTime,
"mm/dd/yyyy HHnnss"
) : "";
local.endTimeFormatted = (local.endTime != "") ?
dateTimeFormat(
local.endTime,
"mm/dd/yyyy HHnnss"
) & " " & local.shortTZ : "";
return {
result: local.isInRange ? "Active" : "Inactive",
isInRange: local.isInRange,
currentTime: local.currentTimeFormatted,
startTime: local.startTimeFormatted,
startTimeNoZone: local.startTimeFormattedNoZone,
timezonepst: local.shortTZ,
endTime: local.endTimeFormatted,
timezone: arguments.timezone
};
} catch (any e) {
return {
result: "Inactive",
message: "Error processing times: #e.message#",
currentTime: "",
startTime: "",
endTime: "",
timezone: arguments.timezone
};
}
}
and its usage is:
<cfset currentTmz = isTimeInRange2( timezone = '#getEvents.abbrFormat#', startDate = "#getEvents.regStartZoneDateTime#", endDate = "#getEvents.regEndZoneDateTime#", expectedoutput='PST')>
Australia/sydney - getEvents.abbrFormat
regStartZoneDateTime - 2024-12-14 094800
regEndZoneDateTime - 2024-12-15 175000
when i dump i get data like this
to me it seems wrong, because database have values in AEST and the now should be between the start and end time because it is expected to in there as i am doing in athiments.timezone which specifiees me to AEDT, i wonder what i am doing wrong here
any clues