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

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