weather_backend.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:Weather-App 作者: Tomasz-Kluczkowski 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号