Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing in a date with yyyy-MM-dd format selects wrong day #678

Open
lvsof opened this issue Feb 13, 2019 · 15 comments
Open

Typing in a date with yyyy-MM-dd format selects wrong day #678

lvsof opened this issue Feb 13, 2019 · 15 comments

Comments

@lvsof
Copy link

lvsof commented Feb 13, 2019

It would be great to allow direct input of the MySQL format but typing it in triggers the previous day to be selected in the calendar.

screen shot 2019-02-13 at 6 43 44 pm

'yyyy-MM-d' format works as expected.

screen shot 2019-02-13 at 6 44 45 pm

@dekadentno
Copy link

Bump. Same issue here.

@vishnurajoria
Copy link

I'm too having the same issue. Any fix for this?

@Johndavidsanford
Copy link

Same. Bump

@Johndavidsanford
Copy link

In order to fix this in my project I changed the parseTypedDate method as follows...
parseTypedDate: function parseTypedDate (event) { // close calendar if escape or enter are pressed if ([ 27, // escape 13 // enter ].includes(event.keyCode)) { this.input.blur(); } if (this.typeable) { var typedDate = Date.parse(this.input.value.replace(/-/g,'/')); if (!isNaN(typedDate)) { this.typedDate = this.input.value; this.$emit('typedDate', new Date(this.typedDate.replace(/-/g,'/'))); } } },

@gauravmak
Copy link

One may be facing this issue based on the timezone. If you're behind UTC, you may be facing this issue. This is related to how the browser parses the date.

To illustrate, try typing new Date('2019-06-20') in your browser console and check the output. You may see '19th June' there.

While typing new Date(2019, 05, 20) (Months start from 0 here) brings expected output.

The library can be updated to parse the date this way to solve this issue.

@PatrickCaneloDigital
Copy link

PatrickCaneloDigital commented Jul 20, 2019

uhhh, that's really a bummer to see that...
to bizarre this behaviour...

new Date(): Date Sat Jul 20 2019 16:20:14 GMT-0400 (Chilenische Normalzeit)
new Date('2019-07-20'): Date Fri Jul 19 2019 20:00:00 GMT-0400 (Chilenische Normalzeit)

So apparently new Date('2019-07-20') is parsed with hours: 00:00:00 so it discounts 4 hours ()in my case because of the timezone offset thus giving 24-4hrs=20.

THERE IS A DIFFERENT WORKAROUND
As mentioned above, you could divide the date string into year, month, day and pass the value with commas
OR
instead of passing only the date as value, add the GMT difference to it (OBS: only for negative GMTs, in the case of positive GMT differences there's nothing to do)
e.g.: :value="this.date+' '+ (new Date().getTimezoneOffset()/60)+':00:01'"
this creates '2019-07-20 4:00:01' which, when discounting the offset should give the right result
At least in my case with GMT-4 it outputs the correct Date

Just as an explanation: getTimezoneOffset is outputting minutes, not hours, and in a timezone -4 it will output a positive value 240. this is why the value has to be divided by 60 and needs not to be put negative... I know, bizarre, but at least there's a workaround

@procedurallygenerated
Copy link

Until the library is fixed one work around can be to just add a fictional 12pm time? So new Date(this.date+'T12:00:00') +11 to -11 no matter which timezone they are in it'll still be the right day

@maxim25
Copy link

maxim25 commented Aug 13, 2020

Until the library is fixed one work around can be to just add a fictional 12pm time? So new Date(this.date+'T12:00:00') +11 to -11 no matter which timezone they are in it'll still be the right day

You'd think so but no, it can still cause issues with certain timezones

@mikeerickson
Copy link

Wow, this is quite a dated issue and still not update? Does anyone know the status of this project? Has it been "abandoned"

@mikeerickson
Copy link

@maxim25 You recently commented on this project so I thought I would ping you. I am trying to use this component and allow users to enter into the component object, but I can't seem to figure out how to enable data entry? Is this something that should work by default, or must I enable it (I don't see it as an available prop?)

@maxim25
Copy link

maxim25 commented Aug 14, 2020

@maxim25 You recently commented on this project so I thought I would ping you. I am trying to use this component and allow users to enter into the component object, but I can't seem to figure out how to enable data entry? Is this something that should work by default, or must I enable it (I don't see it as an available prop?)

Add
:typeable="true"

@mikeerickson
Copy link

@maxim25 thank you so much, I can’t believe I missed that. I read and reread the props section but bypassed it obviously.

@inopinatus
Copy link

inopinatus commented Feb 5, 2021

This is such a severe bug - that picking one date results in another being recorded - that it can only serve as an indicator of an abandoned project.

@maxKimoby
Copy link

Bumping

1 similar comment
@stotes
Copy link

stotes commented Sep 30, 2021

Bumping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests