# HG changeset patch # User Bjoern Ricks # Date 1297074505 -3600 # Node ID 5f87604ea5ed61c99078737976da2cab3b490507 # Parent f1012651979787d4510e93a1b5947b8ae01884e1 add year option for contrib/zeiterfassung default for year is the current year diff -r f10126519797 -r 5f87604ea5ed contrib/zeiterfassung --- a/contrib/zeiterfassung Wed Dec 15 14:47:40 2010 +0100 +++ b/contrib/zeiterfassung Mon Feb 07 11:28:25 2011 +0100 @@ -57,6 +57,7 @@ FROM entries WHERE project_id = :project_id AND + (strftime('%Y', start_time) ) = :year AND (description IS NULL or length(description) = 0) -- trim() function is missing AND (strftime('%W', start_time) = :week OR strftime('%W', stop_time) = :week) GROUP BY round(julianday(start_time)) @@ -65,6 +66,7 @@ FROM entries WHERE project_id = :project_id AND + (strftime('%Y', start_time) ) = :year AND description IS NOT NULL AND length(description) > 0 AND (strftime('%W', start_time) = :week OR strftime('%W', stop_time) = :week) ORDER BY t @@ -85,6 +87,7 @@ FROM entries WHERE project_id = :project_id AND + (strftime('%Y', start_time) ) = :year AND description IS NOT NULL AND length(description) > 0 ''' @@ -124,11 +127,12 @@ project = None encoding = None week = None + year = None opts, args = getopt.getopt( sys.argv[1:], 'd:u:p:e:hl:w:', - ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week=']) + ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week=', 'year=']) for opt, val in opts: if opt in ("--database", "-d"): @@ -145,10 +149,15 @@ list_projects = True elif opt in ("--week", "-w"): week = val + elif opt in ("--year", "-y"): + year = val if not user: user = os.getenv("USER") + if not year: + year = date.today().strftime("%Y") + if encoding: Writer = codecs.getwriter(encoding) sys.stdout = Writer(sys.stdout) @@ -185,7 +194,7 @@ for project_id, project, proj_desc in project_ids: print "# project: %s (%s)" % (project, proj_desc) if not week is None: - cur.execute(WEEK_ENTRIES, {'project_id': project_id, 'week': week}) + cur.execute(WEEK_ENTRIES, {'project_id': project_id, 'week': week, 'year' : year}) else: cur.execute(ENTRIES, {'project_id': project_id}) total = 0 @@ -202,6 +211,7 @@ if m: workpackage = m.group(1) c = c[m.end():].strip() + c = c.replace('\x1b', '') print "%s %sh %s %-3s [%s] %s" % ( d.strftime("%d.%m.%Y"), human_time(t),