def DatetimeToWmiTime(dt):
 td = dt.utcoffset()
 if td:
  offset = ((td.seconds + (((td.days * 60) * 60) * 24)) / 60)
  if (offset >= 0):
   str_offset = ('+%03d' % offset)
  else:
   str_offset = ('%03d' % offset)
 else:
  str_offset = '+000'
 return (u'%04d%02d%02d%02d%02d%02d.%06d%s' % (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.microsecond, str_offset))

def DatetimeToWmiTime ( dt ) : td = dt . utcoffset ( ) if td : offset = ( ( td . seconds + ( ( ( td . days * 60 ) * 60 ) * 24 ) ) / 60 ) if ( offset >= 0 ) : str_offset = ( '+%03d' % offset ) else : str_offset = ( '%03d' % offset ) else : str_offset = '+000' return ( u'%04d%02d%02d%02d%02d%02d.%06d%s' % ( dt . year , dt . month , dt . day , dt . hour , dt . minute , dt . second , dt . microsecond , str_offset ) )
take a datetime tuple and return it as yyyymmddhhmmss .