Beispiel #1
0
 /**
  * Sets the year/month/day from a string. Accepts a wide variety of
  * inputs, but by default rejects ambiguous formats like MM/DD/YY vs
  * DD/MM/YY. Two digit years are handled with a sliding window
  * starting 70 years ago by default.
  *
  * \param s  Date string.
  * \param ambig  Order to use for ambiguous cases like "01/02/03"
  *               or "01/02/1995".
  * \param century_window  Number describing how to handle dates with
  *                        two digit years. Values 1 to 99 mean to use
  *                        a sliding window starting that many years back.
  *                        Values 1000 and higher mean to use a fixed window
  *                        starting at the year given. The value 0 means to
  *                        disallow two digit years.
  */
 inline void
 set_from_str(const std::string &s,
              date_parse_order_t ambig = date_parse_no_ambig,
              int century_window = 70,
              assign_error_mode errmode = assign_error_fractional)
 {
     return set_from_str(s.data(), s.data() + s.size(), ambig, century_window, errmode);
 }
Beispiel #2
0
 /**
  * Sets the hmst from a string.
  *
  * \param s  Date string.
  *
  * \returns  The time zone, if any, found in the string
  */
 inline std::string set_from_str(const std::string& s) {
     const char *tz_begin = NULL, *tz_end = NULL;
     set_from_str(s.data(), s.data() + s.size(), tz_begin, tz_end);
     return std::string(tz_begin, tz_end);
 }