/*
********************************************************************************
-* Copyright (C) 2005-2007, International Business Machines
+* Copyright (C) 2005-2014, International Business Machines
* Corporation and others. All Rights Reserved.
********************************************************************************
*
#include "unicode/utypes.h"
-#ifdef U_WINDOWS
+#if U_PLATFORM_HAS_WIN32_API
#if !UCONFIG_NO_FORMATTING
#include "cmemory.h"
#include "uresimp.h"
#include "windtfmt.h"
-#include "wintz.h"
+#include "wintzimpl.h"
# define WIN32_LEAN_AND_MEAN
# define VC_EXTRALEAN
#define STACK_BUFFER_SIZE 64
-UnicodeString *getTimeDateFormat(const Calendar *cal, const Locale *locale, UErrorCode &status)
+UnicodeString* Win32DateFormat::getTimeDateFormat(const Calendar *cal, const Locale *locale, UErrorCode &status) const
{
UnicodeString *result = NULL;
const char *type = cal->getType();
}
int32_t resStrLen = 0;
- const UChar *resStr = ures_getStringByIndex(patBundle, (int32_t)DateFormat::kDateTime, &resStrLen, &status);
+ int32_t glueIndex = DateFormat::kDateTime;
+ int32_t patSize = ures_getSize(patBundle);
+ if (patSize >= (DateFormat::kDateTimeOffset + DateFormat::kShort + 1)) {
+ // Get proper date time format
+ glueIndex = (int32_t)(DateFormat::kDateTimeOffset + (fDateStyle - DateFormat::kDateOffset));
+ }
+ const UChar *resStr = ures_getStringByIndex(patBundle, glueIndex, &resStrLen, &status);
result = new UnicodeString(TRUE, resStr, resStrLen);
// TODO: Range-check timeStyle, dateStyle
Win32DateFormat::Win32DateFormat(DateFormat::EStyle timeStyle, DateFormat::EStyle dateStyle, const Locale &locale, UErrorCode &status)
- : DateFormat(), fDateTimeMsg(NULL), fTimeStyle(timeStyle), fDateStyle(dateStyle), fLocale(&locale), fZoneID()
+ : DateFormat(), fDateTimeMsg(NULL), fTimeStyle(timeStyle), fDateStyle(dateStyle), fLocale(locale), fZoneID()
{
if (U_SUCCESS(status)) {
fLCID = locale.getLCID();
// delete fCalendar;
- this->fDateTimeMsg = other.fDateTimeMsg;
+ this->fDateTimeMsg = other.fDateTimeMsg == NULL ? NULL : new UnicodeString(*other.fDateTimeMsg);
this->fTimeStyle = other.fTimeStyle;
this->fDateStyle = other.fDateStyle;
+ this->fLocale = other.fLocale;
this->fLCID = other.fLCID;
// this->fCalendar = other.fCalendar->clone();
this->fZoneID = other.fZoneID;
timeDateArray[1].adoptString(date);
if (strcmp(fCalendar->getType(), cal.getType()) != 0) {
- pattern = getTimeDateFormat(&cal, fLocale, status);
+ pattern = getTimeDateFormat(&cal, &fLocale, status);
}
MessageFormat::format(*pattern, timeDateArray, 2, appendTo, status);
if (fDateStyle != DateFormat::kNone && fTimeStyle != DateFormat::kNone) {
delete fDateTimeMsg;
- fDateTimeMsg = getTimeDateFormat(newCalendar, fLocale, status);
+ fDateTimeMsg = getTimeDateFormat(newCalendar, &fLocale, status);
}
}
#endif /* #if !UCONFIG_NO_FORMATTING */
-#endif // #ifdef U_WINDOWS
+#endif // U_PLATFORM_HAS_WIN32_API