bs/bse/cf/is: show local abbreviated month names on monthly columns

This commit is contained in:
Simon Michael 2018-01-18 11:46:12 -08:00
parent 3663c46502
commit e9624486b6
3 changed files with 14 additions and 1 deletions

View File

@ -40,6 +40,7 @@ module Hledger.Data.Dates (
parsedate,
showDate,
showDateSpan,
showDateSpanMonthAbbrev,
elapsedSeconds,
prevday,
parsePeriodExpr,
@ -110,6 +111,11 @@ showDate = formatTime defaultTimeLocale "%0C%y/%m/%d"
showDateSpan :: DateSpan -> String
showDateSpan = showPeriod . dateSpanAsPeriod
-- | Like showDateSpan, but show month spans as just the abbreviated month name
-- in the current locale.
showDateSpanMonthAbbrev :: DateSpan -> String
showDateSpanMonthAbbrev = showPeriodMonthAbbrev . dateSpanAsPeriod
-- | Get the current local date.
getCurrentDay :: IO Day
getCurrentDay = do

View File

@ -144,6 +144,13 @@ showPeriod (PeriodFrom b) = formatTime defaultTimeLocale "%0C%y/%m/%d-" b
showPeriod (PeriodTo e) = formatTime defaultTimeLocale "-%0C%y/%m/%d" (addDays (-1) e) -- -INCLUSIVEENDDATE
showPeriod PeriodAll = "-"
-- | Like showPeriod, but if it's a month period show just
-- the 3 letter month name abbreviation for the current locale.
showPeriodMonthAbbrev (MonthPeriod _ m) -- Jan
| m >= 0 && m < length monthnames = snd $ monthnames !! (m-1)
where monthnames = months defaultTimeLocale
showPeriodMonthAbbrev p = showPeriod p
periodStart :: Period -> Maybe Day
periodStart p = mb
where

View File

@ -408,7 +408,7 @@ compoundBalanceReportAsHtml ropts cbr =
[tr_ $ th_ [colspanattr, leftattr] $ toHtml title]
++ [thRow $
"" :
map showDateSpan colspans
map showDateSpanMonthAbbrev colspans
++ (if row_total_ ropts then ["Total"] else [])
++ (if average_ ropts then ["Average"] else [])
]