CFDateFormatter + time zone = failure or crash
CFDateFormatter + time zone = failure or crash
- Subject: CFDateFormatter + time zone = failure or crash
- From: Jim Correia <email@hidden>
- Date: Wed, 26 Jan 2005 08:26:36 -0500
I'm trying to use CFDateFormatter to format/parse a date time string
with a timezone in it. (Ultimately, I'd like to parse a string with
-0500 for the time zone.)
I've started with the examples on the ICU page. When I include the
timezone, the date doesn't parse. If I try to format the current date
using that formatter, it crashes in the ICU library.
Am I doing something wrong? Or is it time to visit the bug reported?
Thanks,
Jim
===
#0 0x968d6958 in
icu_2_6::SimpleDateFormat::subFormat(icu_2_6::UnicodeString&, unsigned
short, int, icu_2_6::FieldPosition&, icu_2_6::Calendar&, UErrorCode&)
const
#1 0x968da0d0 in icu_2_6::SimpleDateFormat::format(icu_2_6::Calendar&,
icu_2_6::UnicodeString&, icu_2_6::FieldPosition&) const
#2 0x968e02f0 in icu_2_6::DateFormat::format(double,
icu_2_6::UnicodeString&, icu_2_6::FieldPosition&) const
#3 0x968dde24 in udat_format
#4 0x901e2a44 in CFDateFormatterCreateStringWithAbsoluteTime
#5 0x00085ddc in main at main.c:25
===
#include <CoreFoundation/CoreFoundation.h>
int main (int argc, const char * argv[])
{
CFLocaleRef locale = NULL;
CFDateFormatterRef formatter = NULL;
CFStringRef date_string = CFSTR("9:34 AM, PST");
CFDateRef date = NULL;
CFAbsoluteTime time = 0;
locale = CFLocaleCopyCurrent();
formatter = CFDateFormatterCreate(kCFAllocatorDefault, locale,
kCFDateFormatterNoStyle, kCFDateFormatterNoStyle);
CFDateFormatterSetFormat(formatter, CFSTR("K:mm a, Z"));
CFDateFormatterCreateDateFromString(kCFAllocatorDefault, formatter,
date_string, NULL);
CFShow(date);
if ( CFDateFormatterGetAbsoluteTimeFromString(formatter, date_string,
NULL, &time))
{
printf("%.2f\n", time);
}
CFShow(CFDateFormatterCreateStringWithAbsoluteTime(kCFAllocatorDefault,
formatter, CFAbsoluteTimeGetCurrent()));
CFRelease(locale);
CFRelease(formatter);
if (date != NULL)
CFRelease(date);
return 0;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden