Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GOOGLE_API_KEY="Sample Key"
GOOGLE_API_KEY="Sample Key "
API_HOST=https://open-event-api-dev.herokuapp.com
MAP_DISPLAY=embed
FASTBOOT_DISABLED=true
14 changes: 13 additions & 1 deletion app/helpers/general-date.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ import moment from 'moment';

export function generalDate(params) {
const timezone = params[1] || moment.tz.guess();
const format = params[2] || 'h:mm A, MMMM Do YYYY (z)';
let changeTo24 = false;

let format = params[2] || 'h:mm A, MMMM Do YYYY (z)';

if (moment(params[0]).tz(timezone).format('A') === 'AM' || moment(params[0]).tz(timezone).format('A') === 'PM') {
changeTo24 = true;
}

if (changeTo24) {
format = format.replaceAll('h', 'H');
format = format.replace(' A', '');
format = format.replace(' a', '');
}
return moment(params[0]).tz(timezone).format(format);
}

Expand Down
10 changes: 9 additions & 1 deletion app/helpers/header-date.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ import moment from 'moment';

export function headerDate(params) {
const timezone = params[1] ? params[1] : moment.tz.guess();
return `${moment(params[0]).tz(timezone).format('dddd, MMMM Do YYYY, h:mm A')} (${moment.tz(params[0], timezone).zoneAbbr()})`;

let format = 'dddd, MMMM Do YYYY, h:mm A';

if (moment(params[0]).tz(timezone).format('A') === 'AM' || moment(params[0]).tz(timezone).format('A') === 'PM') {
format = format.replaceAll('h', 'H');
format = format.replace(' A', '');
}

return `${moment(params[0]).tz(timezone).format(format)} (${moment.tz(params[0], timezone).zoneAbbr()})`;
}

export default Helper.helper(headerDate);
2 changes: 1 addition & 1 deletion tests/integration/helpers/general-date-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ module('Integration | Helper | general date', function(hooks) {
this.set('inputMomentValue', moment('2019-05-01T03:30:00+09:00'));
this.set('inputTimezoneValue', 'Japan');
await render(hbs`{{general-date inputMomentValue inputTimezoneValue}}`);
assert.equal(this.element.innerHTML.trim(), '3:30 AM, May 1st 2019 (JST)');
assert.equal(this.element.innerHTML.trim(), '3:30, May 1st 2019 (JST)');
});
});
2 changes: 1 addition & 1 deletion tests/integration/helpers/header-date-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ module('Integration | Helper | header date', function(hooks) {
this.set('inputMomentValue', moment('2019-05-01T03:30:00+09:00'));
this.set('inputTimezoneValue', 'Japan');
await render(hbs`{{header-date inputMomentValue inputTimezoneValue}}`);
assert.equal(this.element.innerHTML.trim(), 'Wednesday, May 1st 2019, 3:30 AM (JST)');
assert.equal(this.element.innerHTML.trim(), 'Wednesday, May 1st 2019, 3:30 (JST)');
});
});