I'm looking for the module ChronoUnit
java.time.temporal.ChronoUnit
implementation in Python, found in Java 8.
The reason this modules is useful, is because it contains a procedure that computes the Days, Months, Years etc.. between to arbitrary dates.
PS: Implementing the date computation in python, can result in a lot of problems as there are a lot of corner cases that I simply have no time consider at the moment, so please be constructive while answering.
Edit: I think my question is not clear enough, but what I'm trying to accomplish is to be able to actually substract one date from another and as a result to get the months, days, years etc.. between the two.
As per juanpa.arrivillaga comment the arrow library provides a useful method that provides a near similar function, I think that I'll answer my own question now.
Thanks to @junpa.arrivillaga I figured out that the procedure might be easily implemented in python thanks to the arrow library.
The api to be used it the following:
The final method in Python would be:
Edit: Arrow.range returns a generator, in theory you can't compute the length of a generator, but if you are sure the generator you're using is returning a finite set of elements then you can convert this generato into a list then use
len()to compute it's length.Thanks to everyone.