Closed Snickermicker closed 10 years ago
The calendar object sets or resets the dst offset according to the given date, Are you sure you didn't have a default timezone that does not have a DST or used a historic date that didn't have DST yet.
Yes, you're right. My testcase was wrong. Wrote it without thinking about different timezones.
But, the translator's setData() method accepts 1900/01/01 00:00:00 DST (0x00 01 01 20 00 00 01 00) without throwing and so does getValue() returning "1900/1/1, Mon (no workday) 0:0:0 DST, no sync". This fails only when using getValueMilliseconds() where an exception is thrown. Btw: same behavior when setting 2014-07-31 00:00:00 (without DST flag being set). Question I have is: when is the byte data validated? I might (wrongly) assume that setData() should do that.
Actually, this is described in the API doc. The reasons for that behavior are, that
Therefore, unconditional calendar validation might fail unexpectedly, although the datapoint value is valid. You could never translate data that does not pass your calendar. Those two are different requirements on the data (valid calendar time being stronger).
getValueMilliseconds
returns the UTC milliseconds based on your calendar's epoch (to be useful), calendar validation is important.
Answer: If you want the date/times to be validated against your calendar, call validate
.
Thx for letting me know.
DPTXlatorDateTime thwos an KNXFormatException: "differing daylight saving time", when DST field is set in KNX msg. Problem seems to be in "fromDPTMilliseconds(final int index)", where a Calendar object is cleared and populated with date and time info. Clearing a Calendar object will clear field Calendar.DST_OFFSET. A later comparison in this method will then always fail and hence the exception is thrown.