def encode_timestamps(t1, t2=None, t3=None, explicit=False):
 form = '{0}'
 values = [t1.short]
 if (t2 is not None):
  t2_t1_delta = (t2.raw - t1.raw)
  explicit = (explicit or (t2_t1_delta != 0))
  values.append(t2_t1_delta)
  if (t3 is not None):
   t3_t2_delta = (t3.raw - t2.raw)
   explicit = (explicit or (t3_t2_delta != 0))
   values.append(t3_t2_delta)
  if explicit:
   form += '{1:+x}'
   if (t3 is not None):
    form += '{2:+x}'
 return form.format(*values)

def encode_timestamps ( t1 , t2 = None , t3 = None , explicit = False ) : form = '{0}' values = [ t1 . short ] if ( t2 is not None ) : t2_t1_delta = ( t2 . raw - t1 . raw ) explicit = ( explicit or ( t2_t1_delta != 0 ) ) values . append ( t2_t1_delta ) if ( t3 is not None ) : t3_t2_delta = ( t3 . raw - t2 . raw ) explicit = ( explicit or ( t3_t2_delta != 0 ) ) values . append ( t3_t2_delta ) if explicit : form += '{1:+x}' if ( t3 is not None ) : form += '{2:+x}' return form . format ( * values )
encode up to three timestamps into a string .