getYesterday static method
获取昨天日期返回DateTime。
按日历日回退(DateTime(now.year, now.month, now.day - 1, ...)),
由 DateTime 构造器跨月/年/DST 归一化,避免减固定 24*60*60*1000 毫秒在
DST 边界(一天可能是 23/25 小时)造成的跨日错误。
可选 now 用于注入基准时刻(测试用),默认 DateTime.now。
Implementation
static DateTime getYesterday({DateTime? now}) {
final n = now ?? DateTime.now();
return _date(n.isUtc, n.year, n.month, n.day - 1, n.hour, n.minute,
n.second, n.millisecond, n.microsecond);
}