diff --git a/kfet/context_processors.py b/kfet/context_processors.py
index 6c053ea9..9364c724 100644
--- a/kfet/context_processors.py
+++ b/kfet/context_processors.py
@@ -22,6 +22,6 @@ def kfet_open(request):
kfet_force_close = KFET_FORCE_CLOSE()
return {
'kfet_open': kfet_open,
- 'kfet_open_date': kfet_open_date,
+ 'kfet_open_date': kfet_open_date.isoformat(),
'kfet_force_close': kfet_force_close,
}
diff --git a/kfet/static/kfet/js/kfet_open.js b/kfet/static/kfet/js/kfet_open.js
index e2cccf81..a8f41757 100644
--- a/kfet/static/kfet/js/kfet_open.js
+++ b/kfet/static/kfet/js/kfet_open.js
@@ -56,18 +56,8 @@ function kfet_open(init_date, init_status, init_force_close, force_close_url, fo
});
}
- function nb_min_diff() {
- var date_now = new Date();
- // On calcule le nb de minutes depuis le dernier
- // envoi d'information
- tmp = date_now - kfet_open_date;
-
- tmp = Math.floor(tmp/1000); // Nombre de secondes entre les 2 dates
- diff_sec = tmp % 60; // Extraction du nombre de secondes
-
- tmp = Math.floor((tmp-diff_sec)/60); // Nombre de minutes (partie entière)
-
- return tmp;
+ function kfet_open_min() {
+ return moment().diff(kfet_open_date, 'minute')
}
function do_kfet_close() {
kfet_open_bullet.css({'background-color': closed_color});
@@ -85,7 +75,7 @@ function kfet_open(init_date, init_status, init_force_close, force_close_url, fo
open_status.html("?????");
}
function update_open() {
- var nb_min = nb_min_diff();
+ var nb_min = kfet_open_min();
console.log("K-Fêt ouverte : " + (kfet_open&&(!force_close)));
console.log(nb_min + " minute(s) depuis la dernière mise à jour");
if (force_close) {
@@ -121,7 +111,7 @@ function kfet_open(init_date, init_status, init_force_close, force_close_url, fo
if (data['door_action']) {
console.log("* Message reçu de la part de la porte.");
- kfet_open_date = new Date(data['door_action']['kfet_open_date']);
+ kfet_open_date = moment.utc(data['door_action']['kfet_open_date']);
kfet_open = data['door_action']['kfet_open'];
update_open();
diff --git a/kfet/templates/kfet/base.html b/kfet/templates/kfet/base.html
index 81ca3dfd..d992b209 100644
--- a/kfet/templates/kfet/base.html
+++ b/kfet/templates/kfet/base.html
@@ -21,13 +21,17 @@
+
+
+
+
{# K-Fêt open #}
-
-
-
{% endblock %}
diff --git a/kfet/views.py b/kfet/views.py
index 7865ec34..0a3b6f99 100644
--- a/kfet/views.py
+++ b/kfet/views.py
@@ -97,7 +97,7 @@ class UpdateKfetOpen(View):
websocket_data = {
'door_action': {
'kfet_open': is_open,
- 'kfet_open_date': timezone.now(),
+ 'kfet_open_date': timezone.now().isoformat(),
},
}
consumers.KfetOpen.group_send('kfet.is_open', websocket_data)