Skip to content

Instantly share code, notes, and snippets.

@cjolly
Created April 16, 2010 20:49
Show Gist options
  • Save cjolly/368952 to your computer and use it in GitHub Desktop.
Save cjolly/368952 to your computer and use it in GitHub Desktop.
jQuery hack for 12 hour datetime selects in rails
function convertDateTimeSelectTo12Hour() {
var translate = {"00":"Midnight","01":"1am","02":"2am","03":"3am","04":"4am","05":"5am","06":"6am","07":"7am","08":"8am","09":"9am","10":"10am","11":"11am","12":"Noon","13":"1pm","14":"2pm","15":"3pm","16":"4pm","17":"5pm","18":"6pm","19":"7pm","20":"8pm","21":"9pm","22":"10pm","23":"11pm"};
$("select[name$='(4i)]'] option").each(function() {
$(this).text(translate[$(this).text()]);
});
}
@mtodd
Copy link

mtodd commented Nov 16, 2010

It's parsing that in octal so 08 and 09 are not valid octal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment