Modify

Opened 14 years ago

Closed 12 years ago

Last modified 12 years ago

#7073 closed defect (fixed)

Times and dates are not imported properly

Reported by: Freek Wielstra Owned by: Anton Stroganov
Priority: normal Component: MantisImportScript
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

In the latest version of the mantis2trac.py script (the one linked to from the Trac site, i.e. the latest trunk version (I assume)), times and dates are not retrieved and inserted properly.

The existing version uses time.strftime('%S'), however this will, according to the 2.6.5 documentation of Pyhton, only return the seconds (i.e. a two-digit number at best). I'm thinking that at one time this method returned the amount of seconds since the epoch.

I've spent some time trying to figure out how to fix this, so first I converted the date to a UNIX timestamp (where I assumed this was the format used - note that I was wrong) using

time.mktime(sometime.timetuple())

Note that time. in this case refers to the Python time library, and that all time variables need to be renamed (both in the array keys as the method parameters) to avoid naming collisions.

This however didn't solve the problem - it creates a 32 bits int stamp, and (it seems) Python uses 64 bits. I couldn't find any good conversion scripts, and I'm nowhere near knowledgeable with Python, so I used the following code snippet at all points where time is used (I could find it in tickets, ticket changes, comments, and attachments):

changetime = time.mktime(changetime.timetuple()) changetime = int(changetime) changetime = str(changetime) changetime = changetime + '000000' changetime = long(changetime)

Or, if you like the one-lined version which I didn't try:

changetime = long(str(int(time.mktime(changetime.timetuple())) + '000000')

I'm just posting that here in case there's other people like me that spend a day and a half trying to get this to work.

Attachments (0)

Change History (2)

comment:1 Changed 12 years ago by Anton Stroganov

Resolution: fixed
Status: newclosed

Thank you for the report, I think the latest version with changes from John Líchovnik should take care of it (it uses time.mktime(time2.timetuple())+1e-6*time2.microsecond to convert timestamps.

comment:2 Changed 12 years ago by Anton Stroganov

Er, latest version is at https://github.com/Aeon/mantis2trac/

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Anton Stroganov.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.