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

Fix date/time format in imagery and history tools #4594

Closed
boothym opened this issue Dec 5, 2017 · 5 comments
Closed

Fix date/time format in imagery and history tools #4594

boothym opened this issue Dec 5, 2017 · 5 comments
Labels
localization Adapting iD across languages, regions, and cultures

Comments

@boothym
Copy link
Contributor

boothym commented Dec 5, 2017

The Esri imagery in my area is much newer than Bing so I used ctrl + shift + B to check its date. It says:

Vintage: 6/2/2016

I thought it was a bit strange, as it was clearly not February since there is an annual summer fairground in the imagery!

Please can you change this to an unambiguous date format which can be understood by those outside the USA 😉 Preferably ISO 8601, i.e. 2016-06-02, thanks.

@boothym
Copy link
Contributor Author

boothym commented Dec 6, 2017

Also noticed the history tool (ctrl + shift + H) has the same problem:

Last Edit: 11/29/2017, 10:10:28 PM

Again this should default to ISO 8601, i.e. 2017-11-29, 22:10:28

@boothym boothym changed the title Fix date format in imagery vintage Fix date/time format in imagery and history tools Dec 6, 2017
@bhousel
Copy link
Member

bhousel commented Dec 6, 2017

Oh interesting - I specifically used toLocaleDateString expecting that it would just do the right thing based on your browser and operating system:

function localeDateString(s) {
if (!s) return null;
var d = new Date(s);
if (isNaN(d.getTime())) return null;
return d.toLocaleDateString();
}

Is your operating system or browser locale set to en-US?

This is a tricky thing to get right in a client side JavaScript app, but I think in all modern browsers I can pass the user's locale to toLocaleDateString in order to tell it what to do :

screenshot 2017-12-05 21 00 58

@bhousel bhousel added the localization Adapting iD across languages, regions, and cultures label Dec 6, 2017
@boothym
Copy link
Contributor Author

boothym commented Dec 6, 2017

I have everything set as en-gb. I've just tested it in Chrome and it works fine - so seems like it's a Firefox problem. 😒 Edge also works with the test below.

https://codepen.io/ssohjiro/pen/BygXox - change one of the options to en-GB and it should give you 13/04/2015. If your language is en-GB and you remove the country code altogether it remains the same in Chrome. But with Firefox it goes back to 4/13/2015.

@bhousel
Copy link
Member

bhousel commented Dec 6, 2017

I've adjusted the date and time formats a little to include the short month (less ambiguous), and I'm now passing the current locale to toLocaleDateString()/toLocaleString(), rather than just relying on the browser to guess correctly.. I also made some style tweaks so that long strings would wrap and display better.

I think it's good!

en-US:

screenshot 2017-12-06 15 20 00

en-GB:

screenshot 2017-12-06 15 21 06

de-DE:

screenshot 2017-12-06 15 18 58

@bhousel bhousel closed this as completed in 18ab596 Dec 6, 2017
@boothym
Copy link
Contributor Author

boothym commented Dec 6, 2017

Nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
localization Adapting iD across languages, regions, and cultures
Projects
None yet
Development

No branches or pull requests

2 participants