These are chat archives for jquense/react-widgets

12th
Jun 2015
Mathieu M-Gosselin
@mathieumg
Jun 12 2015 01:04
I just got bitten by not providing a culture to https://github.com/jquense/react-widgets/blob/master/src/DateTimePicker.jsx#L40 while using a custom localizer, perhaps something should mention it in the docs or even better it should have a default one of en-US, en, or something like that
Jason Quense
@jquense
Jun 12 2015 01:31
you using your own localizer?
you shouldn't need to provide a culture if you handle it globally somehow
Mathieu M-Gosselin
@mathieumg
Jun 12 2015 01:31
No, the one you wrote for moment.
Jason Quense
@jquense
Jun 12 2015 01:32
ahhh does it not work if you leave off the culture?
admittedly i don't use moment a lot of i18n
Mathieu M-Gosselin
@mathieumg
Jun 12 2015 01:32
it does not, I took a quick look and there is no default culture and it simply gets passed down to the formatter
and it the end it does a moment.locale(undefined) call
Jason Quense
@jquense
Jun 12 2015 01:33
i was assuming that if you passed nothing moment would use the globally set one i guess
Mathieu M-Gosselin
@mathieumg
Jun 12 2015 01:33
which doesnt return something with a format method, so it crashes there
Jason Quense
@jquense
Jun 12 2015 01:34
hmm my understanding was that momet().locale() should return something...
in your code can you do moment.locale('en') before everything and see if that helps?
it may default to nothing, which is weird...
Mathieu M-Gosselin
@mathieumg
Jun 12 2015 01:35
moment.locale() returns the string of your locale
so moment.locale().format() will crash
Jason Quense
@jquense
Jun 12 2015 01:35
oooo gotcha
Mathieu M-Gosselin
@mathieumg
Jun 12 2015 01:36
moment.locale("en") sets the locale to "en" and returns moment
Jason Quense
@jquense
Jun 12 2015 01:36
it should be culture ? ... : moment(value).format()
i was assuming badly that it would behave like the parse does
Mathieu M-Gosselin
@mathieumg
Jun 12 2015 01:37
yep probably, that would be even better I imagine
Jason Quense
@jquense
Jun 12 2015 01:38
thanks for the heads up, i'll push out an update to the localizer
Mathieu M-Gosselin
@mathieumg
Jun 12 2015 01:39
no problem! thanks for the quick reply
Jason Quense
@jquense
Jun 12 2015 01:49
pushed a new version to npm, didn't test it. yolo. let me know if it worked?
Mathieu M-Gosselin
@mathieumg
Jun 12 2015 06:39
haha, I had just left from work! will test it tomorrow morning :) thanks for the fix!
Mathieu M-Gosselin
@mathieumg
Jun 12 2015 15:21
just tested it, it works :+1:
thanks!