Implemented ParseDateFromJson method.

This commit is contained in:
Mikwk 2020-08-06 12:03:31 +02:00
parent a7a0e4bf12
commit 43ab1990d7
3 changed files with 11 additions and 10 deletions

View File

@ -16,8 +16,8 @@ CommentView _$CommentViewFromJson(Map<String, dynamic> json) {
json['content'] as String,
json['removed'] as bool,
json['read'] as bool,
UtilityClass.ParseDateFromJson(json['published']),
UtilityClass.ParseDateFromJson(json['updated']),
UtilityClass.ParseDateFromJson(json['published'] as String),
UtilityClass.ParseDateFromJson(json['updated'] as String),
json['deleted'] as bool,
json['ap_id'] as String,
json['local'] as bool,
@ -30,7 +30,7 @@ CommentView _$CommentViewFromJson(Map<String, dynamic> json) {
json['creator_actor_id'] as String,
json['creator_local'] as bool,
json['creator_name'] as String,
UtilityClass.ParseDateFromJson(json['creator_published']),
UtilityClass.ParseDateFromJson(json['creator_published'] as String),
json['creator_avatar'] as String,
json['score'] as int,
json['upvotes'] as int,

View File

@ -16,8 +16,8 @@ PostView _$PostViewFromJson(Map<String, dynamic> json) {
json['community_id'] as int,
json['removed'] as bool,
json['locked'] as bool,
UtilityClass.ParseDateFromJson(json['published']),
UtilityClass.ParseDateFromJson(json['updated']),
UtilityClass.ParseDateFromJson(json['published'] as String),
UtilityClass.ParseDateFromJson(json['updated'] as String),
json['deleted'] as bool,
json['nsfw'] as bool,
json['stickied'] as bool,
@ -30,7 +30,7 @@ PostView _$PostViewFromJson(Map<String, dynamic> json) {
json['creator_actor_id'] as String,
json['creator_local'] as bool,
json['creator_name'] as String,
UtilityClass.ParseDateFromJson(json['creator_published']),
UtilityClass.ParseDateFromJson(json['creator_published'] as String),
json['creator_avatar'] as String,
json['banned'] as bool,
json['banned_from_community'] as bool,
@ -45,7 +45,7 @@ PostView _$PostViewFromJson(Map<String, dynamic> json) {
json['upvotes'] as int,
json['downvotes'] as int,
json['hot_rank'] as int,
UtilityClass.ParseDateFromJson(json['newest_activity_time']),
UtilityClass.ParseDateFromJson(json['newest_activity_time'] as String),
json['userId'] as int,
json['myVote'] as int,
json['subscribed'] as bool,

View File

@ -1,6 +1,7 @@
class UtilityClass {
//TODO: Parse date from Json.
static DateTime ParseDateFromJson(t) {
throw Exception("Not implemented exception");
///Parses date from Json.
///May return null on wrong argument
static DateTime ParseDateFromJson(String t) {
return DateTime.tryParse(t);
}
}