我从Cocoapods中导入了SwiftMoment,并从现在开始显示日期:
cell.dateText!.text = moment(notification.createdAt!).fromNow()结果是英语:5小时前的,
我会更改区域设置参数以法语显示它,但是我找不到如何用Swift来实现它。我跳到moment()定义中去找出它是如何处理的,但是我搞不清楚。
我试过的是:
定义是:
public func moment(_ date: Date,
timeZone: TimeZone = TimeZone.current,
locale: Locale = Locale.autoupdatingCurrent) -> Moment {
return Moment(date: date, timeZone: timeZone, locale: locale)
}我试着用这三个参数插入这个时刻,但是我得到了一个错误:
参数标签'(_:,_:,_:)‘不匹配任何可用的重载
有人知道这件事吗?
发布于 2018-02-06 15:37:50
您必须为这个函数命名第二个和第三个参数。试一试
let frLocale = Locale(identifier: "fr_FR")
let str = moment(notification.createdAt!, locale: frLocale).fromNow()https://stackoverflow.com/questions/48646515
复制相似问题