/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/timestamp.py

  • Committer: Matt Giuca
  • Date: 2011-11-20 01:50:38 UTC
  • mto: This revision was merged to the branch mainline in revision 6282.
  • Revision ID: matt.giuca@gmail.com-20111120015038-mln5c1in153786le
bzrlib.timestamp: Better error message if the string is missing a timezone offset.
If it is a valid time stamp but without an offset, the error message specifically mentions that that is the problem.
This gives better feedback when using --commit-time.

Show diffs side-by-side

added added

removed removed

Lines of Context:
128
128
# Format for patch dates: %Y-%m-%d %H:%M:%S [+-]%H%M
129
129
# Groups: 1 = %Y-%m-%d %H:%M:%S; 2 = [+-]%H; 3 = %M
130
130
RE_PATCHDATE = re.compile("(\d+-\d+-\d+\s+\d+:\d+:\d+)\s*([+-]\d\d)(\d\d)$")
 
131
RE_PATCHDATE_NOOFFSET = re.compile("\d+-\d+-\d+\s+\d+:\d+:\d+$")
131
132
 
132
133
def parse_patch_date(date_str):
133
134
    """Parse a patch-style date into a POSIX timestamp and offset.
136
137
    """
137
138
    match = RE_PATCHDATE.match(date_str)
138
139
    if match is None:
139
 
        raise ValueError("time data %r does not match format " % date_str
140
 
            + "'%Y-%m-%d %H:%M:%S %z'")
 
140
        if RE_PATCHDATE_NOOFFSET.match(date_str) is not None:
 
141
            raise ValueError("time data %r is missing a timezone offset"
 
142
                % date_str)
 
143
        else:
 
144
            raise ValueError("time data %r does not match format " % date_str
 
145
                + "'%Y-%m-%d %H:%M:%S %z'")
141
146
    secs_str = match.group(1)
142
147
    offset_hours, offset_mins = int(match.group(2)), int(match.group(3))
143
148
    if abs(offset_hours) >= 24 or offset_mins >= 60: