better date formatting
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
extension DateTimeFormat on DateTime {
|
||||
String _twoDigits(int n) => n.toString().padLeft(2, '0');
|
||||
|
||||
String formatWithMinutePrecision() {
|
||||
final year = this.year.toString();
|
||||
final month = _twoDigits(this.month);
|
||||
final day = _twoDigits(this.day);
|
||||
final hour = _twoDigits(this.hour);
|
||||
final minute = _twoDigits(this.minute);
|
||||
|
||||
return '$year-$month-$day $hour:$minute';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user