Simplified users Timezone handling
David Balažic
xerces9 at gmail.com
Mon Nov 23 12:26:38 UTC 2009
(originally posted on nntp mozilla.support.bugzilla :
http://groups.google.com/group/mozilla.support.bugzilla/browse_thread/thread/c36721d5ec8f8820/cfcdad7d5af3405d
posting here on suggestion from Max Kanat-Alexander <mkanat at bugzilla.org>)
Hi!
In version 3.4.3 for the displaying times and dates in users timezone,
currently this is required:
- a bunch of code on the server (bugzilla)
- user must login (on each visit, unless "cookied")
- user must set timezone in preferences
I suggest a much simpler solution:
- a few lines of code in the server
That's it. No user action required.
This solution also automatically handles daylight saving time changes.
It puzzles me why (web) server software writers go through all this
trouble when a few lines of code does it all ;-)
The code (as sent to users web browser):
Time of action (in your local tz !): <script type="text/javascript">
<!--
var time1 = new Date(654323545*);
Document.write(time1.toLocaleString());
//-->
</script><noscript>2002-11-27 08:09 PDT**</noscript>
* - the time as miliseconds since epoch inserted by server
** - regular time inserted by server, as it is done now (or before,
when it was always in servers TZ)
It needs Java/ECMAScript, obviously, so the NOSCRIPT fallback.
JS is already used so while many (me included) think JS is evil, this
is no change in that regard.
If user happens to have no JS (or have disabled it), a fallback to old
behavior is done, so no harm.
Regards,
David
More information about the developers
mailing list