Mercurial > getan
changeset 108:e7548b8c6dcc
Add option to show entries of last week
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Mon, 21 Nov 2011 09:22:11 +0100 |
parents | a23e8191c6bc |
children | 1165422b5db7 |
files | contrib/zeiterfassung |
diffstat | 1 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/zeiterfassung Mon Sep 12 14:54:00 2011 +0200 +++ b/contrib/zeiterfassung Mon Nov 21 09:22:11 2011 +0100 @@ -19,7 +19,7 @@ from pysqlite2 import dbapi2 as db -from datetime import date +from datetime import date, datetime DEFAULT_DATABASE = "time.db" @@ -37,7 +37,8 @@ [--year=]|-y <year>] : year [--list|-l] : list all projects [--help|-h] : This text - [--emtpy|-m] : show empty projects''' + [--emtpy|-m] : show empty projects + [--lastweek|-c] : entries of last working week''' LIST_PROJECTS = ''' SELECT key, description, active FROM projects @@ -152,8 +153,9 @@ opts, args = getopt.getopt( sys.argv[1:], - 'd:u:p:e:hl:w:y:m', - ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week=', 'year=', 'empty']) + 'd:u:p:e:hl:w:y:mc', + ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week=', + 'year=', 'empty', 'lastweek']) for opt, val in opts: if opt in ("--database", "-d"): @@ -170,6 +172,12 @@ list_projects = True 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 + week = str(lastweek) elif opt in ("--year", "-y"): year = val elif opt in ("--empty", "-m"):