due_date library
Support for creating your own custom due dates.
This package is used to create custom due dates.
Implementing your own DueDateTime is easy. You implement an Every class and pass it to the DueDateTime constructor.
There are already some Every classes implemented in this package. Look for EveryWeekday, EveryDueDayMonth, EveryWeekdayCountInMonth (or WeekdayOccurrences constants) and EveryDayInYear.
The Every class is a base class that processes all the base operations for DueDateTime. You can mix in one of the folowing mixins:
And if you want to be more specific, implement the others.
WARNING: If you mix in two of the above mixins, the order in which you mix them in is important. The last mixin you mix in will be the one that is used for DueDateTime.next and DueDateTime.previous on the DueDateTime class.
Classes
- DateValidator
- A class to save a specific validation for a DateTime.
- DateValidatorDayInYear
- A DateValidator that validates a DateTime if the DateTime.day is the dayInYear of the year.
-
DateValidatorDifference<
E extends DateValidator> - A DateValidator that validates a DateTime if the date is valid for only one of the validators.
- DateValidatorDueDayMonth
- A DateValidator that validates a DateTime if the DateTime.day is the same value as dueDay. If exact is false, and the dueDay is greater than the days in month, the DateTime will be valid if the DateTime.day is the last day of the month.
-
DateValidatorIntersection<
E extends DateValidator> - A DateValidator that validates a DateTime if the date is valid for all of the validators.
-
DateValidatorUnion<
E extends DateValidator> - A DateValidator that validates a DateTime if the date is valid for any of the validators.
- DateValidatorWeekday
- A DateValidator that validates a DateTime if it is on the given weekday.
- DateValidatorWeekdayCountInMonth
- A DateValidator that validates a DateTime if the DateTime.day is the day of the week and is the week of the month.
-
DueDateTime<
T extends Every> - Wrapper for Every and DateTime to represent a due date.
- Every
- Abstract class that, when extended, processes DateTime with custom logic.
- EveryDateValidator
- A base class that represents an Every with a DateValidator.
-
EveryDateValidatorDifference<
E extends EveryDateValidator> - Class that processes DateTime so that the next always returns the next day where only one of the EveryDateValidators conditions is met.
-
EveryDateValidatorIntersection<
E extends EveryDateValidator> - Class that processes DateTime so that the next always returns the next day where all of the EveryDateValidators conditions are met.
-
EveryDateValidatorUnion<
E extends EveryDateValidator> - Class that processes DateTime so that the next always returns the next day where any of the EveryDateValidators conditions are met.
- EveryDayInYear
- Class that processes DateTime so that the addYears always returns the next day where the difference in days between the date and the first day of the year is equal to the dayInYear.
- EveryDueDayMonth
- Class that processes DateTime so that the addMonths always returns the next month's with the DateTime.day as the dueDay clamped to fit in the length of the next month.
- EveryWeekday
- Class that processes DateTime so that the addWeeks always returns the next week's with the DateTime.weekday equals to the weekday.
- EveryWeekdayCountInMonth
- Class that processes DateTime so that the addMonths always returns the next month's with the week occurence of the day (DateTime.weekday is the day's Weekday.dateTimeValue).
- LimitedEvery
- Abstract class that forces the implementation of Every to have a limit parameter for the startDate, next and previous methods.
Mixins
-
DateValidatorListMixin<
E extends DateValidator> - Mixin that represents a list of DateValidators.
- DateValidatorMixin
- Mixin to easily implement the DateValidator.validsIn method.
-
EveryDateValidatorListMixin<
E extends EveryDateValidator> - Mixin that represents a list of EveryDateValidator.
- EveryMonth
- Processes DateTime with custom logic.
- EveryWeek
- Processes DateTime with custom logic.
- EveryYear
- Processes DateTime with custom logic.
Extensions
- AddDays
- Extension methods related to adding or subtracting days from a DateTime.
- ClampInMonth
- Extension methods related to clamping months on DateTime.
- DateValidatorListExt
- Extension methods related to DateValidators. Simpply wrappers around creating DateValidatorIntersection, DateValidatorUnion or DateValidatorDifference.
- DayInYear
- Extension methods to get the day of the year of a DateTime.
- EveryDateValidatorListExt
- Extension methods related to EveryDateValidators. Simpply wrappers around creating EveryDateValidatorIntersection, EveryDateValidatorUnion or EveryDateValidatorDifference.
- PreviousNext
- Extension methods related to adding or subtracting one from an Iterable of Weekday.
- WeekCalc
- Extension methods related to weeks on a DateTime.
Enums
- Month
- Month constants that are returned by DateTime.month method.
- Week
- Week occurences inside a month.
- Weekday
- Weekday constants that are returned by DateTime.weekday method.
- WeekdayOccurrence
- An enum wrapper in EveryWeekdayCountInMonth class.
Exceptions / Errors
- DateTimeLimitReachedException
- Exception thrown when a date limit is reached.