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:48 UTC
[31/38] git commit: BB10: Update getDatePattern to follow options
provided.
BB10: Update getDatePattern to follow options provided.
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/64274b19
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/64274b19
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/64274b19
Branch: refs/heads/lyon-g11n
Commit: 64274b199a06334016df310aab5d7900e3b85d0a
Parents: bb006ee
Author: Lianghui Chen <li...@blackberry.com>
Authored: Tue Jul 29 17:06:34 2014 -0400
Committer: Lianghui Chen <li...@blackberry.com>
Committed: Tue Jul 29 17:06:34 2014 -0400
----------------------------------------------------------------------
.../native/src/globalization_ndk.cpp | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/64274b19/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 0210f0f..c0c0d2d 100644
--- a/src/blackberry10/native/src/globalization_ndk.cpp
+++ b/src/blackberry10/native/src/globalization_ndk.cpp
@@ -460,13 +460,22 @@ std::string GlobalizationNDK::getDatePattern(const std::string& args)
}
UErrorCode status = U_ZERO_ERROR;
- SimpleDateFormat* sdf = new SimpleDateFormat(status);
- if (!sdf) {
- slog2f(0, ID_G11N, SLOG2_ERROR, "GlobalizationNDK::getDatePattern: unable to create SimpleDateFormat instance: %d.",
- status);
- return errorInJson(UNKNOWN_ERROR, "Unable to create SimpleDateFormat instance!");
+ const Locale& loc = Locale::getDefault();
+ DateFormat* df = DateFormat::createDateTimeInstance(dstyle, tstyle, loc);
+
+ if (!df) {
+ slog2f(0, ID_G11N, SLOG2_ERROR, "GlobalizationNDK::getDatePattern: unable to create DateFormat instance!");
+ return errorInJson(UNKNOWN_ERROR, "Unable to create DateFormat instance!");
+ }
+
+ if (df->getDynamicClassID() != SimpleDateFormat::getStaticClassID()) {
+ delete df;
+ slog2f(0, ID_G11N, SLOG2_ERROR, "GlobalizationNDK::getDatePattern: DateFormat instance not SimpleDateFormat!");
+ return errorInJson(UNKNOWN_ERROR, "DateFormat instance not SimpleDateFormat!");
}
+ SimpleDateFormat* sdf = (SimpleDateFormat*) df;
+
UnicodeString pt;
sdf->toPattern(pt);
std::string ptUtf8;