CFLib.org – Common Function Library Project

getDaylightSavingTimeEnd([TheYear])

Last updated December 20, 2006

author

Ken McCafferty

Version: 1 | Requires: CF5 | Library: DateLib

Description:
Returns the date for the End of Daylight Saving Time for a given year. If no year is specified, defaults to current year.

Return Values:
Returns a date object.

Example:

<CFOUTPUT>
This year, Daylight Saving Time ends on #DateFormat(GetDaylightSavingTimeEnd(), 'dddd, mmm dd, yyyy')#.
</CFOUTPUT>

Parameters:

Name Description Required
TheYear Year you want to return the end of Daylight Saving Time. No

Full UDF Source:

/**
 * Returns the date for the End of Daylight Saving Time for a given year.
 * This function requires the GetLastOccOfDayInMonth() function available from the DateLib library.
 * 
 * @param TheYear      Year you want to return the end of Daylight Saving Time. (Optional)
 * @return Returns a date object. 
 * @author Ken McCafferty (mccjdk@yahoo.com) 
 * @version 1, December 20, 2006 
 */
function getDaylightSavingTimeEnd() {
    var TheYear=Year(Now());
      if(ArrayLen(Arguments)) TheYear = Arguments[1];
    //US Congress changed it for 2007,may switch back
    // From last Sunday in October to First Sunday in November 
    if(TheYear lt 2007) return CreateDate(TheYear,10,GetLastOccOfDayInMonth(1,10,TheYear));
    else return CreateDate(TheYear,11,GetNthOccOfDayInMonth(1,1,11,TheYear));
    return CreateDate;
}

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

Created by Raymond Camden / Design by Justin Johnson