Compare commits
No commits in common. "e56cf111e89955e6b3c91d7039cbcce0e0142fa4" and "c7d589ce7438551b241538c0d4c9896506a24dc9" have entirely different histories.
e56cf111e8
...
c7d589ce74
|
@ -1,6 +1,5 @@
|
|||
import configparser
|
||||
import json
|
||||
import operator
|
||||
import os
|
||||
import typing
|
||||
import warnings
|
||||
|
@ -97,12 +96,12 @@ def next_uk_fathers_day(input_date: date) -> date:
|
|||
return fathers_day
|
||||
|
||||
|
||||
def get_next_timezone_transition(tz_name: str) -> date:
|
||||
def get_next_timezone_transition(tz_name: str) -> datetime:
|
||||
"""Datetime of the next time the clocks change."""
|
||||
tz = pytz.timezone(tz_name)
|
||||
dt = next(t for t in tz._utc_transition_times if t > now)
|
||||
|
||||
return typing.cast(date, dt.date())
|
||||
return typing.cast(datetime, dt)
|
||||
|
||||
|
||||
def get_next_bank_holiday() -> dict[str, date | str]:
|
||||
|
@ -277,8 +276,9 @@ def get_data() -> dict[str, str | object]:
|
|||
"next_economist": next_economist(today),
|
||||
"bank_holiday": get_next_bank_holiday(),
|
||||
"us_holiday": get_us_holiday(),
|
||||
# "next_uk_general_election": next_uk_general_election,
|
||||
"next_uk_general_election": next_uk_general_election,
|
||||
"next_us_presidential_election": next_us_presidential_election,
|
||||
# "spacex": spacexdata.get_next_spacex_launch(limit=20),
|
||||
"stock_markets": stock_markets(),
|
||||
"uk_clock_change": get_next_timezone_transition("Europe/London"),
|
||||
"us_clock_change": get_next_timezone_transition("America/New_York"),
|
||||
|
@ -290,24 +290,4 @@ def get_data() -> dict[str, str | object]:
|
|||
"rockets": thespacedevs.get_launches(rocket_dir, limit=40),
|
||||
}
|
||||
|
||||
skip = {"now", "gbpusd", "rockets", "stock_markets", "xmas_last_posting_dates"}
|
||||
events = []
|
||||
for key, value in reply.items():
|
||||
if key in skip:
|
||||
continue
|
||||
if "holiday" in key:
|
||||
assert isinstance(value, dict)
|
||||
event = value
|
||||
event["name"] = key
|
||||
else:
|
||||
event = {"name": key, "date": value}
|
||||
events.append(event)
|
||||
|
||||
for key, value in xmas_last_posting_dates.items():
|
||||
events.append({"name": f"xmas_last_{key}", "date": value})
|
||||
|
||||
events.sort(key=operator.itemgetter("date"))
|
||||
|
||||
reply["events"] = events
|
||||
|
||||
return reply
|
||||
|
|
|
@ -1,30 +1,12 @@
|
|||
{# vim: set ft=htmljinja
|
||||
#}
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Agenda</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
|
||||
</head>
|
||||
|
||||
{% set event_labels = {
|
||||
"next_economist": "The Economist",
|
||||
"mothers_day": "Mothers' day",
|
||||
"fathers_day": "Fathers' day",
|
||||
"uk_financial_year_end": "End of financial year",
|
||||
"bank_holiday": "UK bank holiday",
|
||||
"us_holiday": "US holiday",
|
||||
"uk_clock_change": "UK clock change",
|
||||
"us_clock_change": "US clock change",
|
||||
"next_us_presidential_election": "US pres. election",
|
||||
"xmas_last_second": "Christmas last posting 2nd class",
|
||||
"xmas_last_first": "Christmas last posting 1st class",
|
||||
"xmas_day": "Christmas day",
|
||||
}
|
||||
%}
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container mt-2">
|
||||
|
@ -35,7 +17,7 @@
|
|||
<li>GBPUSD: {{"{:,.3f}".format(gbpusd)}}</li>
|
||||
{# <li>lock down:
|
||||
{{"{:.1f}".format(lockdown_days)}} days
|
||||
({{"{:.2f}".format(lockdown_days / 7)}} weeks) so far</li>
|
||||
({{"{:.2f}".format(lockdown_days / 7)}} weeks) so far</li> #}
|
||||
<li>The Economist: {{days(next_economist)}} (Thursday)</li>
|
||||
|
||||
<li>Mothers' day:
|
||||
|
@ -61,17 +43,17 @@
|
|||
{{us_holiday["title"]}}</li>
|
||||
|
||||
<li>UK clock change:
|
||||
{{days(uk_clock_change)}}
|
||||
{{days(uk_clock_change.date())}}
|
||||
{{uk_clock_change.strftime("%a, %d, %b %Y")}}</li>
|
||||
|
||||
<li>US clock change:
|
||||
{{days(us_clock_change)}}
|
||||
{{days(us_clock_change.date())}}
|
||||
{{us_clock_change.strftime("%a, %d, %b %Y")}}</li>
|
||||
|
||||
{#
|
||||
<li>general election:
|
||||
{{days(next_uk_general_election)}}
|
||||
{{next_uk_general_election.strftime("%a, %d %b %Y")}}</li>
|
||||
|
||||
{{next_uk_general_election.strftime("%a, %d %b %Y")}}</li> #}
|
||||
<li>US pres. election:
|
||||
{{days(next_us_presidential_election)}}
|
||||
{{next_us_presidential_election.strftime("%a, %d %b %Y")}}</li>
|
||||
|
@ -88,27 +70,9 @@
|
|||
{{days(xmas_day)}}
|
||||
{{xmas_day.strftime("%a, %d %b %Y")}}</li>
|
||||
|
||||
#}
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<table class="table table-hover w-auto">
|
||||
{% for event in events %}
|
||||
<tr>
|
||||
<td class="text-end">
|
||||
{{event.date.strftime("%a, %d, %b %Y")}}
|
||||
</td>
|
||||
<td>
|
||||
{{ event_labels[event.name] }}
|
||||
{%- if "title" in event -%}: {{ event.title }}{% endif %}
|
||||
</td>
|
||||
<td class="text-end">
|
||||
{{ days(event.date) }}
|
||||
</td>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<h3>Stock markets</h3>
|
||||
{% for market in stock_markets %}
|
||||
<p>{{ market }}</p>
|
||||
|
@ -149,7 +113,5 @@
|
|||
</table>
|
||||
</div>
|
||||
|
||||
<pre>{{ events | pprint }}</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -25,7 +25,7 @@ def index() -> str:
|
|||
return f"{delta.days:>5,d} days {delta.seconds // 3600:>2.0f} hours"
|
||||
|
||||
def days(when: date) -> str:
|
||||
return "today" if when == today else f"{(when - today).days:,d} days"
|
||||
return " today" if when == today else f"{(when - today).days:>5,d} days"
|
||||
|
||||
return render_template("index.html", days=days, days_hours=days_hours, **data)
|
||||
|
||||
|
|
Loading…
Reference in a new issue