added created.dd and modified.dd to template system, closes #135
This commit is contained in:
@@ -369,6 +369,8 @@ Substitution Description
|
|||||||
creation time
|
creation time
|
||||||
{created.mon} Month abbreviation in the user's locale of
|
{created.mon} Month abbreviation in the user's locale of
|
||||||
the file creation time
|
the file creation time
|
||||||
|
{created.dd} 2-digit day of the month (zero padded) of
|
||||||
|
file creation time
|
||||||
{created.doy} 3-digit day of year (e.g Julian day) of file
|
{created.doy} 3-digit day of year (e.g Julian day) of file
|
||||||
creation time, starting from 1 (zero padded)
|
creation time, starting from 1 (zero padded)
|
||||||
{modified.date} Photo's modification date in ISO format,
|
{modified.date} Photo's modification date in ISO format,
|
||||||
@@ -381,6 +383,8 @@ Substitution Description
|
|||||||
modification time
|
modification time
|
||||||
{modified.mon} Month abbreviation in the user's locale of
|
{modified.mon} Month abbreviation in the user's locale of
|
||||||
the file modification time
|
the file modification time
|
||||||
|
{modified.dd} 2-digit day of the month (zero padded) of
|
||||||
|
the file modification time
|
||||||
{modified.doy} 3-digit day of year (e.g Julian day) of file
|
{modified.doy} 3-digit day of year (e.g Julian day) of file
|
||||||
modification time, starting from 1 (zero
|
modification time, starting from 1 (zero
|
||||||
padded)
|
padded)
|
||||||
@@ -1369,6 +1373,7 @@ The following substitutions are availabe for use with `PhotoInfo.render_template
|
|||||||
|{created.mm}|2-digit month of the file creation time (zero padded)|
|
|{created.mm}|2-digit month of the file creation time (zero padded)|
|
||||||
|{created.month}|Month name in user's locale of the file creation time|
|
|{created.month}|Month name in user's locale of the file creation time|
|
||||||
|{created.mon}|Month abbreviation in the user's locale of the file creation time|
|
|{created.mon}|Month abbreviation in the user's locale of the file creation time|
|
||||||
|
|{created.dd}|2-digit day of the month (zero padded) of file creation time|
|
||||||
|{created.doy}|3-digit day of year (e.g Julian day) of file creation time, starting from 1 (zero padded)|
|
|{created.doy}|3-digit day of year (e.g Julian day) of file creation time, starting from 1 (zero padded)|
|
||||||
|{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'|
|
||||||
|{modified.year}|4-digit year of file modification time|
|
|{modified.year}|4-digit year of file modification time|
|
||||||
@@ -1376,6 +1381,7 @@ The following substitutions are availabe for use with `PhotoInfo.render_template
|
|||||||
|{modified.mm}|2-digit month of the file modification time (zero padded)|
|
|{modified.mm}|2-digit month of the file modification time (zero padded)|
|
||||||
|{modified.month}|Month name in user's locale of the file modification time|
|
|{modified.month}|Month name in user's locale of the file modification time|
|
||||||
|{modified.mon}|Month abbreviation in the user's locale of the file modification time|
|
|{modified.mon}|Month abbreviation in the user's locale of the file modification time|
|
||||||
|
|{modified.dd}|2-digit day of the month (zero padded) of the file modification time|
|
||||||
|{modified.doy}|3-digit day of year (e.g Julian day) of file modification time, starting from 1 (zero padded)|
|
|{modified.doy}|3-digit day of year (e.g Julian day) of file modification time, starting from 1 (zero padded)|
|
||||||
|{place.name}|Place name from the photo's reverse geolocation data, as displayed in Photos|
|
|{place.name}|Place name from the photo's reverse geolocation data, as displayed in Photos|
|
||||||
|{place.country_code}|The ISO country code from the photo's reverse geolocation data|
|
|{place.country_code}|The ISO country code from the photo's reverse geolocation data|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
""" version info """
|
""" version info """
|
||||||
|
|
||||||
__version__ = "0.29.2"
|
__version__ = "0.29.3"
|
||||||
|
|||||||
@@ -45,6 +45,12 @@ class DateTimeFormatter:
|
|||||||
mon = f"{self.dt.strftime('%b')}"
|
mon = f"{self.dt.strftime('%b')}"
|
||||||
return mon
|
return mon
|
||||||
|
|
||||||
|
@property
|
||||||
|
def dd(self):
|
||||||
|
""" 2-digit day of the month """
|
||||||
|
dd = f"{self.dt.strftime('%d')}"
|
||||||
|
return dd
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def doy(self):
|
def doy(self):
|
||||||
""" Julian day of year starting from 001 """
|
""" Julian day of year starting from 001 """
|
||||||
|
|||||||
@@ -836,6 +836,9 @@ class PhotoInfo:
|
|||||||
if lookup == "created.mon":
|
if lookup == "created.mon":
|
||||||
return DateTimeFormatter(self.date).mon
|
return DateTimeFormatter(self.date).mon
|
||||||
|
|
||||||
|
if lookup == "created.dd":
|
||||||
|
return DateTimeFormatter(self.date).dd
|
||||||
|
|
||||||
if lookup == "created.doy":
|
if lookup == "created.doy":
|
||||||
return DateTimeFormatter(self.date).doy
|
return DateTimeFormatter(self.date).doy
|
||||||
|
|
||||||
@@ -877,6 +880,11 @@ class PhotoInfo:
|
|||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if lookup == "modified.dd":
|
||||||
|
return (
|
||||||
|
DateTimeFormatter(self.date_modified).dd if self.date_modified else None
|
||||||
|
)
|
||||||
|
|
||||||
if lookup == "modified.doy":
|
if lookup == "modified.doy":
|
||||||
return (
|
return (
|
||||||
DateTimeFormatter(self.date_modified).doy
|
DateTimeFormatter(self.date_modified).doy
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ TEMPLATE_SUBSTITUTIONS = {
|
|||||||
"{created.mm}": "2-digit month of the file creation time (zero padded)",
|
"{created.mm}": "2-digit month of the file creation time (zero padded)",
|
||||||
"{created.month}": "Month name in user's locale of the file creation time",
|
"{created.month}": "Month name in user's locale of the file creation time",
|
||||||
"{created.mon}": "Month abbreviation in the user's locale of the file creation time",
|
"{created.mon}": "Month abbreviation in the user's locale of the file creation time",
|
||||||
|
"{created.dd}": "2-digit day of the month (zero padded) of file creation time",
|
||||||
"{created.doy}": "3-digit day of year (e.g Julian day) of file creation time, starting from 1 (zero padded)",
|
"{created.doy}": "3-digit day of year (e.g Julian day) of file creation time, starting from 1 (zero padded)",
|
||||||
"{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'",
|
||||||
"{modified.year}": "4-digit year of file modification time",
|
"{modified.year}": "4-digit year of file modification time",
|
||||||
@@ -33,6 +34,7 @@ TEMPLATE_SUBSTITUTIONS = {
|
|||||||
"{modified.mm}": "2-digit month of the file modification time (zero padded)",
|
"{modified.mm}": "2-digit month of the file modification time (zero padded)",
|
||||||
"{modified.month}": "Month name in user's locale of the file modification time",
|
"{modified.month}": "Month name in user's locale of the file modification time",
|
||||||
"{modified.mon}": "Month abbreviation in the user's locale of the file modification time",
|
"{modified.mon}": "Month abbreviation in the user's locale of the file modification time",
|
||||||
|
"{modified.dd}": "2-digit day of the month (zero padded) of the file modification time",
|
||||||
"{modified.doy}": "3-digit day of year (e.g Julian day) of file modification time, starting from 1 (zero padded)",
|
"{modified.doy}": "3-digit day of year (e.g Julian day) of file modification time, starting from 1 (zero padded)",
|
||||||
"{place.name}": "Place name from the photo's reverse geolocation data, as displayed in Photos",
|
"{place.name}": "Place name from the photo's reverse geolocation data, as displayed in Photos",
|
||||||
"{place.country_code}": "The ISO country code from the photo's reverse geolocation data",
|
"{place.country_code}": "The ISO country code from the photo's reverse geolocation data",
|
||||||
|
|||||||
21
tests/test_datetime_formatter.py
Normal file
21
tests/test_datetime_formatter.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
""" test datetime_formatter.DateTimeFormatter """
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
def test_datetime_formatter():
|
||||||
|
import datetime
|
||||||
|
import locale
|
||||||
|
from osxphotos.datetime_formatter import DateTimeFormatter
|
||||||
|
|
||||||
|
locale.setlocale(locale.LC_ALL, "en_US")
|
||||||
|
|
||||||
|
dt = datetime.datetime(2020,5,23)
|
||||||
|
dtf = DateTimeFormatter(dt)
|
||||||
|
|
||||||
|
assert dtf.date == "2020-05-23"
|
||||||
|
assert dtf.year == "2020"
|
||||||
|
assert dtf.yy == "20"
|
||||||
|
assert dtf.month == "May"
|
||||||
|
assert dtf.mon == "May"
|
||||||
|
assert dtf.mm == "05"
|
||||||
|
assert dtf.dd == "23"
|
||||||
|
assert dtf.doy == "144"
|
||||||
@@ -29,6 +29,7 @@ TEMPLATE_VALUES = {
|
|||||||
"{created.mm}": "02",
|
"{created.mm}": "02",
|
||||||
"{created.month}": "February",
|
"{created.month}": "February",
|
||||||
"{created.mon}": "Feb",
|
"{created.mon}": "Feb",
|
||||||
|
"{created.dd}": "04",
|
||||||
"{created.doy}": "035",
|
"{created.doy}": "035",
|
||||||
"{modified.date}": "2020-03-21",
|
"{modified.date}": "2020-03-21",
|
||||||
"{modified.year}": "2020",
|
"{modified.year}": "2020",
|
||||||
@@ -36,6 +37,7 @@ TEMPLATE_VALUES = {
|
|||||||
"{modified.mm}": "03",
|
"{modified.mm}": "03",
|
||||||
"{modified.month}": "March",
|
"{modified.month}": "March",
|
||||||
"{modified.mon}": "Mar",
|
"{modified.mon}": "Mar",
|
||||||
|
"{modified.dd}": "21",
|
||||||
"{modified.doy}": "081",
|
"{modified.doy}": "081",
|
||||||
"{place.name}": "Washington, District of Columbia, United States",
|
"{place.name}": "Washington, District of Columbia, United States",
|
||||||
"{place.country_code}": "US",
|
"{place.country_code}": "US",
|
||||||
@@ -64,6 +66,7 @@ TEMPLATE_VALUES_DEU = {
|
|||||||
"{created.mm}": "02",
|
"{created.mm}": "02",
|
||||||
"{created.month}": "Februar",
|
"{created.month}": "Februar",
|
||||||
"{created.mon}": "Feb",
|
"{created.mon}": "Feb",
|
||||||
|
"{created.dd}": "04",
|
||||||
"{created.doy}": "035",
|
"{created.doy}": "035",
|
||||||
"{modified.date}": "2020-03-21",
|
"{modified.date}": "2020-03-21",
|
||||||
"{modified.year}": "2020",
|
"{modified.year}": "2020",
|
||||||
@@ -71,6 +74,7 @@ TEMPLATE_VALUES_DEU = {
|
|||||||
"{modified.mm}": "03",
|
"{modified.mm}": "03",
|
||||||
"{modified.month}": "März",
|
"{modified.month}": "März",
|
||||||
"{modified.mon}": "Mär",
|
"{modified.mon}": "Mär",
|
||||||
|
"{modified.dd}": "21",
|
||||||
"{modified.doy}": "081",
|
"{modified.doy}": "081",
|
||||||
"{place.name}": "Washington, District of Columbia, United States",
|
"{place.name}": "Washington, District of Columbia, United States",
|
||||||
"{place.country_code}": "US",
|
"{place.country_code}": "US",
|
||||||
|
|||||||
Reference in New Issue
Block a user