mirror of
https://github.com/jagandeepbrar/lunasea.git
synced 2026-08-31 20:52:32 +00:00
14 lines
428 B
Dart
14 lines
428 B
Dart
abstract class LunaParser {
|
|
/// Parse any [String] to a [DateTime] object if possible.
|
|
static DateTime? dateTimeFromString(String? date) {
|
|
return DateTime.tryParse(date ?? '');
|
|
}
|
|
|
|
/// Take a [DateTime] object and convert it to an ISO 8601 [String] representation.
|
|
///
|
|
/// The format is `yyyy-MM-ddTHH:mm:ss.mmmuuuZ`.
|
|
static String? dateTimeToISO8601(DateTime? date) {
|
|
return date?.toIso8601String();
|
|
}
|
|
}
|