@@ -28,9 +28,24 @@ let datetimeObject = Ember.Object.extend({
28
28
date : Ember . computed ( 'option.title' , function ( ) {
29
29
return moment ( this . get ( 'option.title' ) ) ;
30
30
} ) ,
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
+ ) ;
33
47
} ) ,
48
+ i18n : Ember . inject . service ( ) ,
34
49
option : null ,
35
50
time : Ember . computed ( 'option.title' , {
36
51
get ( ) {
@@ -136,10 +151,13 @@ export default Ember.Component.extend(Validations, {
136
151
return moment ( option . get ( 'title' ) ) . isValid ( ) ;
137
152
} ) ;
138
153
154
+ const container = this . get ( 'container' ) ;
139
155
// return an array of datetime object for all valid date strings
140
156
return validDates . map ( ( option ) => {
141
157
return datetimeObject . create ( {
142
- option
158
+ option,
159
+ // necessary for service injection
160
+ container
143
161
} ) ;
144
162
} ) ;
145
163
}
0 commit comments