HTBox / crisischeckin

Crisischeckin Humanitarian Toolbox repository
Apache License 2.0
173 stars 157 forks source link

Wrong date is displayed on the Home page in the volunteer form #116

Open moranlf opened 10 years ago

moranlf commented 10 years ago

The default date if I understand correctly should be DateTime.Now. However, I'm seeing a strange behavior - The default date changes on every refresh. I think it has something to do with the fact that I'm on a non-us pc (I'm from Israel) with a different date/time format. When I changed the datepicker setdate value to DateTime.Now.Date, the date was consistent (it didn't change on each refresh) but it still wasn't the current date. I'm pretty new to MVC and jquery, but I guess that the current format should be taken into consideration. Being an application for global crisis support, I believe that this is pretty important.

BillWagner commented 10 years ago

This is an interesting issue. I agree that this is important. I'll ask a couple colleagues for some suggestions on how best to address it.

BillWagner commented 10 years ago

Scott,

Do you want to take this one on?

Cheers, Bill Wagner http://theBillWagner.com / @billwagner / bill.w.wagner@outlook.com / 734.645.9709

From: ScottSEA Sent: ‎Wednesday‎, ‎January‎ ‎22‎, ‎2014 ‎11‎:‎31‎ ‎AM To: HTBox/crisischeckin Cc: Bill Wagner

This may be as simple as changing to DateTimeOffset.Now.

— Reply to this email directly or view it on GitHub.

ScottSEA commented 10 years ago

Yep, I would love to. I'll probably get to it this weekend.

On Thu, Jan 23, 2014 at 7:48 AM, Bill Wagner notifications@github.comwrote:

Scott,

Do you want to take this one on?

Cheers, Bill Wagner http://theBillWagner.com / @billwagner / bill.w.wagner@outlook.com / 734.645.9709

From: ScottSEA Sent: Wednesday, January 22, 2014 11:31 AM To: HTBox/crisischeckin Cc: Bill Wagner

This may be as simple as changing to DateTimeOffset.Now.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHubhttps://github.com/HTBox/crisischeckin/issues/116#issuecomment-33135338 .

moranlf commented 10 years ago

Make sure to test it on systems with different cultures, as this bug was discovered on a system with a Hebrew locale. I'll be happy to test your fix on my system before the merge if you want.

ScottSEA commented 10 years ago

Troubleshooting Note:
I changed the region on my computer (Win8) to Israel and was unable to duplicate the issue; refreshing the page was rock solid.

I then opened the Region dialog and changed the Format dropdown to "Hebrew (Israel)". Refreshing the page then gave me a seemingly random date - seemingly random month and day, but all in 2019.

Troubleshooting continues, but at least I can duplicate the issue. The thing I find surprising isn't that the date is wrong - I get that part - but that the date is different on subsequent refreshes. This makes no sense to me whatsoever.

The DatePicker UI control has several .js files for localization of the control. I'll update the page to detect the local format and load the right localization file.

moranlf commented 10 years ago

Yes, that is exactly the issue I was facing.

mjmilan commented 8 years ago

I must admit that I too have had issues with the dates, but rather naughtily didn't pursue them. I am in the United Kingdom, and our date format is dd/mm/yyyy, as opposed to this mm/dd/yyyy nonsense that our American cousins prefer...

I beiieve I found that the date picker was assigning dates to the textbox in the American format, and that when they were then submitted the values in the textbox were interpretted using the UK format. So, for instance, if I use the date picker to choose the 13th of April 2016, then the textbox will read "04/13/2016" - the American format. When I submit the form, this would be parsed into an actual datetime using the UK format, meaning an exception would be raised when it was found there isn't a thirteenth month of the year...

Done properly, I suspect both the date picker and the parsing should be looking at the request header to determine the client's culture settings, then working accordingly. Someone should investigate whether this is indeed an option - ie does the date picker support other cultures, and can the culture be selected based on the client as opposed to the server...