Misunderstanding or bug?
Misunderstanding or bug?
Alchetec
Posts: 14Questions: 5Answers: 0
I have the following field definition:
{
"label": "To",
"name": "PermissionToEnter.allow_to",
"type": "datetime",
"format": "MM-DD-YYYY",
"def": function () { return new Date() },
"opts": {
"firstDay" : 0,
"minDate": new Date()
}
},
The default date is correct, but the minDate does not seem to be working i.e. I cannot select the current date. I can select tomorrow but not today.
I am I misunderstanding how things should work of is this a bug?
Thanks!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The issue if the
new Date()
gives the date and the time - i.e. it might be 29th Feb 2016 13:45:10, but because the calendar aspect of thedatetime
field uses just the date part if you add the time then it appears to be greater - hence why it won't let you select that date.What you probably need to do is something like:
Allan
So I did as you showed but things where funky so I did the following:
Which kind of worked BUT the current date when the calendar pops up shows tomorrow. I did this at 2016-03-04 @ 14:50 but the calendar shows its the 5th.
Could you give me a link to the page show I can debug it please? Also, what time zone are you in?
Allan
Sorry for the delay, I am in the Central time zone. I sent you the page link in an email. Please let me know if you did not receive it. Thanks!
Super - thanks for the information and also the PM with the link. The error is in how Editor calculates today's date - its wrong for timezones with a negative UTC offset. I've committed the fix and it will be in Editor 1.5.6 which I expect to be available early / mid April.
In the mean time, if you'd like to make the change locally, search the Editor code for:
And replace with:
The problem was that
toDateString()
uses local time, while Editor's date handling is in UTC as much as possible.Regards,
Allan