feat: date extension
This commit is contained in:
parent
43153f9b0d
commit
e732a27914
33
lib/common/extension/date_extension.dart
Normal file
33
lib/common/extension/date_extension.dart
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
|
extension DateTimeIndonesia on DateTime {
|
||||||
|
/// Format: 13 Agustus 2025
|
||||||
|
String toDate() {
|
||||||
|
return DateFormat('d MMMM yyyy', 'id_ID').format(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Format: 13 Agustus 2025 20:00
|
||||||
|
String toDatetime() {
|
||||||
|
return DateFormat('d MMMM yyyy HH:mm', 'id_ID').format(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Format: Rabu, 13 Agustus 2025
|
||||||
|
String toDayDate() {
|
||||||
|
return DateFormat('EEEE, d MMMM yyyy', 'id_ID').format(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Format: 13/08/2025
|
||||||
|
String toShortDate() {
|
||||||
|
return DateFormat('dd/MM/yyyy', 'id_ID').format(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Format: 13-08-2025
|
||||||
|
String toSeverDate() {
|
||||||
|
return DateFormat('dd-MM-yyyy', 'id_ID').format(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Format jam: 14:30
|
||||||
|
String toHourMinute() {
|
||||||
|
return DateFormat('HH:mm', 'id_ID').format(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user