first commit
This commit is contained in:
63
lib/model/ont_model.dart
Normal file
63
lib/model/ont_model.dart
Normal file
@ -0,0 +1,63 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class OntModel {
|
||||
int? id;
|
||||
String? nama;
|
||||
String? noInternet;
|
||||
String? noHp;
|
||||
String? alamat;
|
||||
String? langganan;
|
||||
String? download;
|
||||
String? upload;
|
||||
String? status;
|
||||
DateTime? updated;
|
||||
|
||||
OntModel({
|
||||
this.id,
|
||||
this.nama,
|
||||
this.noInternet,
|
||||
this.noHp,
|
||||
this.alamat,
|
||||
this.langganan,
|
||||
this.download,
|
||||
this.upload,
|
||||
this.status,
|
||||
this.updated,
|
||||
});
|
||||
|
||||
factory OntModel.fromJson(Map<String, dynamic> json) {
|
||||
DateTime originalTime =
|
||||
DateTime.parse(json['updated'].toString()).toUtc(); // Ensure UTC
|
||||
DateTime utcPlus8 =
|
||||
originalTime.add(const Duration(hours: 8)); // Convert to UTC+8
|
||||
return OntModel(
|
||||
id: json['id'] as int?,
|
||||
nama: json['nama'] as String?,
|
||||
noInternet: json['no_internet'] as String?,
|
||||
noHp: json['no_hp'] as String?,
|
||||
alamat: json['alamat'] as String?,
|
||||
langganan: json['langganan'] as String?,
|
||||
download: json['download'] as String?,
|
||||
upload: json['upload'] as String?,
|
||||
status: json['status'] as String?,
|
||||
updated: utcPlus8,
|
||||
);
|
||||
}
|
||||
|
||||
String getFormattedDate() {
|
||||
return DateFormat('yyyy-MM-dd HH:mm:ss').format(updated!);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'nama': nama,
|
||||
'no_internet': noInternet,
|
||||
'no_hp': noHp,
|
||||
'alamat': alamat,
|
||||
'langganan': langganan,
|
||||
'download': download,
|
||||
'upload': upload,
|
||||
'status': status,
|
||||
'updated': updated?.toIso8601String(),
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user