~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/timestamp.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-07-03 11:36:57 UTC
  • mfrom: (3517.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080703113657-6twl1rf07wq3o42d
(mbp) patch from Martin von Gagern to run setlocale for libsvn

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
        offset = 0
57
57
    tt = time.gmtime(t + offset)
58
58
 
59
 
    return (time.strftime("%a %Y-%m-%d %H:%M:%S", tt)
 
59
    return (osutils.weekdays[tt[6]] +
 
60
            time.strftime(" %Y-%m-%d %H:%M:%S", tt)
60
61
            # Get the high-res seconds, but ignore the 0
61
62
            + ('%.9f' % (t - int(t)))[1:]
62
63
            + ' %+03d%02d' % (offset / 3600, (offset / 60) % 60))
100
101
    ...      break
101
102
 
102
103
    """
 
104
    # Weekday parsing is locale sensitive, so drop the weekday
 
105
    space_loc = date.find(' ')
 
106
    if space_loc == -1 or date[:space_loc] not in osutils.weekdays:
 
107
        raise ValueError(
 
108
            'Date string does not contain a day of week: %r' % date)
103
109
    # Up until the first period is a datestamp that is generated
104
110
    # as normal from time.strftime, so use time.strptime to
105
111
    # parse it
107
113
    if dot_loc == -1:
108
114
        raise ValueError(
109
115
            'Date string does not contain high-precision seconds: %r' % date)
110
 
    base_time = time.strptime(date[:dot_loc], "%a %Y-%m-%d %H:%M:%S")
 
116
    base_time = time.strptime(date[space_loc:dot_loc], " %Y-%m-%d %H:%M:%S")
111
117
    fract_seconds, offset = date[dot_loc:].split()
112
118
    fract_seconds = float(fract_seconds)
113
119