CFLib.org – Common Function Library Project

LSDayOfWeekAsString(day_of_week[, locale])

Last updated July 17, 2001

author

Raymond Camden

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Returns the localized version of a day of the week. For example, if your current locale is set as French (Standard), the value for 1, Sunday, will be dimanche.

Return Values:
Returns a string.

Example:

<CFOUTPUT>
The current locale is #GetLocale()#<BR>
The first day of the week is: #LSDayOfWeekAsString(2)#<BR>
Switching to French (Standard) locale.<BR>
<CFSET SetLocale("French (Standard)")>
The first day of the week in French (Standard) locale is: #LSDayOfWeekAsString(1)#
</CFOUTPUT>

Parameters:

Name Description Required
day_of_week The day of the week. Yes
locale Locale to use. Defaults to current locale. No

Full UDF Source:

/**
 * Returns the localized version of a day of the week.
 * Original idea + code from Ben Forta
 * 
 * @param day_of_week 	 The day of the week. 
 * @param locale 	 Locale to use. Defaults to current locale. 
 * @return Returns a string. 
 * @author Raymond Camden (ray@camdenfamily.com) 
 * @version 1, July 17, 2001 
 */
function LSDayOfWeekAsString(day_of_week) {
	//create arbitrary date
	VAR d=CreateDate(2000, 6, 1);
	VAR dow = DayOfWeek(d);
	VAR oldlocale = "";
	VAR tempstr = "";

	if(dow neq day_of_week) d = dateAdd("d",day_of_week-dow,d);

	if(ArrayLen(Arguments) eq 2) {
		oldLocale = setLocale(arguments[2]);
		tempstr = LSDateFormat(d,"dddd");
		setLocale(oldLocale);
	} else {
		tempstr = LSDateFormat(d,"dddd");
	}
	return tempstr;
}
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