Please export failIfInvalidMonth and failIfInvalidDay from Hledger.Data.Dates #216

Closed
peti opened this Issue Oct 30, 2014 · 4 comments

Projects

None yet

2 participants

@peti
Collaborator
peti commented Oct 30, 2014

I would like to use these utility functions in my hledger-interest tool, and I'd rather avoid duplicating the definitions of these functions (even though they are quite short).

@simonmichael
Owner

Sure thing.

@peti
Collaborator
peti commented Oct 30, 2014

Very cool, thank you! I need to parse any kind of ISO'ish date, i.e. anything that resembles the YYYY-MM-DD format. I considered using the smart date parser from HLedger, but that parser accepts all kind of crazy formats like "today" which I don't want to recognize. So I ended up writing my own little parser. It feels silly to duplicate that functionality, though. Is there maybe a better alternative available in hledger-lib that I missed?

@simonmichael
Owner

They're in Hledger.Data.Dates (code) - how about parsedate or parsedateM ? Or the currently unexported ymd parser. parsetimewith shows how to use Data.Time.Format to parse any format.

@peti
Collaborator
peti commented Oct 30, 2014

It looks like ymd is the parser I want -- its code looks pretty much exactly like the function I have now. parsedateM looks good, too, though. It's nice that the function doesn't depend on Parsec. I'll to have to think about this subject for a moment before I can figure out what works best for me. Thanks for the comments!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment