def last_modified ( self ) -> Optional [ datetime . datetime ] : httpdate = self . _headers . get ( hdrs . LAST_MODIFIED ) if httpdate is not None : timetuple = parsedate ( httpdate ) if timetuple is not None : return datetime . datetime ( * timetuple [ : 6 ] , tzinfo = datetime . timezone . utc ) return None
python get last modified date of file http header lines
The value of Last - Modified HTTP header or None .
def last_modified(self) -> Optional[datetime.datetime]:
        """The value of Last-Modified HTTP header, or None.

        This header is represented as a `datetime` object.
        """
        httpdate = self._headers.get(hdrs.LAST_MODIFIED)
        if httpdate is not None:
            timetuple = parsedate(httpdate)
            if timetuple is not None:
                return datetime.datetime(*timetuple[:6],
                                         tzinfo=datetime.timezone.utc)
        return None