datex_formatter 1.1.0
datex_formatter: ^1.1.0 copied to clipboard
Lightweight DateTime formatting and timezone conversion extensions for Dart and Flutter.
example/main.dart
import 'package:datex_formatter/datex_formatter.dart';
void main() {
final now = DateTime.now();
print('=== Date Formats ===');
print('yyyyMMdd: ${now.yyyyMMdd}');
print('yyyyMMddCompact: ${now.yyyyMMddCompact}');
print('ddMMyyyy: ${now.ddMMyyyy}');
print('ddMMyy: ${now.ddMMyy}');
print('ddMMyyyySlash: ${now.ddMMyyyySlash}');
print('mmDdYyyy: ${now.mmDdYyyy}');
print('ddMMMyyyy: ${now.ddMMMyyyy}');
print('ddMMMMyyyy: ${now.ddMMMMyyyy}');
print('mmmDdYyyy: ${now.mmmDdYyyy}');
print('shortDayDate: ${now.shortDayDate}');
print('fullDate: ${now.fullDate}');
print('ddMMM: ${now.ddMMM}');
print('ddMMMM: ${now.ddMMMM}');
print('mmmDd: ${now.mmmDd}');
print('mmmYyyy: ${now.mmmYyyy}');
print('mmmmYyyy: ${now.mmmmYyyy}');
print('\n=== Time Formats ===');
print('hhmm24: ${now.hhmm24}');
print('hhmm12: ${now.hhmm12}');
print('hhmmss24: ${now.hhmmss24}');
print('hhmmss12: ${now.hhmmss12}');
print('\n=== Date Time Formats ===');
print('dateTime24: ${now.dateTime24}');
print('dateTimeReadable: ${now.dateTimeReadable}');
print('fullDateTime: ${now.fullDateTime}');
print('dateTimeSlash24: ${now.dateTimeSlash24}');
print('dateTimeDash12: ${now.dateTimeDash12}');
print('\n=== Day ===');
print('dayName: ${now.dayName}');
print('dayShort: ${now.dayShort}');
print('\n=== Month ===');
print('monthName: ${now.monthName}');
print('monthShort: ${now.monthShort}');
print('\n=== Year ===');
print('year: ${now.year}');
print('shortYear: ${now.shortYear}');
print('\n=== ISO ===');
print('iso8601String: ${now.iso8601String}');
print('\n=== Custom Format ===');
print(now.format('dd/MM/yyyy'));
print(now.format('dd MMM yyyy'));
print(now.format('yyyy-MM-dd HH:mm:ss'));
print('\n=== Local Time Conversion ===');
final utcDate = DateTime.parse('2026-06-04T10:30:00Z');
print('UTC DateTime: $utcDate');
print('Local DateTime: ${utcDate.local}');
print('UTC Format: ${utcDate.dateTimeReadable}');
print('Local Format: ${utcDate.local.dateTimeReadable}');
print('UTC Time: ${utcDate.hhmm12}');
print('Local Time: ${utcDate.local.hhmm12}');
print('\n=== String Extension ===');
const apiDate = '2026-06-04T10:30:00Z';
print('toDateTime: ${apiDate.toDateTime()}');
print('Formatted: ${apiDate.formatDate('dd MMM yyyy')}');
print('Formatted Slash: ${apiDate.formatDate('dd/MM/yyyy')}');
print(
'Local Formatted: '
'${apiDate.toDateTime().local.dateTimeReadable}',
);
}