comparison contrib/zeiterfassung @ 11:feb6bb4427fe

Applied a variation of Stephan Holl's zeiterfassung.non-utf8-chars-in-db.patch to force the encoding given by --encoding=.
author Sascha L. Teichmann <teichmann@intevation.de>
date Mon, 04 Aug 2008 12:32:46 +0200
parents 4f782a05b4dc
children e347f0de5e22
comparison
equal deleted inserted replaced
10:4f782a05b4dc 11:feb6bb4427fe
50 50
51 ENTRIES = ''' 51 ENTRIES = '''
52 SELECT 52 SELECT
53 date(start_time), 53 date(start_time),
54 sum(strftime('%s', stop_time) - strftime('%s', start_time)), 54 sum(strftime('%s', stop_time) - strftime('%s', start_time)),
55 'no description' 55 'no description' AS description
56 FROM entries 56 FROM entries
57 WHERE 57 WHERE
58 project_id = :project_id AND 58 project_id = :project_id AND
59 (description IS NULL or length(description) = 0) -- trim() function is missing 59 (description IS NULL or length(description) = 0) -- trim() function is missing
60 GROUP BY round(julianday(start_time)) 60 GROUP BY round(julianday(start_time))
65 project_id = :project_id AND 65 project_id = :project_id AND
66 description IS NOT NULL AND length(description) > 0 66 description IS NOT NULL AND length(description) > 0
67 ''' 67 '''
68 68
69 def human_time(s): 69 def human_time(s):
70 s_h = s % 3600
71 h = s / 3600 70 h = s / 3600
72 m = s_h / 60 71 m = (s % 3600) / 60
73 if (s_h % 60) >= 30: 72 if (s % 60) >= 30:
74 m += 1 73 m += 1
75 if m == 60: 74 if m == 60:
76 m = 0 75 m = 0
77 h += 1 76 h += 1
78 return "%2d:%02d" % (h, m) 77 return "%2d:%02d" % (h, m)
135 134
136 con, cur = None, None 135 con, cur = None, None
137 try: 136 try:
138 try: 137 try:
139 con = db.connect(database) 138 con = db.connect(database)
139 if encoding:
140 con.text_factory = lambda s: s.decode(encoding)
140 cur = con.cursor() 141 cur = con.cursor()
141 142
142 if list_projects: 143 if list_projects:
143 cur.execute(LIST_PROJECTS) 144 cur.execute(LIST_PROJECTS)
144 while True: 145 while True:
171 if c: 172 if c:
172 m = WORKPACKAGE.match(c) 173 m = WORKPACKAGE.match(c)
173 if m: 174 if m:
174 workpackage = m.group(1) 175 workpackage = m.group(1)
175 c = c[m.end():].strip() 176 c = c[m.end():].strip()
176 print u"%s %sh %s %3s [%s] %s" % ( 177 print "%s %sh %s %3s [%s] %s" % (
177 d.strftime("%d.%m.%Y"), 178 d.strftime("%d.%m.%Y"),
178 human_time(t), 179 human_time(t),
179 TYPE_OF_ENTRY, 180 TYPE_OF_ENTRY,
180 user, 181 user,
181 workpackage, 182 workpackage,
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)