PDA

View Full Version : Title Time Script code redundancy



djr33
07-29-2007, 04:16 AM
1) Script Title: Title Time Script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex6/titletime.htm

3) Describe problem: This code is just insane.
For every PM hour, there is an else if {} block.
It should simply be updated to if (hour>12 && hour!=24).
No?

function antiMilitaryTime()
{
if (hr == "12"){
ampm="P.M."
}
else if (hr == "13"){
hr="1"
ampm="P.M."
}
else if (hr == "14"){
hr="2"
ampm="P.M."
}
else if (hr == "15"){
hr ="3"
ampm="P.M."
}
else if (hr == "16"){
hr = "4"
ampm="P.M."
}
else if (hr == "17"){
hr = "5"
ampm="P.M."
}
else if (hr == "18"){
hr = "6"
ampm="P.M."
}
else if (hr == "19"){
hr = "7"
ampm="P.M."
}
else if (hr == "20"){
hr = "8"
ampm="P.M."
}
else if (hr == "21"){
hr = "9"
ampm="P.M."
}
else if (hr == "22"){
hr = "10"
ampm="P.M."
}
else if (hr == "23"){
hr = "11"
ampm="P.M."
}
else if (hr == "24"){
hr = "12"
}
}

jscheuer1
07-29-2007, 04:24 AM
Sloppy coding, but - not a bug.