mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 17:12:03 +00:00
Tidy to avoid some external symbols
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22631 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1da85f67df
commit
1cb2d54094
5 changed files with 66 additions and 80 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2006-03-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSTimeZone.m:
|
||||||
|
* Source/NSCalendarDate.m:
|
||||||
|
* Source/GSPrivate.h:
|
||||||
|
* Source/NSDate.m:
|
||||||
|
Reorganise/tidy to avoid making some private symbols external.
|
||||||
|
|
||||||
2006-03-08 Richard Frith-Macdonald <rfm@gnu.org>
|
2006-03-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/unix/GSRunLoopCtxt.m: Don't hanlde windows messages unless
|
* Source/unix/GSRunLoopCtxt.m: Don't hanlde windows messages unless
|
||||||
|
|
|
@ -24,6 +24,19 @@
|
||||||
#ifndef __GSPrivate_h_
|
#ifndef __GSPrivate_h_
|
||||||
#define __GSPrivate_h_
|
#define __GSPrivate_h_
|
||||||
|
|
||||||
|
/* Absolute Gregorian date for NSDate reference date Jan 01 2001
|
||||||
|
*
|
||||||
|
* N = 1; // day of month
|
||||||
|
* N = N + 0; // days in prior months for year
|
||||||
|
* N = N + // days this year
|
||||||
|
* + 365 * (year - 1) // days in previous years ignoring leap days
|
||||||
|
* + (year - 1)/4 // Julian leap days before this year...
|
||||||
|
* - (year - 1)/100 // ...minus prior century years...
|
||||||
|
* + (year - 1)/400 // ...plus prior years divisible by 400
|
||||||
|
*/
|
||||||
|
#define GREGORIAN_REFERENCE 730486
|
||||||
|
|
||||||
|
|
||||||
#include "GNUstepBase/GSObjCRuntime.h"
|
#include "GNUstepBase/GSObjCRuntime.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,23 +42,16 @@
|
||||||
#include "Foundation/NSAutoreleasePool.h"
|
#include "Foundation/NSAutoreleasePool.h"
|
||||||
#include "Foundation/NSDebug.h"
|
#include "Foundation/NSDebug.h"
|
||||||
#include "GNUstepBase/GSObjCRuntime.h"
|
#include "GNUstepBase/GSObjCRuntime.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_TIME_H
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
#include <time.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "GSPrivate.h"
|
#include "GSPrivate.h"
|
||||||
|
|
||||||
// Absolute Gregorian date for NSDate reference date Jan 01 2001
|
|
||||||
//
|
|
||||||
// N = 1; // day of month
|
|
||||||
// N = N + 0; // days in prior months for year
|
|
||||||
// N = N + // days this year
|
|
||||||
// + 365 * (year - 1) // days in previous years ignoring leap days
|
|
||||||
// + (year - 1)/4 // Julian leap days before this year...
|
|
||||||
// - (year - 1)/100 // ...minus prior century years...
|
|
||||||
// + (year - 1)/400 // ...plus prior years divisible by 400
|
|
||||||
|
|
||||||
#define GREGORIAN_REFERENCE 730486
|
|
||||||
|
|
||||||
@class GSTimeZone;
|
@class GSTimeZone;
|
||||||
@interface GSTimeZone : NSObject // Help the compiler
|
@interface GSTimeZone : NSObject // Help the compiler
|
||||||
@end
|
@end
|
||||||
|
@ -185,19 +178,16 @@ absoluteGregorianDay(int day, int month, int year)
|
||||||
+ year/400); // ...plus prior years divisible by 400
|
+ year/400); // ...plus prior years divisible by 400
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Should be static, but temporarily changed to non-static until
|
static inline int
|
||||||
WIndows fixes are done. */
|
|
||||||
int
|
|
||||||
dayOfCommonEra(NSTimeInterval when)
|
dayOfCommonEra(NSTimeInterval when)
|
||||||
{
|
{
|
||||||
double a;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
// Get reference date in terms of days
|
// Get reference date in terms of days
|
||||||
a = when / 86400.0;
|
when /= 86400.0;
|
||||||
// Offset by Gregorian reference
|
// Offset by Gregorian reference
|
||||||
a += GREGORIAN_REFERENCE;
|
when += GREGORIAN_REFERENCE;
|
||||||
r = (int)a;
|
r = (int)when;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,10 +212,9 @@ gregorianDateFromAbsolute(int abs, int *day, int *month, int *year)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a broken out time specification into a time interval
|
* Convert a broken out time specification into a time interval
|
||||||
* since the reference date.<br />
|
* since the reference date.
|
||||||
* External - so NSDate and others can use it.
|
|
||||||
*/
|
*/
|
||||||
NSTimeInterval
|
static NSTimeInterval
|
||||||
GSTime(int day, int month, int year, int hour, int minute, int second, int mil)
|
GSTime(int day, int month, int year, int hour, int minute, int second, int mil)
|
||||||
{
|
{
|
||||||
NSTimeInterval a;
|
NSTimeInterval a;
|
||||||
|
@ -245,7 +234,7 @@ GSTime(int day, int month, int year, int hour, int minute, int second, int mil)
|
||||||
/**
|
/**
|
||||||
* Convert a time interval since the reference date into broken out
|
* Convert a time interval since the reference date into broken out
|
||||||
* elements.<br />
|
* elements.<br />
|
||||||
* External - so NSDate and others can use it.
|
* External - so NSTimeZone can use it ... but should really be static.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
GSBreakTime(NSTimeInterval when, int *year, int *month, int *day,
|
GSBreakTime(NSTimeInterval when, int *year, int *month, int *day,
|
||||||
|
@ -282,6 +271,34 @@ GSBreakTime(NSTimeInterval when, int *year, int *month, int *day,
|
||||||
*mil = (a - h - m - c) * 1000;
|
*mil = (a - h - m - c) * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current time (seconds since reference date) as an NSTimeInterval.
|
||||||
|
*/
|
||||||
|
NSTimeInterval
|
||||||
|
GSTimeNow(void)
|
||||||
|
{
|
||||||
|
#if !defined(__MINGW32__)
|
||||||
|
NSTimeInterval interval;
|
||||||
|
struct timeval tp;
|
||||||
|
|
||||||
|
gettimeofday (&tp, NULL);
|
||||||
|
interval = -NSTimeIntervalSince1970;
|
||||||
|
interval += tp.tv_sec;
|
||||||
|
interval += (double)tp.tv_usec / 1000000.0;
|
||||||
|
return interval;
|
||||||
|
#else
|
||||||
|
SYSTEMTIME sys_time;
|
||||||
|
NSTimeInterval t;
|
||||||
|
/*
|
||||||
|
* Get current GMT time, convert to NSTimeInterval since reference date,
|
||||||
|
*/
|
||||||
|
GetSystemTime(&sys_time);
|
||||||
|
t = GSTime(sys_time.wDay, sys_time.wMonth, sys_time.wYear, sys_time.wHour,
|
||||||
|
sys_time.wMinute, sys_time.wSecond, sys_time.wMilliseconds);
|
||||||
|
return t;
|
||||||
|
#endif /* __MINGW32__ */
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An [NSDate] subclass which understands about timezones and provides
|
* An [NSDate] subclass which understands about timezones and provides
|
||||||
* methods for dealing with date and time information by calendar and
|
* methods for dealing with date and time information by calendar and
|
||||||
|
|
|
@ -42,12 +42,7 @@
|
||||||
#include "Foundation/NSUserDefaults.h"
|
#include "Foundation/NSUserDefaults.h"
|
||||||
#include "GNUstepBase/preface.h"
|
#include "GNUstepBase/preface.h"
|
||||||
#include "GNUstepBase/GSObjCRuntime.h"
|
#include "GNUstepBase/GSObjCRuntime.h"
|
||||||
#ifdef HAVE_SYS_TIME_H
|
|
||||||
#include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
#include <time.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "GSPrivate.h"
|
#include "GSPrivate.h"
|
||||||
|
|
||||||
/* These constants seem to be what MacOS-X uses */
|
/* These constants seem to be what MacOS-X uses */
|
||||||
|
@ -58,6 +53,8 @@ const NSTimeInterval NSTimeIntervalSince1970 = 978307200.0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern NSTimeInterval GSTimeNow(); // In NSCalendarDate.m
|
||||||
|
|
||||||
static BOOL debug = NO;
|
static BOOL debug = NO;
|
||||||
static Class abstractClass = nil;
|
static Class abstractClass = nil;
|
||||||
static Class concreteClass = nil;
|
static Class concreteClass = nil;
|
||||||
|
@ -119,53 +116,6 @@ otherTime(NSDate* other)
|
||||||
return [other timeIntervalSinceReferenceDate];
|
return [other timeIntervalSinceReferenceDate];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current time (seconds since reference date) as an NSTimeInterval.
|
|
||||||
*/
|
|
||||||
NSTimeInterval
|
|
||||||
GSTimeNow(void)
|
|
||||||
{
|
|
||||||
#if !defined(__MINGW32__)
|
|
||||||
NSTimeInterval interval;
|
|
||||||
struct timeval tp;
|
|
||||||
|
|
||||||
gettimeofday (&tp, NULL);
|
|
||||||
interval = -NSTimeIntervalSince1970;
|
|
||||||
interval += tp.tv_sec;
|
|
||||||
interval += (double)tp.tv_usec / 1000000.0;
|
|
||||||
return interval;
|
|
||||||
#else
|
|
||||||
SYSTEMTIME sys_time;
|
|
||||||
NSTimeInterval t;
|
|
||||||
#if 0
|
|
||||||
NSCalendarDate *d;
|
|
||||||
|
|
||||||
// Get the system time
|
|
||||||
GetLocalTime(&sys_time);
|
|
||||||
|
|
||||||
// Use an NSCalendar object to make it easier
|
|
||||||
d = [NSCalendarDate alloc];
|
|
||||||
[d initWithYear: sys_time.wYear
|
|
||||||
month: sys_time.wMonth
|
|
||||||
day: sys_time.wDay
|
|
||||||
hour: sys_time.wHour
|
|
||||||
minute: sys_time.wMinute
|
|
||||||
second: sys_time.wSecond
|
|
||||||
timeZone: [NSTimeZone localTimeZone]];
|
|
||||||
t = otherTime(d);
|
|
||||||
RELEASE(d);
|
|
||||||
#else
|
|
||||||
/*
|
|
||||||
* Get current GMT time, convert to NSTimeInterval since reference date,
|
|
||||||
*/
|
|
||||||
GetSystemTime(&sys_time);
|
|
||||||
t = GSTime(sys_time.wDay, sys_time.wMonth, sys_time.wYear, sys_time.wHour,
|
|
||||||
sys_time.wMinute, sys_time.wSecond, sys_time.wMilliseconds);
|
|
||||||
#endif
|
|
||||||
return t;
|
|
||||||
#endif /* __MINGW32__ */
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An <code>NSDate</code> object encapsulates a constant date/time to a high
|
* An <code>NSDate</code> object encapsulates a constant date/time to a high
|
||||||
* resolution represented by the <code>NSTimeInterval</code> typedef.
|
* resolution represented by the <code>NSTimeInterval</code> typedef.
|
||||||
|
|
|
@ -2100,7 +2100,7 @@ lastDayOfGregorianMonth(int month, int year)
|
||||||
void
|
void
|
||||||
GSBreakTime(NSTimeInterval when, int *year, int *month, int *day,
|
GSBreakTime(NSTimeInterval when, int *year, int *month, int *day,
|
||||||
int *hour, int *minute, int *second, int *mil);
|
int *hour, int *minute, int *second, int *mil);
|
||||||
int dayOfCommonEra(NSTimeInterval when);
|
|
||||||
|
|
||||||
|
|
||||||
/* FIXME
|
/* FIXME
|
||||||
|
@ -2359,9 +2359,7 @@ int dayOfCommonEra(NSTimeInterval when);
|
||||||
// After April and before October is DST
|
// After April and before October is DST
|
||||||
if (month > DaylightDate.wMonth && month < StandardDate.wMonth)
|
if (month > DaylightDate.wMonth && month < StandardDate.wMonth)
|
||||||
return YES;
|
return YES;
|
||||||
dow = dayOfCommonEra(when);
|
dow = ((int)((when / 86400.0) + GREGORIAN_REFERENCE)) % 7;
|
||||||
|
|
||||||
dow = dow % 7;
|
|
||||||
if (dow < 0)
|
if (dow < 0)
|
||||||
dow += 7;
|
dow += 7;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue