You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bh...@apache.org on 2014/07/30 21:06:36 UTC

[19/38] git commit: BB10: Implement getFirstDayOfWeek.

BB10: Implement getFirstDayOfWeek.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/2a40b5bc
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/2a40b5bc
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/2a40b5bc

Branch: refs/heads/lyon-g11n
Commit: 2a40b5bca4a77ac89008f894184999863a336320
Parents: a1719f9
Author: Lianghui Chen <li...@blackberry.com>
Authored: Thu Jul 24 16:06:23 2014 -0400
Committer: Lianghui Chen <li...@blackberry.com>
Committed: Mon Jul 28 15:10:46 2014 -0400

----------------------------------------------------------------------
 .../native/src/globalization_ndk.cpp            | 26 +++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/2a40b5bc/src/blackberry10/native/src/globalization_ndk.cpp
----------------------------------------------------------------------
diff --git a/src/blackberry10/native/src/globalization_ndk.cpp b/src/blackberry10/native/src/globalization_ndk.cpp
index fea9066..c6f09f2 100644
--- a/src/blackberry10/native/src/globalization_ndk.cpp
+++ b/src/blackberry10/native/src/globalization_ndk.cpp
@@ -68,6 +68,15 @@ std::string resultInJson(bool value)
     return writer.write(root);
 }
 
+std::string resultInJson(int value)
+{
+    Json::Value root;
+    root["result"] = value;
+
+    Json::FastWriter writer;
+    return writer.write(root);
+}
+
 std::string resultInJson(const UDate& date)
 {
     UErrorCode status = U_ZERO_ERROR;
@@ -596,7 +605,22 @@ std::string GlobalizationNDK::isDayLightSavingsTime(const std::string& args)
 
 std::string GlobalizationNDK::getFirstDayOfWeek()
 {
-    return errorInJson(UNKNOWN_ERROR, "Not supported!");
+    UErrorCode status = U_ZERO_ERROR;
+    Calendar* cal = Calendar::createInstance(status);
+    if (!cal) {
+        slog2f(0, ID_G11N, SLOG2_ERROR, "GlobalizationNDK::getFirstDayOfWeek: failed to create Calendar instance: %d",
+                status);
+        return errorInJson(UNKNOWN_ERROR, "Failed to create Calendar instance!");
+    }
+
+    UCalendarDaysOfWeek d = cal->getFirstDayOfWeek(status);
+    if (status != U_ZERO_ERROR && status != U_ERROR_WARNING_START) {
+        slog2f(0, ID_G11N, SLOG2_ERROR, "GlobalizationNDK::getFirstDayOfWeek: failed to call getFirstDayOfWeek: %d",
+                status);
+        return errorInJson(UNKNOWN_ERROR, "Failed to call getFirstDayOfWeek!");
+    }
+
+    return resultInJson(d);
 }
 
 std::string GlobalizationNDK::numberToString(const std::string& args)