繁体   English   中英

"斯威夫特:为什么 DateComponentsFormatter.localizedString(from:unitsStyle:) 在工作日不起作用?"

[英]Swift: Why DateComponentsFormatter.localizedString(from:unitsStyle:) does not work for weekday?

为什么DateComponentsFormatter.localizedString(from:unitsStyle:)<\/code>在weekday<\/code>不起作用?

let twoDays = DateComponents(day: 2)
let threeWeeks = DateComponents(weekday: 3)

Text(DateComponentsFormatter.localizedString(from: twoDays, unitsStyle: .full) ?? "found nil") // returns "2 days"
Text(DateComponentsFormatter.localizedString(from: threeWeeks, unitsStyle: .full) ?? "found nil") // returns "found nil"

DateComponents<\/code>有一个名为allowedUnits<\/code>的属性, weekday<\/code>不是合法单位。

允许的单位是:

年 月 weekOfMonth 日 时 分 秒<\/strong>

看到这个参考<\/a>。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM