def _set_tz(values, tz, preserve_UTC=False, coerce=False):
 if (tz is not None):
  name = getattr(values, 'name', None)
  values = values.ravel()
  tz = tslib.get_timezone(_ensure_decoded(tz))
  values = DatetimeIndex(values, name=name)
  if (values.tz is None):
   values = values.tz_localize('UTC').tz_convert(tz)
  if preserve_UTC:
   if (tz == 'UTC'):
    values = list(values)
 elif coerce:
  values = np.asarray(values, dtype='M8[ns]')
 return values

def _set_tz ( values , tz , preserve_UTC = False , coerce = False ) : if ( tz is not None ) : name = getattr ( values , 'name' , None ) values = values . ravel ( ) tz = tslib . get_timezone ( _ensure_decoded ( tz ) ) values = DatetimeIndex ( values , name = name ) if ( values . tz is None ) : values = values . tz_localize ( 'UTC' ) . tz_convert ( tz ) if preserve_UTC : if ( tz == 'UTC' ) : values = list ( values ) elif coerce : values = np . asarray ( values , dtype = 'M8[ns]' ) return values
coerce the values to a datetimeindex if tz is set preserve the input shape if possible parameters values : ndarray tz : string/pickled tz object preserve_utc : boolean .