Re: CFDateFormatter + time zone = failure or crash
Re: CFDateFormatter + time zone = failure or crash
- Subject: Re: CFDateFormatter + time zone = failure or crash
- From: Chris Kane <email@hidden>
- Date: Sun, 6 Feb 2005 16:36:10 -0800
Note that you're not assigning 'date' any value in the test program.
It needs to be 'date = CFDateFormatterCreateDateFromString(...etc...);'
in the middle there.
You're call to CFDateFormatterCreateStringWithAbsoluteTime() though,
which is crashing, doesn't have anything to do with 'date' or the
previous few lines of code. (Assuming this was the actual test
program.) For me, after I make the correct above in the first
paragraph, I get no crash. But I'm on ICU 3.0 on Tiger. Perhaps ICU
fixed a bug.
Chris Kane
CoreFoundation, Apple
On Jan 26, 2005, at 5:26 AM, Jim Correia wrote:
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
_______________________________________________
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