defaultFormatters property
FormatSetOptional
defaultFormatters
final
Implementation
final FormatSetOptional defaultFormatters = {
FormatterToken.M: (dateTime) => dateTime.month.toString(),
FormatterToken.MM: (dateTime) => dateTime.month.toString().padLeft(2, '0'),
FormatterToken.Q: (dateTime) => dateTime.quarter.toString(),
FormatterToken.D: (dateTime) => dateTime.day.toString(),
FormatterToken.DD: (dateTime) => dateTime.day.padZero(),
FormatterToken.DDD: (dateTime) => dateTime.dayOfYear.toString(),
FormatterToken.DDDD: (dateTime) => dateTime.dayOfYear.padZero(3),
FormatterToken.d: (dateTime) => dateTime.weekday.toString(),
FormatterToken.e: (dateTime) => dateTime.weekday.toString(),
FormatterToken.w: (dateTime) => dateTime.week.toString(),
FormatterToken.ww: (dateTime) => dateTime.week.padZero(),
FormatterToken.YY: (dateTime) {
if (dateTime.year < 1970 || dateTime.year > 2030) {
return dateTime.year.toString();
}
return dateTime.year.toString().substring(2);
},
FormatterToken.YYYY: (dateTime) => dateTime.year.toString(),
FormatterToken.y: (dateTime) => dateTime.year.abs().toString(),
FormatterToken.NN: (dateTime) => dateTime.year < 1 ? "B.C." : "A.D.",
FormatterToken.NNNN: (dateTime) =>
dateTime.year < 1 ? "Before Christ" : "Anno Domini",
FormatterToken.NNNNN: (dateTime) => dateTime.year < 1 ? "BC" : "AD",
FormatterToken.gg: (dateTime) {
if (dateTime.weekYear < 1970 || dateTime.weekYear > 2030) {
return dateTime.weekYear.toString();
}
return dateTime.weekYear.toString().substring(2);
},
FormatterToken.gggg: (dateTime) => dateTime.weekYear.toString(),
FormatterToken.H: (dateTime) => dateTime.hour.toString(),
FormatterToken.HH: (dateTime) => dateTime.hour.padZero(),
FormatterToken.h: (dateTime) => dateTime.hour12.toString(),
FormatterToken.hh: (dateTime) => dateTime.hour12.padZero(),
FormatterToken.k: (dateTime) =>
dateTime.hour == 0 ? "24" : dateTime.hour.toString(),
FormatterToken.kk: (dateTime) =>
dateTime.hour == 0 ? "24" : dateTime.hour.padZero(),
FormatterToken.m: (dateTime) => dateTime.minute.toString(),
FormatterToken.mm: (dateTime) => dateTime.minute.padZero(),
FormatterToken.s: (dateTime) => dateTime.second.toString(),
FormatterToken.ss: (dateTime) => dateTime.second.padZero(),
FormatterToken.S: (dateTime) => (dateTime.millisecond ~/ 100).toString(),
FormatterToken.SS: (dateTime) => (dateTime.millisecond ~/ 10).padZero(),
FormatterToken.SSS: (dateTime) => dateTime.millisecond.padZero(3),
FormatterToken.SSSS: (dateTime) =>
dateTime.millisecond.padZero(3) +
(dateTime.microsecond ~/ 100).toString(),
FormatterToken.SSSSS: (dateTime) =>
dateTime.millisecond.padZero(3) +
(dateTime.microsecond ~/ 10).padZero(),
FormatterToken.SSSSSS: (dateTime) =>
dateTime.millisecond.padZero(3) + (dateTime.microsecond).padZero(3),
FormatterToken.Z: (dateTime) => dateTime.timeZoneFormatted(),
FormatterToken.ZZ: (dateTime) => dateTime.timeZoneFormatted(false),
FormatterToken.ZZZ: (dateTime) => dateTime.timeZoneName,
FormatterToken.X: (dateTime) =>
(dateTime.millisecondsSinceEpoch ~/ 1000).toString(),
FormatterToken.x: (dateTime) => dateTime.millisecondsSinceEpoch.toString(),
FormatterToken.xx: (dateTime) => dateTime.microsecondsSinceEpoch.toString(),
// Fallbacks when unimplemented
FormatterToken.Mo: (dateTime) => "Month #${dateTime.month} (ordered)",
FormatterToken.MMM: (dateTime) => "Month #${dateTime.month}",
FormatterToken.MMMM: (dateTime) => "Month #${dateTime.month}",
FormatterToken.Qo: (dateTime) => "Q${dateTime.quarter} (ordered)",
FormatterToken.Do: (dateTime) => "Day ${dateTime.day} of the month",
FormatterToken.DDDo: (dateTime) =>
"Day ${dateTime.day} of the year (ordered)",
FormatterToken.d_o: (dateTime) =>
"Day #${dateTime.weekday} of the week (ordered)",
FormatterToken.dd: (dateTime) => "Day #${dateTime.weekday} of the week",
FormatterToken.ddd: (dateTime) => "Day #${dateTime.weekday} of the week",
FormatterToken.dddd: (dateTime) => "Day #${dateTime.weekday} of the week",
FormatterToken.wo: (dateTime) => "Week #${dateTime.week} of the year (ISO)",
FormatterToken.A: (dateTime) => dateTime.isAm ? "AM" : "PM",
FormatterToken.a: (dateTime) => dateTime.isAm ? "am" : "pm",
};