A date-time is a date-time, regardless of how it is 
displayed or entered or obtained from the system.

The whole purpose of the NSDate object is to allow easy
comparison, and determination of intervals by subtraction...
well, a couple of the main purposes... and be able to
display dates and intervals as appropriate to the context.

Calendar systems and date display formats don't lend 
themselves to such calculations, and change-overs from
one calendar to another have made it more difficult.

> On Fri, 2010/04/09, Ashley Clark <acl...@ghoti.org> wrote:
> From: Ashley Clark <acl...@ghoti.org>
> Subject: Re: How do I compare two NSDates using NSPredicate & Core Data
> To: "Sean McBride" <s...@rogue-research.com>
> Cc: Cocoa-dev@lists.apple.com
> Date: Friday, 2010 April 9, 12:52
>> On 2010 Apr 5, at 19:02, Sean McBride wrote:
>>> On Sun, 2010 Apr 04 23:15:16 -0400, Michael A. Crawford said:
>>> Thus far I've gotten away with using
>>> -predicateWithFormat and scalar
>>> values.  I now need to compare a couple of
>>> NSDate instances but am not
>>> sure how to code it up with NSPredicate. 
>>> Consider me a 'visual' learner.
>>
>> I'm pretty sure you can use just <, >, ==, etc.
>> with NSDates in NSPredicates.
>
> One thing that many people overlook is that NSDates
> *always* include a time component. And if that time
> wasn't specified explicitly it typically defaults
> to a preset value set in the editing control (if
> one was used) or the current time at the time the
> date string was parsed.
> 
> So, if you were expecting to compare a set of NSDate
> objects to be on a particular date irrespective of
> their time value... you have a bit of work to do.
> A simple way to approximate the test is to look at
> a time range from midnight to midnight-1 second
> of the following day.
>
> That of course leaves another issue aside though,
> that of differing timezones. All NSDate objects are
> converted to the local timezone by default and the
> original timezone information is not stored in the
> object, so an NSDate created as {2010/01/01 23:59 EDT}
> when read back at some later point when the computer
> is now on the west coast (PDT) would show as
> {2009/12/31 20:59 PDT}.
> 
> All of that to say, comparing dates with predicates
> (or at all) is hard.



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to