Skip to content

Instantly share code, notes, and snippets.

@jerstlouis
Created September 18, 2014 21:46
Show Gist options
  • Save jerstlouis/880c73535a4624e8eb6e to your computer and use it in GitHub Desktop.
Save jerstlouis/880c73535a4624e8eb6e to your computer and use it in GitHub Desktop.
void addDSTOffset(DateTime t)
{
Date dstStart, dstEnd;
if(t.year > 2006)
{
getWeekDay({ t.year, april, 0 }, sunday, 1, dstStart);
getWeekDay({ t.year, october, 32 }, sunday, -1, dstStart);
}
else
{
getWeekDay({ t.year, march, 0 }, sunday, 2, dstStart);
getWeekDay({ t.year, november, 0 }, sunday, 1, dstStart);
}
if(t.month > dstStart.month && t.month < dstEnd.month)
t.hour++;
else if(t.month == dstStart.month)
{
if(t.day > dstStart.day || (t.day == dstStart.day && t.hour >= 2))
t.hour++;
}
else if(t.month == dstEnd.month)
{
if(t.day < dstEnd.day || (t.day == dstEnd.day && t.hour < 1))
t.hour++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment