Refactor: move unrelated fns out of class definition

This commit is contained in:
Ming Ming 2024-07-15 01:24:25 +08:00
parent f43910f68b
commit 0caa78b074

View file

@ -24,9 +24,6 @@ class Date implements Comparable<Date> {
return Date(year ?? this.year, month ?? this.month, day ?? this.day); return Date(year ?? this.year, month ?? this.month, day ?? this.day);
} }
DateTime toUtcDateTime() => DateTime.utc(year, month, day);
DateTime toLocalDateTime() => DateTime(year, month, day);
@override @override
int compareTo(Date other) => toUtcDateTime().compareTo(other.toUtcDateTime()); int compareTo(Date other) => toUtcDateTime().compareTo(other.toUtcDateTime());
@ -49,6 +46,9 @@ class Date implements Comparable<Date> {
} }
extension DateExtension on Date { extension DateExtension on Date {
DateTime toUtcDateTime() => DateTime.utc(year, month, day);
DateTime toLocalDateTime() => DateTime(year, month, day);
Date add({ Date add({
int? year, int? year,
int? month, int? month,