Created
January 6, 2026 00:02
-
-
Save StewartLynch/9ef8d017e83b5876d3b18374b9b02a63 to your computer and use it in GitHub Desktop.
Date Offset Extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| extension Date { | |
| /// Returns a date that is `offset` days from this date. | |
| /// - Parameter offset: The number of days to add or subtract from `self`. | |
| /// - Returns: A new `Date` `offset` days days before or after `self`. | |
| func offset(_ offset: Int) -> Date { | |
| Calendar.current.date(byAdding: .day, value: offset, to: self)! | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment