diff --git a/app/global/functions.cfm b/app/global/functions.cfm index 345536ae..07c29571 100644 --- a/app/global/functions.cfm +++ b/app/global/functions.cfm @@ -3,6 +3,37 @@ public function GetSignedInUserId(){ return structKeyExists(session, "userID") ? session.userID : 0 } + +/** + * Convert a local datetime to UTC using server's timezone offset + * @localTime The datetime to convert to UTC + * @return The datetime in UTC + */ +public datetime function toUTC(required datetime localTime) { + var tzInfo = GetTimeZoneInfo(); + var offsetSeconds = tzInfo.utcTotalOffset * 60; + return dateAdd("s", -offsetSeconds, arguments.localTime); +} + +/** + * Safely convert a datetime string from a specific timezone to UTC + * @dateTimeStr The datetime string to convert (expected to be ISO format from JavaScript) + * @timeZone The timezone identifier (e.g., "America/New_York") - kept for compatibility but not used since JS sends UTC + * @return The datetime in UTC + */ +public datetime function toSafeUTC(required string dateTimeStr, string timeZone="") { + try { + // Since JavaScript sends ISO string (already in UTC), just parse it + if (len(trim(arguments.dateTimeStr))) { + return parseDateTime(arguments.dateTimeStr); + } else { + return toUTC(now()); + } + } catch (any e) { + // Fallback: return current UTC time + return toUTC(now()); + } +} public function GetUserRoleId(){ return 3; } diff --git a/app/views/layout.cfm b/app/views/layout.cfm index 8efbf440..b5e2c8d4 100644 --- a/app/views/layout.cfm +++ b/app/views/layout.cfm @@ -17,15 +17,15 @@ - + - + - + - + - + @@ -808,6 +808,21 @@ + \ No newline at end of file diff --git a/app/views/web/BlogController/create.cfm b/app/views/web/BlogController/create.cfm index b6344082..a3f59ef8 100644 --- a/app/views/web/BlogController/create.cfm +++ b/app/views/web/BlogController/create.cfm @@ -79,7 +79,7 @@ - + Leave empty to use the current date and time @@ -108,4 +108,50 @@ - \ No newline at end of file + +