-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
36 lines (33 loc) · 931 Bytes
/
main.go
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
35
36
package main
import (
"fmt"
"github.com/crossbone-magister/timewlib"
"hours-day/logic"
"hours-day/output"
"os"
)
func main() {
parsed, err := timewlib.Parse(os.Stdin)
if err == nil {
intervals, err := timewlib.Process(parsed.Intervals)
hoursDay, totalHours, totalOvertime, totalUndertime := logic.CalculateDayHours(intervals)
if err == nil {
for _, row := range output.FormatDayHours(hoursDay) {
fmt.Println(row)
}
fmt.Println(output.FormatTotalDays(hoursDay))
fmt.Println(output.FormatTotalHours(totalHours))
fmt.Println(output.FormatTotalOvertime(totalOvertime))
fmt.Println(output.FormatTotalUndertime(totalUndertime))
fmt.Println(output.FormatActualOvertime(totalOvertime - totalUndertime))
} else {
printErrorAndExit(err)
}
} else {
printErrorAndExit(err)
}
}
func printErrorAndExit(err error) {
fmt.Printf("Error while reading timewarrior input: %s\n", err)
os.Exit(1)
}