Re
suitable for use in SQL queries, e.g., WHERE dob < ? AND dob > ?
Just as a matter of general programming style, I've found that life is improved if you get into the habit of
always, always thinking in terms of half-open intervals and then write your code/libraries accordingly, e.g., here you expect that what people will
actually want is to do queries of the form:
suitable for use in SQL queries, e.g., WHERE ? <= dob AND dob < ?
(note also that this way the parameters have the lower bound first, which is what people generally expect; also this phrasing makes it more immediately visually obvious that
dob is supposed to be between the two limits ... anything you can do to help the reader is a win).
That way, if you're doing two separate queries on "0 to 10" (which includes 0 but not 10) and "10 to 20" (which includes 10 but not 20) that gets you exactly "0 to 20" and you're not forgetting to include 10 or including it twice. Lots of fencepost errors go away without your having to think about it, and if you need to know how many things are in a range, you just subtract ("20 to 30" has 10 things in it because 30-20=10).
And then you get rid of the inclusive/exclusive parameter entirely (because if everybody else using the library follows this convention, then they can just add 1 day to either of the upper or lower bound dates they get back as they need to, and in their own code it'll be obvious what they're doing; but, chances are, they won't be needing to do that at all because the half-open interval will have been the Right Thing in the first place).
Also with respect to your defaults, I'm pretty sure the original respondent meant
my $max = shift || $min;
except in my world (with half-open intervals) it's
my $max = shift || ($min + 1);
which then makes it obvious that if you leave off the second parameter, you're going to get back a 1-year interval (which will have exactly 365 days in it because it will include, say, 2014-May-17 and not 2015-May-17).