我有一个工作日的ID,例如3(星期三)或6(星期六)。
如何获取用户当前语言的格式化工作日名称?
到目前为止,这是我所能获得的,但是我不知道如何将日期设置为所需的工作日。
function rowsToObjects(rows, headers) {
return rows.map(r => r.reduce((o, c, i) => Object.assign(o, { [headers[i]]: c }), {}))
}
答案 0 :(得分:2)
这样做之后:
import 'package:intl/date_symbol_data_local.dart';
String localeName = "pt_BR"; // "en_US" etc.
initializeDateFormatting(localeName);
使用此:
static List<String> weekDays(String localeName) {
DateFormat formatter = DateFormat(DateFormat.WEEKDAY, localeName);
return [DateTime(2000, 1, 3, 1), DateTime(2000, 1, 4, 1), DateTime(2000, 1, 5, 1),
DateTime(2000, 1, 6, 1), DateTime(2000, 1, 7, 1), DateTime(2000, 1, 8, 1),
DateTime(2000, 1, 9, 1)].map((day) => formatter.format(day)).toList();
}
然后:
String getWeekdayShort(int weekday, String localeName) => weekDays(localeName);