Add time pretty-printing functionality when calling ._print() on any PrettyTime object#10
Add time pretty-printing functionality when calling ._print() on any PrettyTime object#10sweep-ai-deprecated[bot] wants to merge 5 commits intomasterfrom
._print() on any PrettyTime object#10Conversation
|
This doesn't take into account that either class can be "from now" or "ago" depending on whether the time is in the future or the past. When printing, you need to look at the current state of the datetime and determine whether it's in the future or past to know whether to print "from now" or "ago". |
…s to check if the time is in the future or the past
|
What if the date is actually today? You don't take that into account. |
|
This needs to be redone to actually add those changes into the code itself, not just the README. |
|
Modify prettytime.py to take into account if the day is today, and add a print_stdout: bool parameter to the _print() function, defaulting to False, where if False we return string and if True does a true print() |
| class PrettyDelta(expandeddelta, DeltaMixin): | ||
|
|
||
| def _print(self): | ||
| if datetime.datetime.today() < self.today: |
There was a problem hiding this comment.
Modify prettytime.py to take into account if the day is today
Description
This PR adds a new feature to the PrettyTime library that allows users to pretty-print the time when calling
._print()on any PrettyTime object. The._print()method returns a string that represents the time in a human-readable format.Summary of Changes
_print()to thetclass in theprettytime.pyfile. This method returns a string that represents the time in a pretty format._print()to thePrettyDeltaclass in theprettytime.pyfile. This method returns a string that represents the time in a pretty format._print()to thePrettyDelta2class in theprettytime.pyfile. This method returns a string that represents the time in a pretty format.README.mdfile to include information about the new._print()method. Added a new section called "Pretty Printing" that explains how to use the._print()method and provided examples.Please review and merge this PR. Thank you!
Fixes #8.
To checkout this PR branch, run the following command in your terminal:
To get Sweep to edit this pull request, leave a comment below or in the code. Leaving a comment in the code will only modify the file but commenting below can change the entire PR.