You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2017/03/29 02:07:24 UTC

incubator-mynewt-core git commit: MYNEWT-696 NMP datetime rsp uses inconsistent fmt

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop fdc3d2b3e -> cb97248bc


MYNEWT-696 NMP datetime rsp uses inconsistent fmt

If the time was set with a time zone, the datetime response includes the
time zone at the end of the string. Otherwise, no time zone is present.

This inconsistency makes parsing more difficult. The fix is to report
UTC as the time zone if none was explicitly specified.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/cb97248b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/cb97248b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/cb97248b

Branch: refs/heads/develop
Commit: cb97248bcd5c05bac0b8177095d0a638bea4221c
Parents: fdc3d2b
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Mar 28 18:55:32 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Mar 28 19:06:34 2017 -0700

----------------------------------------------------------------------
 time/datetime/src/datetime.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cb97248b/time/datetime/src/datetime.c
----------------------------------------------------------------------
diff --git a/time/datetime/src/datetime.c b/time/datetime/src/datetime.c
index f160d4b..229866a 100644
--- a/time/datetime/src/datetime.c
+++ b/time/datetime/src/datetime.c
@@ -405,7 +405,7 @@ datetime_format(const struct os_timeval *tv, const struct os_timezone *tz,
         minswest = 0;
     }
 
-    if (minswest < 0) {
+    if (minswest <= 0) {
         sign = '+';
         minswest = -minswest;
     } else {
@@ -414,14 +414,14 @@ datetime_format(const struct os_timeval *tv, const struct os_timezone *tz,
 
     off_hour = minswest / 60;
     off_min = minswest % 60;
-    if (off_hour || off_min) {
-        rc = snprintf(cp, rlen, "%c%02d:%02d", sign, off_hour, off_min);
-        cp += rc;
-        rlen -= rc;
-        if (rc < 0 || rlen <= 0) {
-            goto err;
-        }
+
+    rc = snprintf(cp, rlen, "%c%02d:%02d", sign, off_hour, off_min);
+    cp += rc;
+    rlen -= rc;
+    if (rc < 0 || rlen <= 0) {
+        goto err;
     }
+
     return (0);
 
 err: