Skip to content

Commit 255c6a9

Browse files
committed
Fixes #80
1 parent e8b6776 commit 255c6a9

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

app/components/create-options-datetime.js

+21-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,24 @@ let datetimeObject = Ember.Object.extend({
2828
date: Ember.computed('option.title', function() {
2929
return moment(this.get('option.title'));
3030
}),
31-
dateString: Ember.computed('date', function() {
32-
return this.get('date').format('YYYY-MM-DD');
31+
dateString: Ember.computed('date', 'i18n.locale', function() {
32+
const date = this.get('date');
33+
const locale = this.get('i18n.locale');
34+
35+
// moment caches locale so we have to check if it's changed
36+
if (date.locale() !== locale) {
37+
date.locale(locale);
38+
}
39+
40+
return date.format(
41+
moment.localeData()
42+
.longDateFormat('LLLL')
43+
.replace(
44+
moment.localeData().longDateFormat('LT'), '')
45+
.trim()
46+
);
3347
}),
48+
i18n: Ember.inject.service(),
3449
option: null,
3550
time: Ember.computed('option.title', {
3651
get() {
@@ -136,10 +151,13 @@ export default Ember.Component.extend(Validations, {
136151
return moment(option.get('title')).isValid();
137152
});
138153

154+
const container = this.get('container');
139155
// return an array of datetime object for all valid date strings
140156
return validDates.map((option) => {
141157
return datetimeObject.create({
142-
option
158+
option,
159+
// necessary for service injection
160+
container
143161
});
144162
});
145163
}

0 commit comments

Comments
 (0)