CFLib.org – Common Function Library Project

LSMonthAsString(month_number[, locale])

Last updated July 17, 2001

author

Raymond Camden

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Returns the localized version of a month number. For example, if your current locale is set as French (Standard), the value for 1, Janaury, will be Janvier.

Return Values:
Returns a string.

Example:

<CFOUTPUT>
The current locale is #GetLocale()#<BR>
The first month is: #LSMonthAsString(1)#<BR>
Switching to French (Standard) locale.<BR>
<CFSET SetLocale("French (Standard)")>
The first month in French (Standard) locale is: #LSMonthAsString(1)#
</CFOUTPUT>

Parameters:

Name Description Required
month_number The month number. Yes
locale Locale to use. Defaults to current locale. No

Full UDF Source:

/**
 * Returns the localized version of a month.
 * Original code + idea from Ben Forta
 * 
 * @param month_number 	 The month number. 
 * @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 LSMonthAsString(month_number) {
	VAR d=CreateDate(2000, month_number, 1);
	VAR oldlocale = "";
	VAR tempstr = "";
	if(ArrayLen(Arguments) eq 2) {
		oldLocale = setLocale(arguments[2]);
		tempstr = LSDateFormat(d,"mmmm");
		setLocale(oldLocale);
	} else {
		tempstr = LSDateFormat(d,"mmmm");
	}
	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