mndrix / clk

a distributed time clock application for the command line
The Unlicense
2 stars 0 forks source link

support periods which cover previous months #9

Closed mndrix closed 14 years ago

mndrix commented 14 years ago

Trying to run clk ls -p 'last month' returns no data because clk ls only queries the most recent month in the timeline. It should really match the Period value against the months and determine which overlap. Then extract matching entries from all entries inside of those months.

mndrix commented 14 years ago

I started hacking on this and realized that I need to refactor first. mostRecentMonthEntries should be reimplemented in terms of

allMonths :: IO [MonthFile]

where MonthFile is a new data type roughly like

data MonthFile = MonthFile Period AbsolutePath

where the Period records the times of the beginning and ending of the month in question and AbsolutePath is like FilePath but guaranteed to be absolute (not relative). AbsolutePath can probably just be implemented roughly like

mkAbsolutePath :: FilePath -> AbsolutePath
mkAbsolutePath p
    | isAbsolute p -> AbsolutePath p
    | otherwise -> error p ++ " not absolute"

Once the period and path are bundled up inside MonthFile values, it should be easier to filter out the values that overlap with a particular date range.

mndrix commented 14 years ago

Progress is in branch gh-9

mndrix commented 14 years ago

Fixed in 0d6774d49dc0e2bec49fd455b8e0f63963da8f75