mirror of
https://github.com/jagandeepbrar/lunasea.git
synced 2026-08-31 04:32:32 +00:00
NEW - [Settings/Modules] Add an information/help button with module descriptions and links TWEAKS - [Radarr] Always show the amount of days content will be available instead of limiting it to only content in the next 30 days - [Settings] Moved "Backup & Restore" and "Logs" to "System" section - [Settings] Merged "Customization" and "Modules" sections into "Configuration" - [Settings/Sonarr] Removed the need to enable Sonarr to test the connection - [Settings/Tautulli] Removed the need to enable Tautulli to test the connection FIXES - [IAPs] Ensure all IAPs are marked as "consumed" - [Flutter] Updated packages - [Logging] Updated Sentry to v4 framework to improve capturing fatal/crashing bugs - [Settings/Logs] Hide exception and stack trace buttons when an error is not available - [Sonarr/History] Fixed history fetching the oldest entries, not the newest - [State] Correctly clear state when clearing LunaSea's configuration - [Tautulli/Activity] Fixed consistency of hardware transcoding indicator compared to the web UI - [UI/Divider] Fix consistency of divider width across regular and AMOLED dark theme
44 lines
1.9 KiB
Dart
44 lines
1.9 KiB
Dart
import 'package:intl/intl.dart';
|
|
import 'package:lunasea/core.dart';
|
|
|
|
extension DateTimeExtension on DateTime {
|
|
/// Get the floor of a date.
|
|
///
|
|
/// The floor is a new [DateTime] object with only the year, month, and day copied from the original source.
|
|
DateTime get lunaFloor => DateTime(this.year, this.month, this.day);
|
|
|
|
/// Returns a string representation of the "age" of the [DateTime] object.
|
|
///
|
|
/// Compares to [DateTime.now().toLocal()] to calculate the age.
|
|
String get lunaAge {
|
|
if(this == null) return 'Unknown';
|
|
Duration diff = DateTime.now().toLocal().difference(this);
|
|
if(diff.inDays >= 1) return '${diff.inDays} ${diff.inDays == 1 ? 'Day' : 'Days'} Ago';
|
|
if(diff.inHours >= 1) return '${diff.inHours} ${diff.inHours == 1 ? 'Hour' : 'Hours'} Ago';
|
|
if(diff.inMinutes >= 1) return '${diff.inMinutes} ${diff.inMinutes == 1 ? 'Minute' : 'Minutes'} Ago';
|
|
return '${diff.inSeconds} ${diff.inSeconds == 1 ? 'Second' : 'Seconds'} Ago';
|
|
}
|
|
|
|
/// Returns a string representation of how far in the future the day is.
|
|
///
|
|
/// Compares to [DateTime.now().toLocal()] to calculate the upcoming time.
|
|
String get lunaUpcomingDays {
|
|
if(this == null) return 'Unknown';
|
|
Duration diff = this.difference(DateTime.now().toLocal());
|
|
if(diff.inDays == 0) return 'Today';
|
|
return 'In ${diff.inDays} ${diff.inDays == 1 ? "Day" : "Days"}';
|
|
}
|
|
|
|
/// Returns just the time as a string.
|
|
///
|
|
/// 3 PM will return either 15:00 (24 hour style) or 3:00 PM depending on the configured database option.
|
|
String get lunaTime => LunaDatabaseValue.USE_24_HOUR_TIME.data ? DateFormat.Hm().format(this) : DateFormat.jm().format(this);
|
|
|
|
/// Returns just the date as a string.
|
|
///
|
|
/// Formatted as YYYY-MM-DD
|
|
String get lunaDate => '${this.year.toString().padLeft(4, '0')}-${this.month.toString().padLeft(2, '0')}-${this.day.toString().padLeft(2, '0')}';
|
|
|
|
|
|
}
|