mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-14 02:14:14 +03:00
split midnight-spanning timelog sessions. Accurate time reports at last!
This commit is contained in:
parent
ae5a9439d0
commit
564aba4976
@ -21,12 +21,20 @@ instance Show TimeLogEntry where
|
|||||||
instance Show TimeLog where
|
instance Show TimeLog where
|
||||||
show tl = printf "TimeLog with %d entries" $ length $ timelog_entries tl
|
show tl = printf "TimeLog with %d entries" $ length $ timelog_entries tl
|
||||||
|
|
||||||
-- | Convert time log entries to ledger entries. When there is no clockout,
|
-- | Convert time log entries to ledger entries. When there is no
|
||||||
-- add one with the provided current time.
|
-- clockout, add one with the provided current time. Sessions crossing
|
||||||
|
-- midnight are split to give accurate per-day totals.
|
||||||
entriesFromTimeLogEntries :: LocalTime -> [TimeLogEntry] -> [Entry]
|
entriesFromTimeLogEntries :: LocalTime -> [TimeLogEntry] -> [Entry]
|
||||||
entriesFromTimeLogEntries _ [] = []
|
entriesFromTimeLogEntries _ [] = []
|
||||||
entriesFromTimeLogEntries t [i] = [entryFromTimeLogInOut i (TimeLogEntry 'o' t "")]
|
entriesFromTimeLogEntries t [i] = [entryFromTimeLogInOut i (TimeLogEntry 'o' t "")]
|
||||||
entriesFromTimeLogEntries t (i:o:rest) = [entryFromTimeLogInOut i o] ++ entriesFromTimeLogEntries t rest
|
entriesFromTimeLogEntries t (i:o:rest)
|
||||||
|
| odate > idate = [entryFromTimeLogInOut i o'] ++ entriesFromTimeLogEntries t (i':o:rest)
|
||||||
|
| otherwise = [entryFromTimeLogInOut i o] ++ entriesFromTimeLogEntries t rest
|
||||||
|
where
|
||||||
|
(itime,otime) = (tldatetime i,tldatetime o)
|
||||||
|
(idate,odate) = (localDay itime,localDay otime)
|
||||||
|
o' = o{tldatetime=itime{localDay=idate, localTimeOfDay=TimeOfDay 23 59 59}}
|
||||||
|
i' = i{tldatetime=itime{localDay=addDays 1 idate, localTimeOfDay=midnight}}
|
||||||
|
|
||||||
-- | Convert a timelog clockin and clockout entry to an equivalent ledger
|
-- | Convert a timelog clockin and clockout entry to an equivalent ledger
|
||||||
-- entry, representing the time expenditure. Note this entry is not balanced,
|
-- entry, representing the time expenditure. Note this entry is not balanced,
|
||||||
@ -38,7 +46,7 @@ entryFromTimeLogInOut i o
|
|||||||
error $ "clock-out time less than clock-in time in:\n" ++ showEntry e
|
error $ "clock-out time less than clock-in time in:\n" ++ showEntry e
|
||||||
where
|
where
|
||||||
e = Entry {
|
e = Entry {
|
||||||
edate = odate, -- like ledger
|
edate = idate,
|
||||||
estatus = True,
|
estatus = True,
|
||||||
ecode = "",
|
ecode = "",
|
||||||
edescription = showtime itod ++ "-" ++ showtime otod,
|
edescription = showtime itod ++ "-" ++ showtime otod,
|
||||||
|
1
NOTES
1
NOTES
@ -55,7 +55,6 @@ clever tricks like the plague." --Edsger Dijkstra
|
|||||||
**** charts
|
**** charts
|
||||||
**** easier data entry
|
**** easier data entry
|
||||||
**** parse more file formats - gnucash, qif, ofx, csv..
|
**** parse more file formats - gnucash, qif, ofx, csv..
|
||||||
**** split day-spanning timelog sessions, don't report more than 24 hours in a day
|
|
||||||
**** easier timelog format
|
**** easier timelog format
|
||||||
**** i18n
|
**** i18n
|
||||||
*** speed
|
*** speed
|
||||||
|
Loading…
Reference in New Issue
Block a user