X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/729e4ab9bc6618bc3d8a898e575df7f4019e29ca..f3c0d7a59d99c2a94c6b8822291f0e42be3773c9:/icuSources/i18n/udatintv.cpp diff --git a/icuSources/i18n/udatintv.cpp b/icuSources/i18n/udatintv.cpp index 85cb1229..49c5aca6 100644 --- a/icuSources/i18n/udatintv.cpp +++ b/icuSources/i18n/udatintv.cpp @@ -1,6 +1,6 @@ /* ***************************************************************************************** -* Copyright (C) 2010 Apple Inc. All Rights Reserved. +* Copyright (C) 2010-2011 Apple Inc. All Rights Reserved. ***************************************************************************************** */ @@ -8,11 +8,8 @@ #if !UCONFIG_NO_FORMATTING +#include "unicode/udateintervalformat.h" #include "unicode/udatintv.h" -#include "unicode/dtitvfmt.h" -#include "unicode/dtintrv.h" -#include "unicode/locid.h" -#include "unicode/unistr.h" U_NAMESPACE_USE @@ -23,18 +20,14 @@ udatintv_open(const char* locale, int32_t skeletonLength, UErrorCode* status) { - if (U_FAILURE(*status)) { - return 0; - } - UnicodeString skel((UBool)(skeletonLength == -1), skeleton, skeletonLength); - return (UDateIntervalFormat*)DateIntervalFormat::createInstance(skel, Locale(locale), *status); + return udtitvfmt_open(locale, skeleton, skeletonLength, NULL, 0, status); } U_CAPI void U_EXPORT2 udatintv_close(UDateIntervalFormat *datintv) { - delete (DateIntervalFormat*)datintv; + udtitvfmt_close(datintv); } @@ -47,31 +40,7 @@ udatintv_format(const UDateIntervalFormat* datintv, UFieldPosition* position, UErrorCode* status) { - if (U_FAILURE(*status)) { - return -1; - } - UnicodeString res; - if (!(result==NULL && resultCapacity==0)) { - // NULL destination for pure preflighting: empty dummy string - // otherwise, alias the destination buffer (copied from udat_format) - res.setTo(result, 0, resultCapacity); - } - FieldPosition fp; - if (position != 0) { - fp.setField(position->field); - } - - DateInterval interval = DateInterval(fromDate,toDate); - ((const DateIntervalFormat*)datintv)->format( &interval, res, fp, *status ); - if (U_FAILURE(*status)) { - return -1; - } - if (position != 0) { - position->beginIndex = fp.getBeginIndex(); - position->endIndex = fp.getEndIndex(); - } - - return res.extract(result, resultCapacity, *status); + return udtitvfmt_format(datintv, fromDate, toDate, result, resultCapacity, position, status); }