swift-Date时间比较

let date1 = Date()
let date2 = Date()
// date1 < date2 升序排列
if date1?.compare(date2!) == .orderedAscending
{
      print("<")
}
//date1 = date2 相等
if date1?.compare(date2!) == .orderedSame
{
      print(" = ")
}  
//降序排列的 date1 > date2 降序排列
if date1?.compare(date2!) == .orderedDescending
{
    print("<")
}