28 lines
602 B
Dart
28 lines
602 B
Dart
|
import 'package:smoke_cess_app/interface/db_record.dart';
|
||
|
|
||
|
class Relapse implements DatabaseRecord {
|
||
|
final String _comment;
|
||
|
final DateTime _date;
|
||
|
|
||
|
Relapse(this._comment, this._date);
|
||
|
|
||
|
@override
|
||
|
factory Relapse.fromDatabase(Map<String, dynamic> map) {
|
||
|
DateTime date = DateTime.parse(map['date']);
|
||
|
return Relapse(map['comment'], date);
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
String toCSV() {
|
||
|
return "${_date.toIso8601String()}, {_wokeUpAt.minute}, $_comment";
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Map<String, dynamic> toMap() {
|
||
|
return {
|
||
|
'comment': _comment,
|
||
|
'date': _date.toIso8601String(),
|
||
|
};
|
||
|
}
|
||
|
}
|