CFLib.org – Common Function Library Project

TranslateFutureMonth(monthcode)

Last updated April 11, 2002

Version: 1 | Requires: ColdFusion 5 | Library: FinancialLib

 
Rated 0 time(s). Average Rating: 0

Description:
Translate month codes from commodity quotes. Can also translate a month back into the proper code.

Return Values:
Returns a string.

Example:

view plain print about
<cfset monthCode = "M">
<cfset month = "February">
<cfoutput>
Month code #monthCode# as a month is: #TranslateFutureMonth(monthCode)#<br>
Month #month# as code is: #TranslateFutureMonth(month)#<br>
</cfoutput>

Parameters:

Name Description Required
monthcode Month, or month code, to translate. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Handles commodity month translation tasks.
 * Removed duplicate My case - rcamden
 * 
 * @param monthcode      Month, or month code, to translate. 
 * @return Returns a string. 
 * @author Mark Kruger (Mkruger@cfwebtools.com) 
 * @version 1.1, April 11, 2002 
 */

function TranslateFutureMonth(monthcode) {
    var TheMonth =    '';
    switch(Monthcode)
    {
        // Translate the letter code into the month code
        case 'F':    {    TheMonth    =    'January';        break;        }
        case 'G':    {    TheMonth    =    'February';        break;        }
        case 'H':    {    TheMonth    =    'March';        break;        }
        case 'J':    {    TheMonth    =    'April';        break;        }
        case 'K':    {    TheMonth    =    'May';            break;        }
        case 'M':    {    TheMonth    =    'June';            break;        }
        case 'N':    {    TheMonth    =    'July';            break;        }
        case 'Q':    {    TheMonth    =    'August';        break;        }
        case 'U':    {    TheMonth    =    'September';    break;        }
        case 'V':    {    TheMonth    =    'October';        break;        }
        case 'X':    {    TheMonth    =    'November';        break;        }
        case 'Z':    {    TheMonth    =    'December';        break;        }
        // Translate the month description into the letter code
        case 'January':        {    TheMonth    =    'F';    break;        }
        case 'February':    {    TheMonth    =    'G';    break;        }
        case 'March':        {    TheMonth    =    'H';    break;        }
        case 'April':        {    TheMonth    =    'J';    break;        }
        case 'June':        {    TheMonth    =    'M';    break;        }
        case 'July':        {    TheMonth    =    'N';    break;        }
        case 'August':        {    TheMonth    =    'Q';    break;        }
        case 'September':    {    TheMonth    =    'U';    break;        }
        case 'October':        {    TheMonth    =    'V';    break;        }
        case 'November':    {    TheMonth    =    'X';    break;        }
        case 'December':    {    TheMonth    =    'Z';    break;        }
        // Translate 3 letter month code into letter code
        case 'Jan':            {    TheMonth    =    'F';    break;        }
        case 'Feb':            {    TheMonth    =    'G';    break;        }
        case 'Mar':            {    TheMonth    =    'H';    break;        }
        case 'Apr':            {    TheMonth    =    'J';    break;        }
        case 'May':            {    TheMonth    =    'K';    break;        }
        case 'Jun':            {    TheMonth    =    'M';    break;        }
        case 'Jul':            {    TheMonth    =    'N';    break;        }
        case 'Aug':            {    TheMonth    =    'Q';    break;        }
        case 'Sep':            {    TheMonth    =    'U';    break;        }
        case 'Oct':            {    TheMonth    =    'V';    break;        }
        case 'Nov':            {    TheMonth    =    'X';    break;        }
        case 'Dec':            {    TheMonth    =    'Z';    break;        }
    }
    
    return(TheMonth);        
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
11 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
30 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson