Making WordPress.org


Ignore:
Timestamp:
12/17/2018 07:34:40 AM (8 years ago)
Author:
vedjain
Message:

WCPT Application Tracker: Make sure that time is rendered in biggest possible unit.

Earlier, because of Math.floor, and > comparison, time like 73 seconds would have rendered as 73 seconds ago instead of 1 minute ago, since Math.floor would have rounded seconds/60 to 1. So using >= comparison operator instead of > will fix this behavior.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/javascript/tracker/source/tracker.jsx

    r7977 r7980  
    2121        let interval = Math.floor(seconds / 31536000);
    2222
    23         if (interval > 1) {
     23        if (interval >= 1) {
    2424                return interval + " years";
    2525        }
    2626        interval = Math.floor(seconds / 2592000);
    27         if (interval > 1) {
     27        if (interval >= 1) {
    2828                return interval + " months";
    2929        }
    3030        interval = Math.floor(seconds / 86400);
    31         if (interval > 1) {
     31        if (interval >= 1) {
    3232                return interval + " days";
    3333        }
    3434        interval = Math.floor(seconds / 3600);
    35         if (interval > 1) {
     35        if (interval >= 1) {
    3636                return interval + " hours";
    3737        }
    3838        interval = Math.floor(seconds / 60);
    39         if (interval > 1) {
     39        if (interval >= 1) {
    4040                return interval + " minutes";
    4141        }
Note: See TracChangeset for help on using the changeset viewer.