Expand my Community achievements bar.

Could someone Please help

Avatar

Level 2

In need a time box that will convert “8pm” or “8 pm” or “8:00pm” or “8:00 pm” to military time.  Currently this does that, I just need to modify this so if the users enter “8p” or “8 p” or “8:00p” or “8:00 p” it will add an “m” but retain the original function.

form1.Page1.ShiftStartTime::exit - (JavaScript, client)

var fldValue = this.formattedValue;

//get the am/pm indicator and make it upper case

var dayIndicator = fldValue.substr(fldValue.length - 2);

dayIndicator = dayIndicator.toUpperCase();

//get the Hours + Mins - set them where neccessary

var hrs

var mins

var regExpression = / /g

var temp = fldValue.substr(0, fldValue.length - 2)

if (temp.length <= 3){

            hrs = temp;

            hrs = hrs.replace(regExpression, "");

}

var lastColon = fldValue.indexOf(":");

if (lastColon == -1){

            mins = ""

} else {

            mins = fldValue.substr(lastColon + 1, 2)

            hrs = fldValue.substr(0,lastColon)

}

//write the military time out

if ((dayIndicator == "PM")&&(hrs ==12)){

            hrs = "00"

}

if ((dayIndicator == "AM")&&(hrs ==12)){

            hrs = "00"

}

if (dayIndicator == "PM"){

            hrs = parseInt(hrs) + 12

}

if (mins == ""){

            mins = "00"

}          

this.rawValue = hrs + ":" + mins

1 Reply