~ubuntu-branches/ubuntu/trusty/gnustep-base/trusty

« back to all changes in this revision

Viewing changes to Source/NSDate.m

Tags: upstream-1.11.2
ImportĀ upstreamĀ versionĀ 1.11.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
   You should have received a copy of the GNU Library General Public
22
22
   License along with this library; if not, write to the Free
23
 
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
 
23
   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
24
24
 
25
25
   <title>NSDate class reference</title>
26
 
   $Date: 2005/02/22 11:22:44 $ $Revision: 1.82 $
 
26
   $Date: 2005/11/06 13:53:39 $ $Revision: 1.88 $
27
27
   */
28
28
 
29
29
#include "config.h"
50
50
#include <stdlib.h>
51
51
#include "GSPrivate.h"
52
52
 
53
 
/* I hope 100,000 years is distant enough. */
54
 
#define DISTANT_YEARS 100000.0
55
 
#define DISTANT_FUTURE  (DISTANT_YEARS * 365.0 * 24 * 60 * 60)
56
 
#define DISTANT_PAST    (-DISTANT_FUTURE)
 
53
/* These constants seem to be what MacOS-X uses */
 
54
#define DISTANT_FUTURE  63113990400.0
 
55
#define DISTANT_PAST    -63113817600.0
57
56
 
58
57
const NSTimeInterval NSTimeIntervalSince1970 = 978307200.0;
59
58
 
126
125
NSTimeInterval
127
126
GSTimeNow(void)
128
127
{
129
 
#if !defined(__MINGW__)
 
128
#if !defined(__MINGW32__)
130
129
  NSTimeInterval interval;
131
130
  struct timeval tp;
132
131
 
164
163
    sys_time.wMinute, sys_time.wSecond, sys_time.wMilliseconds);
165
164
#endif
166
165
  return t;
167
 
#endif /* __MINGW__ */
 
166
#endif /* __MINGW32__ */
168
167
}
169
168
 
170
169
/**
256
255
 *   <desc>An array of arrays of strings identifying the time of day.
257
256
 *   Each array has an hour as its first value, and one or more words
258
257
 *   as subsequent values.<br />
259
 
 *   Defaults are: (0, midnight), (10, mornint), (12, noon, lunch),
 
258
 *   Defaults are: (0, midnight), (10, morning), (12, noon, lunch),
260
259
 *   (14, afternoon), (19, dinner).
261
260
 *   </desc>
262
261
 *   <term>NSLaterTimeDesignations</term>
1335
1334
{
1336
1335
  if (other == nil)
1337
1336
    return NO;
1338
 
  if ([other isKindOf: abstractClass]
1339
 
    && 1.0 > ABS(otherTime(self) - otherTime(other)))
 
1337
  if ([other isKindOfClass: abstractClass]
 
1338
    && otherTime(self) == otherTime(other))
1340
1339
    return YES;
1341
1340
  return NO;
1342
1341
}
1343
1342
 
1344
1343
/**
1345
 
 *  Returns whether equal to other within one <code>NSTimeInterval</code> unit.
 
1344
 *  Returns whether the receiver is exactly equal to other, to the limit
 
1345
 *  of the NSTimeInterval precision.<br />
 
1346
 *  This is the behavior of the current MacOS-X system, not that of the
 
1347
 *  OpenStep specification (which counted two dates within a second of
 
1348
 *  each other as being equal).<br />
 
1349
 *  The old behavior meant that two dates equal to a third date were not
 
1350
 *  necessarily equal to each other (confusing), and meant that there was
 
1351
 *  no reasonable way to use a date as a dictionary key or store dates
 
1352
 *  in a set.
1346
1353
 */
1347
1354
- (BOOL) isEqualToDate: (NSDate*)other
1348
1355
{
1349
1356
  if (other == nil)
1350
1357
    return NO;
1351
 
  if (1.0 > ABS(otherTime(self) - otherTime(other)))
 
1358
  if (otherTime(self) == otherTime(other))
1352
1359
    return YES;
1353
1360
  return NO;
1354
1361
}
1474
1481
  if (other == nil)
1475
1482
    return NO;
1476
1483
  if ([other isKindOfClass: abstractClass]
1477
 
    && 1.0 > ABS(_seconds_since_ref - otherTime(other)))
 
1484
    && _seconds_since_ref == otherTime(other))
1478
1485
    return YES;
1479
1486
  return NO;
1480
1487
}
1483
1490
{
1484
1491
  if (other == nil)
1485
1492
    return NO;
1486
 
  if (1.0 > ABS(_seconds_since_ref - otherTime(other)))
 
1493
  if (_seconds_since_ref == otherTime(other))
1487
1494
    return YES;
1488
1495
  return NO;
1489
1496
}