Fixed modified template to use creation time if no modificationd date, issue #312

This commit is contained in:
Rhet Turnbull
2020-12-31 13:07:00 -08:00
parent f9a43b92c1
commit 2f57abd23c
4 changed files with 74 additions and 58 deletions

View File

@@ -740,27 +740,39 @@ Substitution Description
https://strftime.org/ for help on strftime https://strftime.org/ for help on strftime
templates. templates.
{modified.date} Photo's modification date in ISO format, {modified.date} Photo's modification date in ISO format,
e.g. '2020-03-22' e.g. '2020-03-22'; uses creation date if
{modified.year} 4-digit year of photo modification time photo is not modified
{modified.yy} 2-digit year of photo modification time {modified.year} 4-digit year of photo modification time;
uses creation date if photo is not modified
{modified.yy} 2-digit year of photo modification time;
uses creation date if photo is not modified
{modified.mm} 2-digit month of the photo modification time {modified.mm} 2-digit month of the photo modification time
(zero padded) (zero padded); uses creation date if photo
is not modified
{modified.month} Month name in user's locale of the photo {modified.month} Month name in user's locale of the photo
modification time modification time; uses creation date if
photo is not modified
{modified.mon} Month abbreviation in the user's locale of {modified.mon} Month abbreviation in the user's locale of
the photo modification time the photo modification time; uses creation
date if photo is not modified
{modified.dd} 2-digit day of the month (zero padded) of {modified.dd} 2-digit day of the month (zero padded) of
the photo modification time the photo modification time; uses creation
date if photo is not modified
{modified.dow} Day of week in user's locale of the photo {modified.dow} Day of week in user's locale of the photo
modification time modification time; uses creation date if
photo is not modified
{modified.doy} 3-digit day of year (e.g Julian day) of {modified.doy} 3-digit day of year (e.g Julian day) of
photo modification time, starting from 1 photo modification time, starting from 1
(zero padded) (zero padded); uses creation date if photo
{modified.hour} 2-digit hour of the photo modification time is not modified
{modified.hour} 2-digit hour of the photo modification time;
uses creation date if photo is not modified
{modified.min} 2-digit minute of the photo modification {modified.min} 2-digit minute of the photo modification
time time; uses creation date if photo is not
modified
{modified.sec} 2-digit second of the photo modification {modified.sec} 2-digit second of the photo modification
time time; uses creation date if photo is not
modified
{today.date} Current date in iso format, e.g. {today.date} Current date in iso format, e.g.
'2020-03-22' '2020-03-22'
{today.year} 4-digit year of current date {today.year} 4-digit year of current date
@@ -2297,18 +2309,18 @@ The following template field substitutions are availabe for use with `PhotoInfo.
|{created.min}|2-digit minute of the photo creation time| |{created.min}|2-digit minute of the photo creation time|
|{created.sec}|2-digit second of the photo creation time| |{created.sec}|2-digit second of the photo creation time|
|{created.strftime}|Apply strftime template to file creation date/time. Should be used in form {created.strftime,TEMPLATE} where TEMPLATE is a valid strftime template, e.g. {created.strftime,%Y-%U} would result in year-week number of year: '2020-23'. If used with no template will return null value. See https://strftime.org/ for help on strftime templates.| |{created.strftime}|Apply strftime template to file creation date/time. Should be used in form {created.strftime,TEMPLATE} where TEMPLATE is a valid strftime template, e.g. {created.strftime,%Y-%U} would result in year-week number of year: '2020-23'. If used with no template will return null value. See https://strftime.org/ for help on strftime templates.|
|{modified.date}|Photo's modification date in ISO format, e.g. '2020-03-22'| |{modified.date}|Photo's modification date in ISO format, e.g. '2020-03-22'; uses creation date if photo is not modified|
|{modified.year}|4-digit year of photo modification time| |{modified.year}|4-digit year of photo modification time; uses creation date if photo is not modified|
|{modified.yy}|2-digit year of photo modification time| |{modified.yy}|2-digit year of photo modification time; uses creation date if photo is not modified|
|{modified.mm}|2-digit month of the photo modification time (zero padded)| |{modified.mm}|2-digit month of the photo modification time (zero padded); uses creation date if photo is not modified|
|{modified.month}|Month name in user's locale of the photo modification time| |{modified.month}|Month name in user's locale of the photo modification time; uses creation date if photo is not modified|
|{modified.mon}|Month abbreviation in the user's locale of the photo modification time| |{modified.mon}|Month abbreviation in the user's locale of the photo modification time; uses creation date if photo is not modified|
|{modified.dd}|2-digit day of the month (zero padded) of the photo modification time| |{modified.dd}|2-digit day of the month (zero padded) of the photo modification time; uses creation date if photo is not modified|
|{modified.dow}|Day of week in user's locale of the photo modification time| |{modified.dow}|Day of week in user's locale of the photo modification time; uses creation date if photo is not modified|
|{modified.doy}|3-digit day of year (e.g Julian day) of photo modification time, starting from 1 (zero padded)| |{modified.doy}|3-digit day of year (e.g Julian day) of photo modification time, starting from 1 (zero padded); uses creation date if photo is not modified|
|{modified.hour}|2-digit hour of the photo modification time| |{modified.hour}|2-digit hour of the photo modification time; uses creation date if photo is not modified|
|{modified.min}|2-digit minute of the photo modification time| |{modified.min}|2-digit minute of the photo modification time; uses creation date if photo is not modified|
|{modified.sec}|2-digit second of the photo modification time| |{modified.sec}|2-digit second of the photo modification time; uses creation date if photo is not modified|
|{today.date}|Current date in iso format, e.g. '2020-03-22'| |{today.date}|Current date in iso format, e.g. '2020-03-22'|
|{today.year}|4-digit year of current date| |{today.year}|4-digit year of current date|
|{today.yy}|2-digit year of current date| |{today.yy}|2-digit year of current date|

View File

@@ -1,5 +1,5 @@
""" version info """ """ version info """
__version__ = "0.39.2" __version__ = "0.39.3"

View File

@@ -70,18 +70,18 @@ TEMPLATE_SUBSTITUTIONS = {
+ "{created.strftime,%Y-%U} would result in year-week number of year: '2020-23'. " + "{created.strftime,%Y-%U} would result in year-week number of year: '2020-23'. "
+ "If used with no template will return null value. " + "If used with no template will return null value. "
+ "See https://strftime.org/ for help on strftime templates.", + "See https://strftime.org/ for help on strftime templates.",
"{modified.date}": "Photo's modification date in ISO format, e.g. '2020-03-22'", "{modified.date}": "Photo's modification date in ISO format, e.g. '2020-03-22'; uses creation date if photo is not modified",
"{modified.year}": "4-digit year of photo modification time", "{modified.year}": "4-digit year of photo modification time; uses creation date if photo is not modified",
"{modified.yy}": "2-digit year of photo modification time", "{modified.yy}": "2-digit year of photo modification time; uses creation date if photo is not modified",
"{modified.mm}": "2-digit month of the photo modification time (zero padded)", "{modified.mm}": "2-digit month of the photo modification time (zero padded); uses creation date if photo is not modified",
"{modified.month}": "Month name in user's locale of the photo modification time", "{modified.month}": "Month name in user's locale of the photo modification time; uses creation date if photo is not modified",
"{modified.mon}": "Month abbreviation in the user's locale of the photo modification time", "{modified.mon}": "Month abbreviation in the user's locale of the photo modification time; uses creation date if photo is not modified",
"{modified.dd}": "2-digit day of the month (zero padded) of the photo modification time", "{modified.dd}": "2-digit day of the month (zero padded) of the photo modification time; uses creation date if photo is not modified",
"{modified.dow}": "Day of week in user's locale of the photo modification time", "{modified.dow}": "Day of week in user's locale of the photo modification time; uses creation date if photo is not modified",
"{modified.doy}": "3-digit day of year (e.g Julian day) of photo modification time, starting from 1 (zero padded)", "{modified.doy}": "3-digit day of year (e.g Julian day) of photo modification time, starting from 1 (zero padded); uses creation date if photo is not modified",
"{modified.hour}": "2-digit hour of the photo modification time", "{modified.hour}": "2-digit hour of the photo modification time; uses creation date if photo is not modified",
"{modified.min}": "2-digit minute of the photo modification time", "{modified.min}": "2-digit minute of the photo modification time; uses creation date if photo is not modified",
"{modified.sec}": "2-digit second of the photo modification time", "{modified.sec}": "2-digit second of the photo modification time; uses creation date if photo is not modified",
# "{modified.strftime}": "Apply strftime template to file modification date/time. Should be used in form " # "{modified.strftime}": "Apply strftime template to file modification date/time. Should be used in form "
# + "{modified.strftime,TEMPLATE} where TEMPLATE is a valid strftime template, e.g. " # + "{modified.strftime,TEMPLATE} where TEMPLATE is a valid strftime template, e.g. "
# + "{modified.strftime,%Y-%U} would result in year-week number of year: '2020-23'. " # + "{modified.strftime,%Y-%U} would result in year-week number of year: '2020-23'. "
@@ -679,73 +679,73 @@ class PhotoTemplate:
value = ( value = (
DateTimeFormatter(self.photo.date_modified).date DateTimeFormatter(self.photo.date_modified).date
if self.photo.date_modified if self.photo.date_modified
else None else DateTimeFormatter(self.photo.date).date
) )
elif field == "modified.year": elif field == "modified.year":
value = ( value = (
DateTimeFormatter(self.photo.date_modified).year DateTimeFormatter(self.photo.date_modified).year
if self.photo.date_modified if self.photo.date_modified
else None else DateTimeFormatter(self.photo.date).year
) )
elif field == "modified.yy": elif field == "modified.yy":
value = ( value = (
DateTimeFormatter(self.photo.date_modified).yy DateTimeFormatter(self.photo.date_modified).yy
if self.photo.date_modified if self.photo.date_modified
else None else DateTimeFormatter(self.photo.date).yy
) )
elif field == "modified.mm": elif field == "modified.mm":
value = ( value = (
DateTimeFormatter(self.photo.date_modified).mm DateTimeFormatter(self.photo.date_modified).mm
if self.photo.date_modified if self.photo.date_modified
else None else DateTimeFormatter(self.photo.date).mm
) )
elif field == "modified.month": elif field == "modified.month":
value = ( value = (
DateTimeFormatter(self.photo.date_modified).month DateTimeFormatter(self.photo.date_modified).month
if self.photo.date_modified if self.photo.date_modified
else None else DateTimeFormatter(self.photo.date).month
) )
elif field == "modified.mon": elif field == "modified.mon":
value = ( value = (
DateTimeFormatter(self.photo.date_modified).mon DateTimeFormatter(self.photo.date_modified).mon
if self.photo.date_modified if self.photo.date_modified
else None else DateTimeFormatter(self.photo.date).mon
) )
elif field == "modified.dd": elif field == "modified.dd":
value = ( value = (
DateTimeFormatter(self.photo.date_modified).dd DateTimeFormatter(self.photo.date_modified).dd
if self.photo.date_modified if self.photo.date_modified
else None else DateTimeFormatter(self.photo.date).dd
) )
elif field == "modified.dow": elif field == "modified.dow":
value = ( value = (
DateTimeFormatter(self.photo.date_modified).dow DateTimeFormatter(self.photo.date_modified).dow
if self.photo.date_modified if self.photo.date_modified
else None else DateTimeFormatter(self.photo.date).dow
) )
elif field == "modified.doy": elif field == "modified.doy":
value = ( value = (
DateTimeFormatter(self.photo.date_modified).doy DateTimeFormatter(self.photo.date_modified).doy
if self.photo.date_modified if self.photo.date_modified
else None else DateTimeFormatter(self.photo.date).doy
) )
elif field == "modified.hour": elif field == "modified.hour":
value = ( value = (
DateTimeFormatter(self.photo.date_modified).hour DateTimeFormatter(self.photo.date_modified).hour
if self.photo.date_modified if self.photo.date_modified
else None else DateTimeFormatter(self.photo.date).hour
) )
elif field == "modified.min": elif field == "modified.min":
value = ( value = (
DateTimeFormatter(self.photo.date_modified).min DateTimeFormatter(self.photo.date_modified).min
if self.photo.date_modified if self.photo.date_modified
else None else DateTimeFormatter(self.photo.date).min
) )
elif field == "modified.sec": elif field == "modified.sec":
value = ( value = (
DateTimeFormatter(self.photo.date_modified).sec DateTimeFormatter(self.photo.date_modified).sec
if self.photo.date_modified if self.photo.date_modified
else None else DateTimeFormatter(self.photo.date).sec
) )
elif field == "today.date": elif field == "today.date":
value = DateTimeFormatter(self.today).date value = DateTimeFormatter(self.today).date

View File

@@ -170,17 +170,21 @@ TEMPLATE_VALUES_DATE_MODIFIED = {
} }
TEMPLATE_VALUES_DATE_NOT_MODIFIED = { TEMPLATE_VALUES_DATE_NOT_MODIFIED = {
# uses creation date instead of modified date
"{name}": "128FB4C6-0B16-4E7D-9108-FB2E90DA1546", "{name}": "128FB4C6-0B16-4E7D-9108-FB2E90DA1546",
"{original_name}": "IMG_1064", "{original_name}": "IMG_1064",
"{modified.date}": "_", "{modified.date}": "2020-02-04",
"{modified.year}": "_", "{modified.year}": "2020",
"{modified.yy}": "_", "{modified.yy}": "20",
"{modified.mm}": "_", "{modified.mm}": "02",
"{modified.month}": "_", "{modified.month}": "February",
"{modified.mon}": "_", "{modified.mon}": "Feb",
"{modified.dd}": "_", "{modified.dd}": "04",
"{modified.doy}": "_", "{modified.dow}": "Tuesday",
"{modified.dow}": "_", "{modified.doy}": "035",
"{modified.hour}": "19",
"{modified.min}": "07",
"{modified.sec}": "38",
} }