From 44ca403e94e748cbf1db6941aece22029c77c542 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Sun, 9 Sep 2012 00:51:43 +0000 Subject: Rename some classes. --- .../PostgresKit.xcodeproj/project.pbxproj | 32 ++++---- .../PostgresKit/Source/FLXPostgresKitPrivateAPI.h | 4 +- .../PostgresKit/Source/FLXPostgresTimeInterval.h | 85 ++++++++++++++++++++++ .../PostgresKit/Source/FLXPostgresTimeInterval.m | 71 ++++++++++++++++++ Frameworks/PostgresKit/Source/FLXPostgresTimeTZ.h | 62 ++++++++++++++++ Frameworks/PostgresKit/Source/FLXPostgresTimeTZ.m | 84 +++++++++++++++++++++ .../Source/FLXPostgresTypeDateTimeHandler.m | 8 +- Frameworks/PostgresKit/Source/FLXPostgresTypes.h | 6 +- Frameworks/PostgresKit/Source/FLXTimeInterval.h | 85 ---------------------- Frameworks/PostgresKit/Source/FLXTimeInterval.m | 71 ------------------ Frameworks/PostgresKit/Source/FLXTimeTZ.h | 62 ---------------- Frameworks/PostgresKit/Source/FLXTimeTZ.m | 84 --------------------- 12 files changed, 327 insertions(+), 327 deletions(-) create mode 100644 Frameworks/PostgresKit/Source/FLXPostgresTimeInterval.h create mode 100644 Frameworks/PostgresKit/Source/FLXPostgresTimeInterval.m create mode 100644 Frameworks/PostgresKit/Source/FLXPostgresTimeTZ.h create mode 100644 Frameworks/PostgresKit/Source/FLXPostgresTimeTZ.m delete mode 100644 Frameworks/PostgresKit/Source/FLXTimeInterval.h delete mode 100644 Frameworks/PostgresKit/Source/FLXTimeInterval.m delete mode 100644 Frameworks/PostgresKit/Source/FLXTimeTZ.h delete mode 100644 Frameworks/PostgresKit/Source/FLXTimeTZ.m diff --git a/Frameworks/PostgresKit/PostgresKit.xcodeproj/project.pbxproj b/Frameworks/PostgresKit/PostgresKit.xcodeproj/project.pbxproj index 08a1c7c6..84af5f2d 100644 --- a/Frameworks/PostgresKit/PostgresKit.xcodeproj/project.pbxproj +++ b/Frameworks/PostgresKit/PostgresKit.xcodeproj/project.pbxproj @@ -10,12 +10,12 @@ 170465CE15C2960F00DC5BE5 /* FLXPostgresTypeHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 170465CC15C2960F00DC5BE5 /* FLXPostgresTypeHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; 170465CF15C2960F00DC5BE5 /* FLXPostgresTypeHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 170465CD15C2960F00DC5BE5 /* FLXPostgresTypeHandler.m */; }; 1724C9B815F9ED8600AB2291 /* libpqtypes.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1724C9B715F9ED8600AB2291 /* libpqtypes.a */; }; - 1724CC9215FB4CC200AB2291 /* FLXTimeTZ.h in Headers */ = {isa = PBXBuildFile; fileRef = 1724CC9015FB4CC200AB2291 /* FLXTimeTZ.h */; }; - 1724CC9315FB4CC200AB2291 /* FLXTimeTZ.m in Sources */ = {isa = PBXBuildFile; fileRef = 1724CC9115FB4CC200AB2291 /* FLXTimeTZ.m */; }; + 1724CC9215FB4CC200AB2291 /* FLXPostgresTimeTZ.h in Headers */ = {isa = PBXBuildFile; fileRef = 1724CC9015FB4CC200AB2291 /* FLXPostgresTimeTZ.h */; }; + 1724CC9315FB4CC200AB2291 /* FLXPostgresTimeTZ.m in Sources */ = {isa = PBXBuildFile; fileRef = 1724CC9115FB4CC200AB2291 /* FLXPostgresTimeTZ.m */; }; 1724CD1515FB69EC00AB2291 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17E595F114F3058F0054EE08 /* Foundation.framework */; }; 1724CD1815FB6A0500AB2291 /* PostgresKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* PostgresKit.framework */; }; - 1724CD5915FB8A3300AB2291 /* FLXTimeInterval.h in Headers */ = {isa = PBXBuildFile; fileRef = 1724CD5715FB8A3300AB2291 /* FLXTimeInterval.h */; }; - 1724CD5A15FB8A3300AB2291 /* FLXTimeInterval.m in Sources */ = {isa = PBXBuildFile; fileRef = 1724CD5815FB8A3300AB2291 /* FLXTimeInterval.m */; }; + 1724CD5915FB8A3300AB2291 /* FLXPostgresTimeInterval.h in Headers */ = {isa = PBXBuildFile; fileRef = 1724CD5715FB8A3300AB2291 /* FLXPostgresTimeInterval.h */; }; + 1724CD5A15FB8A3300AB2291 /* FLXPostgresTimeInterval.m in Sources */ = {isa = PBXBuildFile; fileRef = 1724CD5815FB8A3300AB2291 /* FLXPostgresTimeInterval.m */; }; 1731F02B15EE09E000D973EB /* FLXPostgresConnectionParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 1731F02915EE09E000D973EB /* FLXPostgresConnectionParameters.h */; }; 1731F02C15EE09E000D973EB /* FLXPostgresConnectionParameters.m in Sources */ = {isa = PBXBuildFile; fileRef = 1731F02A15EE09E000D973EB /* FLXPostgresConnectionParameters.m */; }; 1731F10815F1A52B00D973EB /* FLXPostgresTypeDateTimeHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 1731F10615F1A52B00D973EB /* FLXPostgresTypeDateTimeHandler.h */; }; @@ -72,12 +72,12 @@ 170465CD15C2960F00DC5BE5 /* FLXPostgresTypeHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLXPostgresTypeHandler.m; sourceTree = ""; }; 1724C9B715F9ED8600AB2291 /* libpqtypes.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libpqtypes.a; sourceTree = ""; }; 1724CA3B15F9EE7300AB2291 /* libpqtypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libpqtypes.h; sourceTree = ""; }; - 1724CC9015FB4CC200AB2291 /* FLXTimeTZ.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLXTimeTZ.h; sourceTree = ""; }; - 1724CC9115FB4CC200AB2291 /* FLXTimeTZ.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLXTimeTZ.m; sourceTree = ""; }; + 1724CC9015FB4CC200AB2291 /* FLXPostgresTimeTZ.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLXPostgresTimeTZ.h; sourceTree = ""; }; + 1724CC9115FB4CC200AB2291 /* FLXPostgresTimeTZ.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLXPostgresTimeTZ.m; sourceTree = ""; }; 1724CD0415FB68E800AB2291 /* Tests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Tests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; 1724CD0515FB68E800AB2291 /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Tests-Info.plist"; path = "Resources/Tests-Info.plist"; sourceTree = ""; }; - 1724CD5715FB8A3300AB2291 /* FLXTimeInterval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLXTimeInterval.h; sourceTree = ""; }; - 1724CD5815FB8A3300AB2291 /* FLXTimeInterval.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLXTimeInterval.m; sourceTree = ""; }; + 1724CD5715FB8A3300AB2291 /* FLXPostgresTimeInterval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLXPostgresTimeInterval.h; sourceTree = ""; }; + 1724CD5815FB8A3300AB2291 /* FLXPostgresTimeInterval.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLXPostgresTimeInterval.m; sourceTree = ""; }; 1731F02915EE09E000D973EB /* FLXPostgresConnectionParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLXPostgresConnectionParameters.h; sourceTree = ""; }; 1731F02A15EE09E000D973EB /* FLXPostgresConnectionParameters.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLXPostgresConnectionParameters.m; sourceTree = ""; }; 1731F10615F1A52B00D973EB /* FLXPostgresTypeDateTimeHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLXPostgresTypeDateTimeHandler.h; sourceTree = ""; }; @@ -229,10 +229,10 @@ 1724CC8715FB4BF400AB2291 /* Domain */ = { isa = PBXGroup; children = ( - 1724CC9015FB4CC200AB2291 /* FLXTimeTZ.h */, - 1724CC9115FB4CC200AB2291 /* FLXTimeTZ.m */, - 1724CD5715FB8A3300AB2291 /* FLXTimeInterval.h */, - 1724CD5815FB8A3300AB2291 /* FLXTimeInterval.m */, + 1724CC9015FB4CC200AB2291 /* FLXPostgresTimeTZ.h */, + 1724CC9115FB4CC200AB2291 /* FLXPostgresTimeTZ.m */, + 1724CD5715FB8A3300AB2291 /* FLXPostgresTimeInterval.h */, + 1724CD5815FB8A3300AB2291 /* FLXPostgresTimeInterval.m */, ); name = Domain; sourceTree = ""; @@ -400,8 +400,8 @@ 1731F02B15EE09E000D973EB /* FLXPostgresConnectionParameters.h in Headers */, 1731F10815F1A52B00D973EB /* FLXPostgresTypeDateTimeHandler.h in Headers */, 1731F52E15F48BA500D973EB /* FLXPostgresError.h in Headers */, - 1724CC9215FB4CC200AB2291 /* FLXTimeTZ.h in Headers */, - 1724CD5915FB8A3300AB2291 /* FLXTimeInterval.h in Headers */, + 1724CC9215FB4CC200AB2291 /* FLXPostgresTimeTZ.h in Headers */, + 1724CD5915FB8A3300AB2291 /* FLXPostgresTimeInterval.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -514,8 +514,8 @@ 1731F02C15EE09E000D973EB /* FLXPostgresConnectionParameters.m in Sources */, 1731F10915F1A52B00D973EB /* FLXPostgresTypeDateTimeHandler.m in Sources */, 1731F52F15F48BA500D973EB /* FLXPostgresError.m in Sources */, - 1724CC9315FB4CC200AB2291 /* FLXTimeTZ.m in Sources */, - 1724CD5A15FB8A3300AB2291 /* FLXTimeInterval.m in Sources */, + 1724CC9315FB4CC200AB2291 /* FLXPostgresTimeTZ.m in Sources */, + 1724CD5A15FB8A3300AB2291 /* FLXPostgresTimeInterval.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Frameworks/PostgresKit/Source/FLXPostgresKitPrivateAPI.h b/Frameworks/PostgresKit/Source/FLXPostgresKitPrivateAPI.h index 174b8018..d78ac063 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresKitPrivateAPI.h +++ b/Frameworks/PostgresKit/Source/FLXPostgresKitPrivateAPI.h @@ -21,7 +21,7 @@ // the License. #import "FLXPostgresConnection.h" -#import "FLXTimeInterval.h" +#import "FLXPostgresTimeInterval.h" @interface FLXPostgresConnection () @@ -35,7 +35,7 @@ @end -@interface FLXTimeInterval () +@interface FLXPostgresTimeInterval () - (id)initWithInterval:(const PGinterval *)interval; diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTimeInterval.h b/Frameworks/PostgresKit/Source/FLXPostgresTimeInterval.h new file mode 100644 index 00000000..74f14c41 --- /dev/null +++ b/Frameworks/PostgresKit/Source/FLXPostgresTimeInterval.h @@ -0,0 +1,85 @@ +// +// $Id$ +// +// FLXPostgresTimeInterval.h +// PostgresKit +// +// Created by Stuart Connolly (stuconnolly.com) on September 9, 2012. +// Copyright (c) 2012 Stuart Connolly. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +/** + * @class FLXPostgresTimeInterval FLXPostgresTimeInterval.h + * + * @author Stuart Connolly http://stuconnolly.com + * + * Simple wrapper around libpqtypes' PQinterval structure. + */ +@interface FLXPostgresTimeInterval : NSObject +{ + NSUInteger _microseconds; + NSUInteger _seconds; + NSUInteger _minutes; + NSUInteger _hours; + NSUInteger _days; + NSUInteger _months; + NSUInteger _years; +} + +/** + * @property microseconds The number of microseconds. + */ +@property (readonly) NSUInteger microseconds; + +/** + * @property seconds The number of seconds. + */ +@property (readonly) NSUInteger seconds; + +/** + * @property minutes The number of minutes. + */ +@property (readonly) NSUInteger minutes; + +/** + * @property hours The number of hours. + */ +@property (readonly) NSUInteger hours; + +/** + * @property days The number of days. + */ +@property (readonly) NSUInteger days; + +/** + * @property months The number of months. + */ +@property (readonly) NSUInteger months; + +/** + * @property years The number of years. + */ +@property (readonly) NSUInteger years; + + +@end diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTimeInterval.m b/Frameworks/PostgresKit/Source/FLXPostgresTimeInterval.m new file mode 100644 index 00000000..7faaad41 --- /dev/null +++ b/Frameworks/PostgresKit/Source/FLXPostgresTimeInterval.m @@ -0,0 +1,71 @@ +// +// $Id$ +// +// FLXPostgresTimeInterval.m +// PostgresKit +// +// Created by Stuart Connolly (stuconnolly.com) on September 9, 2012. +// Copyright (c) 2012 Stuart Connolly. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#import "FLXPostgresTimeInterval.h" +#import "FLXPostgresKitPrivateAPI.h" + +@implementation FLXPostgresTimeInterval + +@synthesize microseconds = _microseconds; +@synthesize seconds = _seconds; +@synthesize minutes = _minutes; +@synthesize hours = _hours; +@synthesize days = _days; +@synthesize months = _months; +@synthesize years = _years; + +#pragma mark - + +- (id)initWithInterval:(const PGinterval *)interval +{ + if ((self = [super init])) { + if (interval) { + _microseconds = interval->usecs; + _seconds = interval->secs; + _minutes = interval->mins; + _hours = interval->hours; + _days = interval->days; + _months = interval->mons; + _years = interval->years; + } + } + + return self; +} + +#pragma mark - + +- (NSString *)description +{ + return [NSString stringWithFormat:@"%d years, %d months, %d days, %d hours, %d minutes, %d seconds and %d microseconds", + _years, _months, _days, _hours, _minutes, _seconds, _microseconds]; +} + +@end diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTimeTZ.h b/Frameworks/PostgresKit/Source/FLXPostgresTimeTZ.h new file mode 100644 index 00000000..dd58f57f --- /dev/null +++ b/Frameworks/PostgresKit/Source/FLXPostgresTimeTZ.h @@ -0,0 +1,62 @@ +// +// $Id$ +// +// FLXPostgresTimeTZ.h +// PostgresKit +// +// Created by Stuart Connolly (stuconnolly.com) on September 8, 2012. +// Copyright (c) 2012 Stuart Connolly. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +/** + * @class FLXPostgresTimeTZ FLXPostgresTimeTZ.h + * + * @author Stuart Connolly http://stuconnolly.com + * + * Simple wrapper to represet a time or timestamp with an associated time zone. + */ +@interface FLXPostgresTimeTZ : NSObject +{ + BOOL _hasDate; + + NSDate *_date; + NSTimeZone *_timeZone; +} + +@property (readwrite, assign) BOOL hasDate; + +/** + * @property date The date instance that holds the time. + */ +@property (readonly) NSDate *date; + +/** + * @property timeZone The time zone of the associated time. + */ +@property (readonly) NSTimeZone *timeZone; + ++ (FLXPostgresTimeTZ *)timeWithDate:(NSDate *)date timeZoneGMTOffset:(NSUInteger)offset; + +- (id)initWithDate:(NSDate *)date timeZoneGMTOffset:(NSUInteger)offset; + +@end diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTimeTZ.m b/Frameworks/PostgresKit/Source/FLXPostgresTimeTZ.m new file mode 100644 index 00000000..692ef200 --- /dev/null +++ b/Frameworks/PostgresKit/Source/FLXPostgresTimeTZ.m @@ -0,0 +1,84 @@ +// +// $Id$ +// +// FLXPostgresTimeTZ.m +// PostgresKit +// +// Created by Stuart Connolly (stuconnolly.com) on September 8, 2012. +// Copyright (c) 2012 Stuart Connolly. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +#import "FLXPostgresTimeTZ.h" + +@implementation FLXPostgresTimeTZ + +@synthesize hasDate = _hasDate; +@synthesize date = _date; +@synthesize timeZone = _timeZone; + +- (id)init +{ + return [self initWithDate:[NSDate date] timeZoneGMTOffset:[[NSTimeZone systemTimeZone] secondsFromGMT]]; +} + ++ (FLXPostgresTimeTZ *)timeWithDate:(NSDate *)date timeZoneGMTOffset:(NSUInteger)offset +{ + return [[[FLXPostgresTimeTZ alloc] initWithDate:date timeZoneGMTOffset:offset] autorelease]; +} + +/** + * Initialise a FLXPostgresTimeTZ with the supplied date and GMT offset. + * + * @param date The date to use. + * @param offset The GMT offset in seconds that the associated time zone is. + * + * @return The initialised instance. + */ +- (id)initWithDate:(NSDate *)date timeZoneGMTOffset:(NSUInteger)offset +{ + if ((self = [super init])) { + _date = date; + _hasDate = NO; + _timeZone = [NSTimeZone timeZoneForSecondsFromGMT:offset]; + } + + return self; +} + +#pragma mark - + +- (NSString *)description +{ + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + + [formatter setDateStyle:_hasDate ? NSDateFormatterMediumStyle : NSDateFormatterNoStyle]; + [formatter setTimeStyle:NSDateFormatterMediumStyle]; + + NSString *output = [formatter stringFromDate:_date]; + + [formatter release]; + + return [NSString stringWithFormat:@"%@ %@", output, [_timeZone abbreviation]]; +} + +@end diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m index c60c1eb9..b28868cc 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m @@ -25,7 +25,7 @@ #import "FLXPostgresConnectionParameters.h" #import "FLXPostgresConnection.h" #import "FLXPostgresConnectionTypeHandling.h" -#import "FLXTimeTZ.h" +#import "FLXPostgresTimeTZ.h" static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] = { @@ -148,7 +148,7 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] = NSDate *date = [self _dateFromComponents:components]; - return hasTimeZone ? [FLXTimeTZ timeWithDate:date timeZoneGMTOffset:time.gmtoff] : date; + return hasTimeZone ? [FLXPostgresTimeTZ timeWithDate:date timeZoneGMTOffset:time.gmtoff] : date; } /** @@ -169,11 +169,11 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] = PQgetf(result, row, hasTimeZone ? "%timstamptz" : "%timestamp", column, ×tamp); - FLXTimeTZ *timestampTZ = nil; + FLXPostgresTimeTZ *timestampTZ = nil; NSDate *date = [NSDate dateWithTimeIntervalSince1970:timestamp.epoch]; if (hasTimeZone) { - timestampTZ = [FLXTimeTZ timeWithDate:date timeZoneGMTOffset:timestamp.time.gmtoff]; + timestampTZ = [FLXPostgresTimeTZ timeWithDate:date timeZoneGMTOffset:timestamp.time.gmtoff]; [timestampTZ setHasDate:YES]; } diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypes.h b/Frameworks/PostgresKit/Source/FLXPostgresTypes.h index 0f57daae..3216ad98 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypes.h +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypes.h @@ -101,9 +101,9 @@ enum FLXPostgresOidDate = 1082, // DateHandler => NSDate FLXPostgresOidTime = 1083, // DateHandler => NSDate FLXPostgresOidTimestamp = 1114, // DateHandler => NSDate - FLXPostgresOidTimestampTZ = 1184, // DateHandler => FLXTimeTZ - FLXPostgresOidInterval = 1186, // DateHandler => FLXTimeInterval - FLXPostgresOidTimeTZ = 1266, // DateHandler => FLXTimeTZ + FLXPostgresOidTimestampTZ = 1184, // DateHandler => FLXPostgresTimeTZ + FLXPostgresOidInterval = 1186, // DateHandler => FLXPostgresTimeInterval + FLXPostgresOidTimeTZ = 1266, // DateHandler => FLXPostgresTimeTZ // Binary FLXPostgresOidBit = 1560, // Currently not supported diff --git a/Frameworks/PostgresKit/Source/FLXTimeInterval.h b/Frameworks/PostgresKit/Source/FLXTimeInterval.h deleted file mode 100644 index 09fe4bf9..00000000 --- a/Frameworks/PostgresKit/Source/FLXTimeInterval.h +++ /dev/null @@ -1,85 +0,0 @@ -// -// $Id$ -// -// FLXTimeInterval.h -// PostgresKit -// -// Created by Stuart Connolly (stuconnolly.com) on September 9, 2012. -// Copyright (c) 2012 Stuart Connolly. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -/** - * @class FLXTimeInterval FLXTimeInterval.h - * - * @author Stuart Connolly http://stuconnolly.com - * - * Simple wrapper around libpqtypes' PQinterval structure. - */ -@interface FLXTimeInterval : NSObject -{ - NSUInteger _microseconds; - NSUInteger _seconds; - NSUInteger _minutes; - NSUInteger _hours; - NSUInteger _days; - NSUInteger _months; - NSUInteger _years; -} - -/** - * @property microseconds The number of microseconds. - */ -@property (readonly) NSUInteger microseconds; - -/** - * @property seconds The number of seconds. - */ -@property (readonly) NSUInteger seconds; - -/** - * @property minutes The number of minutes. - */ -@property (readonly) NSUInteger minutes; - -/** - * @property hours The number of hours. - */ -@property (readonly) NSUInteger hours; - -/** - * @property days The number of days. - */ -@property (readonly) NSUInteger days; - -/** - * @property months The number of months. - */ -@property (readonly) NSUInteger months; - -/** - * @property years The number of years. - */ -@property (readonly) NSUInteger years; - - -@end diff --git a/Frameworks/PostgresKit/Source/FLXTimeInterval.m b/Frameworks/PostgresKit/Source/FLXTimeInterval.m deleted file mode 100644 index 48f8cbd4..00000000 --- a/Frameworks/PostgresKit/Source/FLXTimeInterval.m +++ /dev/null @@ -1,71 +0,0 @@ -// -// $Id$ -// -// FLXTimeInterval.m -// PostgresKit -// -// Created by Stuart Connolly (stuconnolly.com) on September 9, 2012. -// Copyright (c) 2012 Stuart Connolly. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -#import "FLXTimeInterval.h" -#import "FLXPostgresKitPrivateAPI.h" - -@implementation FLXTimeInterval - -@synthesize microseconds = _microseconds; -@synthesize seconds = _seconds; -@synthesize minutes = _minutes; -@synthesize hours = _hours; -@synthesize days = _days; -@synthesize months = _months; -@synthesize years = _years; - -#pragma mark - - -- (id)initWithInterval:(const PGinterval *)interval -{ - if ((self = [super init])) { - if (interval) { - _microseconds = interval->usecs; - _seconds = interval->secs; - _minutes = interval->mins; - _hours = interval->hours; - _days = interval->days; - _months = interval->mons; - _years = interval->years; - } - } - - return self; -} - -#pragma mark - - -- (NSString *)description -{ - return [NSString stringWithFormat:@"%d years, %d months, %d days, %d hours, %d minutes, %d seconds and %d microseconds", - _years, _months, _days, _hours, _minutes, _seconds, _microseconds]; -} - -@end diff --git a/Frameworks/PostgresKit/Source/FLXTimeTZ.h b/Frameworks/PostgresKit/Source/FLXTimeTZ.h deleted file mode 100644 index a24fc2cf..00000000 --- a/Frameworks/PostgresKit/Source/FLXTimeTZ.h +++ /dev/null @@ -1,62 +0,0 @@ -// -// $Id$ -// -// FLXTimeTZ.h -// PostgresKit -// -// Created by Stuart Connolly (stuconnolly.com) on September 8, 2012. -// Copyright (c) 2012 Stuart Connolly. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -/** - * @class FLXTimeTZ FLXTimeTZ.h - * - * @author Stuart Connolly http://stuconnolly.com - * - * Simple wrapper to represet a time or timestamp with an associated time zone. - */ -@interface FLXTimeTZ : NSObject -{ - BOOL _hasDate; - - NSDate *_date; - NSTimeZone *_timeZone; -} - -@property (readwrite, assign) BOOL hasDate; - -/** - * @property date The date instance that holds the time. - */ -@property (readonly) NSDate *date; - -/** - * @property timeZone The time zone of the associated time. - */ -@property (readonly) NSTimeZone *timeZone; - -+ (FLXTimeTZ *)timeWithDate:(NSDate *)date timeZoneGMTOffset:(NSUInteger)offset; - -- (id)initWithDate:(NSDate *)date timeZoneGMTOffset:(NSUInteger)offset; - -@end diff --git a/Frameworks/PostgresKit/Source/FLXTimeTZ.m b/Frameworks/PostgresKit/Source/FLXTimeTZ.m deleted file mode 100644 index 48c97aa9..00000000 --- a/Frameworks/PostgresKit/Source/FLXTimeTZ.m +++ /dev/null @@ -1,84 +0,0 @@ -// -// $Id$ -// -// FLXTimeTZ.m -// PostgresKit -// -// Created by Stuart Connolly (stuconnolly.com) on September 8, 2012. -// Copyright (c) 2012 Stuart Connolly. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -#import "FLXTimeTZ.h" - -@implementation FLXTimeTZ - -@synthesize hasDate = _hasDate; -@synthesize date = _date; -@synthesize timeZone = _timeZone; - -- (id)init -{ - return [self initWithDate:[NSDate date] timeZoneGMTOffset:[[NSTimeZone systemTimeZone] secondsFromGMT]]; -} - -+ (FLXTimeTZ *)timeWithDate:(NSDate *)date timeZoneGMTOffset:(NSUInteger)offset -{ - return [[[FLXTimeTZ alloc] initWithDate:date timeZoneGMTOffset:offset] autorelease]; -} - -/** - * Initialise a FLXTimeTZ with the supplied date and GMT offset. - * - * @param date The date to use. - * @param offset The GMT offset in seconds that the associated time zone is. - * - * @return The initialised instance. - */ -- (id)initWithDate:(NSDate *)date timeZoneGMTOffset:(NSUInteger)offset -{ - if ((self = [super init])) { - _date = date; - _hasDate = NO; - _timeZone = [NSTimeZone timeZoneForSecondsFromGMT:offset]; - } - - return self; -} - -#pragma mark - - -- (NSString *)description -{ - NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; - - [formatter setDateStyle:_hasDate ? NSDateFormatterMediumStyle : NSDateFormatterNoStyle]; - [formatter setTimeStyle:NSDateFormatterMediumStyle]; - - NSString *output = [formatter stringFromDate:_date]; - - [formatter release]; - - return [NSString stringWithFormat:@"%@ %@", output, [_timeZone abbreviation]]; -} - -@end -- cgit v1.2.3