comparison dwtx/dwtxhelper/mangoicu/UDateFormat.d @ 91:11e8159caf7a

make the mango icu fork work.
author Frank Benoit <benoit@tionex.de>
date Mon, 07 Jul 2008 15:53:07 +0200
parents 040da1cb0d76
children
comparison
equal deleted inserted replaced
90:7ffeace6c47f 91:11e8159caf7a
80 All trademarks and registered trademarks mentioned herein are the 80 All trademarks and registered trademarks mentioned herein are the
81 property of their respective owners. 81 property of their respective owners.
82 82
83 *******************************************************************************/ 83 *******************************************************************************/
84 84
85 module dwtx.dwthelper.mangoicu.UDateFormat; 85 module dwtx.dwtxhelper.mangoicu.UDateFormat;
86 86
87 private import dwtx.dwthelper.mangoicu.ICU, 87 private import dwtx.dwtxhelper.mangoicu.ICU,
88 dwtx.dwthelper.mangoicu.UString, 88 dwtx.dwtxhelper.mangoicu.UString,
89 dwtx.dwthelper.mangoicu.UCalendar, 89 dwtx.dwtxhelper.mangoicu.UCalendar,
90 dwtx.dwthelper.mangoicu.UNumberFormat; 90 dwtx.dwtxhelper.mangoicu.UNumberFormat;
91 91
92 /******************************************************************************* 92 /*******************************************************************************
93 93
94 UDateFormat consists of functions that convert dates and 94 UDateFormat consists of functions that convert dates and
95 times from their internal representations to textual form and back 95 times from their internal representations to textual form and back
176 and time. If a pattern is not specified, an appropriate 176 and time. If a pattern is not specified, an appropriate
177 one for the given locale will be used. 177 one for the given locale will be used.
178 178
179 ***********************************************************************/ 179 ***********************************************************************/
180 180
181 this (Style time, Style date, inout ULocale locale, inout UTimeZone tz, UText pattern=null) 181 this (Style time, Style date, inout ULocale locale, inout UTimeZone tz, UStringView pattern=null)
182 { 182 {
183 Error e; 183 UErrorCode e;
184 wchar* p; 184 wchar* p;
185 uint c; 185 uint c;
186 186
187 if (pattern) 187 if (pattern)
188 p = pattern.get.ptr, c = pattern.length; 188 p = pattern.get.ptr, c = pattern.length;
207 207
208 ***********************************************************************/ 208 ***********************************************************************/
209 209
210 void format (UString dst, UDate date, UFieldPos p = null) 210 void format (UString dst, UDate date, UFieldPos p = null)
211 { 211 {
212 uint fmat (wchar* result, uint len, inout Error e) 212 uint fmat (wchar* result, uint len, inout UErrorCode e)
213 { 213 {
214 return udat_format (handle, date, result, len, p, e); 214 return udat_format (handle, date, result, len, p, e);
215 } 215 }
216 216
217 dst.format (&fmat, "date format failed"); 217 dst.format (&fmat, "date format failed");
221 221
222 Parse a string into an date/time using a UDateFormat 222 Parse a string into an date/time using a UDateFormat
223 223
224 ***********************************************************************/ 224 ***********************************************************************/
225 225
226 UDate parse (UText src, uint* index=null) 226 UDate parse (UStringView src, uint* index=null)
227 { 227 {
228 Error e; 228 UErrorCode e;
229 229
230 UDate x = udat_parse (handle, src.content.ptr, src.len, index, e); 230 UDate x = udat_parse (handle, src.content.ptr, src.len, index, e);
231 testError (e, "failed to parse date"); 231 testError (e, "failed to parse date");
232 return x; 232 return x;
233 } 233 }
277 277
278 ***********************************************************************/ 278 ***********************************************************************/
279 279
280 UDate getTwoDigitYearStart () 280 UDate getTwoDigitYearStart ()
281 { 281 {
282 Error e; 282 UErrorCode e;
283 283
284 UDate x = udat_get2DigitYearStart (handle, e); 284 UDate x = udat_get2DigitYearStart (handle, e);
285 testError (e, "failed to get two digit year start"); 285 testError (e, "failed to get two digit year start");
286 return x; 286 return x;
287 } 287 }
293 293
294 ***********************************************************************/ 294 ***********************************************************************/
295 295
296 void setTwoDigitYearStart (UDate start) 296 void setTwoDigitYearStart (UDate start)
297 { 297 {
298 Error e; 298 UErrorCode e;
299 299
300 udat_set2DigitYearStart (handle, start, e); 300 udat_set2DigitYearStart (handle, start, e);
301 testError (e, "failed to set two digit year start"); 301 testError (e, "failed to set two digit year start");
302 } 302 }
303 303
307 307
308 ***********************************************************************/ 308 ***********************************************************************/
309 309
310 void getPattern (UString dst, bool localize) 310 void getPattern (UString dst, bool localize)
311 { 311 {
312 uint fmat (wchar* result, uint len, inout Error e) 312 uint fmat (wchar* result, uint len, inout UErrorCode e)
313 { 313 {
314 return udat_toPattern (handle, localize, result, len, e); 314 return udat_toPattern (handle, localize, result, len, e);
315 } 315 }
316 316
317 dst.format (&fmat, "failed to retrieve date format pattern"); 317 dst.format (&fmat, "failed to retrieve date format pattern");
321 321
322 Set the pattern for a UDateFormat 322 Set the pattern for a UDateFormat
323 323
324 ***********************************************************************/ 324 ***********************************************************************/
325 325
326 void setPattern (UText pattern, bool localized) 326 void setPattern (UStringView pattern, bool localized)
327 { 327 {
328 udat_applyPattern (handle, localized, pattern.get.ptr, pattern.length); 328 udat_applyPattern (handle, localized, pattern.get.ptr, pattern.length);
329 } 329 }
330 330
331 /*********************************************************************** 331 /***********************************************************************
365 365
366 ***********************************************************************/ 366 ***********************************************************************/
367 367
368 private static extern (C) 368 private static extern (C)
369 { 369 {
370 Handle function (uint, uint, char*, wchar*, uint, wchar*, uint, inout Error) udat_open; 370 Handle function (uint, uint, char*, wchar*, uint, wchar*, uint, inout UErrorCode) udat_open;
371 void function (Handle) udat_close; 371 void function (Handle) udat_close;
372 uint function (Handle, UDate, wchar*, uint, UFieldPos, inout Error) udat_format; 372 uint function (Handle, UDate, wchar*, uint, UFieldPos, inout UErrorCode) udat_format;
373 UDate function (Handle, wchar*, uint, uint*, inout Error) udat_parse; 373 UDate function (Handle, wchar*, uint, uint*, inout UErrorCode) udat_parse;
374 void function (Handle, Handle) udat_setCalendar; 374 void function (Handle, Handle) udat_setCalendar;
375 void function (Handle, Handle) udat_setNumberFormat; 375 void function (Handle, Handle) udat_setNumberFormat;
376 UDate function (Handle, inout Error) udat_get2DigitYearStart; 376 UDate function (Handle, inout UErrorCode) udat_get2DigitYearStart;
377 void function (Handle, UDate, inout Error) udat_set2DigitYearStart; 377 void function (Handle, UDate, inout UErrorCode) udat_set2DigitYearStart;
378 uint function (Handle, byte, wchar*, uint, inout Error) udat_toPattern; 378 uint function (Handle, byte, wchar*, uint, inout UErrorCode) udat_toPattern;
379 void function (Handle, byte, wchar*, uint) udat_applyPattern; 379 void function (Handle, byte, wchar*, uint) udat_applyPattern;
380 void function (Handle, byte) udat_setLenient; 380 void function (Handle, byte) udat_setLenient;
381 byte function (Handle) udat_isLenient; 381 byte function (Handle) udat_isLenient;
382 Handle function (Handle) udat_getCalendar; 382 Handle function (Handle) udat_getCalendar;
383 } 383 }