Skip to content

Instantly share code, notes, and snippets.

@TeWu
Last active February 27, 2019 12:40
Show Gist options
  • Save TeWu/f9b861b220f542fbb2b9e5c789b87104 to your computer and use it in GitHub Desktop.
Save TeWu/f9b861b220f542fbb2b9e5c789b87104 to your computer and use it in GitHub Desktop.
Daylight saving time calculation
// is PoLish Daylight Saving Time - source: https://en.wikipedia.org/wiki/Daylight_saving_time_by_country
// month - Month (1..12)
// date - Day of the month (1..31)
// dow - Day Of Week (1..7)
uint8_t isPLDST(uint8_t month, uint8_t date, uint8_t dow) {
if (month < 3 || month > 10) return 0;
if (month > 3 && month < 10) return 1;
uint8_t prevSunday = date > dow ? date - dow : 0;
if (month == 3) return prevSunday >= 25;
else // month == 10
return prevSunday < 25;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment