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

dzVents toUTC() function returns string not domoticz time object #6084

Closed
eagle360 opened this issue May 22, 2024 · 3 comments
Closed

dzVents toUTC() function returns string not domoticz time object #6084

eagle360 opened this issue May 22, 2024 · 3 comments

Comments

@eagle360
Copy link

dzVents v3.1.8 toUTC() function returns a string not domoticz time object as indicated in the Documentation page"DzVents: next generation Lua scripting"

toUTC(string | table,[offset]): domoticz time object. 3.0.9 returns domoticz time object based on first parameter (time as table or string) string format must be ‘yyyy-mm-dd hh:mm:ss’. offset defaults to 0.

	function self.toUTC(oDate, offset)
		local sDate = ( type(oDate) == 'table' and os.date("%Y-%m-%d %H:%M:%S", os.time(oDate)) ) or oDate
		local offset = offset or 0
		return Time(sDate).addSeconds(-1 * getTimezone() + offset).raw
@waltervl
Copy link
Collaborator

Do you have a small dzvents script to reproduce your issue?

With my limited programming skills looking at the code you mentioned it should return a Time object....

@eagle360
Copy link
Author

eagle360 commented May 24, 2024

The function is clearly returning .raw (a string) vs a time object:

return Time(sDate).addSeconds(-1 * getTimezone() + offset).raw

Test:
domoticz.log ('Type of toUTC(Time()) : ' .. type(domoticz.time.toUTC(Time())) )
Result:
Type of toUTC(Time()) : string

It doesn't really matter just that the documentation doesn't match the function. Probably best to leave the function as is (not to make a breaking change) and update the documentation instead.

@waltervl
Copy link
Collaborator

Documented as string now on the wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants