File: date-types.hs

package info (click to toggle)
haskelldb 0.9.cvs.601-13
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 680 kB
  • ctags: 33
  • sloc: haskell: 4,392; sh: 1,900; makefile: 130
file content (34 lines) | stat: -rw-r--r-- 852 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import System.Time (calendarTimeToString)

import Database.HaskellDB
import Dp037.D3proj_time_reports hiding (xid)
import Dp037.D3proj_users

import TestConnect

getUsers = 
    do
    users <- table d3proj_users
    reports <- table d3proj_time_reports
    order [asc reports day]
    restrict (users!xid .==. reports!userid)
    project (first_name << users!first_name # 
	     last_name << users!last_name # 
	     day << reports!day #
	     reported << reports!reported
	     )


showReport r = rpad 20 (r!first_name ++ " " ++ r!last_name) ++ " " 
	       ++ calendarTimeToString (r!day) ++ " "
	       ++ calendarTimeToString (r!reported)

rpad :: Int -> String -> String
rpad x s = s ++ replicate (x - length s) ' '

printReports db = 
    do
    users <- query db getUsers
    mapM_ (putStrLn . showReport) users

main = argConnect printReports