| 37 | namespace datetime_parse_util { |
| 38 | |
| 39 | void DateTimeFormatContext::SetCenturyBreakAndCurrentTime(const TimestampValue& now) { |
| 40 | current_time = &now; |
| 41 | const boost::gregorian::date& now_date = now.date(); |
| 42 | // If the century break is at an invalid 02/29, set it to 02/28 for consistency with |
| 43 | // Hive. |
| 44 | if (now_date.month() == 2 && now_date.day() == 29 && |
| 45 | !boost::gregorian::gregorian_calendar::is_leap_year(now_date.year() - 80)) { |
| 46 | century_break_ptime = boost::posix_time::ptime( |
| 47 | boost::gregorian::date(now_date.year() - 80, 2, 28), now.time()); |
| 48 | } else { |
| 49 | century_break_ptime = boost::posix_time::ptime( |
| 50 | boost::gregorian::date(now_date.year() - 80, now_date.month(), now_date.day()), |
| 51 | now.time()); |
| 52 | } |
| 53 | DCHECK(!century_break_ptime.is_special()); |
| 54 | } |
| 55 | |
| 56 | void DateTimeFormatContext::Reset(const char* fmt, int fmt_len) { |
| 57 | this->fmt = fmt; |