Skip to content

Commit

Permalink
Shut up some tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed Jan 23, 2019
1 parent 302b39e commit 146ee11
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 43 deletions.
10 changes: 5 additions & 5 deletions assign.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ function pcAssignments($qreq) {
'</div><div class="f-h"><ul class="x mb0">'; '</div><div class="f-h"><ul class="x mb0">';
echo '<li>requested'; echo '<li>requested';
if ($rrow->timeRequested) if ($rrow->timeRequested)
echo ' ', $Conf->unparse_interval((int) $rrow->timeRequested); echo ' ', $Conf->unparse_time_relative((int) $rrow->timeRequested);
if ($rrow->requestedBy == $Me->contactId) if ($rrow->requestedBy == $Me->contactId)
echo " by you"; echo " by you";
else if ($Me->can_view_review_requester($prow, $rrow)) else if ($Me->can_view_review_requester($prow, $rrow))
Expand All @@ -310,7 +310,7 @@ function pcAssignments($qreq) {
if ($rrow->reviewModified == 1) { if ($rrow->reviewModified == 1) {
echo '<li>accepted'; echo '<li>accepted';
if ($req[1]) if ($req[1])
echo ' ', $Conf->unparse_interval($req[1]); echo ' ', $Conf->unparse_time_relative($req[1]);
echo '</li>'; echo '</li>';
} }
echo '</ul></div>'; echo '</ul></div>';
Expand All @@ -319,7 +319,7 @@ function pcAssignments($qreq) {
if ($rrow->timeRequested || $Me->can_view_review_requester($prow, $rrow)) { if ($rrow->timeRequested || $Me->can_view_review_requester($prow, $rrow)) {
echo '<li>requested'; echo '<li>requested';
if ($rrow->timeRequested) if ($rrow->timeRequested)
echo ' ', $Conf->unparse_interval((int) $rrow->timeRequested); echo ' ', $Conf->unparse_time_relative((int) $rrow->timeRequested);
if ($rrow->requestedBy == $Me->contactId) if ($rrow->requestedBy == $Me->contactId)
echo " by you"; echo " by you";
else if ($Me->can_view_review_requester($prow, $rrow)) else if ($Me->can_view_review_requester($prow, $rrow))
Expand All @@ -339,7 +339,7 @@ function pcAssignments($qreq) {
if ($rrow->timeRequested || $Me->can_view_review_requester($prow, $rrow)) { if ($rrow->timeRequested || $Me->can_view_review_requester($prow, $rrow)) {
echo '<li>requested'; echo '<li>requested';
if ($rrow->timeRequested) if ($rrow->timeRequested)
echo ' ', $Conf->unparse_interval((int) $rrow->timeRequested); echo ' ', $Conf->unparse_time_relative((int) $rrow->timeRequested);
if ($rrow->requestedBy == $Me->contactId) if ($rrow->requestedBy == $Me->contactId)
echo " by you"; echo " by you";
else if ($Me->can_view_review_requester($prow, $rrow)) else if ($Me->can_view_review_requester($prow, $rrow))
Expand All @@ -348,7 +348,7 @@ function pcAssignments($qreq) {
} }
echo '<li>declined'; echo '<li>declined';
if ($rrow->timeRefused) 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 && (!$rrow->contactId || $rrow->contactId != $rrow->refusedBy)) {
if ($rrow->refusedBy == $Me->contactId) if ($rrow->refusedBy == $Me->contactId)
echo " by you"; echo " by you";
Expand Down
2 changes: 1 addition & 1 deletion deadlines.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


function printDeadline($time, $phrase, $description) { function printDeadline($time, $phrase, $description) {
global $Conf; 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>"; "<dd>", $description, ($description ? "<br />" : ""), "</dd>";
} }


Expand Down
6 changes: 3 additions & 3 deletions log.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -487,9 +487,9 @@ function searchbar(LogRowGenerator $lrg, $page) {
else if ($page === 1) else if ($page === 1)
$dplaceholder = "now"; $dplaceholder = "now";
else if (($rows = $lrg->page_rows($page))) 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) 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"]); echo Ht::form(hoturl("log"), ["method" => "get", "id" => "searchform"]);
if ($Qreq->forceShow) if ($Qreq->forceShow)
Expand Down Expand Up @@ -603,7 +603,7 @@ function render_users($users, $via_chair) {
$trs = []; $trs = [];
$has_dest_user = false; $has_dest_user = false;
foreach ($lrg->page_rows($page) as $row) { 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"); $xusers = $lrg->users_for($row, "contactId");
$xdest_users = $lrg->users_for($row, "destContactId"); $xdest_users = $lrg->users_for($row, "destContactId");
Expand Down
12 changes: 6 additions & 6 deletions scripts/script.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -525,13 +525,13 @@ var strftime = (function () {
return strftime; return strftime;
})(); })();


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


function unparse_duration(d, include_msec) { function unparse_duration(d, include_msec) {
var neg = d < 0, t; var neg = d < 0, t;
Expand Down Expand Up @@ -1626,7 +1626,7 @@ function display_main(is_initial) {
if (!dltime || dltime - now < 0.5) if (!dltime || dltime - now < 0.5)
s += "is NOW"; s += "is NOW";
else else
s += unparse_interval(dltime, now); s += unparse_time_relative(dltime, now, 8);
if (!dltime || dltime - now < 180.5) if (!dltime || dltime - now < 180.5)
s = '<span class="impending">' + s + '</span>'; s = '<span class="impending">' + s + '</span>';
} }
Expand Down
2 changes: 1 addition & 1 deletion src/commentinfo.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ function unparse_json(Contact $contact) {
} }
if ($this->timeModified > 0 && $idable_override) { if ($this->timeModified > 0 && $idable_override) {
$cj->modified_at = (int) $this->timeModified; $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) { } else if ($this->timeModified > 0) {
$cj->modified_at = $this->conf->obscure_time($this->timeModified); $cj->modified_at = $this->conf->obscure_time($this->timeModified);
$cj->modified_at_text = $this->conf->unparse_time_obscure($cj->modified_at); $cj->modified_at_text = $this->conf->unparse_time_obscure($cj->modified_at);
Expand Down
25 changes: 11 additions & 14 deletions src/conference.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2200,7 +2200,7 @@ private function _dateFormat($type) {
return $this->opt["timestampFormat"]; return $this->opt["timestampFormat"];
else if ($type === "obscure") else if ($type === "obscure")
return $this->opt["dateFormatObscure"]; return $this->opt["dateFormatObscure"];
else if ($type) else if ($type === "long")
return $this->opt["dateFormatLong"]; return $this->opt["dateFormatLong"];
else else
return $this->opt["dateFormat"]; return $this->opt["dateFormat"];
Expand Down Expand Up @@ -2257,7 +2257,7 @@ function parse_time($d, $reference = null) {
return strtotime($d, $reference); return strtotime($d, $reference);
} }


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


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


function settingsAfter($name) { function settingsAfter($name) {
Expand Down
2 changes: 0 additions & 2 deletions src/contactlist.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -301,8 +301,6 @@ function content($fieldId, $row) {
case self::FIELD_LASTVISIT: case self::FIELD_LASTVISIT:
if (!$row->activity_at) if (!$row->activity_at)
return "Never"; return "Never";
else if ($this->user->privChair)
return $this->conf->unparse_time_short($row->activity_at);
else else
return $this->conf->unparse_time_obscure($row->activity_at); return $this->conf->unparse_time_obscure($row->activity_at);
case self::FIELD_SELECTOR: case self::FIELD_SELECTOR:
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -512,9 +512,9 @@ function whyNotText($whyNot, $text_only = false) {
} else if ($start <= 0 || $start == $end) { } else if ($start <= 0 || $start == $end) {
$ms[] = $conf->_c("etime", "Action not available.", $open_dname, $paperId); $ms[] = $conf->_c("etime", "Action not available.", $open_dname, $paperId);
} else if ($start > 0 && $Now < $start) { } 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) { } 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 { } else {
$ms[] = $conf->_c("etime", "Action not available.", $dname, $paperId); $ms[] = $conf->_c("etime", "Action not available.", $dname, $paperId);
} }
Expand Down
2 changes: 1 addition & 1 deletion src/papercolumns/pc_timestamp.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function content_empty(PaperList $pl, PaperInfo $row) {
} }
function content(PaperList $pl, PaperInfo $row) { function content(PaperList $pl, PaperInfo $row) {
if (($t = max($row->timeFinalSubmitted, $row->timeSubmitted, 0)) > 0) if (($t = max($row->timeFinalSubmitted, $row->timeSubmitted, 0)) > 0)
return $row->conf->unparse_time_full($t); return $row->conf->unparse_time($t);
return ""; return "";
} }
} }
2 changes: 1 addition & 1 deletion src/papertable.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ static function pdf_stamps_html($data, $options = null) {
if ($tm > 0) if ($tm > 0)
$t[] = ($tooltip ? '<span class="nb need-tooltip" aria-label="Upload time">' : '<span class="nb">') $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>' . '<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")); $ha = new HashAnalysis(get($data, "sha1"));
if ($ha->ok()) { if ($ha->ok()) {
Expand Down
8 changes: 4 additions & 4 deletions src/review.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ function textForm(PaperInfo $prow = null, ReviewInfo $rrow = null, Contact $cont
} }
$time = self::rrow_modified_time($prow, $rrow, $contact, $revViewScore); $time = self::rrow_modified_time($prow, $rrow, $contact, $revViewScore);
if ($time > 1) if ($time > 1)
$x .= "==-== Updated " . $this->conf->printableTime($time) . "\n"; $x .= "==-== Updated " . $this->conf->unparse_time($time) . "\n";


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


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


// ratings // ratings
Expand Down
7 changes: 4 additions & 3 deletions test/test02.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -198,14 +198,15 @@ function random_paper_ids() {
$t = $Conf->parse_time("1 Sep 2010 00:00:01"); $t = $Conf->parse_time("1 Sep 2010 00:00:01");
$t0 = $Conf->obscure_time($t); $t0 = $Conf->obscure_time($t);
xassert_eqq($Conf->unparse_time_obscure($t0), "1 Sep 2010"); 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"); $t = $Conf->parse_time("1 Sep 2010 23:59:59");
$t0 = $Conf->obscure_time($t); $t0 = $Conf->obscure_time($t);
xassert_eqq($Conf->unparse_time_obscure($t0), "1 Sep 2010"); 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 // timezone tests
xassert_eqq(true === "obscure", false);
$t = $Conf->parse_time("29 May 2018 11:00:00 EDT"); $t = $Conf->parse_time("29 May 2018 11:00:00 EDT");
xassert_eqq($t, 1527606000); xassert_eqq($t, 1527606000);
$t = $Conf->parse_time("29 May 2018 03:00:00 AoE"); $t = $Conf->parse_time("29 May 2018 03:00:00 AoE");
Expand All @@ -214,7 +215,7 @@ function random_paper_ids() {
$Conf->crosscheck_options(); $Conf->crosscheck_options();
$t = $Conf->parse_time("29 May 2018 03:00:00"); $t = $Conf->parse_time("29 May 2018 03:00:00");
xassert_eqq($t, 1527606000); xassert_eqq($t, 1527606000);
$t = $Conf->printableTime(1527606000); $t = $Conf->unparse_time(1527606000);
xassert_eqq($t, "29 May 2018 3am AoE"); xassert_eqq($t, "29 May 2018 3am AoE");


// review ordinal tests // review ordinal tests
Expand Down

0 comments on commit 146ee11

Please sign in to comment.