incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [22/34] wp7 commit: Added timestamp to accel return method
Date Mon, 09 Apr 2012 22:40:30 GMT
Added timestamp to accel return method


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/3eef2a92
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/tree/3eef2a92
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/diff/3eef2a92

Branch: refs/heads/master
Commit: 3eef2a925e756ebecd07b0c4951cb355eb783e03
Parents: d91087f
Author: filmaj <maj.fil@gmail.com>
Authored: Sun Apr 8 13:25:26 2012 -0700
Committer: filmaj <maj.fil@gmail.com>
Committed: Sun Apr 8 13:25:26 2012 -0700

----------------------------------------------------------------------
 framework/Cordova/Commands/Accelerometer.cs |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/3eef2a92/framework/Cordova/Commands/Accelerometer.cs
----------------------------------------------------------------------
diff --git a/framework/Cordova/Commands/Accelerometer.cs b/framework/Cordova/Commands/Accelerometer.cs
index 54cd1fe..80500dd 100644
--- a/framework/Cordova/Commands/Accelerometer.cs
+++ b/framework/Cordova/Commands/Accelerometer.cs
@@ -101,6 +101,8 @@ namespace WP7CordovaClassLib.Cordova.Commands
         /// </summary>
         private static Dictionary<string, Accelerometer> watchers = new Dictionary<string,
Accelerometer>();
 
+        private static DateTime StartOfEpoch = new DateTime(1970, 1, 1, 0, 0, 0);
+
         #endregion
 
         /// <summary>
@@ -295,10 +297,13 @@ namespace WP7CordovaClassLib.Cordova.Commands
         /// <returns>Coordinates in JSON format</returns>
         private string GetCurrentAccelerationFormatted()
         {
-            string resultCoordinates = String.Format("\"x\":{0},\"y\":{1},\"z\":{2}",
+            // 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}",
                             (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));
+                            (accelerometer.CurrentValue.Acceleration.Z * gConstant).ToString("0.00000",
CultureInfo.InvariantCulture),
+                            timestamp.ToString());
             resultCoordinates = "{" + resultCoordinates + "}";
             return resultCoordinates;
         }


Mime
View raw message