Skip to content

Commit

Permalink
Merge pull request #32 from Bart274/master
Browse files Browse the repository at this point in the history
change days back to search to month length
  • Loading branch information
jakewaldron authored Aug 16, 2016
2 parents 7a370f4 + ab77ff4 commit e8320af
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts/plexEmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,13 @@ def replaceConfigTokens():
if (config['web_domain'].rfind('/') < len(config['web_domain']) - len('/')):
config['web_domain'] = config['web_domain'] + '/'

if (config['date_days_back_to_search'] == 31):
now = datetime.datetime.now()
if (now.month == 1):
config['date_days_back_to_search'] = calendar.monthrange(now.year - 1, 12)[1]
else:
config['date_days_back_to_search'] = calendar.monthrange(now.year, now.month - 1)[1]

for value in config:
if (isinstance(config[value], str)):
config[value] = config[value].replace('{past_day}', str((date.today() - timedelta(days=config['date_days_back_to_search'], hours=config['date_hours_back_to_search'], minutes=config['date_minutes_back_to_search'])).strftime(config['date_format'])))
Expand Down

0 comments on commit e8320af

Please sign in to comment.