Makes user-facing dates local when possible

[?]
Jan 22, 2019, 12:58 AM
ORWUR47ZCFUFUU2LX7SEBTZA7R2ET4WSBX5F4BGEIRWIYHSHV4SQC

Dependencies

  • [2] XA4U3RP6 Jobset job tab: Show eval date rather than eval ID
  • [3] EPWEMRI2 Allow determinism checking for entire jobsets
  • [4] PMTIAQEP Build page: Show output / closure sizes
  • [5] 4WZQW2N6 Fix indentation and get rid of some unnecessary whitespace in the output
  • [6] IK53RV4V
  • [7] GNIEG2GC * Disambiguate jobs by jobset name. I.e. jobs with the same name in
  • [8] E5DMQRPO Remove unnecessary whitespace in the HTML output
  • [9] JLDUSNUO * Unify rendering of finished and scheduled builds.
  • [10] 6KIJX24R Get rid of unnecessary [%- and -%] tags
  • [11] H7CNGK4O * Log evaluation errors etc. in the DB.
  • [12] JAH3UPWA Support revision control systems via plugins
  • [*] J5UVLXOK * Start of a basic Catalyst web interface.
  • [*] 2P7VNAAC Move common Javascript code into a separate file
  • [*] KSBB33RE Add a dashboard

Change contents

  • edit in src/root/common.tt at line 9
    [4.76][4.5204:5205](),[4.412][4.5204:5205](),[4.609][4.5204:5205](),[4.623][4.5204:5205](),[4.3027][4.5204:5205]()
  • replacement in src/root/common.tt at line 10
    [4.625][4.413:435](),[4.5205][4.413:435]()
    BLOCK renderDateTime;
    [4.625]
    [4.435]
    # Formatted date time, in hydra-local timezone.
    # Use only where an HTML element cannot be used.
    BLOCK dateTimeText;
  • edit in src/root/common.tt at line 16
    [4.5221]
    [4.3991]
    # HTML-rendered date. Formatted in hydra-local timezone.
    # It is enhanced with JavaScript to show user-local and UTC time zones.
    BLOCK renderDateTime %]
    <time [% HTML.attributes(
    "data-timestamp" => timestamp,
    title => date.format(timestamp, '%Y-%m-%d %H:%M:%S (%Z)'),
    datetime => date.format(timestamp, "%Y-%m-%dT%H:%M:%SZ", gmt => 1),
    ) %] class="date is-absolute">
    [% INCLUDE dateTimeText %]
    </time>
    [% END;
  • replacement in src/root/common.tt at line 28
    [4.3992][2.131:157]()
    BLOCK renderRelativeDate;
    [4.3992]
    [2.157]
    # Relative date, as text.
    # Use only where an HTML element cannot be used.
    BLOCK relativeDateText;
  • edit in src/root/common.tt at line 45
    [2.558]
    [2.558]
    # HTML-rendered relative date.
    # It is enhanced with JavaScript to show user-local and UTC time zones.
    BLOCK renderRelativeDate %]
    <time [% HTML.attributes(
    "data-timestamp" => timestamp,
    title => date.format(timestamp, '%Y-%m-%d %H:%M:%S (%Z)'),
    datetime => date.format(timestamp, "%Y-%m-%dT%H:%M:%SZ", gmt => 1),
    ) %] class="date is-relative">
    [% INCLUDE relativeDateText %]
    </time>
    [% END;
  • edit in src/root/static/css/hydra.css at line 145
    [3.4195]
    .date {
    cursor: help;
    border-bottom: 1px dotted #999;
    }
  • edit in src/root/static/js/common.js at line 100
    [16.7712]
    [15.2151]
    /* Makes dates more user friendly. */
    // Friendly date format
    var DATE_FORMAT = "YYYY-MM-DD HH:mm:ss";
    // Local timezone offset to display.
    var tz = moment().format("Z");
    $("time.date").each(function(i, el) {
    var el = $(el);
    var localTime = moment(el.data("timestamp"), "%X");
    var hydraTime = el.attr("title");
    if (el.hasClass("is-absolute")) {
    el.attr( "title", [
    "Adjusted to local time (" + tz + ")",
    "Other timezones:",
    " UTC: " + localTime.clone().utc().format(DATE_FORMAT),
    " As Hydra reported: " + hydraTime,
    ].join("\n"));
    el.text(localTime.format(DATE_FORMAT));
    el.addClass("is-local");
    }
    else if (el.hasClass("is-relative")) {
    el.attr( "title", [
    "Local (" + tz + "): " + localTime.format(DATE_FORMAT),
    "UTC: " + localTime.clone().utc().format(DATE_FORMAT),
    "As Hydra reported: " + hydraTime,
    ].join("\n"));
    el.addClass("is-local");
    }
    });