Skip to content

Commit 70f296c

Browse files
author
daretobedifferent18
committed
Revert changes
1 parent 64bde57 commit 70f296c

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{general-date @record @props.options.timezone '' @props.options.dateFormat}}
1+
{{general-date @record @props.options.timezone @props.options.dateFormat}}

app/helpers/test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Helper from '@ember/component/helper';
2+
import moment from 'moment';
3+
4+
const locales12Hours = new Set(['en', 'bn', 'hi', 'id', 'ja', 'run', 'th', 'vi', 'ko']);
5+
6+
export function generalDate(params) {
7+
const timezone = params[1] || moment.tz.guess();
8+
const reg = new RegExp('[+-]?[0-9]+');
9+
const local = moment(params[0]).tz(timezone).locale();
10+
11+
let format = params[2] || 'dddd, D MMMM, YYYY h:mm A (z)';
12+
13+
if (!locales12Hours.has(local)) {
14+
format = format.replaceAll('h', 'H');
15+
format = format.replace(' A', '');
16+
format = format.replace(' a', '');
17+
}
18+
19+
let dateTime = moment(params[0]).tz(timezone).format(format);
20+
const z = moment(params[0]).tz(timezone).format('z');
21+
22+
if (reg.test(z)) {
23+
dateTime = dateTime.replace(z, timezone);
24+
}
25+
26+
return dateTime;
27+
}
28+
29+
export default Helper.helper(generalDate);

0 commit comments

Comments
 (0)