Mercurial > getan
changeset 126:8d533c1b6d23
Replace hack to find last week of the previous year.
week number might be 53, e.g. last week of 2009
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Mon, 16 Jan 2012 10:13:05 +0100 |
parents | d8c372f57da9 |
children | 5b334ab7f1b0 |
files | getan/contrib/zeiterfassung.py |
diffstat | 1 files changed, 2 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/getan/contrib/zeiterfassung.py Mon Jan 16 10:00:49 2012 +0100 +++ b/getan/contrib/zeiterfassung.py Mon Jan 16 10:13:05 2012 +0100 @@ -19,7 +19,7 @@ from pysqlite2 import dbapi2 as db -from datetime import date, datetime +from datetime import date, datetime, timedelta DEFAULT_DATABASE = "time.db" @@ -179,10 +179,7 @@ elif opt in ("--week", "-w"): week = val elif opt in ("--lastweek", "-c") and not week: - currentweek = datetime.now().isocalendar()[1] - lastweek = currentweek - 1 - if lastweek <= 0: - lastweek = 52 + lastweek = (datetime.now()-timedelta(7)).isocalendar()[1] week = "%02d" % lastweek elif opt in ("--year", "-y"): year = val