Commits

Cédric Bonhomme committed 7e19ccd

Added last update time for bike stations.

  • Participants
  • Parent commits 65a7391

Comments (0)

Files changed (1)

 
 import cgi
 import json
+import datetime
 import urllib.request, urllib.parse, urllib.error
 from xml.dom.minidom import parseString
 
 
         if station["available_bikes"] == 0:
             html += """
-                        popupContentHTML = "<p>No bikes available.<br />Payment terminal: %s</p>";""" % \
-                            ([station["banking"]==True and "yes" or "no"][0],)
+                        popupContentHTML = "<p>No bikes available.<br />Payment terminal: %s<br />Last update: %s</p>";""" % \
+                            ([station["banking"]==True and "yes" or "no"][0], \
+                                datetime.datetime.fromtimestamp(station['last_update']/1000).strftime('%Y-%m-%d %H:%M:%S'))
             html += """
                         addMarker(station%s, popupClass, popupContentHTML, true, true, "./marker-red.png");""" % \
                             (idx,)
         else:
             html += """
-                        popupContentHTML = "<p>Available bikes: %s<br />Payment terminal: %s</p>";""" % \
-                            (station["available_bikes"], [station["banking"]==True and "yes" or "no"][0])
+                        popupContentHTML = "<p>Available bikes: %s<br />Payment terminal: %s<br />Last update: %s</p>";""" % \
+                            (station["available_bikes"], [station["banking"]==True and "yes" or "no"][0], \
+                                datetime.datetime.fromtimestamp(station['last_update']/1000).strftime('%Y-%m-%d %H:%M:%S'))
             html += """
                         addMarker(station%s, popupClass, popupContentHTML, true, true, "./marker-green.png");""" % \
                             (idx,)