There are date/time-manipulation libraries where the difference between two
dates is a date-interval, stored just as the endpoints. Subsequent function
calls are used to translate that interval into the number of calendar days,
or fiscal days, or whatever. I think the Datetime.jl package stores date
differences as the number of days. See the docs:
https://github.com/karbarcca/Datetime.jl/wiki/Datetime-Manual

If your use case is different, you could probably wrap the Datetime package
in something more specific to your needs. Having nice support for arbitrary
business calendars, with weird offset fiscal years, fiscal weeks, specified
work days, etc., is probably pretty useful...



On Sun, Apr 20, 2014 at 10:53 AM, andrew cooke <[email protected]> wrote:

> look at promote and convert.  you may be able to promote to some common
> intermediate type, do the the calculation, and then convert back again.
>
>
> On Sunday, 20 April 2014 05:31:40 UTC-3, MikeEI wrote:
>>
>> I hope not too contrived, just for learning the Julia style:
>> Let's say one wants to implement different day count methods that have
>> same argument types (enddate, begindate), using (-), means not using
>> different function names. Which way would You recommend to realize
>> something like this:
>> (-) (enddate, begindate) =  (alg for # of calendrical days in between)
>> (-) (enddate, begindate) =  (alg for # of interest days in between)
>> (-) (enddate, begindate) =  (alg for # of work days in between)
>>
>> Could it be done via multiple dispatch and different return type?
>> Or via higher order function, defining subtraction beforehand?
>> Or does the "problem" just require different function names?
>>
>>
>>

Reply via email to