jdotjdot / PrettyTime

Python PrettyTime - A Python module allowing Rails-style pretty times like t(3).days.ago
8 stars 4 forks source link

Sweep: add time pretty-printing functionality when you call `._print()` on any PrettyTime object #8

Open jdotjdot opened 1 year ago

jdotjdot commented 1 year ago
Checklist - [X] `prettytime.py` > * Add a new method called `_print` to the `t` class. This method should return a string that represents the time in a pretty format. The exact format will depend on the attributes of the `t` object. For example, if the `t` object represents 3 days, the `_print` method could return the string "3 days". > • Add a new method called `_print` to the `PrettyDelta` class. This method should return a string that represents the time in a pretty format. The exact format will depend on the attributes of the `PrettyDelta` object. For example, if the `PrettyDelta` object represents 2 hours from now, the `_print` method could return the string "2 hours from now". > • Add a new method called `_print` to the `PrettyDelta2` class. This method should return a string that represents the time in a pretty format. The exact format will depend on the attributes of the `PrettyDelta2` object. For example, if the `PrettyDelta2` object represents 1 week ago, the `_print` method could return the string "1 week ago". - [X] `README.md` > * Add a new section called "Pretty Printing". In this section, explain that users can call the `._print()` method on any PrettyTime object to get a pretty-printed string of the time. Provide some examples of how to use the `._print()` method.
sweep-ai[bot] commented 1 year ago

Here's the PR! https://github.com/jdotjdot/PrettyTime/pull/10.

⚡ Sweep Free Trial: I used GPT-4 to create this ticket. You have 5 GPT-4 tickets left for the month and 2 for the day. For more GPT-4 tickets, visit our payment portal.To get Sweep to recreate this ticket, leave a comment prefixed with "sweep:" or edit the issue.


Step 1: 🔍 Code Search

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/jdotjdot/PrettyTime/blob/e7aac5786125a5e585c279bcc212a683766d2ef1/README.md#L1-L91 https://github.com/jdotjdot/PrettyTime/blob/e7aac5786125a5e585c279bcc212a683766d2ef1/prettytime.py#L1-L233 https://github.com/jdotjdot/PrettyTime/blob/e7aac5786125a5e585c279bcc212a683766d2ef1/setup.py#L1-L11 https://github.com/jdotjdot/PrettyTime/blob/e7aac5786125a5e585c279bcc212a683766d2ef1/MANIFEST#L1-L3

Step 2: 🧐 Snippet Analysis

From looking through the relevant snippets, I decided to make the following modifications:

File Path Proposed Changes
prettytime.py Modify prettytime.py with contents:
* Add a new method called _print to the t class. This method should return a string that represents the time in a pretty format. The exact format will depend on the attributes of the t object. For example, if the t object represents 3 days, the _print method could return the string "3 days".
• Add a new method called _print to the PrettyDelta class. This method should return a string that represents the time in a pretty format. The exact format will depend on the attributes of the PrettyDelta object. For example, if the PrettyDelta object represents 2 hours from now, the _print method could return the string "2 hours from now".
• Add a new method called _print to the PrettyDelta2 class. This method should return a string that represents the time in a pretty format. The exact format will depend on the attributes of the PrettyDelta2 object. For example, if the PrettyDelta2 object represents 1 week ago, the _print method could return the string "1 week ago".
README.md Modify README.md with contents:
* Add a new section called "Pretty Printing". In this section, explain that users can call the ._print() method on any PrettyTime object to get a pretty-printed string of the time. Provide some examples of how to use the ._print() method.

Step 3: 📝 Planning

I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:

Add time pretty-printing functionality when calling ._print() on any PrettyTime object sweep/add-time-pretty-printing

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

  • Added a new method called _print() to the t class in the prettytime.py file. This method returns a string that represents the time in a pretty format.
  • Added a new method called _print() to the PrettyDelta class in the prettytime.py file. This method returns a string that represents the time in a pretty format.
  • Added a new method called _print() to the PrettyDelta2 class in the prettytime.py file. This method returns a string that represents the time in a pretty format.
  • Updated the README.md file 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!


Step 4: ⌨️ Coding

File Instructions Progress
prettytime.py Modify prettytime.py with contents:
* Add a new method called _print to the t class. This method should return a string that represents the time in a pretty format. The exact format will depend on the attributes of the t object. For example, if the t object represents 3 days, the _print method could return the string "3 days".
• Add a new method called _print to the PrettyDelta class. This method should return a string that represents the time in a pretty format. The exact format will depend on the attributes of the PrettyDelta object. For example, if the PrettyDelta object represents 2 hours from now, the _print method could return the string "2 hours from now".
• Add a new method called _print to the PrettyDelta2 class. This method should return a string that represents the time in a pretty format. The exact format will depend on the attributes of the PrettyDelta2 object. For example, if the PrettyDelta2 object represents 1 week ago, the _print method could return the string "1 week ago".
✅ Commit 580f709
README.md Modify README.md with contents:
* Add a new section called "Pretty Printing". In this section, explain that users can call the ._print() method on any PrettyTime object to get a pretty-printed string of the time. Provide some examples of how to use the ._print() method.
✅ Commit 580f709 I have finished coding the issue. I am now reviewing it for completeness.

Step 5: 🔁 Code Review

Here are my self-reviews of my changes at sweep/add-time-pretty-printing.

Here is the 1st review

No changes required. The added documentation in README.md is clear and the _print() method has been correctly implemented in the t, PrettyDelta, and PrettyDelta2 classes in prettytime.py. Good job!

I finished incorporating these changes.


To recreate the pull request, or edit the issue title or description. Join Our Discord