toHumanReadableTimestamp method
Convert this DateTime to a human readable timestamp.
The output is similar to the output from the date binary from
GNU coreutils.
Example
final date = DateTime(2024, 5, 7, 5, 9, 4);
// Prints "Tue 7 May 05:09:04 CEST 2024"
// The value of the timezone depends on your region.
print(date.toHumanReadableTimestamp())
Other locales
To use locales other than the default en_US one, you need to load them
first. This can be done with MyDateUtility.initializeFormatting,
MyDateUtility.initializeFormattingFromFile or
MyDateUtility.initializeFormattingFromUrl.
Implementation
String toHumanReadableTimestamp([String locale = "en_US"]) {
final date = this;
// See https://pub.flutter-io.cn/documentation/intl/latest/intl/DateFormat-class.html
var res = intl.DateFormat("E d LLL HH:mm:ss ", locale).format(date);
res += "${date.timeZoneName} ${date.year.toString().padLeft(4, "0")}";
return res;
}