Time translation
Posted: Thursday 19 November 2020 17:52
Reading a JSON-file from a Domoticz-device, the time info included is often reported in different formats.
Below is result of extraction of a few fields from a JSON-file by means of a lua-script:
Actualtime is EPOCH, other fields are text.
For harmonization of time-values from a JSON-file (for a common_base time-processing, or just for display of the date&time-string also for Actualtime), it seems useful to have quick translation back & forth.
Plenty of dedicated, longer scripting solutions, and 'glueing' of found pieces will ultimately do the job,
but looking for a very short & simple 'general' set of functions performing both.
No reason to reinvent the wheel ....
Therefore question related to lua-scripting:
- is short translation function available from a given EPOCH value to text-string?
- is reverse a short translation function available from given text-string to related EPOCH value?
Test case to be processed, see above.
Below is result of extraction of a few fields from a JSON-file by means of a lua-script:
Actualtime is EPOCH, other fields are text.
Code: Select all
========== JSONFile-times ==========
Actualtime = 1605803582
Servertime = 2020-11-19 17:33:02
LastUpdate = 2020-11-13 06:06:58
Plenty of dedicated, longer scripting solutions, and 'glueing' of found pieces will ultimately do the job,
but looking for a very short & simple 'general' set of functions performing both.
Therefore question related to lua-scripting:
- is short translation function available from a given EPOCH value to text-string?
- is reverse a short translation function available from given text-string to related EPOCH value?
Test case to be processed, see above.