diff --git a/src/apps/haikudepot/util/LocaleUtils.cpp b/src/apps/haikudepot/util/LocaleUtils.cpp index 46eb7bced4..4014b3fcb9 100644 --- a/src/apps/haikudepot/util/LocaleUtils.cpp +++ b/src/apps/haikudepot/util/LocaleUtils.cpp @@ -5,13 +5,10 @@ #include "LocaleUtils.h" #include -#include -#include -#include #include #include -#include +#include #include #include #include @@ -48,37 +45,19 @@ LocaleUtils::GetCollator(BCollator* collator) } -/*! There was some difficulty in getting BDateTime and friends to - work for the purposes of this application. Data comes in as millis since - the epoc relative to GMT0. These need to be displayed in the local time - zone, but the timezone aspect never seems to be quite right with BDateTime! - For now, to avoid this work over-spilling into a debug of the date-time - classes in Haiku, I am adding this method that uses ICU directly in order - to get something basic working for now. Later this should be migrated to - use the BDateTime etc... classes from Haiku once these problems have been - ironed out. -*/ - /*static*/ BString LocaleUtils::TimestampToDateTimeString(uint64 millis) { if (millis == 0) return "?"; - UnicodeString pattern("yyyy-MM-dd HH:mm:ss"); - // later use variants of DateFormat::createInstance() - UErrorCode success = U_ZERO_ERROR; - SimpleDateFormat sdf(pattern, success); - - if (U_FAILURE(success)) + BDateTimeFormat format; + BString buffer; + if (format.Format(buffer, millis / 1000, B_SHORT_DATE_FORMAT, + B_SHORT_TIME_FORMAT) != B_OK) return "!"; - UnicodeString icuResult; - sdf.format((UDate) millis, icuResult); - BString result; - BStringByteSink converter(&result); - icuResult.toUTF8(converter); - return result; + return buffer; }