Seite 1 von 1
#1 Wochtag im Logic tab unterschiedlich zu den Timern
Verfasst: Di 9. Sep 2014, 09:37
von koboldo
Moin,
wenn ich bei den Timern den Wochentag benutze beginnt dieser am Sonntag mit 1 und endet am Samstag mit 7.
Im Logic Tab fängt das ganze aber am Montag mit 1 an und endet am Sonntag mit 7
Heute ist Dienstag, das bedeutet bei Timern eine 3 und im Logic eine 2
Ist das so gewollt ?
Code: Alles auswählen
wochentag = date("%w")
print(wochentag)
2
INFO: SCRIPT RELOADED AT 09:30
#2 RE: Wochtag im Logic tab unterschiedlich zu den Timern
Verfasst: Di 9. Sep 2014, 10:01
von DOMIQ-Support
In the Lua language weekdays start at Sunday with index of 1, So monday is 2 and so on.
#3 RE: Wochtag im Logic tab unterschiedlich zu den Timern
Verfasst: Di 9. Sep 2014, 10:10
von koboldo
In the Lua language weekdays start at Sunday with index of 1, So monday is 2 and so on.
That is how the timer works....
Have you seen my script ?
Code: Alles auswählen
wochentag = date("%w")
print(wochentag)
2
INFO: SCRIPT RELOADED AT 09:30
Today it is tuesday ....So the script must say 3 or not ?
But it says 2 !
Or what is wrong in my script ?
#4 RE: Wochtag im Logic tab unterschiedlich zu den Timern
Verfasst: Di 9. Sep 2014, 10:27
von DOMIQ-Support
use this line instead: wochentag = date("*t").wday
Expression date("%w") refers to operating system which count weekdays starting at 0 (Sunday).
#5 RE: Wochtag im Logic tab unterschiedlich zu den Timern
Verfasst: Di 9. Sep 2014, 10:31
von DOMIQ
Hello, if you want all the details, here is short tutorial about Lua built-in functions date and time:
http://lua-users.org/wiki/OsLibraryTutorial
Formatting of all "percent" expressions is done internally by strftime POSIX function, here is the manual page:
http://pubs.opengroup.org/onlinepubs/00 ... ftime.html
In Scheduler we use date("*t") method to get current time, so everything counts from 1 as is the convention in Lua.
#6 RE: Wochtag im Logic tab unterschiedlich zu den Timern
Verfasst: Di 9. Sep 2014, 11:01
von koboldo
Now it works
Thanks for the links...