svn-import mistakes timezones/DST-offsets

Asked by svilen

g'day
the conrvesion of timestamps from svn is wrong when there is DST.
the function mapping.parse_svn_dateprop() uses subvertpy.properties.time_from_cstring which wrongly uses time.mktime, ignoring DST and subtracting local timezone...

here the fixed one:
def time_from_cstring(text):
    """Parse a time from a cstring.
    :param text: Parse text
    :return: timestamp
    """
    (basestr, usecstr) = text.split(".", 1)
    assert usecstr[-1] == "Z"
    tm_usec = int(usecstr[:-1])
    tm = time.strptime(basestr, "%Y-%m-%dT%H:%M:%S")
    return (long(calendar.timegm(tm)) * 1000000 + tm_usec)

i'll try relay this to subvertpy developers too

Question information

Language:
English Edit question
Status:
Answered
For:
Bazaar Subversion Plugin Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jelmer Vernooij (jelmer) said :
#1

Hi,

On Thu, 2010-10-07 at 10:16 +0000, svilen wrote:
> the conrvesion of timestamps from svn is wrong when there is DST.
> the function mapping.parse_svn_dateprop() uses subvertpy.properties.time_from_cstring which wrongly uses time.mktime, ignoring DST and subtracting local timezone...
>
> here the fixed one:
> def time_from_cstring(text):
> """Parse a time from a cstring.
> :param text: Parse text
> :return: timestamp
> """
> (basestr, usecstr) = text.split(".", 1)
> assert usecstr[-1] == "Z"
> tm_usec = int(usecstr[:-1])
> tm = time.strptime(basestr, "%Y-%m-%dT%H:%M:%S")
> return (long(calendar.timegm(tm)) * 1000000 + tm_usec)
Thanks.

> i'll try relay this to subvertpy developers too
That's the same people as the bzr-svn developers. :-)

Cheers,

Jelmer

Can you help with this problem?

Provide an answer of your own, or ask svilen for more information if necessary.

To post a message you must log in.