Last updated:
0 purchases
month calculator
This will calculate the days and months in a givin date time range.
It will also account for leap years.
So if we have a range like this
DateTimeRange(start: DateTime(2023, 12, 20), end: DateTime(2024, 3, 21))
copied to clipboard
It will return 4 months and 0 days, but if we run the same thing with 2021 and 2022 we'll get 4 months and 1 day.
Usage #
final DateTimeRange rangeToMeasure = DateTimeRange(start: DateTime(2023, 12, 20), end: DateTime(2024, 3, 21));
final DayMonthCount count = MonthCalculator.monthsInRange(rangeToMeasure);
print("${count.months} months and ${count.days} days");
copied to clipboard
Additional information #
Feel free to make a PR if ya wanna add something cool or just improve efficiency.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.