[Mysql-cocoa-users] Fixes for problems with "unexisting" dates and times
Brought to you by:
sergecohen
|
From: Lorenz T. <lo...@te...> - 2003-09-21 11:36:45
|
Hi Serge,
I have noticed that the framework has some problems with dates like
0000-00-00 or 0000-01-01, or times like 222:12:10. I have changed some
lines in the fetchRow methods, so that it tries to initialize a
NSCalendarDate object, and if that isn't possible, it just returns the
value as a string.
Maybe you want to implement that in your version.
Best Regards,
Lorenz
// changes in fetchRow methods to fix problems with "unexisting" dates
and times
case FIELD_TYPE_DATE:
theCurrentObj = [NSCalendarDate
dateWithString:[NSString stringWithUTF8String:theData]
calendarFormat:@"%Y-%m-%d"];
if ( !theCurrentObj ) {
theCurrentObj = [NSString
stringWithUTF8String:theData];
}
break;
case FIELD_TYPE_TIME:
theCurrentObj = [NSCalendarDate
dateWithString:[NSString stringWithUTF8String:theData]
calendarFormat:@"%H:%M:%S"];
if ( !theCurrentObj ) {
theCurrentObj = [NSString
stringWithUTF8String:theData];
}
break;
case FIELD_TYPE_DATETIME:
theCurrentObj = [NSCalendarDate
dateWithString:[NSString stringWithUTF8String:theData]
calendarFormat:@"%Y-%m-%d %H:%M:%S"];
if ( !theCurrentObj ) {
theCurrentObj = [NSString
stringWithUTF8String:theData];
}
break;
case FIELD_TYPE_YEAR:
theCurrentObj = [NSCalendarDate
dateWithString:[NSString stringWithUTF8String:theData]
calendarFormat:@"%Y"];
if ( !theCurrentObj ) {
theCurrentObj = [NSString
stringWithUTF8String:theData];
}
break;
|