mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +00:00
MacOS-X compatibility tweaks
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19298 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5e2655c060
commit
9f67a91253
2 changed files with 32 additions and 13 deletions
|
@ -6,6 +6,7 @@
|
||||||
a couple of logs.
|
a couple of logs.
|
||||||
Also changed to accept nil/empty string values for format and
|
Also changed to accept nil/empty string values for format and
|
||||||
description as MacOS-X does.
|
description as MacOS-X does.
|
||||||
|
Also changed default year to be current year for compatibility.
|
||||||
|
|
||||||
2004-05-12 Richard Frith-Macdonald <rfm@gnu.org>
|
2004-05-12 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
|
|
@ -576,15 +576,20 @@ static inline int getDigits(const char *from, char *to, int limit)
|
||||||
* %Z time zone abbreviation
|
* %Z time zone abbreviation
|
||||||
* </item>
|
* </item>
|
||||||
* </list>
|
* </list>
|
||||||
|
* If no year is specified in the format, the current year is assumed.<br />
|
||||||
|
* If no month is specified in the format, January is assumed.<br />
|
||||||
|
* If no day is specified in the format, 1 is assumed.<br />
|
||||||
|
* If no hour is specified in the format, 0 is assumed.<br />
|
||||||
|
* If no minute is specified in the format, 0 is assumed.<br />
|
||||||
|
* If no second is specified in the format, 0 is assumed.<br />
|
||||||
|
* If no millisecond is specified in the format, 0 is assumed.<br />
|
||||||
|
* If no timezone is specified in the format, the local timezone is assumed.
|
||||||
*/
|
*/
|
||||||
- (id) initWithString: (NSString*)description
|
- (id) initWithString: (NSString*)description
|
||||||
calendarFormat: (NSString*)fmt
|
calendarFormat: (NSString*)fmt
|
||||||
locale: (NSDictionary*)locale
|
locale: (NSDictionary*)locale
|
||||||
{
|
{
|
||||||
int milliseconds = 0;
|
int milliseconds = 0;
|
||||||
/* Default to gregorian year one ... there is no year zero and
|
|
||||||
* the algorithms we use look odd for earlier dates.
|
|
||||||
*/
|
|
||||||
int year = 1;
|
int year = 1;
|
||||||
int month = 1;
|
int month = 1;
|
||||||
int day = 1;
|
int day = 1;
|
||||||
|
@ -1175,7 +1180,7 @@ static inline int getDigits(const char *from, char *to, int limit)
|
||||||
|
|
||||||
if ((had & (hadY|hadw)) != (hadY|hadw))
|
if ((had & (hadY|hadw)) != (hadY|hadw))
|
||||||
{
|
{
|
||||||
NSCalendarDate *now = [NSCalendarDate date];
|
NSCalendarDate *now = [[NSCalendarDate alloc] init];
|
||||||
|
|
||||||
[now setTimeZone: gmtZone];
|
[now setTimeZone: gmtZone];
|
||||||
if ((had | hadY) == 0)
|
if ((had | hadY) == 0)
|
||||||
|
@ -1188,9 +1193,10 @@ static inline int getDigits(const char *from, char *to, int limit)
|
||||||
dayOfWeek = [now dayOfWeek];
|
dayOfWeek = [now dayOfWeek];
|
||||||
had |= hadw;
|
had |= hadw;
|
||||||
}
|
}
|
||||||
|
RELEASE(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
d = [NSCalendarDate dateWithYear: year
|
d = [[NSCalendarDate alloc] initWithYear: year
|
||||||
month: 1
|
month: 1
|
||||||
day: 1
|
day: 1
|
||||||
hour: 0
|
hour: 0
|
||||||
|
@ -1198,6 +1204,7 @@ static inline int getDigits(const char *from, char *to, int limit)
|
||||||
second: 0
|
second: 0
|
||||||
timeZone: gmtZone];
|
timeZone: gmtZone];
|
||||||
currDay = [d dayOfWeek];
|
currDay = [d dayOfWeek];
|
||||||
|
RELEASE(d);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The julian weeks are either sunday relative or monday relative
|
* The julian weeks are either sunday relative or monday relative
|
||||||
|
@ -1220,6 +1227,17 @@ static inline int getDigits(const char *from, char *to, int limit)
|
||||||
had |= hadD;
|
had |= hadD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the year has not been set ... use this year ... as on MacOS-X
|
||||||
|
*/
|
||||||
|
if ((had | hadY) == 0)
|
||||||
|
{
|
||||||
|
NSCalendarDate *now = [[NSCalendarDate alloc] init];
|
||||||
|
|
||||||
|
year = [now yearOfCommonEra];
|
||||||
|
RELEASE(now);
|
||||||
|
}
|
||||||
|
|
||||||
self = [self initWithYear: year
|
self = [self initWithYear: year
|
||||||
month: month
|
month: month
|
||||||
day: day
|
day: day
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue