aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2012-09-09 01:10:06 +0000
committerstuconnolly <stuart02@gmail.com>2012-09-09 01:10:06 +0000
commit6ac4ca07b1b0d61d718e73e0ba35a579ccc162c7 (patch)
tree5c2b21db911d0f80dda3c4a2fc23af35fb8a766e /Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m
parent44ca403e94e748cbf1db6941aece22029c77c542 (diff)
downloadsequelpro-6ac4ca07b1b0d61d718e73e0ba35a579ccc162c7.tar.gz
sequelpro-6ac4ca07b1b0d61d718e73e0ba35a579ccc162c7.tar.bz2
sequelpro-6ac4ca07b1b0d61d718e73e0ba35a579ccc162c7.zip
Hook up time interval support.
Diffstat (limited to 'Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m')
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m25
1 files changed, 25 insertions, 0 deletions
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m
index b28868cc..2dd4227c 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m
+++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m
@@ -26,6 +26,8 @@
#import "FLXPostgresConnection.h"
#import "FLXPostgresConnectionTypeHandling.h"
#import "FLXPostgresTimeTZ.h"
+#import "FLXPostgresTimeInterval.h"
+#import "FLXPostgresKitPrivateAPI.h"
static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] =
{
@@ -35,12 +37,15 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] =
FLXPostgresOidAbsTime,
FLXPostgresOidTimestamp,
FLXPostgresOidTimestampTZ,
+ FLXPostgresOidInterval,
0
};
@interface FLXPostgresTypeDateTimeHandler ()
- (NSDate *)_dateFromResult:(const PGresult *)result atRow:(NSUInteger)row column:(NSUInteger)column;
+- (FLXPostgresTimeInterval *)_timeIntervalFromResult:(const PGresult *)result atRow:(NSUInteger)row column:(NSUInteger)column;
+
- (id)_timeFromResult:(const PGresult *)result atRow:(NSUInteger)row column:(NSUInteger)column type:(FLXPostgresOid)type;
- (id)_timestmpFromResult:(const PGresult *)result atRow:(NSUInteger)row column:(NSUInteger)column type:(FLXPostgresOid)type;
@@ -83,6 +88,8 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] =
case FLXPostgresOidTimestamp:
case FLXPostgresOidTimestampTZ:
return [self _timestmpFromResult:result atRow:row column:column type:type];
+ case FLXPostgresOidInterval:
+ return [self _timeIntervalFromResult:result atRow:row column:column];
default:
return nil;
}
@@ -116,6 +123,24 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] =
}
/**
+ * Converts a time interval value to a FLXPostgresTimeInterval instance.
+ *
+ * @param result The result to extract the value from.
+ * @param row The row to extract the value from.
+ * @param column The column to extract the value from.
+ *
+ * @return The FLXPostgresTimeInterval representation.
+ */
+- (FLXPostgresTimeInterval *)_timeIntervalFromResult:(const PGresult *)result atRow:(NSUInteger)row column:(NSUInteger)column
+{
+ PGinterval interval;
+
+ if (!PQgetf(result, row, "%interval", column, &interval)) return nil;
+
+ return [FLXPostgresTimeInterval intervalWithPGInterval:&interval];
+}
+
+/**
* Returns a native object created from a time value.
*
* @note The date part should be ignored as it's set to a default value.