Swift Why isn't my date object that's (Equatable) equal after converting it to a string and back?

后端 未结 1 1540
悲&欢浪女
悲&欢浪女 2021-01-27 02:57

I\'m writing a unit test to check that my conversion from a date to string and back is successful.

I convert it to a string via:

func convertDateToString         


        
相关标签:
1条回答
  • 2021-01-27 03:21

    The problem there is that Date is stored as a FloatingPoint value (timeIntervalSinceReferenceDate). There is fractional seconds being discarded there when converting your Date to String and back to Date. Take a look at post.

    0 讨论(0)
提交回复
热议问题