Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
Fix issue #10; support for lower case AM/PM indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
GregDThomas committed Sep 15, 2013
1 parent e9506fe commit 6ac633f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion jquery.localtime.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"formatting",
"ISO8601"
],
"version": "0.7.1",
"version": "0.8.0-SNAPSHOT",
"author": {
"name": "Greg Thomas"
},
Expand Down
6 changes: 4 additions & 2 deletions src/jquery.localtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@
}
break;
case "a":
case "tt": formattedDate += (hour >= 12) ? "PM" : "AM"; break;
case "t": formattedDate += (hour >= 12) ? "P" : "A"; break;
case "TT": formattedDate += (hour >= 12) ? "PM" : "AM"; break;
case "tt": formattedDate += (hour >= 12) ? "pm" : "am"; break;
case "T": formattedDate += (hour >= 12) ? "P" : "A"; break;
case "t": formattedDate += (hour >= 12) ? "p" : "a"; break;
case "z":
formattedDate += tzSign + parseInt(tzOffset / 60, 10);
break;
Expand Down
8 changes: 7 additions & 1 deletion test/jquery.localtime_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,15 @@
});
test("AM/PM format 2", function() {
$.localtime.setFormat("t");
equal("a", $.localtime.toLocalTime("2011-01-03 08:39:30.003Z") );
equal("p", $.localtime.toLocalTime("2011-01-03 16:39:30.003Z") );
$.localtime.setFormat("tt");
equal("am", $.localtime.toLocalTime("2011-01-03 08:39:30.003Z") );
equal("pm", $.localtime.toLocalTime("2011-01-03 16:39:30.003Z") );
$.localtime.setFormat("T");
equal("A", $.localtime.toLocalTime("2011-01-03 08:39:30.003Z") );
equal("P", $.localtime.toLocalTime("2011-01-03 16:39:30.003Z") );
$.localtime.setFormat("tt");
$.localtime.setFormat("TT");
equal("AM", $.localtime.toLocalTime("2011-01-03 08:39:30.003Z") );
equal("PM", $.localtime.toLocalTime("2011-01-03 16:39:30.003Z") );
});
Expand Down

0 comments on commit 6ac633f

Please sign in to comment.