(4) VMware timestamps are considered to be in UTC. Unfortunately, there is no standard function to assemble timestamp from broken-down time structure. There are timegm() and mkgmtime() but no portable solution. I spoke to Alexander Vladishev and he agreed that it would be useful to have our own function for this purpose. Conversion should be straightforward since there is no DST in UTC. We can draw inspiration from here and here. The latter is probably overly complicated, it tries to check if "hh:mm:60" and "hh:mm:61" are valid leap seconds.
Viktors Tjarve RESOLVED in development branch svn://svn.zabbix.com/branches/dev/ZBX-9839 r59414
Note that on a system which has 2 byte int value assigned to timestamp will be incorrect. 2 byte int can not hold value of Epoch time.
Glebs Ivanovskis Things to improve here:
- zbx_mkgmtime() makes humble attempts to validate and normalize input (month and year). We should either remove all validation and leave timestamp calculation only or validate every field of input tm structure. I would prefer second option given the fact that input comes from outside.
- Lots of "magic numbers" (60, another 60, 24, 365, 70, 69, 299).
One more thing to discuss. We are not obliged to use struct tm return time_t unless we want to mimic mktime() as closely as possible. If we use explicit types we will have more control over ranges (as you rightly pointed out about int).
Viktors Tjarve RESOLVED all issues the way suggested above.
Glebs Ivanovskis Variable of type struct tm is no longer needed in vmware_get_events(). See my changes in r59531.
Parameter validation in zbx_utc_time() works incorrectly. (Fails in case of "23:mm:ss", for example.) Would be nice to sync parameter names in zbx_utc_time() declaration, definition and call(s).
Viktors Tjarve Changes look good. Also RESOLVED the imperfections.
Glebs Ivanovskis Now vmware_get_events() looks good. Just a minor stylistic fix in r59748. Let's deal with zbx_utc_time() in (6). Feel free to close this subissue if you are happy about it. Still RESOLVED.
Viktors Tjarve vmware_get_events() is good. CLOSED