String format(DateTime date)

Format a date according to RFC-1123, e.g. Thu, 1 Jan 1970 00:00:00 GMT.

Source

static String format(DateTime date) {
  const List wkday = const ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
  const List month = const [
    "Jan",
    "Feb",
    "Mar",
    "Apr",
    "May",
    "Jun",
    "Jul",
    "Aug",
    "Sep",
    "Oct",
    "Nov",
    "Dec"
  ];

  DateTime d = date.toUtc();
  StringBuffer sb = new StringBuffer()
    ..write(wkday[d.weekday - 1])
    ..write(", ")
    ..write(d.day <= 9 ? "0" : "")
    ..write(d.day.toString())
    ..write(" ")
    ..write(month[d.month - 1])
    ..write(" ")
    ..write(d.year.toString())
    ..write(d.hour <= 9 ? " 0" : " ")
    ..write(d.hour.toString())
    ..write(d.minute <= 9 ? ":0" : ":")
    ..write(d.minute.toString())
    ..write(d.second <= 9 ? ":0" : ":")
    ..write(d.second.toString())
    ..write(" GMT");
  return sb.toString();
}