format datetime in tooltip headers
authorgregor herrmann <gregor@toastfreeware.priv.at>
Thu, 9 Aug 2018 13:53:42 +0000 (15:53 +0200)
committergregor herrmann <gregor@toastfreeware.priv.at>
Thu, 9 Aug 2018 13:53:42 +0000 (15:53 +0200)
web/static/seepark_web.js

index 2944e90..4ee570f 100644 (file)
@@ -120,9 +120,15 @@ function dayschart(element, title, days, xtickformat) {
                                value: function (value, ratio, id, index) {
                                        return value.toFixed(2) + '°';
                                },
-                               title: function (x) {
-                                       // TODO: format datetime into something readable
-                                       return x;
+                               title: function (datetime) {
+                                       // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
+                                       options = {
+                                               weekday: 'short',
+                                               year: 'numeric', month: 'numeric', day: 'numeric',
+                                               hour: 'numeric', minute: 'numeric', second: 'numeric',
+                                               timeZone: 'Europe/Vienna', timeZoneName: 'short'
+                                       };
+                                       return datetime.toLocaleString('de-AT', options);
                                }
                        }
                },