diff --git a/headers/os/locale/Locale.h b/headers/os/locale/Locale.h index 915565e12d..a4cbdce90c 100644 --- a/headers/os/locale/Locale.h +++ b/headers/os/locale/Locale.h @@ -13,6 +13,7 @@ class BCatalog; class BString; +class BTimeZone; class BLocale { @@ -46,6 +47,8 @@ public: // Date + // TODO: drop some of these once BDateFormat + // has been implemented! status_t FormatDate(char* string, size_t maxSize, time_t time, bool longFormat); status_t FormatDate(BString* string, time_t time, @@ -63,10 +66,13 @@ public: // Time + // TODO: drop some of these once BTimeFormat + // has been implemented! status_t FormatTime(char* string, size_t maxSize, time_t time, bool longFormat); status_t FormatTime(BString* string, time_t time, - bool longFormat); + bool longFormat, + const BTimeZone* timeZone = NULL); status_t FormatTime(BString* string, int*& fieldPositions, int& fieldCount, time_t time, bool longFormat); diff --git a/src/kits/locale/Locale.cpp b/src/kits/locale/Locale.cpp index 07e7a19dd1..2cccd6c7bb 100644 --- a/src/kits/locale/Locale.cpp +++ b/src/kits/locale/Locale.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -393,7 +394,8 @@ BLocale::FormatTime(char* string, size_t maxSize, time_t time, bool longFormat) status_t -BLocale::FormatTime(BString* string, time_t time, bool longFormat) +BLocale::FormatTime(BString* string, time_t time, bool longFormat, + const BTimeZone* timeZone) { string->Truncate(0); @@ -402,6 +404,14 @@ BLocale::FormatTime(BString* string, time_t time, bool longFormat) if (timeFormatter.Get() == NULL) return B_NO_MEMORY; + if (timeZone != NULL) { + ObjectDeleter icuTimeZone + = TimeZone::createTimeZone(timeZone->Code().String()); + if (icuTimeZone.Get() == NULL) + return B_NO_MEMORY; + timeFormatter->setTimeZone(*icuTimeZone.Get()); + } + UnicodeString ICUString; ICUString = timeFormatter->format((UDate)time * 1000, ICUString);