/*
*******************************************************************************
-* Copyright (C) 1996-2012, International Business Machines
+* Copyright (C) 1996-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
-#include <typeinfo> // for 'typeid' to work
+#include "utypeinfo.h" // for 'typeid' to work
#include "unicode/utypes.h"
#include "unicode/simpletz.h"
#include "unicode/ustring.h"
#include "unicode/strenum.h"
+#include "unicode/localpointer.h"
#include "cmemory.h"
#include "cstring.h"
#include "ustrenum.h"
}
}
+U_CAPI int32_t U_EXPORT2
+ucal_getTimeZoneID(const UCalendar *cal,
+ UChar *result,
+ int32_t resultLength,
+ UErrorCode *status)
+{
+ if (U_FAILURE(*status)) {
+ return 0;
+ }
+ const TimeZone& tz = ((Calendar*)cal)->getTimeZone();
+ UnicodeString id;
+ tz.getID(id);
+ return id.extract(result, resultLength, *status);
+}
+
U_CAPI int32_t U_EXPORT2
ucal_getTimeZoneDisplayName(const UCalendar* cal,
UCalendarDisplayNameType type,
return en;
}
+U_CAPI UBool U_EXPORT2
+ucal_getTimeZoneTransitionDate(const UCalendar* cal, UTimeZoneTransitionType type,
+ UDate* transition, UErrorCode* status)
+{
+ if (U_FAILURE(*status)) {
+ return FALSE;
+ }
+ UDate base = ((Calendar*)cal)->getTime(*status);
+ const TimeZone& tz = ((Calendar*)cal)->getTimeZone();
+ const BasicTimeZone * btz = dynamic_cast<const BasicTimeZone *>(&tz);
+ if (btz != NULL && U_SUCCESS(*status)) {
+ TimeZoneTransition tzt;
+ UBool inclusive = (type == UCAL_TZ_TRANSITION_NEXT_INCLUSIVE || type == UCAL_TZ_TRANSITION_PREVIOUS_INCLUSIVE);
+ UBool result = (type == UCAL_TZ_TRANSITION_NEXT || type == UCAL_TZ_TRANSITION_NEXT_INCLUSIVE)?
+ btz->getNextTransition(base, inclusive, tzt):
+ btz->getPreviousTransition(base, inclusive, tzt);
+ if (result) {
+ *transition = tzt.getTime();
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
#endif /* #if !UCONFIG_NO_FORMATTING */