mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-15 07:56:11 +08:00
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:
@ -41,15 +41,13 @@ 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 = "";
|
String body = "";
|
||||||
if (json.containsKey("body")) {
|
if (json.containsKey("body")) {
|
||||||
body = json['body'];
|
body = json['body'];
|
||||||
@ -66,7 +64,10 @@ class Note implements Comparable {
|
|||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
var json = Map<String, dynamic>.from(extraProperties);
|
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['body'] = body;
|
||||||
json['fileName'] = fileName;
|
json['fileName'] = fileName;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user