H-uru/Plasma — pull request #185 by cwalther (2012-03-30 20:24:07+00:00)
Title: Fix plUnifiedTime::SetGMTime

The default value of the "dst" argument must be 0, because -1 leads to incorrect results when the given time falls into local DST. However, a "dst" argument makes no sense on a method that deals with GMT anyway, so remove it entirely.

An alternative and somewhat more elegant fix would be to implement SetGMTime using the timegm() function where available (at least Mac OS X and Linux), but since this fix appears to work I didn’t bother figuring out how to have CMake detect that.

Here’s the trivial test that fails in the current implementation and succeeds after the fix – if anyone ever feels like setting up a unit test framework, that could be integrated there:

```c++
// test with two dates, one at the beginning and one in the middle of the year, so that one of them falls into local DST (if present)
plUnifiedTime t1;
t1.SetGMTime(1984, 1, 24, 18, 27, 43, 123456);
assert(t1.GetYear() == 1984);
assert(t1.GetMonth() == 1);
assert(t1.GetDay() == 24);
assert(t1.GetHour() == 18);
assert(t1.GetMinute() == 27);
assert(t1.GetSecond() == 43);
assert(t1.GetMicros() == 123456);

plUnifiedTime t2;
t2.SetGMTime(2003, 7, 10, 5, 46, 14, 654321);
assert(t2.GetYear() == 2003);
assert(t2.GetMonth() == 7);
assert(t2.GetDay() == 10);
assert(t2.GetHour() == 5);
assert(t2.GetMinute() == 46);
assert(t2.GetSecond() == 14);
assert(t2.GetMicros() == 654321);
```