Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement] Make Date-Format ISO-conform #913

Closed
DB1BMN opened this issue Apr 29, 2023 · 5 comments
Closed

[Improvement] Make Date-Format ISO-conform #913

DB1BMN opened this issue Apr 29, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request fixed dev fixed

Comments

@DB1BMN
Copy link

DB1BMN commented Apr 29, 2023

Hi,

on several pages (Start Page, Live, System, Sunrise / Sunset) the date format is in "German Style" i.e. DD.MM.YYYY.

I propose to change it to ISO8601-Style i.e. YYYY-MM-DD or at least to make it configurable in the Web-UI.
Display view seems to be already correct :-)
Taking a quick look at 'api/index' it seems internally the Unix-Timestamp is used, right?

Best Regards, Mark

https://xkcd.com/1179/

@Argafal
Copy link
Contributor

Argafal commented May 1, 2023

I made a quick experiment to see what this would look like. I used the toISOString() method. It outputs the date and time following ISO8601, as per your suggestion. See also https://www.w3schools.com/jsref/jsref_toisostring.asp.

The result looks like this:
Polling inverter(s), will pause at sunset 2023-05-01T20:12:02.000Z

I honestly don't know if Zulu time is a better choice for someone living in CEST, but this is now strictly ISO8601. Maybe those who find this issue important could experiment a little bit and come up with a specific suggestion how to display the date/timestamp. I copy a diff of my patch below as starting point for you. Thanks :)

diff --git a/src/web/html/index.html b/src/web/html/index.html
index 72537e5..cdcc236 100644
--- a/src/web/html/index.html
+++ b/src/web/html/index.html
@@ -102,15 +102,15 @@
                 if(obj["disNightComm"]) {
                     if(((obj["ts_sunrise"] - obj["ts_offset"]) < obj["ts_now"])
                         && ((obj["ts_sunset"] + obj["ts_offset"]) > obj["ts_now"])) {
-                        commInfo = "Polling inverter(s), will pause at sunset " + (new Date((obj["ts_sunset"] + obj["ts_offset"]) * 1000).toLocaleString('de-DE'));
+                        commInfo = "Polling inverter(s), will pause at sunset " + (new Date((obj["ts_sunset"] + obj["ts_offset"]) * 1000).toISOString());
                     }
                     else {
                         commInfo = "Night time, inverter polling disabled, ";
                         if(obj["ts_now"] > (obj["ts_sunrise"] - obj["ts_offset"])) {
-                            commInfo += "paused at " + (new Date((obj["ts_sunset"] + obj["ts_offset"]) * 1000).toLocaleString('de-DE'));
+                            commInfo += "paused at " + (new Date((obj["ts_sunset"] + obj["ts_offset"]) * 1000).toISOString());
                         }
                         else {
-                            commInfo += "will start polling at " + (new Date((obj["ts_sunrise"] - obj["ts_offset"]) * 1000).toLocaleString('de-DE'));
+                            commInfo += "will start polling at " + (new Date((obj["ts_sunrise"] - obj["ts_offset"]) * 1000).toISOString());
                         }
                     }
                 }

@DB1BMN
Copy link
Author

DB1BMN commented May 1, 2023

Hi thanks for quick testing!

I think there might me some options or flags to adjust to time-zones and DST if necessary. I think NTP delivers also UTC only.
At least in PHP you have plenty of formatting options: https://www.php.net/manual/en/datetime.format.php

My only wish was to print date in YYYY-mm-dd format so just swap days and year.
And shorten sunrise/sunset times to minutes, see also: #914 (comment)

@Argafal
Copy link
Contributor

Argafal commented May 1, 2023

Nice, good for looking into it. Maybe @DB1BMN you can come up with a specific suggestion how to change the code and then we can ask @lumapu to integrate it. The places you need to touch you can see in my example diff.

@DB1BMN
Copy link
Author

DB1BMN commented May 1, 2023

LOL, what a pleasure!

But I'm sorry, my programming skills are somewhere between '8051 Assemlby and QBASIC.
So the code you postet is only Czech Villages to me.

But I can do some testing, habe several boards spare here and not afraid to fry them ;-)

@lumapu lumapu self-assigned this Jul 23, 2023
@lumapu lumapu added enhancement New feature or request fixed dev fixed labels Jul 23, 2023
lumapu added a commit that referenced this issue Jul 23, 2023
* add NTP sync interval #1019
* adjusted range of contrast / luminance setting #1041
* use only ISO time format in Web-UI #913
@dtuuser
Copy link

dtuuser commented Jul 24, 2023

ESP-Time: 2023-07-24, 07:15:04
Geht bei mir nach den Update 2 Stunden nach

lumapu added a commit that referenced this issue Jul 24, 2023
* next attempt to fix yield day for multiple inverters #1016
* fix export settings date #1040
* fix time on WebUI (timezone was not observed) #913 #1016
@lumapu lumapu closed this as completed Aug 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed dev fixed
Projects
None yet
Development

No branches or pull requests

4 participants