Created
February 20, 2025 16:12
-
-
Save federkamm/8b014976754d4b4a1b9c10cb2e4c87fb to your computer and use it in GitHub Desktop.
convert date to unix timestamp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Gregorian calender only, fails in Jan and Feb of year 0 */ | |
int days_since_1970(uint16_t year, uint8_t month, uint8_t day) { | |
if (month < 3) { month += 12; year--; } | |
return day + (int)(30.6 * month - 719561.3) + (1461 * year >> 2) - ((year / 100 * 3 + 3) >> 2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment