Opened 5 years ago
Closed 5 years ago
#13309 closed defect (fixed)
TicketQuery shows time for time custom field of format date
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.4.2 |
Component: | ticket system | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
|
||
API Changes: | |||
Internal Changes: |
Description (last modified by )
Attachments (1)
Change History (17)
by , 5 years ago
Attachment: | Screen Shot 2020-06-02 at 00.50.11.jpg added |
---|
comment:1 by , 5 years ago
Description: | modified (diff) |
---|
follow-up: 8 comment:2 by , 5 years ago
follow-up: 10 comment:3 by , 5 years ago
Also, avoid text decoration in query results:
-
trac/ticket/templates/query_results.html
diff --git a/trac/ticket/templates/query_results.html b/trac/ticket/templates/query_results.html index b8d58ecbf..7b4efd253 100644
a b 129 129 # if name == 'summary': 130 130 <a href="${result.href}" title="${_('View ticket')}">${value}</a> 131 131 # elif header.field.type == 'time': 132 ${pretty_dateinfo(value, header.field.format )}132 ${pretty_dateinfo(value, header.field.format, dateonly=True)} 133 133 # elif header.field.type == 'checkbox': 134 134 ${_("yes") if value else _("no")} 135 135 # elif name == 'reporter':
comment:4 by , 5 years ago
Milestone: | next-stable-1.4.x → 1.4.2 |
---|---|
Owner: | set to |
Status: | new → assigned |
comment:5 by , 5 years ago
Release Notes: | modified (diff) |
---|
comment:6 by , 5 years ago
Proposed changes in [b1da5506a/rjollos.git] (fixed test failure in [2b0c6418b/rjollos.git]).
Once the Python 3 work is integrated I'll try adding more test coverage of pretty_dateinfo
and [[TicketQuery(..., format=table, col=time1)]]
using unittest.mock.patch to replace datetime_now
. Setting a fixed date now (rather than using the actual system date) will make it easier to deal with the relative datetimes: in x years, x years ago.
follow-up: 11 comment:7 by , 5 years ago
I tried the proposed changes. test_pretty_dateinfo
fails when Babel is unavailable.
FAIL: test_pretty_dateinfo (trac.web.tests.chrome.ChromeTemplateRenderingTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "trac/web/tests/chrome.py", line 1115, in test_pretty_dateinfo </html>"""), content) AssertionError: <!DOCTYPE html> <html> <body> <ul> <li></li> <li><span title="07/01/07 12:34:56">13 years ago</span></li> <li><span title="07/01/07 12:34:56">13 years ago</span></li> <li><span title="13 years ago">on 07/01/07</span></li> <li><span title="13 years ago">on 07/01/07 at 12:34:56</span></li> <li><span title="13 years ago">07/01/07</span></li> <li><span title="13 years ago">07/01/07 12:34:56</span></li> </ul> </body> </html>: '<!DOCTYPE html>\n<html>\n<body>\n<ul>\n<li></li>\n<li><span title="Jul 1, 2007, 12:34:56 PM">\\d+ years ago</span></li>\n<li><span title="Jul 1, 2007, 12:34:56 PM">\\d+ years ago</span></li>\n<li><span title="\\d+ years ago">on Jul 1, 2007</span></li>\n<li><span title="\\d+ years ago">on Jul 1, 2007 at 12:34:56 PM</span></li>\n<li><span title="\\d+ years ago">Jul 1, 2007</span></li>\n<li><span title="\\d+ years ago">Jul 1, 2007, 12:34:56 PM</span></li>\n</ul>\n</body>\n</html>' not found in '<!DOCTYPE html>\n<html>\n<body>\n<ul>\n<li></li>\n<li><span title="07/01/07 12:34:56">13 years ago</span></li>\n<li><span title="07/01/07 12:34:56">13 years ago</span></li>\n<li><span title="13 years ago">on 07/01/07</span></li>\n<li><span title="13 years ago">on 07/01/07 at 12:34:56</span></li>\n<li><span title="13 years ago">07/01/07</span></li>\n<li><span title="13 years ago">07/01/07 12:34:56</span></li>\n</ul>\n</body>\n</html>'
follow-up: 9 comment:8 by , 5 years ago
Replying to Ryan J Ollos:
- else: + elif format == 'date': + label = _("on %(date)s", + date=user_time(req, format_date, date)) + else: # format == 'datetime'
I consider the changes would be nice when the all users are using same timezone, but not good for a user which is using other timezone.
comment:9 by , 5 years ago
Replying to Jun Omae:
Replying to Ryan J Ollos:
- else: + elif format == 'date': + label = _("on %(date)s", + date=user_time(req, format_date, date)) + else: # format == 'datetime'I consider the changes would be nice when the all users are using same timezone, but not good for a user which is using other timezone.
I missed pretty_dateinfo()
in TimelineModule
already has format == 'date
' at tags/trac-1.2/trac/timeline/web_ui.py@:307-308#L277.
comment:10 by , 5 years ago
Replying to Ryan J Ollos:
Also, avoid text decoration in query results:
- ${pretty_dateinfo(value, header.field.format)} + ${pretty_dateinfo(value, header.field.format, dateonly=True)}
comment:11 by , 5 years ago
Replying to Jun Omae:
I tried the proposed changes.
test_pretty_dateinfo
fails when Babel is unavailable.
Yeah, I noticed and amended comment:6. Still waiting for tests on Travis CI to finish but I think the issue is fixed. Thanks for testing.
comment:12 by , 5 years ago
Thanks for pointing to similar code in TimelineModule
. I added a refactoring [ed49cb8b4/rjollos.git].
I don't understand the timezone issue in comment:8. I considered format=date
should be rendered similar to format=datetime
. Is there another change you are suggesting?
follow-up: 14 comment:13 by , 5 years ago
Considering the field has 2020-06-10
which is updated by a user with UTC timezone, the field would be shown for each user:
UTC | 2020-06-10
|
UTC +09:00 | 2020-06-10
|
UTC -07:00 | 2020-06-09
|
I think this behavior is not nice.
How about formatting date only when time part is zero for user's timezone?
-
trac/timeline/web_ui.py
diff --git a/trac/timeline/web_ui.py b/trac/timeline/web_ui.py index 2ef06b465..8b632a0b0 100644
a b class TimelineModule(Component): 276 276 def pretty_dateinfo(date, format=None, dateonly=False): 277 277 if not date: 278 278 return '' 279 date = to_datetime(date, tzinfo=req.tz) 279 280 if format == 'date': 280 281 absolute = user_time(req, format_date, date) 281 282 else: … … class TimelineModule(Component): 303 304 label = absolute 304 305 elif req.lc_time == 'iso8601': 305 306 label = _("at %(iso8601)s", iso8601=absolute) 306 elif format == 'date': 307 elif format == 'date' and date.hour == 0 and \ 308 date.minute == 0 and date.second == 0 and \ 309 date.microsecond == 0: 307 310 label = _("on %(date)s", date=absolute) 308 311 else: 309 312 label = _("on %(date)s at %(time)s",
comment:14 by , 5 years ago
Replying to Jun Omae:
How about formatting date only when time part is zero for user's timezone?
I've only considered format=date
which doesn't have a time component, and format=datetime
. Is there a use-case, such as a plugin, for requesting format=date
with a time component and expecting to see a formatted datetime? Shouldn't the plugin just request format=datetime
?
I agree about the poor behavior showing different dates in different timezones, but isn't it just a fundamental characteristic to format=date
?
comment:15 by , 5 years ago
Another consideration regarding proposed comment:13 changes:
They don't seem to have an effect on query results for time
fields with format=date
, which is primarily what I was trying to address in this ticket. The proposed changes make pretty_dateinfo
for Chrome
behave like pretty_dateinfo
in TimelineModule
.
If there are other considerations maybe we could do them in another ticket, assuming I'm correct about proposed changes having no impact on query results for time
fields. Since I don't understand the impacts entirely it would be better that I didn't make those changes.
comment:16 by , 5 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Committed to 1.4-stable in r17417, merged to trunk in r17418.
If you want to push additional changes such as comment:13, we can hold on the release, or do in 1.4.3. Just let me know.
trac/web/chrome.py