Date Parse

Handles parsing of  dates for easier user date entry.

Author: Bob Cusick, Servoy USAÂ

Handles parsing of  dates for easier user date entry.

var myDate = arguments[0]
var delim = '\/'  //default delimiter character is '/'

if(myDate) 
{ 
    //determine the delimiter 
    if(utils.stringPosition(myDate, '\/', 1, 1) > 0)
    { 
        delim = '\/'  
    } 
    else if(utils.stringPosition(myDate, '-', 1, 1) > 0)
    { 
        delim = '-'  
    } 
    else if(utils.stringPosition(myDate, '.', 1, 1) > 0)
    { 
        delim = '.'  
    } 
    else 
    { 
        //none of the above delimiter! 
        return null; 
    } 
     
    //if they entered a 2 character year' 
    var yearSlash = myDate.lastIndexOf(delim,myDate.length)+1
    var mylength= myDate.length 
    if(yearSlash == myDate.length-2) 
    { 
        if (yearSlash <= 15)
        { 
            myDate = myDate.substr(0, yearSlash) + '19' + myDate.substr(yearSlash, 2)
        } 
        else 
        { 
            myDate = myDate.substr(0, yearSlash) + '20' + myDate.substr(yearSlash, 2)
        } 
    } 
     
    return utils.dateFormat(myDate,i18n.getDefaultDateFormat())
} 
else 
{ 
    return null 
}