Refactors
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class DateRange {
|
||||
DateRange({required this.start, required this.end});
|
||||
final DateTime? start;
|
||||
final DateTime? end;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
final DateFormat dateFormat = DateFormat("MMM yyyy");
|
||||
if (start == null && end == null) {
|
||||
return '';
|
||||
}
|
||||
if (start == null && end != null) {
|
||||
return dateFormat.format(end!);
|
||||
}
|
||||
if (start != null && end == null) {
|
||||
return "${dateFormat.format(start!)} - Current";
|
||||
}
|
||||
return "${dateFormat.format(start!)} - ${dateFormat.format(end!)}";
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return Object.hashAll([start, end]);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return super.hashCode == other.hashCode;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user