Skip to content

Commit

Permalink
Fixing Am/pm marker with compatible a Java format
Browse files Browse the repository at this point in the history
  • Loading branch information
ddivin-sc committed Aug 26, 2019
1 parent b825ca0 commit d1481a0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/external_modules/date-and-time.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ const date = {
D: d => '' + d.getDate(),
HH: d => ('0' + d.getHours()).slice(-2),
H: d => '' + d.getHours(),
A: d => ['AM', 'PM'][d.getHours() > 11 | 0],
a: d => ['am', 'pm'][d.getHours() > 11 | 0],
a: d => ['AM', 'PM'][d.getHours() > 11 | 0],
hh: d => ('0' + (d.getHours() % 12 || 12)).slice(-2),
h: d => '' + (d.getHours() % 12 || 12),
mm: d => ('0' + d.getMinutes()).slice(-2),
Expand Down
17 changes: 1 addition & 16 deletions src/utils/I18nManager.converters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,6 @@ describe('I18nManager: converters', () => {
assert.equal('10/01/2001 00:00:00', dateTimeAsString);
});

it('should format and parse date and time with AM', () => {
const localeFormattingInfo = {
en: {
dateTimePattern: 'dd/MM/yyyy HH:mm:ss A'
}
};
const i18n = new I18nManager({
locale: 'en',
localeFormattingInfo
})
const date = new Date('December 17, 2005 09:24:00');
const dateTimeAsString = i18n.formatDateTime(date);
assert.equal('17/12/2005 09:24:00 AM', dateTimeAsString);
});

it('should format and parse date and time with pm', () => {
const localeFormattingInfo = {
en: {
Expand All @@ -86,7 +71,7 @@ describe('I18nManager: converters', () => {
})
const date = new Date('December 17, 2005 19:24:00');
const dateTimeAsString = i18n.formatDateTime(date);
assert.equal('12/17/2005 7:24:00 pm', dateTimeAsString);
assert.equal('12/17/2005 7:24:00 PM', dateTimeAsString);
});

it('should format and parse numbers', () => {
Expand Down

0 comments on commit d1481a0

Please sign in to comment.