It really doesn't have to be traumatic :)

You can search through the mailing list - there have been numerous discussions in the past. What's important is that the timezone you're using consistent.

Most importantly, EOF has an attribute that I always set on attributes:

            serverTimeZone = GMT;

I'm not sure what this defaults to anymore, but I find it useful to make sure EOF is always looking at dates as being in GMT. Also, if there's something that I always want to be a date, I use this code:

                                        GregorianCalendar cal = new 
GregorianCalendar();
                                        cal.setTime(sourceDateTime);
                                        int year = 
cal.get(GregorianCalendar.YEAR);
                                        int dayOfMonth = 
cal.get(GregorianCalendar.DAY_OF_MONTH);
                                        int month = 
cal.get(GregorianCalendar.MONTH);
NSTimestamp outputDate = new NSTimestamp(year, month+1, dayOfMonth, 0, 0, 0, TimeZone.getTimeZone("GMT"));


I make sure that be default, the entire WO app is thinking in GMT:

                TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
                NSTimeZone.setDefault(TimeZone.getTimeZone("GMT"));

Lastly, if I'm doing something where users need to see dates and times, I always like them to see the date and time in their own time zone. To do that, I have some javascript that determines the time zone of the user's computer:

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 + '" />');
}

and places a new element in the header. I put this javascript on an early page, like the login page. I then grab the header and set a formatter in the user's session for their own time zone.

I realize there are some serious machinations here, but all in all, it works and people can use the site from anywhere on the planet and see the right time.

Ken



On May 15, 2006, at 5:39 PM, WebObjects wrote:

YUCK!  Are you saying that if a user is entering a date that I have to
relate what time zone my server is in, vs. GMT, and ensure that it always
corresponds?  This does sound nasty.

Just to be certain I understand... If I submit a date, and 'today' isn't
the same day as it is in 'GMT', then my submission will be adjusted
accordingly, UNLESS I send GMT along with it?

Why do I feel like I just confused myself?  And why do I editorialize?

-Bill


on 5/15/06 14:32, Art Isbell at [EMAIL PROTECTED] wrote:

On May 15, 2006, at 11:25 AM, WebObjects wrote:

I output the date it's sending to the EC to save, and get "1919-02-24
08:00:00 Etc/GMT" - showing 'GMT' as the timezone.  I'm in Los
Angeles - a
far way from the GMT.

1919-02-24 08:00:00 Etc/GMT may have been 1919-02-23 in PST assuming
that PST existed in 1919.  Dates and time zones are such nasty
concepts, especially in the distant past.  Because the JDBC version
used by EOF doesn't support a "datetime with timezone" data type, all
datetime values are stored in GMT.  So you'll need to decide how you
want to display dates and do the time zone adjustments yourself.

Aloha,
Art

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/webobjects% 40concyse.com

This email sent to [EMAIL PROTECTED]


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/lists% 40anderhome.com

This email sent to [EMAIL PROTECTED]

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com

Reply via email to