Advertisement
Fiblund

Python3 photosorter add date

Oct 19th, 2020
2,616
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.53 KB | None | 0 0
  1. # try to correct wrong picture date stamps
  2. if "2015" in data["captureDate"]:
  3.     date_year = data["captureDate"][0:4]
  4.     date_month = data["captureDate"][5:7]
  5.     date_day = data["captureDate"][8:10]
  6.     date_hour = data["captureDate"][11:13]
  7.     date_minute = data["captureDate"][14:16]
  8.     date_second = data["captureDate"][17:19]
  9.  
  10.     minutes_to_add = 3
  11.     hours_to_add = 17
  12.     days_to_add = 13
  13.     months_to_add = 7
  14.     years_to_add = 3
  15.  
  16.     # add 3 minutes to minute field
  17.     date_minute = int(date_minute) + minutes_to_add
  18.     minutes_removed = 0
  19.     if date_minute > 60:
  20.         while date_minute > 60:
  21.             date_minute -= 1
  22.             minutes_removed += 1
  23.         date_minute = minutes_removed
  24.         hours_to_add += 1
  25.     if len(str(date_minute)) == 1:
  26.         date_minute = f"0{date_minute}"
  27.  
  28.     # add 17 hours to hour field
  29.     date_hour = int(date_hour) + hours_to_add
  30.     hours_removed = 0
  31.     if date_hour > 24:
  32.         while date_hour > 24:
  33.             date_hour -= 1
  34.             hours_removed += 1
  35.         date_hour = hours_removed
  36.         days_to_add += 1
  37.     if len(str(date_hour)) == 1:
  38.         date_hour = f"0{date_hour}"
  39.  
  40.     # add 13 days to day field
  41.     date_day = int(date_day) + days_to_add
  42.     if len(str(date_day)) == 1:
  43.         date_day = f"0{date_day}"
  44.  
  45.     # add 7 months to month field
  46.     date_month = int(date_month) + months_to_add
  47.     if len(str(date_month)) == 1:
  48.         date_month = f"0{date_month}"
  49.  
  50.     # add 3 years to year field
  51.     date_year = int(date_year) + years_to_add
  52.     if len(str(date_year)) == 1:
  53.         date_year = f"0{date_year}"
  54.  
  55.     data["captureDate"] = f"{date_year}:{date_month}:{date_day} {date_hour}:{date_minute}:{date_second}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement