int WorldClock::GetTimezoneNo(const model::Timezone *timezone) const
{
- for (int i = timezone->gmt_offset / 60 + 11; i < time_zones_.size(); i++) {
- if (time_zones_.at(i).gmt_offset == timezone->gmt_offset) {
- return i;
- }
- }
+ for (auto it = time_zones_.begin() ; it != time_zones_.end(); it++) {
+ if (it->gmt_offset == timezone->gmt_offset)
+ return it - time_zones_.begin();
+ }
return -1;
}
const Timezone *WorldClock::GetTimezoneByOffset(int offset) const
{
- for (int i = offset / 60 + 11; i < time_zones_.size(); i++) {
- if (time_zones_.at(i).gmt_offset == offset) {
- return &time_zones_.at(i);
- }
+ for (auto &it: time_zones_) {
+ if (it.gmt_offset == offset)
+ return &(it);
}
return NULL;
}