-
-
Notifications
You must be signed in to change notification settings - Fork 771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Date - Date order issue #306
Comments
Hi, you can use let D1 = try! "1/2/2015".date(format: .custom("dd/MM/yyyy"))
let D2 = try! "1/2/2016".date(format: .custom("dd/MM/yyyy"))
let v = (D2 - D1).in(.day) // 365 |
I believe this will crash because in here we specifies the lhs is the start of the interval instead of the end of the interval. Please try run the code above and let me know! |
I've tried it right now; do you encounter a crash? |
Hi @malcommac I tested your code and it works fine.
|
I've tried using let today = DateInRegion()
let tomorrow = DateInRegion() + 1.days
let diffInDays = (tomorrow - today).in(.day) // -> 1
print(tomorrow - today) // -> in seconds = 86400.0012260079 Can you post your crash? |
The problem is that I have to use Date().
I still think the Date+Math order should be reversed or consider absolute like how it is done in DateInRegion+Math Is the order of minus between Dates intended? |
Ok should be fixed 👍 |
If we have (not sure if it will compile, just want to show that D2 is later than D1)
D1 = "1/2/2015"
D2 = "1/2/2016"
I was expecting D2 - D1 would give me 365 days. But in fact in code we have to use D1 - D2 to get the actual time interval.
Is this intended behavior?
Thank you!
The text was updated successfully, but these errors were encountered: