How to Calculate Daylight Savings Time

Is it Daylight Savings Time? This code can help you find out.

int addHourForDST(int day, int month, int dow) {
	if (month < 3 || month > 11) return 0;
	if (month == 3 && (day-dow) >= 8) return 1;
	if (month > 3 && month < 11) return 1;
	if (month == 11 & (day-dow) <= 0) return 1;
	if (month == 11 & (day-dow) > 0) return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *