CFLib.org – Common Function Library Project

JulianDayofWeek([fullDate])

Last updated September 5, 2001

author

Beau A.C. Harbin

Version: 1 | Requires: CF5 | Library: DateLib

Description:
Returns the day of the week for a date in the Julian. If no date is provided, defaults to the current day. Verified to be accurate between 400 and 9999 AD.

Return Values:
Returns an integer between 1 and 7 representing the day of the week (1=Sunday).

Example:

<CFOUTPUT>
#DayofWeekAsString(JulianDayofWeek("2/1/445"))#
</CFOUTPUT>

Parameters:

Name Description Required
fullDate Date you want to return the Julian day of the week for. No

Full UDF Source:

/**
 * Returns the day of the week for a date in the Julian calendar.
 * The original alogrithim for the calculation was found at: http://www.faqs.org/faqs/calendars/faq/part1/
 * 
 * @param fullDate 	 Date you want to return the Julian day of the week for. 
 * @return Returns an integer between 1 and 7 representing the day of the week (1=Sunday). 
 * @author Beau A.C. Harbin (bharbin@figleaf.com) 
 * @version 1.0, September 5, 2001 
 */
function JulianDayofWeek(){
        var date=iif(arraylen(arguments) gt 0,"arguments[1]", "Now()");
	var month = DatePart("m", date);
	var day = DatePart("d", date);
	var year = DatePart("yyyy", date);
	var a = 0;
	var y = 0;
	var m = 0;
	var dayOfWeek = 0;
	a = (14 - month) \ 12;
	y = year - a;
	m = month + 12*a - 2;
	// for Julian calendar:
	dayOfWeek = ((5 + day + y + y\4 + (31*m)\12) mod 7)+1;

	// for Gregorian calendar:
	if(arraylen(arguments) EQ 0){
		dayOfWeek = DayofWeek(date);
	}

	return dayOfWeek;
}
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