Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1"""All the functionality to do with analysing photos 

2 

3:copyright: Copyright 2020 Edward Armitage. 

4:license: MIT, see LICENSE for details. 

5""" 

6from datetime import datetime, date 

7from pathlib import Path 

8 

9from exif import Image 

10 

11 

12def read_date(path: Path) -> date: 

13 """Reads the creation date of a photo file 

14 

15 :param path: The path of the file to extract the date from 

16 :return: returns the date when the photo was created 

17 """ 

18 with path.open(mode="rb") as image_file: 

19 image = Image(image_file) 

20 return datetime.strptime(image.datetime_original, "%Y:%m:%d %H:%M:%S").date()