formatHttpDate function
Return a HTTP-formatted string representation of date
.
This follows RFC 822 as updated by
RFC 1123.
Implementation
String formatHttpDate(DateTime date) {
date = date.toUtc();
final buffer = StringBuffer()
..write(_weekdays[date.weekday - 1])
..write(', ')
..write(date.day <= 9 ? '0' : '')
..write(date.day.toString())
..write(' ')
..write(_months[date.month - 1])
..write(' ')
..write(date.year.toString())
..write(date.hour <= 9 ? ' 0' : ' ')
..write(date.hour.toString())
..write(date.minute <= 9 ? ':0' : ':')
..write(date.minute.toString())
..write(date.second <= 9 ? ':0' : ':')
..write(date.second.toString())
..write(' GMT');
return buffer.toString();
}