CFLib.org – Common Function Library Project

getDaylightSavingTimeStart([TheYear])

Last updated December 20, 2006

author

Ken McCafferty

Version: 2 | Requires: CF5 | Library: DateLib

Description:
Returns the date for The start 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 starts on #DateFormat(GetDaylightSavingTimeStart(), 'dddd, mmm dd, yyyy')#.
</CFOUTPUT>

Parameters:

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

Full UDF Source:

/**
 * Returns the date for The start of Daylight Saving Time for a given year.
 * This function requires the GetNthOccOfDayInMonth() function available from the DateLib library.
 * 
 * @param TheYear      Year you want to return the start of Daylight Saving Time. (Optional)
 * @return Returns a date object. 
 * @author Ken McCafferty (mccjdk@yahoo.com) 
 * @version 2, December 20, 2006 
 */
function getDaylightSavingTimeStart() {
    var TheYear=Year(Now());
      if(ArrayLen(arguments)) TheYear = arguments[1];
    //US Congress changed it for 2007,may switch back
    // From first Sunday in April to Second Sunday in March 
    if(TheYear lt 2007) return CreateDate(TheYear,4,GetNthOccOfDayInMonth(1,1,4,TheYear));
    else return CreateDate(TheYear,3,GetNthOccOfDayInMonth(2,1,3,TheYear));
}

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