def finish_get_date(self, unix_time, dst_offset):
"""Converts date from unix time to string.
Args:
dst_offset: (bool) Set to True to offset time received from
open weather API by daylight savings time.
unix_time (int): Time given in seconds from beginning of the
epoch as on unix machines.
Returns:
name_of_day (str): Name of the day on date.
date_str (str): Date in string representation.
"""
if dst_offset:
dst_offset = self.v_link["timezone"]["dstOffset"] * 3600
else:
dst_offset = 0
date = datetime.datetime.utcfromtimestamp(unix_time + dst_offset)
date_str = date.strftime("%d/%m/%Y")
name_of_day = calendar.day_name[date.weekday()]
return name_of_day, date_str
评论列表
文章目录