def pdf_date(path):
"""
Extract a date from PDF file metadata.
Args:
path (str): The file path.
Returns:
datetime: The created date.
"""
reader = PdfFileReader(path)
# Get rid of `D:` prefix and timezone.
stamp = reader.documentInfo['/CreationDate']
match = re.search('\d+', stamp)
return datetime.strptime(
match.group(),
'%Y%m%d%H%M%S'
)
评论列表
文章目录