29 lines
656 B
Dart
29 lines
656 B
Dart
|
import 'package:date_format/date_format.dart';
|
||
|
|
||
|
class DateUtil {
|
||
|
static String getMonth(DateTime date) {
|
||
|
String formattedDate = formatDate(date, ['MMM']);
|
||
|
return formattedDate;
|
||
|
}
|
||
|
|
||
|
static String getDate(DateTime date) {
|
||
|
String formattedDate = formatDate(date, ['d']);
|
||
|
if (formattedDate.length == 1) {
|
||
|
formattedDate = '0$formattedDate';
|
||
|
}
|
||
|
return formattedDate;
|
||
|
}
|
||
|
|
||
|
static String getDay(DateTime date) {
|
||
|
String formattedDate = formatDate(date, ['EEE']);
|
||
|
return formattedDate;
|
||
|
}
|
||
|
|
||
|
static String addPrefix(String string) {
|
||
|
if (string.length == 1) {
|
||
|
string = '0$string';
|
||
|
}
|
||
|
return string;
|
||
|
}
|
||
|
}
|