Opened 4 years ago

Closed 2 years ago

Last modified 2 years ago

#7073 closed defect (fixed)

Times and dates are not imported properly

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


In the latest version of the 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


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 2 years ago by codeFiend

  • Resolution set to fixed
  • Status changed from new to closed

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 2 years ago by codeFiend

Er, latest version is at

Add Comment

Modify Ticket

as closed .
The resolution will be deleted. Next status will be 'reopened'.

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

Note: See TracTickets for help on using tickets.