Closed pmav99 closed 5 years ago
I like it! However, there seem to be a few bugs in your implementation. If today's date is October 1st, 2018, the current fiscal year is FiscalYear(2019)
. It might be better to use:
@classmethod
def current(cls):
today = FiscalDate.today()
return cls(today.fiscal_year)
and similarly for FiscalQuarter
.
I'll have to think about whether we should call it current
or today
. current
makes more sense, but today
is more in line with the datetime
module.
I also toyed around with the idea of having FiscalDate.today().fiscal_year
return a FiscalYear
object instead of an int
, but I figured the current implementation would be more useful.
Pull requests are always welcome! Just make sure to write a good docstring and unit tests. Hopefully the unit testing framework is pretty simple to understand, but let me know if you have any questions.
You are right about the bug. I am not in the US so I was thinking about Fiscal Years starting on 1st of January... :P
I will make a pull request.
I think it would be nice if there was an easy way to get the current
FiscalYear
/FiscalQuarter
.This could easily be achieved by using a couple of
classmethods
. E.g.:This way you could write:
If you want, I can try to make a pull request.