-
Couldn't load subscription status.
- Fork 120
fix date_input not using dateFormat to parse #360
Conversation
|
@lejard-h Could you provide a minimal repro of the issue so we can see how the issue appears? |
|
and try to select October 8 for example, after you will need to double click on input to open dialog, and the date will be August 10 |
|
This does not seem to handle every case, it works on my timezone but this is probably an if you take the following code final format = DateFormat('dd/MM/y');
final str = '05/08/2018';
final date = format.parseLoose(str);
print(date);
print(format.format(date));it print but with I will follow the bug to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. The general approach looks good, but I'd want to see a regression test before merging this. Left a couple of other comments also.
| /// Returns the parsed date, or null if the string didn't match any format. | ||
| Date _parseDateUsingFormatList(String input, List<DateFormat> formatList) { | ||
| Date date; | ||
| formatList.any((format) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you're here, can you replace this .any() call with a regular for loop? This construction is pretty odd.
| // DateTime's max allowed time | ||
| return false; | ||
| } | ||
| date = _parseDateUsingFormat(input, format); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Careful - this is the member variable date, not a local. We should define a local variable to avoid interfering with the state of the component.
Ideally this method would be static.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I just had an issue about this, this should be fix now but I will do some renaming work to avoid it and make it static
fix date_input not using dateFormat to parse use the given `dateFormat` to decode the input value. for the following format `dd/mm/yy`, the parser was inversing month and days, `08/12/2018` -> `12/08/2018` Closes #360 PiperOrigin-RevId: 244367402
use the given
dateFormatto decode the input value.for the following format
dd/mm/yy, the parser was inversing month and days,08/12/2018->12/08/2018