2020-02-21 16:04:02 +01:00
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
2020-02-09 13:29:09 +01:00
|
|
|
class EpisodeBrief {
|
|
|
|
final String title;
|
|
|
|
String description;
|
2020-02-21 16:04:02 +01:00
|
|
|
final int pubDate;
|
2020-02-09 13:29:09 +01:00
|
|
|
final int enclosureLength;
|
|
|
|
final String enclosureUrl;
|
|
|
|
final String feedTitle;
|
|
|
|
final String primaryColor;
|
|
|
|
final int liked;
|
|
|
|
final String downloaded;
|
|
|
|
final int duration;
|
|
|
|
final int explicit;
|
2020-02-20 16:44:42 +01:00
|
|
|
final String imagePath;
|
2020-02-09 13:29:09 +01:00
|
|
|
EpisodeBrief(
|
|
|
|
this.title,
|
|
|
|
this.enclosureUrl,
|
|
|
|
this.enclosureLength,
|
|
|
|
this.pubDate,
|
|
|
|
this.feedTitle,
|
|
|
|
this.primaryColor,
|
|
|
|
this.liked,
|
|
|
|
this.downloaded,
|
|
|
|
this.duration,
|
2020-02-20 16:44:42 +01:00
|
|
|
this.explicit,
|
|
|
|
this.imagePath
|
2020-02-09 13:29:09 +01:00
|
|
|
);
|
2020-02-21 16:04:02 +01:00
|
|
|
|
|
|
|
String dateToString(){
|
|
|
|
DateTime date = DateTime.fromMillisecondsSinceEpoch(pubDate);
|
|
|
|
var diffrence = DateTime.now().difference(date);
|
|
|
|
if(diffrence.inHours < 24) {
|
|
|
|
return '${diffrence.inHours} hours ago';
|
|
|
|
} else if (diffrence.inDays < 7){
|
|
|
|
return '${diffrence.inDays} days ago';}
|
|
|
|
else {
|
|
|
|
return DateFormat.yMMMd().format( DateTime.fromMillisecondsSinceEpoch(pubDate));
|
|
|
|
}
|
|
|
|
}
|
2020-02-09 13:29:09 +01:00
|
|
|
}
|