Created
July 12, 2024 09:00
-
-
Save recantha/bd54dbc575e5377346268170d8fe28c4 to your computer and use it in GitHub Desktop.
A CFML function to determine whether a date is in GMT or BST for the Europe/London region
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="getDateTimeZone" returntype="string" access="public"> | |
<cfargument name="the_date" type="date" required="true"> | |
<cfset var local = {}> | |
<cftry> | |
<cfset local.timezone = ""> | |
<cfset local.obj_timezone = createObject("java", "java.util.TimeZone").getTimeZone("Europe/London")> | |
<cfset local.is_daylight_time = local.obj_timezone.inDaylightTime(arguments.the_date)> | |
<cfif local.is_daylight_time> | |
<cfset local.timezone = "BST"> | |
<cfelse> | |
<cfset local.timezone = "GMT"> | |
</cfif> | |
<cfcatch type="any"> | |
<cfset local.timezone = ""> | |
</cfcatch> | |
</cftry> | |
<cfreturn local.timezone> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment