[aprs-tools] bugfix for backlog for the 31st of the previous month

main-solar-only
Richard Meadows 2016-06-02 11:35:32 +01:00
rodzic 9d0c02835e
commit 233a1a5533
1 zmienionych plików z 10 dodań i 3 usunięć

Wyświetl plik

@ -37,10 +37,17 @@ def extract_time(line):
utcnow = arrow.utcnow()
# Set dt year/month from current utc
arw = arw.replace(year=utcnow.year, month=utcnow.month)
# Need to calculate year/month manually because months have varying number of days
#
if arw.day > utcnow.day: # from last month
arw = arw.replace(months=-1)
last_month = utcnow.month-1
if last_month == 0: # Last December
arw = arw.replace(year=utcnow.year-1, month=12)
else:
arw = arw.replace(year=utcnow.year, month=last_month)
else: # current month
arw = arw.replace(year=utcnow.year, month=utcnow.month)
return arw