[haiku-commits] Change in haiku[master]: HaikuDepot: do not use ICU directly.

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 17 May 2020 14:52:42 +0000

From Adrien Destugues <pulkomandy@xxxxxxxxx>:

Adrien Destugues has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/2724 ;)


Change subject: HaikuDepot: do not use ICU directly.
......................................................................

HaikuDepot: do not use ICU directly.
---
M src/apps/haikudepot/util/LocaleUtils.cpp
1 file changed, 6 insertions(+), 27 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/24/2724/1

diff --git a/src/apps/haikudepot/util/LocaleUtils.cpp 
b/src/apps/haikudepot/util/LocaleUtils.cpp
index 46eb7bc..4014b3f 100644
--- a/src/apps/haikudepot/util/LocaleUtils.cpp
+++ b/src/apps/haikudepot/util/LocaleUtils.cpp
@@ -5,13 +5,10 @@
 #include "LocaleUtils.h"

 #include <stdlib.h>
-#include <unicode/datefmt.h>
-#include <unicode/dtptngen.h>
-#include <unicode/smpdtfmt.h>

 #include <Catalog.h>
 #include <Collator.h>
-#include <ICUWrapper.h>
+#include <DateTimeFormat.h>
 #include <Locale.h>
 #include <LocaleRoster.h>
 #include <StringFormat.h>
@@ -48,37 +45,19 @@
 }


-/*! 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;
 }



--
To view, visit https://review.haiku-os.org/c/haiku/+/2724
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I0097fe51cc9b41509e5ba0d2452c5f28eac0538a
Gerrit-Change-Number: 2724
Gerrit-PatchSet: 1
Gerrit-Owner: Adrien Destugues <pulkomandy@xxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: HaikuDepot: do not use ICU directly. - Gerrit