mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-02 13:20:51 +00:00
remove duplicated epoch handling, test it
This commit is contained in:
1 parent
7a2a3fc136
commit
b6a353cae9
7 files changed
+63
-80
No files matched your search
+16
@@ -9,6 +9,22 @@ void mg_bzero(volatile unsigned char *buf, size_t len) {
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t mg_timegm(unsigned int year, unsigned int month, unsigned int day,
|
||||
unsigned int hour, unsigned int min, unsigned int sec) {
|
||||
static const uint16_t dm[12] = {0, 31, 59, 90, 120, 151,
|
||||
181, 212, 243, 273, 304, 334};
|
||||
const uint64_t day_secs = 86400;
|
||||
const uint64_t year_secs = 31536000;
|
||||
unsigned int y, ly;
|
||||
if (year < 1970) return 0;
|
||||
y = year - 1900;
|
||||
ly = month > 2 ? y + 1 : y;
|
||||
return (uint64_t) sec + 60 * min + 3600 * hour +
|
||||
day_secs * (dm[month - 1] + day - 1) + year_secs * (y - 70) +
|
||||
day_secs * ((ly - 69) / 4) - day_secs * ((ly - 1) / 100) +
|
||||
day_secs * ((ly + 299) / 400);
|
||||
}
|
||||
|
||||
#if MG_ENABLE_CUSTOM_RANDOM
|
||||
#else
|
||||
bool mg_random(void *buf, size_t len) {
|
||||
|
||||
Reference in new issue
Block a user