raymon1 / financial

Financial is a Rust crate that contains collection of finance calculations memicking some of Excel Financial Functions interface.
https://docs.rs/crate/financial
14 stars 5 forks source link

Why does it use DateTime instead of NaiveDate #6

Closed shrektan closed 2 years ago

shrektan commented 2 years ago

Hi,

I'm curious that why this package uses DateTime with the TimeZone to be as the Cashflow Constructor.

Using NaiveDate (the Date class without HMS and TimeZone) feels much more natural to me, as Excel functions usually don't use HMS (the time part) and the TimeZone info at all.

Thanks.

raymon1 commented 2 years ago

Hi,

Good questions, it seemed more natural to me as it's more generic and you can always convert NaiveDate to DateTime, however doig the opposite, will drop some info.

That being said, you still have a point, and it might be useful to introduce another interface. would you like to create a PR for that?

shrektan commented 2 years ago

Happy to. Probably I should put the functions that accept NaiveDate as the input in a pub mod like dateapi? So use it like financial::dateapi::xirr(...).

raymon1 commented 2 years ago

yes, maybe financial::naiveDate::