我有一个模型,其中包含一个日期属性。
我可以通过 "Dictionary(grouping..)" 将日期分组。
但问题是在解码时,我这样做了:
我可以通过 "Dictionary(grouping..)" 将日期分组。
let grouped = Dictionary(grouping: orders.results, by: { $0.createdAt })
但问题是在解码时,我这样做了:
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
所以我的Date
属性也考虑了时间。
我应该如何按照yyyy-MM-dd
进行分组?