timestamps were incorrect, leaving JS to create timestamps that are consistent with other platforms.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/commit/ae300da8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/tree/ae300da8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/diff/ae300da8 Branch: refs/heads/master Commit: ae300da8701ec3071dc1fb1dbf2ed78991a60521 Parents: 1fa215c Author: Jesse MacFadyen <purplecabb...@gmail.com> Authored: Thu Sep 6 15:04:43 2012 -0700 Committer: Jesse MacFadyen <purplecabb...@gmail.com> Committed: Thu Sep 6 15:04:43 2012 -0700 ---------------------------------------------------------------------- .../cordovalib/Commands/Accelerometer.cs | 13 +++++++------ .../standalone/cordovalib/Commands/Compass.cs | 11 +++++------ 2 files changed, 12 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/ae300da8/templates/standalone/cordovalib/Commands/Accelerometer.cs ---------------------------------------------------------------------- diff --git a/templates/standalone/cordovalib/Commands/Accelerometer.cs b/templates/standalone/cordovalib/Commands/Accelerometer.cs index ae1e860..baea009 100644 --- a/templates/standalone/cordovalib/Commands/Accelerometer.cs +++ b/templates/standalone/cordovalib/Commands/Accelerometer.cs @@ -19,6 +19,7 @@ using System.Runtime.Serialization; using System.Threading; using Microsoft.Devices.Sensors; using System.Globalization; +using System.Diagnostics; namespace WP7CordovaClassLib.Cordova.Commands { @@ -172,14 +173,14 @@ namespace WP7CordovaClassLib.Cordova.Commands private string GetCurrentAccelerationFormatted() { // convert to unix timestamp - long timestamp = ((accelerometer.CurrentValue.Timestamp.DateTime - StartOfEpoch).Ticks) / 10000; - string resultCoordinates = String.Format("\"x\":{0},\"y\":{1},\"z\":{2},\"timestamp\":{3}", + // long timestamp = ((accelerometer.CurrentValue.Timestamp.DateTime - StartOfEpoch).Ticks) / 10000; + // Note: Removed timestamp, to let the JS side create it using (new Date().getTime()) -jm + // this resolves an issue with inconsistencies between JS dates and Native DateTime + string resultCoordinates = String.Format("\"x\":{0},\"y\":{1},\"z\":{2}", (accelerometer.CurrentValue.Acceleration.X * gConstant).ToString("0.00000", CultureInfo.InvariantCulture), (accelerometer.CurrentValue.Acceleration.Y * gConstant).ToString("0.00000", CultureInfo.InvariantCulture), - (accelerometer.CurrentValue.Acceleration.Z * gConstant).ToString("0.00000", CultureInfo.InvariantCulture), - timestamp.ToString()); - resultCoordinates = "{" + resultCoordinates + "}"; - return resultCoordinates; + (accelerometer.CurrentValue.Acceleration.Z * gConstant).ToString("0.00000", CultureInfo.InvariantCulture)); + return "{" + resultCoordinates + "}"; } /// <summary> http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/ae300da8/templates/standalone/cordovalib/Commands/Compass.cs ---------------------------------------------------------------------- diff --git a/templates/standalone/cordovalib/Commands/Compass.cs b/templates/standalone/cordovalib/Commands/Compass.cs index 9f8d402..02defd6 100644 --- a/templates/standalone/cordovalib/Commands/Compass.cs +++ b/templates/standalone/cordovalib/Commands/Compass.cs @@ -129,14 +129,13 @@ namespace WP7CordovaClassLib.Cordova.Commands /// </summary> /// <returns>Coordinates in JSON format</returns> private string GetHeadingFormatted(CompassReading reading) - { - string result = String.Format("\"magneticHeading\":{0},\"headingAccuracy\":{1},\"trueHeading\":{2},\"timestamp\":{3}", + { + // NOTE: timestamp is generated on the JS side, to avoid issues with format conversions + string result = String.Format("\"magneticHeading\":{0},\"headingAccuracy\":{1},\"trueHeading\":{2}", reading.MagneticHeading.ToString("0.0", CultureInfo.InvariantCulture), reading.HeadingAccuracy.ToString("0.0", CultureInfo.InvariantCulture), - reading.TrueHeading.ToString("0.0", CultureInfo.InvariantCulture), - reading.Timestamp.UtcTicks.ToString()); - result = "{" + result + "}"; - return result; + reading.TrueHeading.ToString("0.0", CultureInfo.InvariantCulture)); + return "{" + result + "}"; } public void getHeading(string options)