diff options
author | Özgür Kesim <oec@codeblau.de> | 2024-11-28 11:48:49 +0100 |
---|---|---|
committer | Özgür Kesim <oec@codeblau.de> | 2024-11-28 11:48:49 +0100 |
commit | 248f4a1276ee6eceae69d12042ed2d527c635ab6 (patch) | |
tree | 1e11772df07cab01a532ce25aa0091481d926eb4 /zeitgeist.go | |
parent | 574a953078e1b9a68a8528bf16e91860283542b3 (diff) |
correction to report
Diffstat (limited to 'zeitgeist.go')
-rw-r--r-- | zeitgeist.go | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/zeitgeist.go b/zeitgeist.go index abcbe52..869d062 100644 --- a/zeitgeist.go +++ b/zeitgeist.go @@ -177,25 +177,25 @@ func (a Date) After(b Date) bool { type Amount float64 const ( - Days Amount = Amount(215) - DaysInMonth = Amount(Days) / 12 - HoursInDay = Amount(8) + DaysInYear = 215 + DaysInMonth = DaysInYear / 12 + HoursInDay = 8 ) func (u Amount) String() string { - d := u / HoursInDay + d := int(u / HoursInDay) m := d / DaysInMonth - h := u - Amount(int(d))*HoursInDay + h := int(u) - d*HoursInDay r := "" - if int(m) > 0 { - r = fmt.Sprintf("%dm", int(m)) + if m != 0 { + r = fmt.Sprintf("%dM", m) d -= DaysInMonth * m } - if int(d) > 0 { - r += fmt.Sprintf("%dd", int(d)) + if d != 0 { + r += fmt.Sprintf("%dd", d) } - if h > 0 { - r += fmt.Sprintf("%dh", int(h)) + if h != 0 { + r += fmt.Sprintf("%dh", h) } return r } @@ -209,7 +209,7 @@ func (b Amount) AsDay() string { } func (b Amount) AsMonth() string { - return fmt.Sprintf("%5.2fm", b/HoursInDay/Amount(DaysInMonth)) + return fmt.Sprintf("%5.2fm", b/HoursInDay/DaysInMonth) } func (u *Amount) UnmarshalText(b []byte) error { @@ -448,7 +448,7 @@ func (p *Project) readPlans(dir string) error { Amount: a, Comment: parts[3]} - entries := p.Timeline[Date(d)] + entries := p.Planned[Date(d)] entries = append(entries, entry) p.Planned[Date(d)] = entries } @@ -796,7 +796,7 @@ type Totals struct { func (t *Totals) Unaccounted() Amount { d := t.Budgeted - t.Planned // TODO: rounding OK!? - if d < 0.01 { + if d*d < 1 { return 0 } return d |