1 /********************************************************************
3 * Copyright (c) 1997-2008, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6 /********************************************************************************
10 * Madhu Katragadda Ported for C API
11 * Modification History:
12 * Date Name Description
13 * 07/15/99 helena Ported to HPUX 10/11 CC.
14 *********************************************************************************
16 /* REGRESSION TEST FOR DATE FORMAT */
18 #include "unicode/utypes.h"
20 #if !UCONFIG_NO_FORMATTING
22 #include "unicode/uloc.h"
23 #include "unicode/udat.h"
24 #include "unicode/ucal.h"
25 #include "unicode/unum.h"
26 #include "unicode/ustring.h"
31 void addDateForRgrTest(TestNode
** root
);
33 void addDateForRgrTest(TestNode
** root
)
35 addTest(root
, &Test4029195
, "tsformat/cdtrgtst/Test4029195");
36 addTest(root
, &Test4056591
, "tsformat/cdtrgtst/Test4056591");
37 addTest(root
, &Test4059917
, "tsformat/cdtrgtst/Test4059917");
38 addTest(root
, &Test4060212
, "tsformat/cdtrgtst/Test4060212");
39 addTest(root
, &Test4061287
, "tsformat/cdtrgtst/Test4061287");
40 addTest(root
, &Test4073003
, "tsformat/cdtrgtst/Test4073003");
41 addTest(root
, &Test4162071
, "tsformat/cdtrgtst/Test4162071");
42 addTest(root
, &Test714
, "tsformat/cdtrgtst/Test714");
43 addTest(root
, &Test_GEec
, "tsformat/cdtrgtst/Test_GEec"); /* tests for format chars GEec, jitterbugs 5726 6072 6585 */
51 int32_t resultlength
, resultlengthneeded
;
52 UChar
*fmdt
, *todayS
, *rt
;
58 UErrorCode status
= U_ZERO_ERROR
;
60 log_verbose("Testing date format and parse function in regression test\n");
61 today
= ucal_getNow();
63 df
= udat_open(UDAT_DEFAULT
,UDAT_DEFAULT
,"en_US", NULL
, 0, NULL
, 0, &status
);
66 log_err("FAIL: error in creating the dateformat using default date and time style : %s\n", myErrorName(status
));
70 resultlengthneeded
=udat_toPattern(df
, TRUE
, NULL
, resultlength
, &status
);
71 if(status
==U_BUFFER_OVERFLOW_ERROR
)
74 resultlength
=resultlengthneeded
+ 1;
75 pat
=(UChar
*)malloc(sizeof(UChar
) * resultlength
);
76 udat_toPattern(df
, TRUE
, pat
, resultlength
, &status
);
79 log_verbose("pattern: %s\n", austrdup(pat
));
82 fmdt
= myFormatit(df
, today
);
84 log_verbose("today: %s\n", austrdup(fmdt
));
86 log_data_err("ERROR: couldn't format, exitting test");
90 temp
=(UChar
*)malloc(sizeof(UChar
) * 10);
91 u_uastrcpy(temp
, "M yyyy dd");
92 udat_applyPattern(df
, TRUE
, temp
, u_strlen(temp
));
94 todayS
=myFormatit(df
, today
);
95 log_verbose("After teh pattern is applied\n today: %s\n", austrdup(todayS
) );
97 d1
=udat_parse(df
, todayS
, u_strlen(todayS
), &parsepos
, &status
);
100 log_err("FAIL: Error in parsing using udat_parse(.....): %s\n", myErrorName(status
));
103 rt
=myFormatit(df
, d1
);
104 log_verbose("today: %s\n", austrdup(rt
) );
106 log_verbose("round trip: %s\n", austrdup(rt
) );
108 if(u_strcmp(rt
, todayS
)!=0) {
109 log_err("Fail: Want %s Got %s\n", austrdup(todayS
), austrdup(rt
) );
112 log_verbose("Pass: parse and format working fine\n");
123 * Verify the function of the [s|g]et2DigitYearStart() API.
132 UChar
*gotdate
, *expdate
;
135 UErrorCode status
= U_ZERO_ERROR
;
136 const char* strings
[] = {
143 log_verbose("Testing s[get] 2 digit year start regressively\n");
144 cal
=ucal_open(NULL
, 0, "en_US", UCAL_GREGORIAN
, &status
);
145 if(U_FAILURE(status
)){
146 log_err("error in ucal_open caldef : %s\n", myErrorName(status
));
148 ucal_setDateTime(cal
, 1809, UCAL_DECEMBER
, 25, 17, 40, 30, &status
);
149 d
[0]=ucal_getMillis(cal
, &status
);
150 if(U_FAILURE(status
)){
151 log_err("Error: failure in get millis: %s\n", myErrorName(status
));
153 ucal_setDateTime(cal
, 1909, UCAL_DECEMBER
, 24, 17, 40, 30, &status
);
154 d
[1]=ucal_getMillis(cal
, &status
);
155 ucal_setDateTime(cal
, 1861, UCAL_DECEMBER
, 26, 17, 40, 30, &status
);
156 d
[2]=ucal_getMillis(cal
, &status
);
157 ucal_setDateTime(cal
, 1999, UCAL_DECEMBER
, 27, 17, 40, 30, &status
);
158 d
[3]=ucal_getMillis(cal
, &status
);
161 u_uastrcpy(pat
, "yyMMdd");
162 def
= udat_open(UDAT_IGNORE
,UDAT_IGNORE
,NULL
, NULL
, 0, pat
, u_strlen(pat
), &status
);
163 if(U_FAILURE(status
))
165 log_err("FAIL: error in creating the dateformat using u_openPattern(): %s\n", myErrorName(status
));
169 udat_set2DigitYearStart(def
, start
, &status
);
170 if(U_FAILURE(status
))
171 log_err("ERROR: in setTwoDigitStartDate: %s\n", myErrorName(status
));
172 if( (udat_get2DigitYearStart(def
, &status
) != start
))
173 log_err("ERROR: get2DigitYearStart broken\n");
176 for(i
= 0; i
< 4; ++i
) {
177 u_uastrcpy(s
, strings
[i
]);
179 got
= udat_parse(def
, s
, u_strlen(s
), 0, &status
);
180 gotdate
=myFormatit(def
, got
);
181 expdate
=myFormatit(def
, exp
);
183 if (gotdate
== NULL
|| expdate
== NULL
) {
184 log_err("myFormatit failed!\n");
186 else if(u_strcmp(gotdate
, expdate
) !=0){
187 log_err("set2DigitYearStart broken for %s \n got: %s, expected: %s\n", austrdup(s
),
188 austrdup(gotdate
), austrdup(expdate
) );
198 * SimpleDateFormat does not properly parse date strings without delimiters
205 UErrorCode status
= U_ZERO_ERROR
;
209 log_verbose("Testing apply pattern and to pattern regressively\n");
210 u_uastrcpy(tzID
, "PST");
211 u_uastrcpy(pattern
, "yyyy/MM/dd");
212 log_verbose("%s\n", austrdup(pattern
) );
213 def
= udat_open(UDAT_IGNORE
,UDAT_IGNORE
,NULL
,tzID
,-1,pattern
, u_strlen(pattern
),&status
);
214 if(U_FAILURE(status
))
216 log_err("FAIL: error in creating the dateformat using openPattern: %s\n", myErrorName(status
));
219 myDate
=(UChar
*)malloc(sizeof(UChar
) * 11);
220 u_uastrcpy(myDate
, "1970/01/12");
222 aux917( def
, myDate
);
225 u_uastrcpy(pattern
, "yyyyMMdd");
226 def
= udat_open(UDAT_IGNORE
,UDAT_IGNORE
,NULL
,tzID
,-1,pattern
, u_strlen(pattern
),&status
);
227 if(U_FAILURE(status
))
229 log_err("FAIL: error in creating the dateformat using openPattern: %s\n", myErrorName(status
));
232 u_uastrcpy(myDate
, "19700112");
233 aux917( def
, myDate
);
238 void aux917( UDateFormat
*fmt
, UChar
* str
)
240 int32_t resultlength
, resultlengthneeded
;
241 UErrorCode status
= U_ZERO_ERROR
;
242 UChar
* formatted
=NULL
;
244 UDate d1
=1000000000.0;
247 resultlengthneeded
=udat_toPattern(fmt
, TRUE
, NULL
, resultlength
, &status
);
248 if(status
==U_BUFFER_OVERFLOW_ERROR
)
251 resultlength
=resultlengthneeded
+ 1;
252 pat
=(UChar
*)malloc(sizeof(UChar
) * (resultlength
));
253 udat_toPattern(fmt
, TRUE
, pat
, resultlength
, &status
);
255 if(U_FAILURE(status
)){
256 log_err("failure in retrieving the pattern: %s\n", myErrorName(status
));
258 log_verbose("pattern: %s\n", austrdup(pat
) );
260 status
= U_ZERO_ERROR
;
261 formatted
= myFormatit(fmt
, d1
);
262 if( u_strcmp(formatted
,str
)!=0) {
263 log_err("Fail: Want %s Got: %s\n", austrdup(str
), austrdup(formatted
) );
275 UDateFormat
*formatter
, *fmt
;
276 UErrorCode status
= U_ZERO_ERROR
;
279 UChar dateString
[30], pattern
[20], tzID
[4];
280 u_uastrcpy(dateString
, "1995-040.05:01:29 -8");
281 u_uastrcpy(pattern
, "yyyy-DDD.hh:mm:ss z");
283 log_verbose( "dateString= %s Using yyyy-DDD.hh:mm:ss\n", austrdup(dateString
) );
284 status
= U_ZERO_ERROR
;
285 u_uastrcpy(tzID
, "PST");
287 formatter
= udat_open(UDAT_IGNORE
,UDAT_IGNORE
,"en_US",tzID
,-1,pattern
, u_strlen(pattern
), &status
);
289 myDate
= udat_parse(formatter
, dateString
, u_strlen(dateString
), &pos
, &status
);
292 fmt
= udat_open(UDAT_FULL
,UDAT_LONG
,NULL
, tzID
, -1, NULL
, 0, &status
);
293 if(U_FAILURE(status
))
295 log_err("FAIL: error in creating the dateformat using default date and time style: %s\n",
296 myErrorName(status
) );
299 myString
= myFormatit(fmt
, myDate
);
300 cal
=ucal_open(tzID
, u_strlen(tzID
), "en_US", UCAL_GREGORIAN
, &status
);
301 if(U_FAILURE(status
)){
302 log_err("FAIL: error in ucal_open caldef : %s\n", myErrorName(status
));
304 ucal_setMillis(cal
, myDate
, &status
);
305 if ((ucal_get(cal
, UCAL_DAY_OF_YEAR
, &status
) != 40)){
306 log_err("Fail: Got %d Expected 40\n", ucal_get(cal
, UCAL_DAY_OF_YEAR
, &status
));
309 udat_close(formatter
);
323 UErrorCode status
= U_ZERO_ERROR
;
325 UChar pattern
[21], dateString
[11];
327 u_uastrcpy(dateString
, "35/13/1971");
328 u_uastrcpy(pattern
, "dd/mm/yyyy");
329 status
= U_ZERO_ERROR
;
330 log_verbose("Testing parsing by changing the attribute lenient\n");
331 df
= udat_open(UDAT_IGNORE
,UDAT_IGNORE
,NULL
,NULL
,0,pattern
, u_strlen(pattern
),&status
);
332 if(U_FAILURE(status
)){
333 log_err("ERROR: failure in open pattern of test4061287: %s\n", myErrorName(status
));
339 udat_setLenient(df
, FALSE
);
340 ok
=udat_isLenient(df
);
342 log_err("setLenient nor working\n");
344 myDate
= udat_parse(df
, dateString
, u_strlen(dateString
), &pos
, &status
);
345 if(U_FAILURE(status
))
348 log_err("Fail: Lenient not working: does lenient parsing in spite of setting Leninent as FALSE ");
356 /* The java.text.DateFormat.parse(String) method expects for the
357 US locale a string formatted according to mm/dd/yy and parses it
360 When given a string mm/dd/yyyy it only parses up to the first
361 two y's, typically resulting in a date in the year 1919.
363 Please extend the parsing method(s) to handle strings with
364 four-digit year values (probably also applicable to various
375 UErrorCode status
= U_ZERO_ERROR
;
377 UChar
*result
, *result2
;
378 const char* tests
[] = {
385 fmt
= udat_open(UDAT_SHORT
,UDAT_SHORT
,NULL
, NULL
, 0, NULL
, 0, &status
);
386 if(U_FAILURE(status
))
388 log_err("FAIL: error in creating the dateformat using short date and time style: %s\n",
389 myErrorName(status
));
392 u_uastrcpy(temp
, "m/D/yy");
393 udat_applyPattern(fmt
, FALSE
, temp
, u_strlen(temp
));
395 for(i
= 0; i
< 4; i
+=2) {
397 datestr
=(UChar
*)malloc(sizeof(UChar
) * (strlen(tests
[i
])+1));
398 u_uastrcpy(datestr
, tests
[i
]);
401 d
= udat_parse(fmt
, datestr
, u_strlen(datestr
), &pos
, &status
);
402 if(U_FAILURE(status
)){
403 log_err("ERROR : in test 4073003: %s\n", myErrorName(status
));
407 datestr
=(UChar
*)malloc(sizeof(UChar
) * (strlen(tests
[i
+1])+1));
408 u_uastrcpy(datestr
, tests
[i
+1]);
412 dd
= udat_parse(fmt
, datestr
, u_strlen(datestr
), &pos
, &status
);
413 if(U_FAILURE(status
)){
414 log_err("ERROR : in test 4073003: %s\n", myErrorName(status
));
418 result
=myFormatit(fmt
, d
);
419 result2
=myFormatit(fmt
, dd
);
420 if(!result
|| !result2
) {
421 log_data_err("Fail: could not format - exitting test\n");
424 if (u_strcmp(result
, result2
)!=0){
425 log_err("Fail: %s != %s\n", austrdup(result
), austrdup(result2
) );
428 log_verbose("Ok: %s == %s\n", austrdup(result
), austrdup(result2
) );
442 UErrorCode status
= U_ZERO_ERROR
;
446 u_uastrcpy(datestr
, "Thu, 30-Jul-1999 11:51:14 GMT");
447 u_uastrcpy(format
, "EEE', 'dd-MMM-yyyy HH:mm:ss z"); /* RFC 822/1123 */
448 status
= U_ZERO_ERROR
;
449 /* Can't hardcode the result to assume the default locale is "en_US". */
450 df
= udat_open(UDAT_IGNORE
,UDAT_IGNORE
,"en_US",NULL
,0,format
, u_strlen(format
),&status
);
451 if(U_FAILURE(status
)){
452 log_data_err("ERROR: couldn't create date format: %s\n", myErrorName(status
));
456 x
= udat_parse(df
, datestr
, u_strlen(datestr
), &pos
, &status
);
457 if(U_FAILURE(status
)){
458 log_data_err("ERROR : parse format %s fails : %s\n", austrdup(format
), myErrorName(status
));
461 log_verbose("Parse format \"%s \" ok.\n", austrdup(format
) );
463 /*log_verbose("date= %s\n", austrdup(myFormatit(df, x)) );*/
469 UDate d
=978103543000.0;
471 UErrorCode status
= U_ZERO_ERROR
;
474 const char* expect
= "7:25:43 AM";
476 ctest_setTimeZone(NULL
, &status
);
478 fmt
= udat_open(UDAT_MEDIUM
,UDAT_NONE
,"en_US_CA", NULL
, -1, NULL
, 0, &status
);
479 if(U_FAILURE(status
))
481 log_err("FAIL: error in creating the dateformat using medium time style and NO date style: %s\n",
482 myErrorName(status
));
485 result
=myFormatit(fmt
, d
);
487 log_data_err("Fail: could not format - exitting test\n");
490 u_uastrcpy(temp
, expect
);
491 if (u_strcmp(result
, temp
)!=0){
492 log_err("Fail: %s != %s\n", austrdup(result
), expect
);
495 log_verbose("Ok: %s == %s\n", austrdup(result
), expect
);
500 ctest_resetTimeZone();
503 enum { DATE_TEXT_MAX_CHARS
= 64 };
504 static const UChar zonePST
[] = { 0x50,0x53,0x54,0 }; /* "PST" */
505 static const UDate july022008
= 1.215e+12; /* 02 July 2008 5:00 AM PDT (approx ICU 4.0 release date :-) */
506 static const double dayMillisec
= 8.64e+07;
508 static const UChar dMyGGGPattern
[] = { 0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0x20,0x47,0x47,0x47,0 }; /* "dd MMM yyyy GGG" */
509 static const UChar dMyGGGGGPattern
[] = { 0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0x20,0x47,0x47,0x47,0x47,0x47,0 }; /* "dd MMM yyyy GGGGG" */
510 static const UChar dMyGGGText
[] = { 0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0x20,0x41,0x44,0 }; /* "02 Jul 2008 AD" */
511 static const UChar dMyGGGGGText
[] = { 0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0x20,0x41,0 }; /* "02 Jul 2008 A" */
512 static const UChar edMyPattern
[] = { 0x65,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "e dd MMM yyyy" */
513 static const UChar eedMyPattern
[] = { 0x65,0x65,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "ee dd MMM yyyy" */
514 static const UChar cdMyPattern
[] = { 0x63,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "c dd MMM yyyy" */
515 static const UChar ccdMyPattern
[] = { 0x63,0x63,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "cc dd MMM yyyy" */
516 static const UChar edMyText
[] = { 0x33,0x20,0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0 }; /* "3 02 Jul 2008" */
517 static const UChar eedMyText
[] = { 0x30,0x33,0x20,0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0 }; /* "03 02 Jul 2008" */
518 static const UChar eeedMyPattern
[] = { 0x65,0x65,0x65,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "eee dd MMM yyyy" */
519 static const UChar EEEdMyPattern
[] = { 0x45,0x45,0x45,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "EEE dd MMM yyyy" */
520 static const UChar EEdMyPattern
[] = { 0x45,0x45,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "EE dd MMM yyyy" */
521 static const UChar eeedMyText
[] = { 0x57,0x65,0x64,0x20,0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0 }; /* "Wed 02 Jul 2008" */
522 static const UChar eeeedMyPattern
[] = { 0x65,0x65,0x65,0x65,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "eeee dd MMM yyyy" */
523 static const UChar eeeedMyText
[] = { 0x57,0x65,0x64,0x6E,0x65,0x73,0x64,0x61,0x79,0x20,0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0 }; /* "Wednesday 02 Jul 2008" */
524 static const UChar eeeeedMyPattern
[] = { 0x65,0x65,0x65,0x65,0x65,0x20,0x64,0x64,0x20,0x4D,0x4D,0x4D,0x20,0x79,0x79,0x79,0x79,0 }; /* "eeeee dd MMM yyyy" */
525 static const UChar eeeeedMyText
[] = { 0x57,0x20,0x30,0x32,0x20,0x4A,0x75,0x6C,0x20,0x32,0x30,0x30,0x38,0 }; /* "W 02 Jul 2008" */
526 static const UChar ewYPattern
[] = { 0x65,0x20,0x77,0x77,0x20,0x59,0x59,0x59,0x59,0 }; /* "e ww YYYY" */
527 static const UChar cwYPattern
[] = { 0x63,0x20,0x77,0x77,0x20,0x59,0x59,0x59,0x59,0 }; /* "c ww YYYY" */
528 static const UChar ewYText
[] = { 0x33,0x20,0x32,0x37,0x20,0x32,0x30,0x30,0x38,0 }; /* "3 27 2008" */
531 const UChar
* pattern
;
534 } DatePatternAndText
;
535 static const DatePatternAndText datePatternsAndText
[] = {
536 { dMyGGGPattern
, dMyGGGText
, "dd MMM yyyy GGG" },
537 { dMyGGGGGPattern
, dMyGGGGGText
, "dd MMM yyyy GGGGG" },
538 { edMyPattern
, edMyText
, "e dd MMM yyyy" },
539 { eedMyPattern
, eedMyText
, "ee dd MMM yyyy" },
540 { cdMyPattern
, edMyText
, "c dd MMM yyyy" },
541 { ccdMyPattern
, edMyText
, "cc dd MMM yyyy" },
542 { eeedMyPattern
, eeedMyText
, "eee dd MMM yyyy" },
543 { EEEdMyPattern
, eeedMyText
, "EEE dd MMM yyyy" },
544 { EEdMyPattern
, eeedMyText
, "EE dd MMM yyyy" },
545 { eeeedMyPattern
, eeeedMyText
, "eeee dd MMM yyyy" },
546 { eeeeedMyPattern
, eeeeedMyText
, "eeeee dd MMM yyyy" },
547 { ewYPattern
, ewYText
, "e ww YYYY" },
548 { cwYPattern
, ewYText
, "c ww YYYY" },
553 UErrorCode status
= U_ZERO_ERROR
;
554 UDateFormat
* dtfmt
= udat_open(UDAT_LONG
, UDAT_LONG
, "en", zonePST
, -1, NULL
, 0, &status
);
555 if ( U_SUCCESS(status
) ) {
556 const DatePatternAndText
*patTextPtr
;
557 for (patTextPtr
= datePatternsAndText
; patTextPtr
->pattern
!= NULL
; ++patTextPtr
) {
558 UChar dmyGnText
[DATE_TEXT_MAX_CHARS
];
559 int32_t dmyGnTextLen
;
562 udat_applyPattern(dtfmt
, FALSE
, patTextPtr
->pattern
, -1);
563 dmyGnTextLen
= udat_format(dtfmt
, july022008
, dmyGnText
, DATE_TEXT_MAX_CHARS
, NULL
, &status
);
564 if ( U_FAILURE(status
) ) {
565 log_err("FAIL: udat_format with %s: %s\n", patTextPtr
->label
, myErrorName(status
) );
566 status
= U_ZERO_ERROR
;
567 } else if ( u_strcmp(dmyGnText
, patTextPtr
->text
) != 0 ) {
568 log_err("FAIL: udat_format with %s: wrong UChar[] result\n", patTextPtr
->label
);
571 dateResult
= udat_parse(dtfmt
, patTextPtr
->text
, -1, NULL
, &status
); /* no time, dateResult != july022008 by some hours */
572 if ( U_FAILURE(status
) ) {
573 log_err("FAIL: udat_parse with %s: %s\n", patTextPtr
->label
, myErrorName(status
) );
574 status
= U_ZERO_ERROR
;
575 } else if ( july022008
- dateResult
> dayMillisec
) {
576 log_err("FAIL: udat_parse with %s: wrong UDate result\n", patTextPtr
->label
);
581 log_err("FAIL: udat_open fails: %s\n", myErrorName(status
));
585 /*INTERNAL FUNCTION USED */
587 UChar
* myFormatit(UDateFormat
* datdef
, UDate d1
)
590 int32_t resultlength
, resultlengthneeded
;
591 UErrorCode status
= U_ZERO_ERROR
;
594 resultlengthneeded
=udat_format(datdef
, d1
, NULL
, resultlength
, NULL
, &status
);
595 if(status
==U_BUFFER_OVERFLOW_ERROR
)
598 resultlength
=resultlengthneeded
+1;
599 /*result1=(UChar*)malloc(sizeof(UChar) * resultlength);*/ /*this leaks*/
600 result1
=(UChar
*)ctst_malloc(sizeof(UChar
) * resultlength
); /*this won't*/
601 udat_format(datdef
, d1
, result1
, resultlength
, NULL
, &status
);
603 if(U_FAILURE(status
))
605 log_err("FAIL: Error in formatting using udat_format(.....): %s\n", myErrorName(status
));
614 #endif /* #if !UCONFIG_NO_FORMATTING */