An attempt to tidy up current_timezone()

This commit is contained in:
Ville Voutilainen
2015-07-30 01:00:49 +03:00
parent a2c632bb5b
commit 17bd48d23c

9
tz.cpp
View File

@@ -1670,10 +1670,11 @@ current_timezone()
if (sz <= tmp) if (sz <= tmp)
break; break;
} }
if (result.compare(0, 20, "/usr/share/zoneinfo/")==0) const char zonepath[] = "/usr/share/zoneinfo/";
result.erase(0, 20); const size_t zonepath_len = sizeof(zonepath)/sizeof(zonepath[0])-1;
else if (result.compare(0, 22, "../usr/share/zoneinfo/")==0) const size_t pos = result.find(zonepath);
result.erase(0, 22); if (pos != result.npos)
result.erase(0, zonepath_len+pos);
return locate_zone(result); return locate_zone(result);
} }