def _millis_to_datetime(millis, opts):
 diff = (((millis % 1000) + 1000) % 1000)
 seconds = ((millis - diff) / 1000)
 micros = (diff * 1000)
 if opts.tz_aware:
  dt = (EPOCH_AWARE + datetime.timedelta(seconds=seconds, microseconds=micros))
  if opts.tzinfo:
   dt = dt.astimezone(opts.tzinfo)
  return dt
 else:
  return (EPOCH_NAIVE + datetime.timedelta(seconds=seconds, microseconds=micros))

def _millis_to_datetime ( millis , opts ) : diff = ( ( ( millis % 1000 ) + 1000 ) % 1000 ) seconds = ( ( millis - diff ) / 1000 ) micros = ( diff * 1000 ) if opts . tz_aware : dt = ( EPOCH_AWARE + datetime . timedelta ( seconds = seconds , microseconds = micros ) ) if opts . tzinfo : dt = dt . astimezone ( opts . tzinfo ) return dt else : return ( EPOCH_NAIVE + datetime . timedelta ( seconds = seconds , microseconds = micros ) )
convert milliseconds since epoch utc to datetime .