import 'package:intl/intl.dart'; /// Locale-aware short date (S5-R4). /// /// Replaces the old hardcoded `DD/MM/YYYY` pattern, which was wrong for /// locales like en-US (M/D/Y) or ja (Y/M/D). [localeTag] accepts both /// BCP-47 ('en-US') and ICU ('en_US') forms — intl canonicalizes them. /// /// Date symbols for the active locale are loaded by /// GlobalMaterialLocalizations, so any widget below MaterialApp can call /// this safely. String fechaCortaLocalizada(String localeTag, DateTime fecha) => DateFormat.yMd(localeTag).format(fecha); /// Day + abbreviated month, locale-aware (e.g. "28 jul" for `es`, "Jul 28" /// for `en`) — item 21 / audit 9b.4 (t4:459), the big digit half of the /// vacation screen's date-pair. String diaMesLocalizado(String localeTag, DateTime fecha) => DateFormat.MMMd(localeTag).format(fecha); /// Full weekday name, locale-aware (e.g. "lunes"/"Monday") — item 21 / /// audit 9b.4 (t4:459), the small caption under the day-month. String nombreDiaSemanaLocalizado(String localeTag, DateTime fecha) => DateFormat.EEEE(localeTag).format(fecha); /// Full weekday + month + day, locale-aware (e.g. "lunes, 3 de agosto" for /// `es`, "Monday, August 3" for `en`) — audit 9.4 (t4:419), the ringing /// screen's date line between the schedule pill and the hero time. String fechaLargaConDiaSemana(String localeTag, DateTime fecha) => DateFormat.MMMMEEEEd(localeTag).format(fecha); /// Short "d–d MON" range pill, locale-aware month abbreviation, uppercased /// (e.g. "4–18 AGO" for `es`, "4–18 AUG" for `en`) — audit 7.3 (t4:332), /// the vacation-row date-range pill on the Alarmas root. Always labels the /// range with the END date's month: vacation ranges are short (days to a /// couple of weeks), so a cross-month span is the rare case, and the /// prototype itself only ever shows a single abbreviation. String rangoFechasCorto(String localeTag, DateTime inicio, DateTime fin) { final dia = DateFormat.d(localeTag); final mes = DateFormat.MMM(localeTag).format(fin).toUpperCase(); return '${dia.format(inicio)}–${dia.format(fin)} $mes'; }