Skip to content
Permalink
Browse files

Shut up some tests.

  • Loading branch information
kohler committed Jan 23, 2019
1 parent 302b39e commit 146ee111d51133e64c8dca96a5dd7faa7f4a36d6
Showing with 39 additions and 43 deletions.
  1. +5 −5 assign.php
  2. +1 −1 deadlines.php
  3. +3 −3 log.php
  4. +6 −6 scripts/script.js
  5. +1 −1 src/commentinfo.php
  6. +11 −14 src/conference.php
  7. +0 −2 src/contactlist.php
  8. +2 −2 src/helpers.php
  9. +1 −1 src/papercolumns/pc_timestamp.php
  10. +1 −1 src/papertable.php
  11. +4 −4 src/review.php
  12. +4 −3 test/test02.php
@@ -301,7 +301,7 @@ function pcAssignments($qreq) {
'</div><div class="f-h"><ul class="x mb0">';
echo '<li>requested';
if ($rrow->timeRequested)
echo ' ', $Conf->unparse_interval((int) $rrow->timeRequested);
echo ' ', $Conf->unparse_time_relative((int) $rrow->timeRequested);
if ($rrow->requestedBy == $Me->contactId)
echo " by you";
else if ($Me->can_view_review_requester($prow, $rrow))
@@ -310,7 +310,7 @@ function pcAssignments($qreq) {
if ($rrow->reviewModified == 1) {
echo '<li>accepted';
if ($req[1])
echo ' ', $Conf->unparse_interval($req[1]);
echo ' ', $Conf->unparse_time_relative($req[1]);
echo '</li>';
}
echo '</ul></div>';
@@ -319,7 +319,7 @@ function pcAssignments($qreq) {
if ($rrow->timeRequested || $Me->can_view_review_requester($prow, $rrow)) {
echo '<li>requested';
if ($rrow->timeRequested)
echo ' ', $Conf->unparse_interval((int) $rrow->timeRequested);
echo ' ', $Conf->unparse_time_relative((int) $rrow->timeRequested);
if ($rrow->requestedBy == $Me->contactId)
echo " by you";
else if ($Me->can_view_review_requester($prow, $rrow))
@@ -339,7 +339,7 @@ function pcAssignments($qreq) {
if ($rrow->timeRequested || $Me->can_view_review_requester($prow, $rrow)) {
echo '<li>requested';
if ($rrow->timeRequested)
echo ' ', $Conf->unparse_interval((int) $rrow->timeRequested);
echo ' ', $Conf->unparse_time_relative((int) $rrow->timeRequested);
if ($rrow->requestedBy == $Me->contactId)
echo " by you";
else if ($Me->can_view_review_requester($prow, $rrow))
@@ -348,7 +348,7 @@ function pcAssignments($qreq) {
}
echo '<li>declined';
if ($rrow->timeRefused)
echo ' ', $Conf->unparse_interval((int) $rrow->timeRefused);
echo ' ', $Conf->unparse_time_relative((int) $rrow->timeRefused);
if ($rrow->refusedBy && (!$rrow->contactId || $rrow->contactId != $rrow->refusedBy)) {
if ($rrow->refusedBy == $Me->contactId)
echo " by you";
@@ -18,7 +18,7 @@

function printDeadline($time, $phrase, $description) {
global $Conf;
echo "<dt><strong>", $phrase, "</strong>: ", $Conf->printableTime($time, "span") , "</dt>\n",
echo "<dt><strong>", $phrase, "</strong>: ", $Conf->unparse_time_long($time, "span") , "</dt>\n",
"<dd>", $description, ($description ? "<br />" : ""), "</dd>";
}

@@ -487,9 +487,9 @@ function searchbar(LogRowGenerator $lrg, $page) {
else if ($page === 1)
$dplaceholder = "now";
else if (($rows = $lrg->page_rows($page)))
$dplaceholder = $Conf->unparse_time_short($rows[0]->timestamp);
$dplaceholder = $Conf->unparse_time($rows[0]->timestamp);
else if ($first_timestamp)
$dplaceholder = $Conf->unparse_time_short($first_timestamp);
$dplaceholder = $Conf->unparse_time($first_timestamp);

echo Ht::form(hoturl("log"), ["method" => "get", "id" => "searchform"]);
if ($Qreq->forceShow)
@@ -603,7 +603,7 @@ function render_users($users, $via_chair) {
$trs = [];
$has_dest_user = false;
foreach ($lrg->page_rows($page) as $row) {
$t = ['<td class="pl pl_logtime">' . $Conf->unparse_time_short($row->timestamp) . '</td>'];
$t = ['<td class="pl pl_logtime">' . $Conf->unparse_time($row->timestamp) . '</td>'];

$xusers = $lrg->users_for($row, "contactId");
$xdest_users = $lrg->users_for($row, "destContactId");
@@ -525,13 +525,13 @@ var strftime = (function () {
return strftime;
})();

function unparse_interval(t, now, format) {
function unparse_time_relative(t, now, format) {
now = now || now_sec();
format = format || 0;
var d = Math.abs(now - t), unit = 0;
if (d >= 5227200) { // 60.5d
if (!(format & 1))
return strftime((format & 4 ? "" : "on ") + "%#e %b %Y", t);
return strftime((format & 8 ? "on " : "") + "%#e %b %Y", t);
unit = 5;
} else if (d >= 259200) // 3d
unit = 4;
@@ -554,9 +554,9 @@ function unparse_interval(t, now, format) {
else
return t < now ? d + " ago" : "in " + d;
}
unparse_interval.NO_DATE = 1;
unparse_interval.NO_PREP = 2;
unparse_interval.SHORT = 4;
unparse_time_relative.NO_DATE = 1;
unparse_time_relative.NO_PREP = 2;
unparse_time_relative.SHORT = 4;

function unparse_duration(d, include_msec) {
var neg = d < 0, t;
@@ -1626,7 +1626,7 @@ function display_main(is_initial) {
if (!dltime || dltime - now < 0.5)
s += "is NOW";
else
s += unparse_interval(dltime, now);
s += unparse_time_relative(dltime, now, 8);
if (!dltime || dltime - now < 180.5)
s = '<span class="impending">' + s + '</span>';
}
@@ -326,7 +326,7 @@ function unparse_json(Contact $contact) {
}
if ($this->timeModified > 0 && $idable_override) {
$cj->modified_at = (int) $this->timeModified;
$cj->modified_at_text = $this->conf->printableTime($cj->modified_at);
$cj->modified_at_text = $this->conf->unparse_time_long($cj->modified_at);
} else if ($this->timeModified > 0) {
$cj->modified_at = $this->conf->obscure_time($this->timeModified);
$cj->modified_at_text = $this->conf->unparse_time_obscure($cj->modified_at);
@@ -2200,7 +2200,7 @@ private function _dateFormat($type) {
return $this->opt["timestampFormat"];
else if ($type === "obscure")
return $this->opt["dateFormatObscure"];
else if ($type)
else if ($type === "long")
return $this->opt["dateFormatLong"];
else
return $this->opt["dateFormat"];
@@ -2257,7 +2257,7 @@ function parse_time($d, $reference = null) {
return strtotime($d, $reference);
}

function _printableTime($value, $type, $useradjust, $preadjust = null) {
private function _unparse_time($value, $type, $useradjust, $preadjust = null) {
if ($value <= 0)
return "N/A";
$t = date($this->_dateFormat($type), $value);
@@ -2273,9 +2273,6 @@ function _printableTime($value, $type, $useradjust, $preadjust = null) {
}
return $t;
}
function printableTime($value, $useradjust = false, $preadjust = null) {
return $this->_printableTime($value, true, $useradjust, $preadjust);
}
function obscure_time($timestamp) {
if ($timestamp !== null)
$timestamp = (int) ($timestamp + 0.5);
@@ -2287,25 +2284,25 @@ function obscure_time($timestamp) {
}
return $timestamp;
}
function unparse_time_short($value) {
return $this->_printableTime($value, false, false, null);
function unparse_time_long($value, $useradjust = false, $preadjust = null) {
return $this->_unparse_time($value, "long", $useradjust, $preadjust);
}
function unparse_time_full($value) {
return $this->_printableTime($value, "timestamp", false, null);
function unparse_time($value) {
return $this->_unparse_time($value, "timestamp", false, null);
}
function unparse_time_obscure($value) {
return $this->_printableTime($value, "obscure", false, null);
return $this->_unparse_time($value, "obscure", false, null);
}
function unparse_time_log($value) {
return date("d/M/Y:H:i:s O", $value);
}
function unparse_interval($when, $now = 0, $format = 0) {
function unparse_time_relative($when, $now = 0, $format = 0) {
global $Now;
$d = abs($when - ($now ? : $Now));
$unit = 0;
if ($d >= 5227200) {
if (!($format & 1))
return ($format & 4 ? "" : "on ") . date($this->_dateFormat("obscure"), $when);
return ($format & 8 ? "on " : "") . date($this->_dateFormat("obscure"), $when);
$unit = 5;
} else if ($d >= 259200)
$unit = 4;
@@ -2333,13 +2330,13 @@ function unparse_interval($when, $now = 0, $format = 0) {
}

function printableTimeSetting($what, $useradjust = false, $preadjust = null) {
return $this->printableTime(defval($this->settings, $what, 0), $useradjust, $preadjust);
return $this->unparse_time_long(defval($this->settings, $what, 0), $useradjust, $preadjust);
}
function printableDeadlineSetting($what, $useradjust = false, $preadjust = null) {
if (!isset($this->settings[$what]) || $this->settings[$what] <= 0)
return "No deadline";
else
return "Deadline: " . $this->printableTime($this->settings[$what], $useradjust, $preadjust);
return "Deadline: " . $this->unparse_time_long($this->settings[$what], $useradjust, $preadjust);
}

function settingsAfter($name) {
@@ -301,8 +301,6 @@ function content($fieldId, $row) {
case self::FIELD_LASTVISIT:
if (!$row->activity_at)
return "Never";
else if ($this->user->privChair)
return $this->conf->unparse_time_short($row->activity_at);
else
return $this->conf->unparse_time_obscure($row->activity_at);
case self::FIELD_SELECTOR:
@@ -512,9 +512,9 @@ function whyNotText($whyNot, $text_only = false) {
} else if ($start <= 0 || $start == $end) {
$ms[] = $conf->_c("etime", "Action not available.", $open_dname, $paperId);
} else if ($start > 0 && $Now < $start) {
$ms[] = $conf->_c("etime", "Action not available until %3$s.", $open_dname, $paperId, $conf->printableTime($start, "span"));
$ms[] = $conf->_c("etime", "Action not available until %3$s.", $open_dname, $paperId, $conf->unparse_time($start, "span"));
} else if ($end > 0 && $Now > $end) {
$ms[] = $conf->_c("etime", "Deadline passed.", $dname, $paperId, $conf->printableTime($end, "span"));
$ms[] = $conf->_c("etime", "Deadline passed.", $dname, $paperId, $conf->unparse_time($end, "span"));
} else {
$ms[] = $conf->_c("etime", "Action not available.", $dname, $paperId);
}
@@ -19,7 +19,7 @@ function content_empty(PaperList $pl, PaperInfo $row) {
}
function content(PaperList $pl, PaperInfo $row) {
if (($t = max($row->timeFinalSubmitted, $row->timeSubmitted, 0)) > 0)
return $row->conf->unparse_time_full($t);
return $row->conf->unparse_time($t);
return "";
}
}
@@ -498,7 +498,7 @@ static function pdf_stamps_html($data, $options = null) {
if ($tm > 0)
$t[] = ($tooltip ? '<span class="nb need-tooltip" aria-label="Upload time">' : '<span class="nb">')
. '<svg width="12" height="12" viewBox="0 0 96 96" class="licon"><path d="M48 6a42 42 0 1 1 0 84 42 42 0 1 1 0-84zm0 10a32 32 0 1 0 0 64 32 32 0 1 0 0-64zM48 19A5 5 0 0 0 43 24V46c0 2.352.37 4.44 1.464 5.536l12 12c4.714 4.908 12-2.36 7-7L53 46V24A5 5 0 0 0 43 24z"/></svg>'
. " " . $Conf->unparse_time_full($tm) . "</span>";
. " " . $Conf->unparse_time($tm) . "</span>";

$ha = new HashAnalysis(get($data, "sha1"));
if ($ha->ok()) {
@@ -715,7 +715,7 @@ function textForm(PaperInfo $prow = null, ReviewInfo $rrow = null, Contact $cont
}
$time = self::rrow_modified_time($prow, $rrow, $contact, $revViewScore);
if ($time > 1)
$x .= "==-== Updated " . $this->conf->printableTime($time) . "\n";
$x .= "==-== Updated " . $this->conf->unparse_time($time) . "\n";

if ($prow)
$x .= "\n==+== Paper #$prow->paperId\n"
@@ -827,7 +827,7 @@ function pretty_text(PaperInfo $prow, ReviewInfo $rrow, Contact $contact,
$x .= "* Reviewer: " . Text::user_text($rrow) . "\n";
$time = self::rrow_modified_time($prow, $rrow, $contact, $revViewScore);
if ($time > 1)
$x .= "* Updated: " . $this->conf->printableTime($time) . "\n";
$x .= "* Updated: " . $this->conf->unparse_time($time) . "\n";

foreach ($this->forder as $fid => $f) {
if ($f->view_score <= $revViewScore
@@ -1007,7 +1007,7 @@ function show(PaperInfo $prow, ReviewInfo $rrow = null, &$options, ReviewValues
$sep = $xsep;
}
if ($rrow && $rrow->reviewModified > 1 && $Me->can_view_review_time($prow, $rrow)) {
echo $sep, "Updated ", $this->conf->printableTime($rrow->reviewModified);
echo $sep, "Updated ", $this->conf->unparse_time($rrow->reviewModified);
$sep = $xsep;
}
if ($sep != $open)
@@ -1145,7 +1145,7 @@ function unparse_review_json(PaperInfo $prow, ReviewInfo $rrow,
$time = self::rrow_modified_time($prow, $rrow, $contact, $revViewScore);
if ($time > 1) {
$rj["modified_at"] = (int) $time;
$rj["modified_at_text"] = $this->conf->printableTime($time);
$rj["modified_at_text"] = $this->conf->unparse_time($time);
}

// ratings
@@ -198,14 +198,15 @@ function random_paper_ids() {
$t = $Conf->parse_time("1 Sep 2010 00:00:01");
$t0 = $Conf->obscure_time($t);
xassert_eqq($Conf->unparse_time_obscure($t0), "1 Sep 2010");
xassert_eqq($Conf->printableTime($t0), "1 Sep 2010 12pm EDT");
xassert_eqq($Conf->unparse_time($t0), "1 Sep 2010 12pm EDT");

$t = $Conf->parse_time("1 Sep 2010 23:59:59");
$t0 = $Conf->obscure_time($t);
xassert_eqq($Conf->unparse_time_obscure($t0), "1 Sep 2010");
xassert_eqq($Conf->printableTime($t0), "1 Sep 2010 12pm EDT");
xassert_eqq($Conf->unparse_time($t0), "1 Sep 2010 12pm EDT");

// timezone tests
xassert_eqq(true === "obscure", false);
$t = $Conf->parse_time("29 May 2018 11:00:00 EDT");
xassert_eqq($t, 1527606000);
$t = $Conf->parse_time("29 May 2018 03:00:00 AoE");
@@ -214,7 +215,7 @@ function random_paper_ids() {
$Conf->crosscheck_options();
$t = $Conf->parse_time("29 May 2018 03:00:00");
xassert_eqq($t, 1527606000);
$t = $Conf->printableTime(1527606000);
$t = $Conf->unparse_time(1527606000);
xassert_eqq($t, "29 May 2018 3am AoE");

// review ordinal tests

0 comments on commit 146ee11

Please sign in to comment.
You can’t perform that action at this time.