Created
January 24, 2017 18:04
-
-
Save requinix/dffeb6a11b278182901cd277bc5b6ba8 to your computer and use it in GitHub Desktop.
This file contains 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
const static timelib_tz_lookup_table* abbr_search(const char *word, timelib_long gmtoffset, int isdst) | |
{ | |
int abbr_found = 0, offset_found = 0; | |
const timelib_tz_lookup_table *tp, *abbr_found_elem = NULL, *offset_found_elem = NULL; | |
if (strcasecmp("utc", word) == 0 || strcasecmp("gmt", word) == 0) { | |
return timelib_timezone_utc; | |
} | |
for (tp = timelib_timezone_lookup; tp->name; tp++) { | |
if (strcasecmp(word, tp->name) == 0) { | |
if (!abbr_found) { | |
abbr_found = 1; | |
abbr_found_elem = tp; | |
if (gmtoffset == -1) { | |
return tp; | |
} | |
} | |
if (tp->gmtoffset == gmtoffset) { | |
return tp; | |
} | |
} else if (!offset_found && tp->gmtoffset == gmtoffset && (isdst == -1 || tp->type == isdst)) { | |
offset_found = 1; | |
offset_found_elem = tp; | |
if (!*word) { | |
return tp; | |
} | |
} | |
} | |
if (abbr_found) { | |
return abbr_found_elem; | |
} else if (offset_found) { | |
return offset_found_elem; | |
} | |
return NULL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment