mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
32 lines
785 B
Dart
32 lines
785 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
String formatDateTime(DateTime? dateTime) {
|
|
if (dateTime == null) {
|
|
return '-';
|
|
}
|
|
final DateFormat dateFormatter = DateFormat('dd/MM/yyyy');
|
|
final DateFormat timeFormatter = DateFormat('HH:mm');
|
|
|
|
return '${dateFormatter.format(dateTime)} ${timeFormatter.format(dateTime)}';
|
|
}
|
|
|
|
String formatTimeOfDayToISO(TimeOfDay time, {DateTime? currentDate}) {
|
|
final now = currentDate ?? DateTime.now();
|
|
|
|
final dateTime = DateTime(
|
|
now.year,
|
|
now.month,
|
|
now.day,
|
|
time.hour,
|
|
time.minute,
|
|
);
|
|
|
|
return dateTime.toUtc().toIso8601String();
|
|
}
|
|
|
|
String formatIsoStringToTime(String isoString) {
|
|
final dateTime = DateTime.parse(isoString);
|
|
return DateFormat('hh:mm a').format(dateTime);
|
|
}
|