-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add random and randomBetween extensions to Date #326 #336
Conversation
Generated by 🚫 Danger |
Codecov Report
@@ Coverage Diff @@
## master #336 +/- ##
==========================================
+ Coverage 89.64% 89.65% +0.01%
==========================================
Files 55 55
Lines 3323 3336 +13
Branches 154 155 +1
==========================================
+ Hits 2979 2991 +12
Misses 338 338
- Partials 6 7 +1
Continue to review full report at Codecov.
|
/// - startDate: minimum date (default is Date.distantPast) | ||
/// - endDate: maximum date (default is Date.distantFuture) | ||
/// - Returns: random date between two dates. | ||
public static func random(since startDate: Date = Date.distantPast, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @akuzminskyi, thanks for submitting this PR! 😃
What do you think about changing the external parameter names?
since
to from
to
to upTo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
English is not my native language, so if you think that will be better I'll change it.
@@ -860,4 +860,58 @@ final class DateExtensionsTests: XCTestCase { | |||
XCTAssertEqual(date, dateFromUnixTimestamp) | |||
} | |||
|
|||
func testRandom() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if we could just combine all the tests below into this single test.
I would like to maintain a 1 : 1 ratio between tests and extensions. This way when they fail we are clear of the cause.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks. I'll do it
Combined tests for Date.radom into single test
CHANGELOG.md
Outdated
@@ -25,7 +25,9 @@ N/A | |||
### Enhancements | |||
- New **NSImage** extensions: | |||
- added `write(to url: URL, fileType type: _, compressionFactor: _)` to write NSImage to url. [#320](https://github.com/SwifterSwift/SwifterSwift/pulls/320) by [omaralbeik](https://github.com/omaralbeik). | |||
|
|||
- New **Date** extensions | |||
- added `random(since startDate: Date = Date.distantPast, to endDate: Date = Date.distantFuture) -> Date` method that return radom date in in the specified range [#336](https://github.com/SwifterSwift/SwifterSwift/pull/336) by [akuzminskyi](https://github.com/akuzminskyi). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've changed this now:
random(from:upTo:) -> Date
will be fine for CHANGELOG entry. You don't need the full signature. There's also a CHANGELOG merge conflict we need to resolve
Thank you for your contribution @akuzminskyi 💯 👍 |
Add random extensions to Date #326
Checklist