Skip to content

Commit

Permalink
refactor: Add toString method is some app classes
Browse files Browse the repository at this point in the history
  • Loading branch information
enrique-lozano committed Feb 2, 2025
1 parent 6becdb9 commit e3a52d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions lib/core/models/date-utils/date_period.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ class DatePeriod {

const DatePeriod.customRange(DateTime? start, DateTime? end)
: this(periodType: PeriodType.dateRange, customDateRange: (start, end));

@override
String toString() {
return 'DatePeriod(periodType: $periodType)';
}
}
11 changes: 7 additions & 4 deletions lib/core/models/date-utils/date_period_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ class DatePeriodState {
DateTime? get startDate => getDates().$1;
DateTime? get endDate => getDates().$2;

/// Returns the duration of the current period state. Will return null
/// if the `startDate` or the `endDate` of this period are null.
Duration? get periodStateDuration {
@override
String toString() {
return 'DatePeriodState(datePeriod: $datePeriod, modifier $periodModifier) -> [$startDate, $endDate]';
}

DateTimeRange? get toDateTimeRange {
if (startDate == null || endDate == null) {
return null;
}

return endDate!.difference(startDate!);
return DateTimeRange(start: startDate!, end: endDate!);
}

/// Given the current period status, return the dates of the next period
Expand Down

0 comments on commit e3a52d4

Please sign in to comment.