• 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: NSNumberFormatter & NSTimestamp -- Not Happening
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNumberFormatter & NSTimestamp -- Not Happening


  • Subject: Re: NSNumberFormatter & NSTimestamp -- Not Happening
  • From: Denis Stanton <email@hidden>
  • Date: Wed, 17 Sep 2003 19:19:30 +1200

Hi Albert

Thank you for taking the time to look into this.

On Wednesday, September 17, 2003, at 04:52  PM, Albert Jagnow wrote:

> I am pretty sure that NSTimestamp is stored in UTC which is not
> affected by daylight savings time.  If you compare two timestamps
> where one was stored on October 25 2003 at 2:00AM local time and the
> other was stored on October 26 2003 at 1:00AM local time after the
> time change, these dates are 24 hours apart even though one is at 2:00
> local time and the other is at 1:00 local time.  If you look at the
> UTC time for each in a database (assuming local time is central time)
> you should see something like 2003-10-25 07:00:00 for the first time
> and 2003-10-26 07:00:00 for the second.  The difference calculation
> below should give you a diff of 24 hours or 1 day.  This is the
> correct difference is it not?

That's not the way it works out in practice.  I am prepared to believe
that that I am causing this through my own ignorance, but my experience
so far suggests that not all days are equal.

I am developing an application for booking rental cars.  The user sets
outDate and returnDate by selecting day number, month name and year
number from three pop-up menus.  These are used to form dates with
approximately the following code:

         NSTimeZone timeZone = NSTimeZone.systemTimeZone();
         outDate = new NSTimestamp(dateYear, dateMonth, dateDay, 0, 0,
0, timeZone);

If I set an outDate of 1 October and a return date of 7th October, and
then use System.out.println to display the results without formatting I
will see:

2003-01-01 12:00:00 Etc/GMT
2003-01-07 11:00:00 Etc/GMT

The user intends renting for a whole week, but performing the
calculation discussed would return a duration of  6.9583 days,
truncated to 6 days.

The workaround is to always add 1 hour before performing the division.
Some weeks will then be 7 days and others 7.0416.  All will truncate to
7.

Maybe the better answer is to set a timezone of UTC in the first place,
but I haven't figured out how to do this so I'm using system time.

Denis
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSNumberFormatter & NSTimestamp -- Not Happening
      • From: Art Isbell <email@hidden>
    • Re: NSNumberFormatter & NSTimestamp -- Not Happening
      • From: Albert Jagnow <email@hidden>
    • Re: NSNumberFormatter & NSTimestamp -- Not Happening
      • From: Chuck Hill <email@hidden>
  • Prev by Date: RE: NSNumberFormatter & NSTimestamp -- Not Happening
  • Next by Date: Re: _eoForGID exception (was: java 1.4 solaris memory issue)
  • Previous by thread: RE: NSNumberFormatter & NSTimestamp -- Not Happening
  • Next by thread: Re: NSNumberFormatter & NSTimestamp -- Not Happening
  • Index(es):
    • Date
    • Thread