utcOffsetToMinutes(offset)
Last updated January 08, 2015
Version: 1 | Requires: CF10 | Library: DateLib
Description:
Converts UTC Offset to minutes.
Return Values:
Returns a number.
Example:
<cfoutput>
#utcOffsetToMinutes("UTC-05:00")# = -300<br />
#utcOffsetToMinutes("UTC+0500")# = 300<br />
#utcOffsetToMinutes("05")# = 300<br />
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
offset | The formatted UTC offset to be converted to minutes. | Yes |
Full UDF Source:
<!---
Converts UTC Offset to minutes.
@param offset The formatted UTC offset to be converted to minutes. (Required)
@return Returns a number.
@author Mosh Teitelbaum (mosh.teitelbaum@evoch.com)
@version 1, 1/8/2015
--->
<cffunction name="utcOffsetToMinutes" returntype="numeric" output="no" description="Converts UTC Offset to minutes.">
<cfargument name="offset" type="string" required="yes" hint="The formatted UTC offset to be converted to minutes.">
<!--- Initialize local variables --->
<cfset var h = 0> <!--- hours --->
<cfset var m = 0> <!--- minutes --->
<cfset var s = 1> <!--- sign --->
<cfset var str = ReReplaceNoCase(arguments.offset, "[^-:0-9]", "", "ALL")> <!--- offset with non-important characters removed --->
<!--- If first character is "-", adjust sign --->
<cfif Compare(Left(str, 1), "-") EQ 0>
<cfset s = -1>
<cfset str = Right(str, Len(str) - 1)>
</cfif>
<!--- Determine number of hours and minutes --->
<cfif ListLen(str, ":") EQ 2>
<cfset h = ListFirst(str, ":")>
<cfset m = ListLast(str, ":")>
<cfelseif Len(str) EQ 2>
<cfset h = str>
<cfelseif Len(str) EQ 3>
<cfset h = Left(str, 1)>
<cfset m = Right(str, 2)>
<cfelseif Len(str) EQ 4>
<cfset h = Left(str, 2)>
<cfset m = Right(str, 2)>
</cfif>
<!--- Return number of minutes --->
<cfreturn s * ((h * 60) + m)>
</cffunction>
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016