• 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: NSDate without time portion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDate without time portion


  • Subject: Re: NSDate without time portion
  • From: Brian Bruinewoud <email@hidden>
  • Date: Wed, 6 Jan 2010 20:55:10 +1100

Wow.

I didn't expect so much conversation from such a 'simple' question. Obviously, not a simple question after all.

My iPhone app records events input by the user. The user can then view a list of events with a count for each day on which there was at least one event.

I've stuck with the code I originally posted:

   NSDateFormatter *dateFmter = [[NSDateFormatter alloc] init];
   [dateFmter setTimeStyle:NSDateFormatterNoStyle];
   [dateFmter setDateStyle:NSDateFormatterMediumStyle];

   NSString dateText = [ dateFmter stringFromDate: self.now ]; // !! !! I need dateText anyway

   self.now = [ dateFmter dateFromString: dateText ]; // !! truncate time to 00:00:00

From the conversation above, my understanding is as follows:

If 'self.now' is now: 2010-01-06 20:40:00 (UTC+11) at the beginning* of the the above code, it will actually be stored as (2010-01-06 10:40:00 UTC) minus epoch as seconds in the memory.

At the end of the code, it will store 2010-01-06 00:00:00 (UTC+11) as 2010-01-05 14:00:00 UTC minus epoch.

Now, if I take the iPhone over to Greenwich, which oscillates between north and south London, and I look at the event, it will say it happened 'Yesterday' 2010-01-05 instead of when I thought it happened, ie: today 2010-10-06. This could be confusing to the user.

Is that a good summary?

I'm not sure how NSDateComponents would stop the user getting confused in this instance.

I'm betting on my users (a) not travelling much; (b) not having events around midnight and (c) not looking at the list of events very often or very carefully. So, in summary, I don't care :)

If I did care, it seems to me that the only option would be to store the date as a string or to store the date and the timezone and display both or something based on the timezone, like a location... (20:40:00 in Melbourne, Australia rather than 20:40:00 AEDT, etc).

Meh.

Thanks,
Brian.

*is 'beginning' really spelled with two 'n's? I get red dots under it with one 'n'..._______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSDate without time portion
      • From: Matthew Lindfield Seager <email@hidden>
References: 
 >NSDate without time portion (From: Brian Bruinewoud <email@hidden>)
 >Re: NSDate without time portion (From: Quincey Morris <email@hidden>)
 >Re: NSDate without time portion (From: Chris Ridd <email@hidden>)
 >Re: NSDate without time portion (From: "Sean McBride" <email@hidden>)
 >Re: NSDate without time portion (From: Chris Ridd <email@hidden>)

  • Prev by Date: Re: Path comparison and case sensitivity
  • Next by Date: Re: Path comparison and case sensitivity
  • Previous by thread: Re: NSDate without time portion
  • Next by thread: Re: NSDate without time portion
  • Index(es):
    • Date
    • Thread