• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How do you handle time zones?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do you handle time zones?


  • Subject: Re: How do you handle time zones?
  • From: Alex Cone <email@hidden>
  • Date: Sat, 6 Oct 2007 13:45:25 -0400

So, how do you handle this? Does the browser inform the server of the local time in the http requests? If not, how?


I put something like this on the Login form to snag the TZ from the user's browser, then set up formatters in the session (with input parsers and output formatters) with the captured time zone. The TZ is actually passed as a hidden field in the login form. This is somewhat better than storing the TZ in the db because while I am often in NY, I'm not going to always be logging in from NY.


abc

==== [ ClientTimeZone.js ] ====

// This code lifted from 'http://www.mkolar.org/javascript/ clock.html' and liberally modified

var msie = navigator.userAgent.indexOf("MSIE");
var now = new Date();
var clientTimeZoneOffset = now.getTimezoneOffset(); // = what browser thinks is TZ; but
// MS IE version 3 gives wrong sign of TZ
// MSIE 4.0b2 shifts TZ by -1 hour
// Any other problems?


if (clientTimeZoneOffset) {
if (msie > -1) {
if (navigator.userAgent.substring(msie+5,msie+6) <= 3) {
clientTimeZoneOffset *= -1;
} else {
if (navigator.userAgent.indexOf("4.0b2") > -1) {
clientTimeZoneOffset += 60;
}
}
}
document.write('<input type="hidden" name="x-clientTimeZoneOffset" value="' + clientTimeZoneOffset * 60 * -1 + '" />');
}
===========


(thanks to Ken Anderson who first showed me this trick)

__alex cone
    ceo  codefab  inc
    212 465-8484 x101
    email@hidden
    http://www.codefab.com

If you are not living on the edge, you are taking up too much space.



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Windows XP Dev D2W Issue
  • Next by Date: WebObjects training: who's offering it
  • Previous by thread: fetchlimit rule
  • Next by thread: WebObjects training: who's offering it
  • Index(es):
    • Date
    • Thread