-
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
Adding daysRemaining(in:) to DateExtensions. #982
Conversation
NOTE: This extension uses
|
return Int(daysRemaining) | ||
} | ||
default: | ||
() |
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.
You could also return nil
in the default
case:
default:
return nil
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.
You have to return from this function outside the switch, so better to use
() | |
break |
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.
Nice. Just a few small suggestions.
N.B. Agree that it makes sense here to use another end(of:)
, more because it's a pretty complicated function than because that one already uses others.
@@ -57,6 +57,8 @@ The changelog for **SwifterSwift**. Also see the [releases](https://github.com/S | |||
- Added `loadFromNib(withClass:)`, which loads a UIView of a particular type from a nib file. [#885](https://github.com/SwifterSwift/SwifterSwift/pull/885) by [gurgeous](https://github.com/gurgeous) | |||
- Added `findConstraint` for finding an existing constraint. [#886](https://github.com/SwifterSwift/SwifterSwift/pull/886) by [gurgeous] | |||
- Added `widthConstraint`, `heightConstraint`, `leadingConstraint`, `trailingConstraint`, `topConstraint`, and `bottomConstraint` for finding specific constraints. [#886](https://github.com/SwifterSwift/SwifterSwift/pull/886) by [gurgeous] | |||
**Date**: |
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.
**Date**: | |
- **Date**: |
XCTAssertEqual(Date(year: 2021, month: 8, day: 31, hour: 1)?.daysRemaining(in: .weekOfYear), 4) | ||
XCTAssertEqual(Date(year: 2021, month: 9, day: 11, hour: 1)?.daysRemaining(in: .weekOfYear), 0) | ||
XCTAssertEqual(Date(year: 2020, month: 2, day: 23, hour: 1)?.daysRemaining(in: .weekOfMonth), 6) // leap | ||
|
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.
Remove empty line
return Int(daysRemaining) | ||
} | ||
default: | ||
() |
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.
You have to return from this function outside the switch, so better to use
() | |
break |
Codecov Report
@@ Coverage Diff @@
## master #982 +/- ##
==========================================
+ Coverage 92.92% 92.97% +0.04%
==========================================
Files 102 103 +1
Lines 3691 3717 +26
==========================================
+ Hits 3430 3456 +26
Misses 261 261
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Generated by 🚫 Danger |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Addresses #552.
This PR adds a
Date
extension which returns the number of days remaining in variousCalendar.Components
such as.month
or.year
.Checklist
@available
if not.