implemented Time formating

solved #5
This commit is contained in:
schrom01 2022-08-27 19:41:01 +02:00
parent 0264375d3f
commit cb9a3b6830
5 changed files with 18 additions and 4 deletions

View File

@ -2,6 +2,6 @@
<!-- <td>{{ job.id }}</td> -->
<td>{{ job.zone.number|string}}</td>
<td>{{job.zone.name }}</td>
<td>{{ ((job.duration/60)|int)|string + " " + translater.getTranslation("minutes")}}</td>
<td>{{ ((job.duration/60))|string + " " + translater.getTranslation("minutes")}}</td>
<td><button onclick="buttonDeleteJobById('{{ job.id }}')">{{ translater.getTranslation("delete") }}</button></td>
</tr>

View File

@ -36,7 +36,7 @@
<td></td>
<td></td>
<td>
{{translater.getTranslation("irragation is planed for") }} <p id="planed_duration_zone{{ zone.number }}" class="planed_duration_value"></p> {{ translater.getTranslation("minutes") + "." }}
{{translater.getTranslation("irrigation is planed.") }}<br>{{ translater.getTranslation("planed duration")}}: <p id="planed_duration_zone{{ zone.number }}" class="planed_duration_value"></p> {{ translater.getTranslation("minutes") + "." }}
</td>
<td>
<button onclick="deleteJobsForZone('delete_jobs_for_zone','{{ zone.number }}')">{{ translater.getTranslation("delete") }}</button>

View File

@ -1,4 +1,6 @@
from enum import Enum
from time import strftime
from time import gmtime
class Language(Enum):
ENGLISH = 1
GERMAN = 2
@ -27,7 +29,7 @@ class Translater:
"switch to automatic mode": "Auf Automatikbetrieb umstellen",
"minutes": "Minuten",
"until": "bis",
"irragation is planed for": "Bewässerung ist geplant für",
"irrigation is planed.": "Bewässerung ist geplant.",
"planed irrigationjobs": "geplante Bewässerungsaufträge",
"planed duration": "geplante Dauer",
"cancel": "abbrechen",
@ -45,3 +47,14 @@ class Translater:
return self.dict_german[english_String]
case _:
return "no translations for these language"
def formatTime(self, timeInt):
format = ""
match self.language:
case Language.ENGLISH:
format = "%I.%S %p"
case Language.GERMAN:
format = "%H:%M:%S"
case _:
format = ""
return strftime(format, gmtime(timeInt))

View File

@ -4,7 +4,7 @@ function refreshZone(zone_json) {
document.getElementById("inner_icon_state_zone_" + zone.number).className = 'inner_icon ' + (zone.state ? 'dot_green' : 'dot_red');
document.getElementById("state_text_zone_" + zone.number).innerHTML = zone.state_text;
document.getElementById("end_time_row_zone_" + zone.number).style.display = ((zone.setState == 1 || zone.setState == 2) ? 'table-row' : 'none');
document.getElementById("end_time_zone_" + zone.number).innerHTML = zone.endTimeSetState;
document.getElementById("end_time_zone_" + zone.number).innerHTML = zone.endTimeSetStateFormated;
document.getElementById("planed_duration_row_zone_" + zone.number).style.display = ((zone.planedDuration > 0) ? 'table-row' : 'none');
document.getElementById("planed_duration_zone" + zone.number).innerHTML = zone.planedDuration/60;
document.getElementById("inner_icon_mode_zone_" + zone.number).innerHTML = zone.autoMode ? 'A' : 'M';

View File

@ -26,6 +26,7 @@ class Zone:
"state_text": translater.getTranslation("switched on" if self.state else "switched off"),
"setState": self.setState,
"endTimeSetState" : self.endTimeSetState,
"endTimeSetStateFormated" : translater.formatTime(self.endTimeSetState),
"planedDuration": self.planedDuration,
}