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:
Richard Frith-MacDonald 2006-03-10 10:46:37 +00:00
parent 0060ce88ce
commit 32bd52f23c
5 changed files with 66 additions and 80 deletions

View file

@ -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>
* Source/unix/GSRunLoopCtxt.m: Don't hanlde windows messages unless

View file

@ -24,6 +24,19 @@
#ifndef __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"
/**

View file

@ -42,23 +42,16 @@
#include "Foundation/NSAutoreleasePool.h"
#include "Foundation/NSDebug.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 <ctype.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;
@interface GSTimeZone : NSObject // Help the compiler
@end
@ -185,19 +178,16 @@ absoluteGregorianDay(int day, int month, int year)
+ year/400); // ...plus prior years divisible by 400
}
/* Should be static, but temporarily changed to non-static until
WIndows fixes are done. */
int
static inline int
dayOfCommonEra(NSTimeInterval when)
{
double a;
int r;
// Get reference date in terms of days
a = when / 86400.0;
when /= 86400.0;
// Offset by Gregorian reference
a += GREGORIAN_REFERENCE;
r = (int)a;
when += GREGORIAN_REFERENCE;
r = (int)when;
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
* since the reference date.<br />
* External - so NSDate and others can use it.
* since the reference date.
*/
NSTimeInterval
static NSTimeInterval
GSTime(int day, int month, int year, int hour, int minute, int second, int mil)
{
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
* elements.<br />
* External - so NSDate and others can use it.
* External - so NSTimeZone can use it ... but should really be static.
*/
void
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;
}
/**
* 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
* methods for dealing with date and time information by calendar and

View file

@ -42,12 +42,7 @@
#include "Foundation/NSUserDefaults.h"
#include "GNUstepBase/preface.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"
/* 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 Class abstractClass = nil;
static Class concreteClass = nil;
@ -119,53 +116,6 @@ otherTime(NSDate* other)
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
* resolution represented by the <code>NSTimeInterval</code> typedef.

View file

@ -2100,7 +2100,7 @@ lastDayOfGregorianMonth(int month, int year)
void
GSBreakTime(NSTimeInterval when, int *year, int *month, int *day,
int *hour, int *minute, int *second, int *mil);
int dayOfCommonEra(NSTimeInterval when);
/* FIXME
@ -2359,9 +2359,7 @@ int dayOfCommonEra(NSTimeInterval when);
// After April and before October is DST
if (month > DaylightDate.wMonth && month < StandardDate.wMonth)
return YES;
dow = dayOfCommonEra(when);
dow = dow % 7;
dow = ((int)((when / 86400.0) + GREGORIAN_REFERENCE)) % 7;
if (dow < 0)
dow += 7;