formatDate static method
Formats date using the format key outputKey.
Implementation
static String formatDate(DateTime date, String outputKey) {
final pattern = FormatRegistry.resolve(outputKey);
if (pattern == null) {
throw ArgumentError('Unknown format key: $outputKey');
}
if (pattern == 'epoch') {
return date.millisecondsSinceEpoch.toString();
}
if (pattern == 'relative') {
return _formatRelative(date);
}
return DateFormat(pattern).format(date);
}