def strptime(cls, date_string, format, tz=None):
    """Parse date_string according to format and construct BaseTimestamp.

    Args:
      date_string: string passed to time.strptime.
      format: format string passed to time.strptime.
      tz: if not specified, local timezone assumed.
    Returns:
      New BaseTimestamp.
    """
    if tz is None:
      return cls.Localize(cls(*(time.strptime(date_string, format)[:6])))
    return tz.localize(cls(*(time.strptime(date_string, format)[:6])))