* Source/NSISO8601DateFormatter.m,

* Source/NSOrthography.m: Clean up some compiler warnings.
This commit is contained in:
fredkiefer 2020-05-10 23:07:27 +02:00
parent 6c7defba24
commit e71c2f68fa
3 changed files with 65 additions and 25 deletions

View file

@ -1,3 +1,8 @@
2020-05-10 Fred Kiefer <fredkiefer@gmx.de>
* Source/NSISO8601DateFormatter.m,
* Source/NSOrthography.m: Clean up some compiler warnings.
2020-05-09 Fred Kiefer <fredkiefer@gmx.de> 2020-05-09 Fred Kiefer <fredkiefer@gmx.de>
* Tests/base/NSLocale/general.m: Mark more tests that depend on * Tests/base/NSLocale/general.m: Mark more tests that depend on

View file

@ -22,17 +22,18 @@
Boston, MA 02110 USA. Boston, MA 02110 USA.
*/ */
#include <Foundation/NSISO8601DateFormatter.h> #import "Foundation/NSCoder.h"
#include <Foundation/NSDateFormatter.h> #import "Foundation/NSDateFormatter.h"
#include <Foundation/NSTimeZone.h> #import "Foundation/NSISO8601DateFormatter.h"
#include <Foundation/NSString.h> #import "Foundation/NSString.h"
#import "Foundation/NSTimeZone.h"
@implementation NSISO8601DateFormatter @implementation NSISO8601DateFormatter
- (instancetype) init - (instancetype) init
{ {
self = [super init]; self = [super init];
if(self != nil) if (self != nil)
{ {
_formatter = [[NSDateFormatter alloc] init]; _formatter = [[NSDateFormatter alloc] init];
_timeZone = RETAIN([NSTimeZone localTimeZone]); _timeZone = RETAIN([NSTimeZone localTimeZone]);
@ -41,11 +42,11 @@
return self; return self;
} }
- (oneway void) release - (oneway void) dealloc
{ {
RELEASE(_formatter); RELEASE(_formatter);
RELEASE(_timeZone); RELEASE(_timeZone);
[super release]; [super dealloc];
} }
- (NSTimeZone *) timeZone - (NSTimeZone *) timeZone
@ -68,31 +69,31 @@
NSString *result = @""; NSString *result = @"";
// Build date... // Build date...
if(_formatOptions & NSISO8601DateFormatWithYear) if (_formatOptions & NSISO8601DateFormatWithYear)
{ {
result = [result stringByAppendingString: @"yyyy"]; result = [result stringByAppendingString: @"yyyy"];
} }
if(_formatOptions & NSISO8601DateFormatWithDashSeparatorInDate && if (_formatOptions & NSISO8601DateFormatWithDashSeparatorInDate &&
_formatOptions & NSISO8601DateFormatWithMonth) _formatOptions & NSISO8601DateFormatWithMonth)
{ {
result = [result stringByAppendingString: @"-"]; result = [result stringByAppendingString: @"-"];
} }
if(_formatOptions & NSISO8601DateFormatWithMonth) if (_formatOptions & NSISO8601DateFormatWithMonth)
{ {
result = [result stringByAppendingString: @"MM"]; result = [result stringByAppendingString: @"MM"];
} }
if(_formatOptions & NSISO8601DateFormatWithDashSeparatorInDate && if (_formatOptions & NSISO8601DateFormatWithDashSeparatorInDate &&
_formatOptions & NSISO8601DateFormatWithDay) _formatOptions & NSISO8601DateFormatWithDay)
{ {
result = [result stringByAppendingString: @"-"]; result = [result stringByAppendingString: @"-"];
} }
if(_formatOptions & NSISO8601DateFormatWithDay) if (_formatOptions & NSISO8601DateFormatWithDay)
{ {
result = [result stringByAppendingString: @"dd"]; result = [result stringByAppendingString: @"dd"];
} }
// Build time... // Build time...
if(_formatOptions & NSISO8601DateFormatWithSpaceBetweenDateAndTime && if (_formatOptions & NSISO8601DateFormatWithSpaceBetweenDateAndTime &&
_formatOptions & NSISO8601DateFormatWithTime) _formatOptions & NSISO8601DateFormatWithTime)
{ {
result = [result stringByAppendingString: @" "]; result = [result stringByAppendingString: @" "];
@ -102,9 +103,9 @@
// Add T in format if we have a time component... // Add T in format if we have a time component...
result = [result stringByAppendingString: @"'T'"]; result = [result stringByAppendingString: @"'T'"];
} }
if(_formatOptions & NSISO8601DateFormatWithTime) if (_formatOptions & NSISO8601DateFormatWithTime)
{ {
if(_formatOptions & NSISO8601DateFormatWithColonSeparatorInTime) if (_formatOptions & NSISO8601DateFormatWithColonSeparatorInTime)
{ {
result = [result stringByAppendingString: @"HH:mm:ss"]; result = [result stringByAppendingString: @"HH:mm:ss"];
} }
@ -113,13 +114,13 @@
result = [result stringByAppendingString: @"HHmmss"]; result = [result stringByAppendingString: @"HHmmss"];
} }
} }
if(_formatOptions & NSISO8601DateFormatWithFractionalSeconds) if (_formatOptions & NSISO8601DateFormatWithFractionalSeconds)
{ {
result = [result stringByAppendingString: @".SSSSSS"]; result = [result stringByAppendingString: @".SSSSSS"];
} }
if(_formatOptions & NSISO8601DateFormatWithTimeZone) if (_formatOptions & NSISO8601DateFormatWithTimeZone)
{ {
if(_formatOptions & NSISO8601DateFormatWithColonSeparatorInTimeZone) if (_formatOptions & NSISO8601DateFormatWithColonSeparatorInTimeZone)
{ {
result = [result stringByAppendingString: @"ZZ:ZZ"]; result = [result stringByAppendingString: @"ZZ:ZZ"];
} }
@ -164,5 +165,36 @@
return [formatter stringFromDate: date]; return [formatter stringFromDate: date];
} }
- (void) encodeWithCoder: (NSCoder *)coder
{
if ([coder allowsKeyedCoding])
{
[coder encodeObject: _timeZone forKey: @"NS.timeZone"];
[coder encodeInteger: _formatOptions forKey: @"NS.formatOptions"];
}
else
{
[coder encodeObject: _timeZone];
[coder encodeValueOfObjCType: @encode(NSUInteger) at: &_formatOptions];
}
}
- (id) initWithCoder: (NSCoder *)decoder
{
if ((self = [super init]) != nil)
{
if ([decoder allowsKeyedCoding])
{
ASSIGN(_timeZone, [decoder decodeObjectForKey: @"NS.timeZone"]);
_formatOptions = [decoder decodeIntegerForKey: @"NS.formatOptions"];
}
else
{
ASSIGN(_timeZone, [decoder decodeObject]);
[decoder decodeValueOfObjCType: @encode(NSUInteger) at: &_formatOptions];
}
}
return self;
}
@end @end

View file

@ -22,7 +22,10 @@
Boston, MA 02110 USA. Boston, MA 02110 USA.
*/ */
#include <Foundation/NSOrthography.h> #import "Foundation/NSArray.h"
#import "Foundation/NSDictionary.h"
#import "Foundation/NSOrthography.h"
#import "Foundation/NSString.h"
@implementation NSOrthography @implementation NSOrthography
@ -30,7 +33,7 @@
languageMap: (NSDictionary *)map languageMap: (NSDictionary *)map
{ {
self = [super init]; self = [super init];
if(self != nil) if (self != nil)
{ {
ASSIGNCOPY(_dominantScript, script); ASSIGNCOPY(_dominantScript, script);
ASSIGNCOPY(_languageMap, map); ASSIGNCOPY(_languageMap, map);
@ -38,11 +41,11 @@
return self; return self;
} }
- (oneway void) release - (oneway void) dealloc
{ {
RELEASE(_dominantScript); RELEASE(_dominantScript);
RELEASE(_languageMap); RELEASE(_languageMap);
[super release]; [super dealloc];
} }
- (NSString *) dominantScript - (NSString *) dominantScript