Fakultas Ilmu Komputer UI

Verified Commit 67cc76a8 authored by Muhammad Ariq Basyar's avatar Muhammad Ariq Basyar
Browse files

[CHORE] fix test, now komentar posting have default datetime format

parent 26c635ba
import 'package:intl/intl.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:bisaGo/config/custom_serializer.dart';
......@@ -16,7 +17,7 @@ class KomentarModel {
final String namaLokasi;
final String deskripsi;
final String creator;
@JsonKey(name: 'date_time', fromJson: CustomSerializer.stringToDateTime)
@JsonKey(name: 'date_time', fromJson: _stringToDateTime)
final DateTime dateTime;
final String tag;
final List<String> disabilitas;
......@@ -48,3 +49,7 @@ class KomentarModel {
Map<String, dynamic> toJson() => _$KomentarModelToJson(this);
}
DateTime _stringToDateTime(String date) {
return DateFormat('dd-MM-yyyy hh:mm').parse(date);
}
......@@ -27,7 +27,7 @@ KomentarModel _$KomentarModelFromJson(Map<String, dynamic> json) {
namaLokasi: json['nama_lokasi'] as String,
deskripsi: json['deskripsi'] as String,
creator: json['creator'] as String,
dateTime: CustomSerializer.stringToDateTime(json['date_time'] as String),
dateTime: _stringToDateTime(json['date_time'] as String),
tag: json['tag'] as String,
disabilitas:
(json['disabilitas'] as List)?.map((e) => e as String)?.toList(),
......
......@@ -29,7 +29,7 @@ KomentarPostingKegiatanModel _$KomentarPostingKegiatanModelFromJson(
id: json['id'] as int,
creator: json['creator'] as String,
deskripsi: json['deskripsi'] as String,
created: _stringToDateTime(json['created'] as String),
created: CustomSerializer.stringToDateTime(json['created'] as String),
creatorEmail: json['creator_email'] as String,
creatorPicture: json['creator_picture'] as String,
);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment