Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
13 changes: 12 additions & 1 deletion app/helpers/general-date.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import Helper from '@ember/component/helper';
import moment from 'moment';

const locales12Hours = new Set(['en', 'bn', 'hi', 'id', 'ja', 'run', 'th', 'vi', 'ko']);

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

const local = moment(params[0]).tz(timezone).locale();

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

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

Expand Down
14 changes: 13 additions & 1 deletion app/helpers/header-date.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import Helper from '@ember/component/helper';
import moment from 'moment';

const locales12Hours = new Set(['en', 'bn', 'hi', 'id', 'ja', 'run', 'th', 'vi', 'ko']);

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()})`;

const local = moment(params[0]).tz(timezone).locale();

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

if (!locales12Hours.has(local)) {
format = format.replace('h', 'HH');
format = format.replace(' A', '');
}

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

export default Helper.helper(headerDate);