From e732a27914cb0d629e91e92638e3286c4146c7c9 Mon Sep 17 00:00:00 2001 From: efrilm Date: Wed, 13 Aug 2025 00:22:49 +0700 Subject: [PATCH] feat: date extension --- lib/common/extension/date_extension.dart | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 lib/common/extension/date_extension.dart diff --git a/lib/common/extension/date_extension.dart b/lib/common/extension/date_extension.dart new file mode 100644 index 0000000..292a27b --- /dev/null +++ b/lib/common/extension/date_extension.dart @@ -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); + } +}