Do not add a 'created' field if it does not exist

It should, but it's fine if it doesn't. It does look a bit strange
since Dart puts the date to Nov 0001, but whatever.
This commit is contained in:
Vishesh Handa
2019-01-18 16:58:06 +01:00
parent c99fe854a1
commit 905f501a6f

View File

@ -41,13 +41,11 @@ class Note implements Comparable {
}
}
// FIXME: Get created from file system or from git!
if (created == null) {
// FIXME: make this 0
created = DateTime.now();
json.remove("created");
}
json.remove("created");
if (created == null) {
created = DateTime(0, 0, 0, 0, 0, 0, 0, 0);
}
String body = "";
@ -66,7 +64,10 @@ class Note implements Comparable {
Map<String, dynamic> toJson() {
var json = Map<String, dynamic>.from(extraProperties);
json['created'] = toIso8601WithTimezone(created);
var createdStr = toIso8601WithTimezone(created);
if (!createdStr.startsWith("00")) {
json['created'] = createdStr;
}
json['body'] = body;
json['fileName'] = fileName;