| 1 | /// A gregorian calendar date generated by |
| 2 | /// OpenAPI generator to differentiate |
| 3 | /// between [DateTime] and [Date] |
| 4 | class Date implements Comparable |
| 5 | final int year; |
| 6 | |
| 7 | /// January is 1. |
| 8 | final int month; |
| 9 | |
| 10 | /// First day is 1. |
| 11 | final int day; |
| 12 | |
| 13 | Date(this.year, |
| 14 | |
| 15 | /// The current date |
| 16 | static Date now |
| 17 | var now = DateTime. |
| 18 | if (utc) { |
| 19 | now = now.toUtc(); |
| 20 | } |
| 21 | return now.toDate(); |
| 22 | } |
| 23 | |
| 24 | /// Convert to a [DateTime]. |
| 25 | DateTime toDateTime({bool |
| 26 | if (utc) { |
| 27 | return DateTime.utc |
| 28 | } else { |
| 29 | return DateTime(year, month |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | @override |
| 34 | int compareTo(Date |
| 35 | int d = year.compareTo |
| 36 | if (d != 0) { |
| 37 | return d; |
| 38 | } |
| 39 | d = month.compareTo(other.month) |
| 40 | if (d != 0) { |
| 41 | return d; |
| 42 | } |
| 43 | return day.compareTo(other. |
| 44 | } |
| 45 | |
| 46 | @override |
| 47 | bool operator ==(Object |
| 48 | identical(this, other) || |
| 49 | other is Date && |
| 50 | runtimeType == other.runtimeType && |
| 51 | year == other.year && |
| 52 | month == other.month && |
| 53 | day == other.day; |
| 54 | |
| 55 | @override |
| 56 | int get hashCode => year. |
| 57 | |
| 58 | @override |
| 59 | String toString() { |
| 60 | final yyyy = year.toString |
| 61 | final mm = month.toString |
| 62 | final dd = day.toString |
| 63 | |
| 64 | return '$yyyy- |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | extension DateTimeToDate on DateTime |
| 69 | Date toDate() => |
| 70 | } |