# HG changeset patch # User Björn Ricks # Date 1321863731 -3600 # Node ID e7548b8c6dcc34aa94dd2a611541da8f13bfc446 # Parent a23e8191c6bc1a380780419f4d8f4375c1107283 Add option to show entries of last week diff -r a23e8191c6bc -r e7548b8c6dcc contrib/zeiterfassung --- 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 [--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"):