mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Merged in dst (http://foundry.openuru.org/fisheye/cru/CWE-8)
DST Fix Original implementation by Adam Johnson, with some bug fixes by Christian Walther. Includes a fix for plUnifiedTime::SetGMTime not working correctly when the given time falls into local DST.
This commit is contained in:
@ -649,25 +649,25 @@ 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,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;
|
||||
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 (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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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;}
|
||||
|
Reference in New Issue
Block a user