code: def datetime_from_timestamp(ts, tz=None, as_utc=False):
      # type: (float, dateutil.tz, bool) -> datetime.datetime
      
      if tz is None:
          tz = dateutil.tz.tzlocal()
      dt = datetime.datetime.fromtimestamp(ts, tz=tz)
      if as_utc:
          return dt.astimezone(tz=dateutil.tz.tzutc())
      else:
          return dt
docs: Convert a timestamp into datetime with offset
      :param float ts: timestamp
      :param dateutil.tz tz: time zone or local tz if not specified
      :param bool as_utc: convert datetime to UTC
      :rtype: datetime.datetime
      :return: converted timestamp to datetime