def _microseconds_from_datetime(value):
 if (not value.tzinfo):
  value = value.replace(tzinfo=UTC)
 value = value.astimezone(UTC)
 return (int((calendar.timegm(value.timetuple()) * 1000000.0)) + value.microsecond)

def _microseconds_from_datetime ( value ) : if ( not value . tzinfo ) : value = value . replace ( tzinfo = UTC ) value = value . astimezone ( UTC ) return ( int ( ( calendar . timegm ( value . timetuple ( ) ) * 1000000.0 ) ) + value . microsecond )
convert non-none datetime to microseconds .