| 261 | } |
| 262 | |
| 263 | bool Timezone::ParseTZRule(string::const_iterator& it,const string::const_iterator& end,TransitionRule& rule) { |
| 264 | if (it == end) |
| 265 | return false; |
| 266 | TransitionRule::Type type(TransitionRule::NIL); |
| 267 | UInt8 month(0), week(0), day(0); |
| 268 | if (*it == 'J' && ++it!=end) { |
| 269 | while (it!=end && isdigit(*it)) { day = day*10 + ((*it)-'0'); ++it;} // julian day (1 to 365 without leap counted) |
| 270 | if (day>0) |
| 271 | type = TransitionRule::JULIAN; |
| 272 | } else if (*it == 'M' && ++it!=end) { |
| 273 | while (it != end && isdigit(*it)) { month = month*10 + ((*it)-'0'); ++it; } // month |
| 274 | if (it != end && *it == '.') { ++it; while (it != end && isdigit(*it)) { week = week*10 + ((*it)-'0'); ++it; } } // week |
| 275 | if (it != end && *it == '.') { ++it; while (it != end && isdigit(*it)) { day = day*10 + ((*it)-'0'); ++it; } } // day |
| 276 | if (month>0 && week>0) |
| 277 | type = TransitionRule::RELATIVE; |
| 278 | } else { |
| 279 | while (it!=end && isdigit(*it)) { day = day*10 + ((*it)-'0'); ++it;} // absolute day (0 to 365 with leap counted) |
| 280 | if (day>0) |
| 281 | type = TransitionRule::ABSOLUTE; |
| 282 | } |
| 283 | if (type==TransitionRule::NIL) |
| 284 | return false; |
| 285 | rule.type = type; rule.month = month; rule.week = week; rule.day = day; |
| 286 | if (it != end && *it == '/') { |
| 287 | bool gotten(false); |
| 288 | month = week = day = 0; |
| 289 | ++it; |
| 290 | while (it != end && isdigit(*it)) { month = month * 10 + ((*it) - '0'); ++it; gotten = true; } // hour |
| 291 | if (!gotten) { |
| 292 | rule.clock = month*3600000; |
| 293 | return true; |
| 294 | } |
| 295 | if (it != end && *it == ':') { ++it; while (it != end && isdigit(*it)) { week = week*10 + ((*it)-'0'); ++it; } } // minute |
| 296 | rule.clock += week*60000; |
| 297 | if (it != end && *it == ':') { ++it; while (it != end && isdigit(*it)) { day = day*10 + 1000 * ((*it)-'0'); ++it; } } // second |
| 298 | rule.clock += day*1000; |
| 299 | |
| 300 | } |
| 301 | return true; |
| 302 | } |
| 303 | |
| 304 | |
| 305 | bool Timezone::readTZDatabase(const string& path) { |