aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableStatus.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2009-03-01 16:50:55 +0000
committerstuconnolly <stuart02@gmail.com>2009-03-01 16:50:55 +0000
commit79156f6fccf7b49d02c95df0f43627b78584d80f (patch)
treef77dc44a8dbc3fa70c7ef34f6c4c0656cddb59eb /Source/TableStatus.m
parent33bf02039fc6902fa1951fef690fc0ee3b8d5cf9 (diff)
downloadsequelpro-79156f6fccf7b49d02c95df0f43627b78584d80f.tar.gz
sequelpro-79156f6fccf7b49d02c95df0f43627b78584d80f.tar.bz2
sequelpro-79156f6fccf7b49d02c95df0f43627b78584d80f.zip
- In the table status view use the user's long date format and medium time format when displaying the create and update date/time of the selected table.
- In the table info pane set the date formatter's behaviour otherwise setting it's date and time style have no effect. Also consolidate the date formatting code into a single private method to reduce the amount of code duplication.
Diffstat (limited to 'Source/TableStatus.m')
-rw-r--r--Source/TableStatus.m38
1 files changed, 32 insertions, 6 deletions
diff --git a/Source/TableStatus.m b/Source/TableStatus.m
index d1a4d45b..4edaa4e0 100644
--- a/Source/TableStatus.m
+++ b/Source/TableStatus.m
@@ -17,16 +17,42 @@
- (NSString*)formatValueWithKey:(NSString *)aKey inDictionary:(NSDictionary*)statusDict withLabel:(NSString*)label
{
- NSString* value = [statusDict objectForKey:aKey];
- if([value isKindOfClass:[NSNull class]]) {
+ NSString *value = [statusDict objectForKey:aKey];
+
+ if ([value isKindOfClass:[NSNull class]]) {
value = @"--";
- } else {
-
+ }
+ else {
// Format size strings
- if ([aKey isEqualToString:@"Data_length"] || [aKey isEqualToString:@"Max_data_length"]
- || [aKey isEqualToString:@"Index_length"] || [aKey isEqualToString:@"Data_free"]) {
+ if ([aKey isEqualToString:@"Data_length"] ||
+ [aKey isEqualToString:@"Max_data_length"] ||
+ [aKey isEqualToString:@"Index_length"] ||
+ [aKey isEqualToString:@"Data_free"]) {
+
value = [NSString stringForByteSize:[value intValue]];
}
+ // Format date strings to the user's long date format
+ else if ([aKey isEqualToString:@"Create_time"] ||
+ [aKey isEqualToString:@"Update_time"]) {
+
+ // Create date formatter
+ NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
+
+ // Set the date format returned by MySQL
+ [dateFormatter setDateFormat:@"%Y-%m-%d %H:%M:%S"];
+
+ // Get the date instance
+ NSDate *date = [dateFormatter dateFromString:value];
+
+ // This behaviour should be set after the above date string is parsed to a date object so we can
+ // use the below style methods.
+ [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
+
+ [dateFormatter setDateStyle:NSDateFormatterLongStyle];
+ [dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
+
+ value = [dateFormatter stringFromDate:date];
+ }
}
NSString* labelVal = [NSString stringWithFormat:@"%@: %@", label, value];