Bug 740710 - B2G SMS: Timezone offset sign is wrong. r=philikon
authorKan-Ru Chen <kanru@kanru.info>
Fri, 06 Apr 2012 17:48:08 -0700
changeset 94524 d7a4dfac3acf04d10e68458fb490c3d6c72549e7
parent 94523 26adf71d5c6154e94050cc1ec8554e548b3c3657
child 94525 26a56a089f89119aab886df3023bc09b0cf74d88
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilikon
bugs740710
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 740710 - B2G SMS: Timezone offset sign is wrong. r=philikon
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -2938,24 +2938,24 @@ let GsmPDUHelper = {
     let month  = this.readSwappedNibbleBCD(1) - 1;
     let day    = this.readSwappedNibbleBCD(1);
     let hour   = this.readSwappedNibbleBCD(1);
     let minute = this.readSwappedNibbleBCD(1);
     let second = this.readSwappedNibbleBCD(1);
     let timestamp = Date.UTC(year, month, day, hour, minute, second);
 
     // If the most significant bit of the least significant nibble is 1,
-    // the timezone offset is negative (fourth bit from the right => 0x08).
+    // the timezone offset is negative (fourth bit from the right => 0x08):
+    //   localtime = UTC + tzOffset
+    // therefore
+    //   UTC = localtime - tzOffset
     let tzOctet = this.readHexOctet();
     let tzOffset = this.octetToBCD(tzOctet & ~0x08) * 15 * 60 * 1000;
-    if (tzOctet & 0x08) {
-      timestamp -= tzOffset;
-    } else {
-      timestamp += tzOffset;
-    }
+    tzOffset = (tzOctet & 0x08) ? -tzOffset : tzOffset;
+    timestamp -= tzOffset;
 
     return timestamp;
   },
 
   /**
    * User data can be 7 bit (default alphabet) data, 8 bit data, or 16 bit
    * (UCS2) data.
    *