• 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: NSTimestamp bug??
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTimestamp bug??


  • Subject: Re: NSTimestamp bug??
  • From: Jonathan Rochkind <email@hidden>
  • Date: Mon, 5 Apr 2004 10:56:54 -0500

Figuring out how to properly do date arithmetic in WO is confusing---there are too many date/time classes in Java already, and then Apple adds one more, NSTimestamp. And both the Java classes _and_ the Apple class have a history of bugs---I can never remember the current status of such bugs in a given Java/WO version. I don't know for sure why you are seeing the behavior you are seeing, but given the day you are trying it is right around the US daylight savings time switch, I suspect daylight savings time might be implicated. (So if you want to test doing this a different way, you might want to make sure to use the same input, so it's still right around the DST switch, to make sure a different way is truly different).

When I do date arithmetic, I always use Java GregorianCalendar instead of NSTimestamp's own methods. Which at one point is what the NSTimestamp documentation reccomended you do, but I'm not sure it does anymore. But I seem to have had luck with it.

NSTimestamp timestamp; //assume exists
//Create a GregorianCalendar matching the timestamp value
 GregorianCalendar myCalendar = new GregorianCalendar();
 myCalendar.setTime(myNSTimestamp);
//go back one calendar day
myCalendar.add(  GregorianCalendar.DATE, -1 );
//translate back to NSTimestamp
timestamp = new NSTimestamp( myCalendar.getTime() );

--Jonathan


At 11:25 AM -0400 4/5/04, Tom Pelaia wrote:
It appears to me that the timestampByAddingGregorianUnits() method of NSTimestamp does not properly handle changing by day increments. The documentation claims that the method preserves "clock time" across daylight savings changes, but that doesn't appear to be happening in my application. Instead when I start from 00:00 on today (Monday) and go back one day I get 23:00 on Saturday. Has anyone else seen this issue or does it indicate something wrong with the system clock on our server?

thanks,
-tom

--
Tom Pelaia
SNS Project, 701 Scarboro Road, MS-6473, Oak Ridge, TN 37830
phone: (865)574-6421, fax: (865)574-6617
_______________________________________________
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.
_______________________________________________
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.


References: 
 >NSTimestamp bug?? (From: Tom Pelaia <email@hidden>)

  • Prev by Date: Re: Destroying a page instance
  • Next by Date: Re: refuseNewSessions knocks out app instance
  • Previous by thread: NSTimestamp bug??
  • Next by thread: Re: NSTimestamp bug??
  • Index(es):
    • Date
    • Thread