document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. def adapt_datetime(dt):
  2.     # Get the datetime for the POSIX epoch.
  3.     epoch = datetime.datetime.utcfromtimestamp(0.0)
  4.     elapsedtime = dt - epoch
  5.     # Calculate the number of milliseconds.
  6.     seconds = float(elapsedtime.days)*24.*60.*60. + float(elapsedtime.seconds) + float(elapsedtime.microseconds)/1000000.0
  7.     return seconds
  8.  
  9. def convert_datetime(tf):
  10.     # Note: strange math is used to account for daylight savings time and
  11.     #    times in the Eastern (US) time zone (e.g. EDT)
  12.     tf = float(tf)
  13.     edt_adjustment = 6 * 60. * 60.
  14.     if time.localtime(tf).tm_isdst:
  15.         edt_adjustment = 5 * 60. * 60.
  16.     return datetime.datetime.fromtimestamp(tf+edt_adjustment)
  17.    
  18. sqlite3.register_adapter(datetime.datetime, adapt_datetime)
  19. sqlite3.register_converter("datetime", convert_datetime)
');