|
17 | 17 | logger = regzbot.logger |
18 | 18 |
|
19 | 19 |
|
| 20 | + |
| 21 | +def _web_now(): |
| 22 | + mail_now = regzbot._TESTING.get("mail_now") |
| 23 | + if mail_now is not None: |
| 24 | + return mail_now |
| 25 | + return regzbot.timendate_now() |
| 26 | + |
| 27 | + |
| 28 | +def _web_days_delta(past): |
| 29 | + return (_web_now() - datetime.datetime.fromtimestamp(past, datetime.timezone.utc)).days |
| 30 | + |
| 31 | + |
20 | 32 | class RegLinkWeb(regzbot.RegLink): |
21 | 33 | def __init__(self, *args): |
22 | 34 | super().__init__(*args) |
@@ -718,7 +730,7 @@ def outpage_footer(yattagdoc, count): |
718 | 730 | yattagdoc.text("[compiled by ") |
719 | 731 | with yattagdoc.tag("a", href="https://linux-regtracking.leemhuis.info"): |
720 | 732 | yattagdoc.text("regzbot") |
721 | | - currenttime = datetime.datetime.now(datetime.timezone.utc) |
| 733 | + currenttime = _web_now() |
722 | 734 | yattagdoc.text(" on %s (UTC). " % currenttime.strftime("%Y-%m-%d %H:%M:%S")) |
723 | 735 |
|
724 | 736 | yattagdoc.text("Wanna know more about regzbot? Then check out its ") |
@@ -999,7 +1011,7 @@ def categorize(cls, regressionlist): |
999 | 1011 | } |
1000 | 1012 |
|
1001 | 1013 | for regression in regressionlist: |
1002 | | - last_activity_days = regzbot.days_delta(regression.gmtime_activity) |
| 1014 | + last_activity_days = _web_days_delta(regression.gmtime_activity) |
1003 | 1015 | if regression.solved_reason == "inconclusive": |
1004 | 1016 | categories["inconclusive"]["default"]["entries"].append(regression) |
1005 | 1017 | elif regression.gmtime_solved: |
@@ -1110,7 +1122,7 @@ def compile(cls): |
1110 | 1122 | regressionslist = list() |
1111 | 1123 | eventslist = list() |
1112 | 1124 | events_gmtime_offset = ( |
1113 | | - int(datetime.datetime.now(datetime.timezone.utc).timestamp()) - 604800 |
| 1125 | + int(_web_now().timestamp()) - 604800 |
1114 | 1126 | ) |
1115 | 1127 | if regzbot.is_running_citesting("offline"): |
1116 | 1128 | events_gmtime_offset = 604800 * 52 * 10 |
@@ -1187,10 +1199,7 @@ def compile(cls): |
1187 | 1199 | for regression in regressionslist: |
1188 | 1200 | if regression.gmtime_solved: |
1189 | 1201 | continue |
1190 | | - filed_days = ( |
1191 | | - datetime.datetime.now(datetime.timezone.utc) |
1192 | | - - datetime.datetime.fromtimestamp(regression.gmtime_filed, datetime.timezone.utc) |
1193 | | - ).days |
| 1202 | + filed_days = _web_days_delta(regression.gmtime_filed) |
1194 | 1203 | if filed_days < 7: |
1195 | 1204 | categories[regression.treename]["entries"].append(regression) |
1196 | 1205 | else: |
|
0 commit comments