aboutsummaryrefslogtreecommitdiffstats
path: root/www/js
diff options
context:
space:
mode:
authorMark Longair <mhl@pobox.com>2012-11-20 18:07:37 +0000
committerMark Longair <mhl@pobox.com>2012-11-20 18:28:34 +0000
commit7f45a2fc19e5e225b2cc9e6acbb515c9f6efe2ac (patch)
tree4f2e87fe5bff1c73ed7d72f50ed93c109abe28c8 /www/js
parentd7a43e068987311398ff48459fe3d9db8a1ec821 (diff)
Store the time as milliseconds since the epoch rather than ISO 8601
Annoyingly, many variants of Javascript can't parse datetimes in the ISO 8601 variant that is output by Date's toString method. Instead, store the date and time as milliseconds since the Unix epoch, which is more widely supported.
Diffstat (limited to 'www/js')
-rw-r--r--www/js/mobile.js4
-rw-r--r--www/js/report.js4
2 files changed, 4 insertions, 4 deletions
diff --git a/www/js/mobile.js b/www/js/mobile.js
index 09c9479..53838e4 100644
--- a/www/js/mobile.js
+++ b/www/js/mobile.js
@@ -515,7 +515,7 @@ function get_report_params () {
lon: $('#fixmystreet\\.longitude').val(),
phone: $('#form_phone').val(),
pc: $('#pc').val(),
- time: new Date()
+ time: new Date().getTime()
};
if ( localStorage.username && localStorage.password && localStorage.name ) {
@@ -572,7 +572,7 @@ function display_saved_reports() {
var item = $('<li class="saved-report" id="' + i + '"></li>');
var date;
if ( r[i].time ) {
- var date_o = new Date( r[i].time );
+ var date_o = new Date( parseInt(r[i].time, 10) );
date = date_o.getDate() + '/' + ( date_o.getMonth() + 1 ) + '/' + date_o.getFullYear();
date = date + ' ' + date_o.getHours() + ':' + date_o.getMinutes();
} else {
diff --git a/www/js/report.js b/www/js/report.js
index a14f38b..4a79568 100644
--- a/www/js/report.js
+++ b/www/js/report.js
@@ -32,7 +32,7 @@ function Report(spec) {
var t;
if ( typeof props.time === 'String' ) {
- t = new Date( props.time );
+ t = new Date( parseInt(props.time, 10) );
} else {
t = props.time;
}
@@ -47,7 +47,7 @@ function Report(spec) {
if ( ! reports ) {
reports = [];
}
- props.time = new Date();
+ props.time = new Date().getTime();
if ( my_id != -1 ) {
reports[my_id] = props;
} else {