-
-
Notifications
You must be signed in to change notification settings - Fork 251
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
User-friendly date and time formatting. #1218
base: main
Are you sure you want to change the base?
Conversation
zulipterminal/ui_tools/views.py
Outdated
@@ -1162,6 +1163,7 @@ def _fetch_user_data(controller: Any, user_id: int) -> Dict[str, Any]: | |||
} | |||
return display_data | |||
|
|||
pretty_date = user_friendly_time(data["last_active"]) |
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.
For users who have been inactive for longer than two weeks, the data["last_active"]
is empty. This is causing ZT to crash for such users when I tried running it.
@plugyawn You saw my feedback in the stream, but essentially:
|
Sorry for the late reply!
|
eefdc96
to
19d8477
Compare
@neiljp could you check the commit flow now? |
@plugyawn As per discussion in the stream, you really need a rebase (or other adjustment) since you seem to have squashed commits from upstream/main or another PR into one of these commits. |
zulipterminal/helper.py
Outdated
datetime_object = datetime.strptime( | ||
time_stamp, "%a %b %d %Y %I:%M:%S %p" | ||
) # Fri Apr 29 2022 05:15:12 AM is an example | ||
else: # for user_info, year not included | ||
if time_stamp[-1] == "M": # AM or PM | ||
else: # for user_info, year not included |
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'll want to keep these lint fixes in the commit in which they were introduced. If you do an interactive rebase and edit the previous commit and run make fix
, then when you continue the rebase, these changes should likely drop out of this commit (or similarly in later commits, in other complex PRs).
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.
Oh, okay! Didn't know, I'll try it out.
e6afbdd
to
b89b8ab
Compare
@mounilKshah @neiljp Could you check this now? I think the changes I made in test_popups.py need to be changed -- but I'm unsure as to what those changes should be. Also, I've made sure the commits only contain changes in their respective files, as you said. Editing the commits and running commit --amend was the solution, as you said. |
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.
The PR works well, without any glitches and the commit structure is better than when I had last seen. I have left a few comments,
Also, maybe change the name of the branch on your forked repo? It can create confusion while working with multiple PRs.
@@ -816,3 +817,61 @@ def open_media(controller: Any, tool: str, media_path: str) -> None: | |||
|
|||
if error: | |||
controller.report_error(error) | |||
|
|||
|
|||
def user_friendly_time(time_stamp: str) -> str: # message_info has a different format |
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.
Instead of writing what the function does in the commit message, I think it would be more convenient to write it as comments within the function body, so that the next person working on it doesn't have to search for the respective commit(s).
if seconds < 86400: # 24 hours | ||
return str(seconds // 3600) + " hours ago" | ||
|
||
time_string = "" |
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.
The value of time_string
is assigned only in the first conditional, but not returned/used anywhere.
This commit adds a function that takes in a datetime string, checks whether it came from message_info or user_info depending on string length (later, we could include a boolean in the arguments. For now, that's an unnecessary variable), and then returns a user-friendly version of the date and time. For example, if the string is "Fri Apr 29 2022 05:15:12 AM", then converted will be something like "A week ago", "43 minutes ago", and so on.
This commit implements the helper function for friendly times to the user and message info pop-ups. It shows up as Fri 4 Apr 11:05:20 PM (A week ago) And so on.
Reviews incorporated into the PR. |
Heads up @plugyawn, we just merged some commits that conflict with the changes you made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
What does this PR do?
Adds user friendly times to the user and message info views. The current view just includes the timestamp, which is hard to decipher.
Partial fix for issues #1211 and addresses #1086
Tested?
Commit flow
Notes & Questions
Interactions
Visual changes
For message info:
For user info: