almende / chap-links-library

a web based visualization library for displaying graphs, networks, and timelines
http://almende.github.com/chap-links-library
Apache License 2.0
599 stars 167 forks source link

Timeline: render timestamps in UTC? #31

Open joefutrelle opened 12 years ago

joefutrelle commented 12 years ago

My app uses UTC times exclusively; always a PITA in Javascript. I found that I had to hack timeline.js to get the tooltip on the current time to show UTC instead of locale time. IWBNI this was configurable so you could inject a time format when creating the timeline?

joefutrelle commented 12 years ago

This is my diff from timeline v2.2.1:

<     // JMF modified this line to use toISOString to render the date, because
<     // the GBMF OII apps all use UTC. See top of the file for change rationale.
<     // August 31, 2012
<     dom.currentTime.title = "Current time: " + nowOffset.toISOString();
---
>     dom.currentTime.title = "Current time: " + nowOffset;
josdejong commented 12 years ago

Yes, it would be useful to be able to configure the timezones as wel as localization (see also issue #13). It may be an interesting idea to integrate with a Javascript date/time library like moment.js in the future.

mfairchild365 commented 11 years ago

+1 for @josdejong idea to integrate moment.js.

ova2 commented 11 years ago

Time zone support is one of the most required feature for us. And the moment.js looks great! Like it +1.

ova2 commented 11 years ago

But how can we set a time zone in moment.js like "Europe/Berlin"?

ova2 commented 11 years ago

WallTime lib. looks good for me https://github.com/sproutsocial/walltime-js

josdejong commented 11 years ago

But how can we set a time zone in moment.js like "Europe/Berlin"?

Do you want to display dates in another time zone than the local time zone?

ova2 commented 11 years ago

User should choose his preferred time zone. In 99% cases this is his / her local time zone. Time zone on server can differ from the local time zone of course.

To be honest, I don't care about the time zone stuff because we wrapped this great Timeline widget in an JSF (JavaServer Faces) component which provide a "timeZone" attribute. So, we convert dates with given time zone in Java before Timeline displaying. The more important thing is internationalization (i18n) because AFAIK it's hardcoded in the widget and we can not customize text in an easy way.

josdejong commented 11 years ago

moment.js comes with i18n, so that should be solved more or less automatically when switching to moment.js :)

ova2 commented 11 years ago

Ah ok, you are right. Does it also mean, when user add a new event, he / she will see an I18N text "New" as content of the new event? :-)

josdejong commented 11 years ago

well, that is what I meant with "more or less automatically", as there are still some other text messages in the Timeline which must be localized too.

vlsi commented 11 years ago

Moment.js solves the problem of localized date formatting, but it does not solve the Europe/Berlin stuff yet. Javascript does not have "format datetime to string" built-in function, thus something like moment.js is required. https://github.com/timrwood/moment/issues/482#issuecomment-15093627 says full timezone support in moment.js is very close.

must be localized too

Full localization is a plus, but for readonly scenarios "New" buttons do not matter.