Date parameters (also referred to as date objects) in the Hotline protocol contain the following information. The numerical values, as always, are encoded using Big Endian or Network Byte Order:
Year (2 bytes), Milliseconds (2 bytes), Seconds (4 bytes).
Seconds and milliseconds represent the amount of time that passed since January 1st of any given year. For instance, 70 seconds and 2,000 milliseconds for a year value of 2010 would represent 1 January 2010 at 00:01:12 AM. 432,000 seconds and 5,000 milliseconds for a year value of 2008 would represent 6 January 2008 at 00:00:15 AM (43,210 seconds = 5 days, 10 seconds; 5,000 milliseconds = 5 seconds).
The algorithm for converting to a date parameter is as follows:
|Month||Seconds ellapsed since 1/1/YYYY 0:00 (at first of month)|
|March||5,097,600 (non leap year)|
Given a SYSTEMTIME structure and an integer array of the above table called MONTH_SECS, in order to get the seconds:
MONTH_SECS[wMonth - 1] + (if (wMonth > 2) and isLeapYear(wYear): 86400 else 0) + (wSecond + (60 * (wMinute + 60 * ((wHour + 24 * (wDay - 1))))))
The year and milliseconds are simply copied over.