Propped value of type String is not formatted correctly.
See original GitHub issueWhen propping a String value to the component with a format like so:
<datepicker format="dd/MM/yyyy" value="01/03/2017"></datepicker>
The component doesn’t use the format propped to it, which creates an incorrect date. It will show “03/01/2017” instead of the value propped. I checked the source codes and it looks like the issue is on Datepicker.vue file.
formattedValue () {
if (!this.selectedDate) {
return null
}
return DateUtils.formatDate(new Date(this.selectedDate), this.format, this.translation)
},
On Datepicker.vue, it passes new Date(this.selectedDate)
as the first parameter, it uses the default date format of the Date object which causes the component to return the incorrect value.
Thanks! 👍
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
java - How to nicely format floating numbers to string without ...
Have a look at String. format. You need to use the correct format type, float in this instance. Look at my above answer....
Read more >Improved interpolated strings - C# 10.0 draft specifications
We introduce a new pattern for creating and using interpolated string expressions to allow for efficient formatting and use in both general ...
Read more >Python 3's f-Strings: An Improved String Formatting Syntax ...
As of Python 3.6, f-strings are a great new way to format strings. ... is verbose and leads to errors, like not displaying...
Read more >PEP 3101 – Advanced String Formatting
Within a format string, each positional argument is identified with a number, starting from zero, so in the above example, 'a' is argument...
Read more >Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So, is there a format string for the value? I dont want it to be Date object. I want it to be like “2018-01-12”
Got it. Maybe it is best to put the string format on the read me file to avoid confusion? 😄
Anyway, thanks for checking on my issue. Also, thanks for building this component! 😄