Permalink
Browse files

Forward port two edge-case fixes from Luke Melia

  • Loading branch information...
1 parent 2563f75 commit e202e7971da5f9d3b5cf9565db2441f586e514b9 Devin Torres committed Jan 4, 2012
Showing with 10 additions and 1 deletion.
  1. +4 −1 lib/datetime.js
  2. +6 −0 tests/datetime_test.js
View
5 lib/datetime.js
@@ -997,7 +997,10 @@ Ember.DateTime.reopenClass(Ember.Comparable,
}
if (!Ember.none(opts.meridian) && !Ember.none(opts.hour)) {
- if (opts.meridian === 1) opts.hour = (opts.hour + 12) % 24;
+ if ((opts.meridian === 1 && opts.hour !== 12)
+ || (opts.meridian === 0 && opts.hour === 12)) {
+ opts.hour = (opts.hour + 12) % 24;
+ }
delete opts.meridian;
}
View
6 tests/datetime_test.js
@@ -308,6 +308,12 @@ test('parse', function() {
timeShouldBeEqualToHash(
Ember.DateTime.parse('71-01-01 00:00:00', '%y-%m-%d %H:%M:%S'),
{ year: 1971, month: 1, day: 1, hour: 0, minute: 0, second: 0, millisecond: 0 });
+ timeShouldBeEqualToHash(
+ Ember.DateTime.parse('71-01-01 12:00 AM', '%y-%m-%d %i:%M %p'),
+ { year: 1971, month: 1, day: 1, hour: 0, minute: 0, second: 0, millisecond: 0 });
+ timeShouldBeEqualToHash(
+ Ember.DateTime.parse('71-01-01 12:00 PM', '%y-%m-%d %i:%M %p'),
+ { year: 1971, month: 1, day: 1, hour: 12, minute: 0, second: 0, millisecond: 0 });
});
test('parse with time zones',function() {

0 comments on commit e202e79

Please sign in to comment.