CFLib.org – Common Function Library Project

GetSeason([myDate])

Last updated May 13, 2003

author

William Steiner

Version: 1 | Requires: CF5 | Library: DateLib

Description:
Returns the Season for a given date. If no date is specified, defaults to the current date.

Return Values:
Returns a string.

Example:

<CFOUTPUT>
The current season is #GetSeason()#.
</CFOUTPUT>

Parameters:

Name Description Required
myDate The date. Defaults to now. No

Full UDF Source:

/**
 * Returns season for given date.
 * 
 * @param myDate 	 The date. Defaults to now. (Optional)
 * @return Returns a string. 
 * @author William Steiner (williams@hkusa.com) 
 * @version 1, May 13, 2003 
 */
function GetSeason() {
	var myDate = iif(arraylen(arguments) gt 0,"arguments[1]", "now()");
	var myYear = Year(myDate);
	//Winter
	var winterStart = '12-21-' & decrementValue(myYear);
	var winterEnd = '03-20-' & myYear;
	//Spring
	var springStart = '3-21-' & myYear;
	var springEnd = '06-20-' & myYear;
	//Summenr 
	var summerStart = '06-21-' & myYear;
	var summerEnd ='09-20-' & myYear;
	//Fall
	var fallStart = '09-21-' & myYear;
	var fallEnd = '12-20-' & myYear;
	
	// return the correct season
	if (myDate GTE winterStart AND myDate LTE winterEnd) {
		return "Winter";
	} else if (myDate GTE springStart AND myDate LTE springEnd) {
		return "Spring";
	} else if (myDate GTE summerStart AND myDate LTE summerEnd) {
		return "Summer";
	} else if (myDate GTE fallStart AND myDate LTE fallEnd) {
		return "Fall";
	} else {
		return "";
	}
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson