From 423e0c2142bc305a2c173f52e2e128d31b217c38 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Wed, 28 Mar 2012 16:36:37 -0400 Subject: [PATCH 1/3] Use George Bush style (2007) DST begin/end dates --- .../Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp index 02aa1f9e..efb9804e 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp @@ -649,19 +649,19 @@ UInt32 cyMisc::ConvertGMTtoDni(UInt32 gtime) plUnifiedTime utime = plUnifiedTime(); utime.SetSecs(dtime); // check for daylight savings time in New Mexico and adjust - if ( utime.GetMonth() >= 4 && utime.GetMonth() < 11 ) + if ( utime.GetMonth() >= 3 && utime.GetMonth() < 11 ) { plUnifiedTime dstStart = plUnifiedTime(); - dstStart.SetGMTime(utime.GetYear(),4,1,2,0,0); - // find first Sunday after 4/1 (first sunday of April) + dstStart.SetGMTime(utime.GetYear(),3,7,2,0,0); + // find first Sunday after 3/7 (second Sunday of March) UInt32 days_to_go = 7 - dstStart.GetDayOfWeek(); if (days_to_go == 7) days_to_go = 0; UInt32 dstStartSecs = dstStart.GetSecs() + days_to_go * kOneDay; plUnifiedTime dstEnd = plUnifiedTime(); - dstEnd.SetGMTime(utime.GetYear(),10,25,1,0,0); - // find first sunday after 10/25 (last sunday of Oct.) + dstEnd.SetGMTime(utime.GetYear(),11,1,1,0,0); + // find first sunday after 11/1 (first Sunday of November) days_to_go = 7 - dstEnd.GetDayOfWeek(); if (days_to_go == 7) days_to_go = 0; From 59b04b546fd5c3e77ec0f3f37504405b64418717 Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Sat, 31 Mar 2012 20:06:55 +0200 Subject: [PATCH 2/3] 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. --- .../Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp | 4 ++-- .../Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp index a7a53574..c6c360b6 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.cpp @@ -263,9 +263,9 @@ void plUnifiedTime::ToCurrentTime() SetToUTC(); } -hsBool plUnifiedTime::SetGMTime(short year, short month, short day, short hour, short minute, short second, unsigned long usec, int dst) +hsBool plUnifiedTime::SetGMTime(short year, short month, short day, short hour, short minute, short second, unsigned long usec) { - if( !SetTime( year, month, day, hour, minute, second, usec, dst ) ) + if( !SetTime( year, month, day, hour, minute, second, usec, 0 ) ) return false; fSecs -= IGetLocalTimeZoneOffset(); diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.h b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.h index bfdb9435..86172eea 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.h +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plUnifiedTime/plUnifiedTime.h @@ -129,7 +129,7 @@ public: void SetSecsDouble(double secs); void SetMicros(const UInt32 micros) { fMicros = micros; } hsBool SetTime(short year, short month, short day, short hour, short minute, short second, unsigned long usec=0, int dst=-1); - hsBool SetGMTime(short year, short month, short day, short hour, short minute, short second, unsigned long usec=0, int dst=-1); + hsBool SetGMTime(short year, short month, short day, short hour, short minute, short second, unsigned long usec=0); hsBool SetToUTC(); void ToCurrentTime(); void ToEpoch() { fSecs = 0; fMicros = 0;} From a9cb4723d0baa4951962f86a31c19c3296a214b9 Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Sat, 31 Mar 2012 20:13:58 +0200 Subject: [PATCH 3/3] Fix KI daylight saving time calculation. The previous implementation had the following bugs: - DST was truncated to end of October - DST start was off by one week in years where March 1st is a Monday - DST start was off by one second (1:59:59 -> 2:00:00 -> 3:00:01 instead of the correct 1:59:59 -> 3:00:00 -> 3:00:01) Tested against tzdata 2009g. --- .../Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp index efb9804e..beca03b2 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp @@ -649,11 +649,11 @@ UInt32 cyMisc::ConvertGMTtoDni(UInt32 gtime) plUnifiedTime utime = plUnifiedTime(); utime.SetSecs(dtime); // check for daylight savings time in New Mexico and adjust - if ( utime.GetMonth() >= 3 && utime.GetMonth() < 11 ) + if ( utime.GetMonth() >= 3 && utime.GetMonth() <= 11 ) { plUnifiedTime dstStart = plUnifiedTime(); - dstStart.SetGMTime(utime.GetYear(),3,7,2,0,0); - // find first Sunday after 3/7 (second Sunday of March) + dstStart.SetGMTime(utime.GetYear(),3,8,2,0,0); + // find first Sunday after (including) 3/8 (second Sunday of March) UInt32 days_to_go = 7 - dstStart.GetDayOfWeek(); if (days_to_go == 7) days_to_go = 0; @@ -661,13 +661,13 @@ UInt32 cyMisc::ConvertGMTtoDni(UInt32 gtime) plUnifiedTime dstEnd = plUnifiedTime(); dstEnd.SetGMTime(utime.GetYear(),11,1,1,0,0); - // find first sunday after 11/1 (first Sunday of November) + // find first sunday after (including) 11/1 (first Sunday of November) days_to_go = 7 - dstEnd.GetDayOfWeek(); if (days_to_go == 7) days_to_go = 0; UInt32 dstEndSecs = dstEnd.GetSecs() + days_to_go * kOneDay; - if ( dtime > dstStartSecs && dtime < dstEndSecs ) + if ( dtime >= dstStartSecs && dtime < dstEndSecs ) // add hour for daylight savings time dtime += kOneHour; }