-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
51 additions
and
13 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class r_versions(str): | ||
def compare(self, other: str) -> int: | ||
yearA, monthA = map(int, self.split(".")) | ||
yearB, monthB = map(int, other.split(".")) | ||
|
||
if yearA < yearB or (yearA == yearB and monthA < monthB): | ||
return -1 | ||
elif yearA == yearB and monthA == monthB: | ||
return 0 | ||
else: | ||
return 1 | ||
|
||
def is_less_than(self, other: str) -> bool: | ||
return self.compare(other) == -1 | ||
|
||
def is_greater_than(self, other: str) -> bool: | ||
return self.compare(other) == 1 |
This file contains 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