Re: NSDate without time portion

2010-01-06 Thread Matthew Lindfield Seager
Yeah... There are many situations that the simple way will be right 99% of the time... And for the other 1% I reckon 99% of affected users will forgive you for not wasting bug hunting time worrying about leap seconds... Of course 72.3% of statistics are made up on the spot so don't quote me on tho

Re: NSDate without time portion

2010-01-06 Thread Brian Bruinewoud
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

Re: NSDate without time portion

2010-01-05 Thread Chris Ridd
On 5 Jan 2010, at 20:56, Sean McBride wrote: > On 1/5/10 7:23 PM, Chris Ridd said: > >> However Core Data models "dates" using NSDate. If you needed to model >> dates without times in Core Data (and be able to sort/filter on them) >> what would you do? > > Core Data has the concept of a 'transf

Re: NSDate without time portion

2010-01-05 Thread Quincey Morris
On Jan 5, 2010, at 13:43, mmalc Crawford wrote: > I'm not sure what the point is here, though? Well, taking what's likely a rhetorical question literally, the point (at least my point) is that switching from dates represented by conceptual structures such as NSDateComponents + NSCalendar + time

Re: NSDate without time portion

2010-01-05 Thread Henry McGilton (Boulevardier)
On Jan 5, 2010, at 1:43 PM, mmalc Crawford wrote: > > On Jan 5, 2010, at 1:35 pm, Kyle Sluder wrote: > >> On Tue, Jan 5, 2010 at 1:23 PM, mmalc Crawford wrote: >>> An NSDate object represent a single point in time -- you can think of it >>> basically as a wrapper for an NSTimeInterval from th

Re: NSDate without time portion

2010-01-05 Thread Greg Guerin
Many good points have already been made. Just wanted to add: http://en.wikipedia.org/wiki/Julian_day "The Julian day number can be considered a very simple calendar, where its calendar date is just an integer. This is useful for reference, computations, and conversions. It allows the time b

Re: NSDate without time portion

2010-01-05 Thread mmalc Crawford
On Jan 5, 2010, at 1:35 pm, Kyle Sluder wrote: > On Tue, Jan 5, 2010 at 1:23 PM, mmalc Crawford wrote: >> An NSDate object represent a single point in time -- you can think of it >> basically as a wrapper for an NSTimeInterval from the reference date. If >> you want to create components from

Re: NSDate without time portion

2010-01-05 Thread Kyle Sluder
On Tue, Jan 5, 2010 at 1:23 PM, mmalc Crawford wrote: > An NSDate object represent a single point in time -- you can think of it > basically as a wrapper for an NSTimeInterval from the reference date.  If you > want to create components from the date, then you must do so with respect to > a par

Re: NSDate without time portion

2010-01-05 Thread mmalc Crawford
On Jan 5, 2010, at 1:02 pm, Quincey Morris wrote: > The OP wanted to use NSDate objects to avoid the clunkiness of multiple > values/variables with NSDateComponents. I'm arguing that avoiding > NSDateComponents is a *lot* more work, and that using NSDate for this purpose > is *very* easy to ge

Re: NSDate without time portion

2010-01-05 Thread Robert Claeson
On 5 Jan 2010, at 20:59, mmalc Crawford wrote: > > On Jan 5, 2010, at 12:40 pm, Robert Claeson wrote: > >> (Greenwich, the "G" in GMT, is in North London) >> > Well, if we're being pedantic, South East of London, actually... >

Re: NSDate without time portion

2010-01-05 Thread Quincey Morris
On Jan 5, 2010, at 12:33, Nick Zitzmann wrote: > On Jan 5, 2010, at 1:23 PM, Quincey Morris wrote: > >> Firstly, you can't *in general* normalize to a specific time, because you >> can't in general know that the time exists on every date. > > Unless you use a specific time zone, and store that

Re: NSDate without time portion

2010-01-05 Thread mmalc Crawford
On Jan 5, 2010, at 12:40 pm, Robert Claeson wrote: > (Greenwich, the "G" in GMT, is in North London) > Well, if we're being pedantic, South East of London, actually...

Re: NSDate without time portion

2010-01-05 Thread Sean McBride
On 1/5/10 7:23 PM, Chris Ridd said: >However Core Data models "dates" using NSDate. If you needed to model >dates without times in Core Data (and be able to sort/filter on them) >what would you do? Core Data has the concept of a 'transformable' type. You can use it to store an NSDateComponents (

Re: NSDate without time portion

2010-01-05 Thread Nick Zitzmann
On Jan 5, 2010, at 1:40 PM, Robert Claeson wrote: > Not really. We use GMT (Greenwich, the "G" in GMT, is in North London) here > in the UK and we do have daylight savings. GMT without daylight savings or > any other features are commonly referred to as UTC nowadays. To be pedantic, you are co

Re: NSDate without time portion

2010-01-05 Thread Robert Claeson
On 5 Jan 2010, at 20:33, Nick Zitzmann wrote: > > On Jan 5, 2010, at 1:23 PM, Quincey Morris wrote: > >> Firstly, you can't *in general* normalize to a specific time, because you >> can't in general know that the time exists on every date. > > Unless you use a specific time zone, and store th

Re: NSDate without time portion

2010-01-05 Thread Nick Zitzmann
On Jan 5, 2010, at 1:23 PM, Quincey Morris wrote: > Firstly, you can't *in general* normalize to a specific time, because you > can't in general know that the time exists on every date. Unless you use a specific time zone, and store that time zone information elsewhere in the model. And if you

Re: NSDate without time portion

2010-01-05 Thread Karolis Ramanauskas
> > NSDate conceptually store time relative to Jan 1, 2001, GMT. > > When it is formatted for display, it uses the current time zone (or more > correctly, the NSDateFormatter uses whatever time zone has been specified, > or the current system time zone). If your time zone changes (such as by > day

Re: NSDate without time portion

2010-01-05 Thread David Duncan
On Jan 5, 2010, at 12:15 PM, Chris Ridd wrote: > On 5 Jan 2010, at 19:41, Nick Zitzmann wrote: > >> >> On Jan 5, 2010, at 12:23 PM, Chris Ridd wrote: >> >>> However Core Data models "dates" using NSDate. If you needed to model dates >>> without times in Core Data (and be able to sort/filter on

Re: NSDate without time portion

2010-01-05 Thread Quincey Morris
On Jan 5, 2010, at 11:31, David Duncan wrote: >> However Core Data models "dates" using NSDate. If you needed to model dates >> without times in Core Data (and be able to sort/filter on them) what would >> you do? > > > The typical approach is to normalize your dates to a specific time before

Re: NSDate without time portion

2010-01-05 Thread Chris Ridd
On 5 Jan 2010, at 19:41, Nick Zitzmann wrote: > > On Jan 5, 2010, at 12:23 PM, Chris Ridd wrote: > >> However Core Data models "dates" using NSDate. If you needed to model dates >> without times in Core Data (and be able to sort/filter on them) what would >> you do? > > Normalize the time co

Re: NSDate without time portion

2010-01-05 Thread glenn andreas
On Jan 5, 2010, at 1:48 PM, Karolis Ramanauskas wrote: >> >> By formatting the dates as MMDD and keeping them in strings you can use >> simple string comparison to sort, compare and filter. They are also very >> easy to format for display purposes. If you want to go standard then use the >>

Re: NSDate without time portion

2010-01-05 Thread Karolis Ramanauskas
> > By formatting the dates as MMDD and keeping them in strings you can use > simple string comparison to sort, compare and filter. They are also very > easy to format for display purposes. If you want to go standard then use the > ISO 8601 date format. It's -MM-DD. See > http://www.iso.org

Re: NSDate without time portion

2010-01-05 Thread Nick Zitzmann
On Jan 5, 2010, at 12:23 PM, Chris Ridd wrote: > However Core Data models "dates" using NSDate. If you needed to model dates > without times in Core Data (and be able to sort/filter on them) what would > you do? Normalize the time component of the date. One idea is to use 12 PM GMT as a const

Re: NSDate without time portion

2010-01-05 Thread Robert Claeson
On 5 Jan 2010, at 19:23, Chris Ridd wrote: > > On 4 Jan 2010, at 13:50, Quincey Morris wrote: > >> On Jan 4, 2010, at 02:26, Brian Bruinewoud wrote: >> >>> What's the best way to get an NSDate object for 'today' such that the time >>> is 00:00:00 (or any other constant). >>> I not interested

Re: NSDate without time portion

2010-01-05 Thread David Duncan
On Jan 5, 2010, at 11:23 AM, Chris Ridd wrote: > However Core Data models "dates" using NSDate. If you needed to model dates > without times in Core Data (and be able to sort/filter on them) what would > you do? The typical approach is to normalize your dates to a specific time before storing

Re: NSDate without time portion

2010-01-05 Thread Chris Ridd
On 4 Jan 2010, at 13:50, Quincey Morris wrote: > On Jan 4, 2010, at 02:26, Brian Bruinewoud wrote: > >> What's the best way to get an NSDate object for 'today' such that the time >> is 00:00:00 (or any other constant). >> I not interested in the time, I only care about the year-month-day, but I

Re: NSDate without time portion

2010-01-04 Thread Quincey Morris
On Jan 4, 2010, at 02:26, Brian Bruinewoud wrote: > What's the best way to get an NSDate object for 'today' such that the time is > 00:00:00 (or any other constant). > I not interested in the time, I only care about the year-month-day, but I do > need the the hours-minutes-seconds to be the same

NSDate without time portion

2010-01-04 Thread Brian Bruinewoud
Hi All, What's the best way to get an NSDate object for 'today' such that the time is 00:00:00 (or any other constant). I not interested in the time, I only care about the year-month-day, but I do need the the hours-minutes-seconds to be the same on all dates so that I can compare the dates. C