Closed dxvladislavvolkov closed 6 years ago
There's no day
option and it's therefore ignored. Please, check https://github.com/globalizejs/globalize/blob/master/doc/api/date/date-formatter.md
You should get a formatter with default options and I believe that's what you get. Otherwise, please let me know and I will reopen this bug.
@rxaviers this is my problem. when I pass the wrong option, I get a formatter by default (although I expect an error, as it was before)
I've verified that on 1.1.1 we get an error like you mention:
Globalize('en').dateFormatter({foo: "bar"})
[object Object]: E_INVALID_PAR_VALUE: Invalid `{"name":"options","value":{"foo":"bar"}}` value (undefined).
But that was certainly a bug. Still on 1.1.1, other formatters don't behave like that.
Globalize('en').numberFormatter({foo:"bar"})
{ [Function: numberFormatter], ...}
On JavaScript, usually the kind of assertion you mention isn't performed, e.g.:
// Ignores foo: "bar" as well.
new Intl.DateTimeFormat('en', {foo: "bar"})
{}
Can you share a little more details on your use case? Why do you need that?
I used to catch the error when I passed e.g. { day: 'numeric' } to the method. Now I get the function as the return value. Is it breaking change? or bug? You can see examples
Globalize 1.1.1 (get error) http://plnkr.co/edit/wzRAJFW09PGhW8pr2Tne?p=preview
Globalize 1.3.0 (get function) http://plnkr.co/edit/m1cYmQ7FWcrHbLKvJUyu?p=preview