Skip to content
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

Bug 1739225: Timestamp component always shows dates in the future as relative dates #2341

Merged

Conversation

dtaylor113
Copy link
Contributor

@dtaylor113 dtaylor113 commented Aug 13, 2019

Updated Timestamp component to only show dates 10.5 minutes in past as relative dates (ex: "2 minutes ago"). Future dates will never be displayed as relative dates, always as full dates.

Before fix, dates in the future always displayed as relative:

image

After fix, future dates displayed as actual date (minus year if current year):

image

https://bugzilla.redhat.com/show_bug.cgi

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Aug 13, 2019
@openshift-ci-robot
Copy link
Contributor

@dtaylor113: This pull request references a valid Bugzilla bug. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Bug 1739225: Timestamp component always shows dates in the future as relative dates

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. component/core Related to console core functionality labels Aug 13, 2019
@dtaylor113 dtaylor113 requested review from spadgett and chancez and removed request for jeff-phillips-18 and TheRealJon August 13, 2019 16:34
@spadgett
Copy link
Member

Hey @dtaylor113, this doesn't really fix Bug 1739225. This is more an implementation detail for Chargeback.

The bug is that dates far off in the future should not be relative dates for any Timestamp, even if noRelative is not specified. But we should still add noRelative specifically for the Chargeback case.

@dtaylor113
Copy link
Contributor Author

The bug is that dates far off in the future should not be relative dates for any Timestamp, even if noRelative is not specified. But we should still add noRelative specifically for the Chargeback case.

Ok, if we define what 'far off in the future' is, I can implement that fix. >9 months in the future?

@spadgett
Copy link
Member

spadgett commented Aug 13, 2019

Ok, if we define what 'far off in the future' is, I can implement that fix. >9 months in the future?

No, it should be the existing value we check which is 10.5 minutes

https://github.com/openshift/console/blob/master/frontend/public/components/utils/timestamp.tsx#L20-L22

We need to check +/- 10.5 minutes instead of assuming all dates more recent than 10.5 minutes are relative.

@dtaylor113
Copy link
Contributor Author

dtaylor113 commented Aug 13, 2019

We need to check +/- 10.5 minutes instead of assuming all dates more recent than 10.5 minutes are relative.

Ok, added a Math.abs(..) around the time comparison value, so it will be compared +/- 10.5 minutes.

@openshift-ci-robot openshift-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 14, 2019
@openshift-ci-robot
Copy link
Contributor

@dtaylor113: This pull request references a valid Bugzilla bug.

In response to this:

Bug 1739225: Timestamp component always shows dates in the future as relative dates

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

if (omitSuffix) {
return dateTime.fromNow(mdate, undefined, {omitSuffix: true});
}
if (timeAgo < 630000) { // 10.5 minutes
if (timeFromNow < 630000) { // 10.5 minutes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't assign timeFromNow to a variable to make sure we don't accidentally use it as the date we show. (With Math.abs it could be the wrong value.) We should add a comment explaining as well.

Suggested change
if (timeFromNow < 630000) { // 10.5 minutes
// Show a relative time if within 10.5 minutes from the current time (in the past or future).
if (Math.abs(now.getTime() - mdate.getTime()) < 630000) { // 10.5 minutes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to timeDifference

@spadgett
Copy link
Member

Thinking on this more, I'd recommend showing any future date as a full date. This avoids weirdness due to client clock skew where we might show something like "Build started 2 minutes from now"

@chancez
Copy link
Contributor

chancez commented Aug 15, 2019

Thinking on this more, I'd recommend showing any future date as a full date. This avoids weirdness due to client clock skew where we might show something like "Build started 2 minutes from now"

Holy crap I totally forgot about this. That is something annoying I've seen before if I recall. However, you could also fix it by taking into account the user's timezone.

@spadgett
Copy link
Member

spadgett commented Aug 15, 2019

We account for timezones... The problem occurs when the user's clock is a few minutes off from the API server's (or the node's) :/

@chancez
Copy link
Contributor

chancez commented Aug 15, 2019

Ah. Either way, seems like a solid idea to fix the issue.

@dtaylor113
Copy link
Contributor Author

Thinking on this more, I'd recommend showing any future date as a full date.

All future dates will be in normal Timestamp format, no relative displays for future dates:
image

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 15, 2019
@spadgett
Copy link
Member

/approve

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 15, 2019
@spadgett spadgett added this to the v4.2 milestone Aug 15, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dtaylor113, spadgett

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot
Copy link
Contributor

@dtaylor113: This pull request references a valid Bugzilla bug.

In response to this:

Bug 1739225: Timestamp component always shows dates in the future as relative dates

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

1 similar comment
@openshift-ci-robot
Copy link
Contributor

@dtaylor113: This pull request references a valid Bugzilla bug.

In response to this:

Bug 1739225: Timestamp component always shows dates in the future as relative dates

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@joshuawilson
Copy link
Contributor

Why doesn't it have the year?

@spadgett
Copy link
Member

Timestamp currently only shows the year if not the current year. We could look at changing that

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

2 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit d72187a into openshift:master Aug 16, 2019
@openshift-ci-robot
Copy link
Contributor

@dtaylor113: All pull requests linked via external trackers have merged. The Bugzilla bug has been moved to the MODIFIED state.

In response to this:

Bug 1739225: Timestamp component always shows dates in the future as relative dates

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@dtaylor113 dtaylor113 deleted the timestamp-norelative branch August 22, 2019 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/core Related to console core functionality lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants