Skip to content

Commit a847a64

Browse files
committed
By default, past calendar events will disappear from the list.
Added option to show all past events from today, `CALENDAR_INCLUDE_PAST_EVENTS_FOR_TODAY=1` Issue #31
1 parent d22459e commit a847a64

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2022-04-21
2+
* By default, past calendar events will disappear from the list.
3+
* Added option to show all past events from today, `CALENDAR_INCLUDE_PAST_EVENTS_FOR_TODAY=1`
4+
15
## 2022-04-13
26
* Add new layouts for the user to choose from. Set the value `export SCREEN_LAYOUT=1` to 2, 3, 4...
37
* Layouts contributed by @feh123 and @jmason

env.sh.sample

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,7 @@ export CALENDAR_TTL=3600
5353

5454

5555
# Which layout to use. 1, 2, 3...
56-
export SCREEN_LAYOUT=1
56+
export SCREEN_LAYOUT=1
57+
58+
# Include all calendar events from today, even if they are past.
59+
# CALENDAR_INCLUDE_PAST_EVENTS_FOR_TODAY=1

screen-calendar-get.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ def get_outlook_events(max_event_results):
2727

2828
if is_stale(os.getcwd() + "/" + outlook_calendar_pickle, ttl):
2929
logging.debug("Pickle is stale, calling the Outlook Calendar API")
30-
today_midnight = datetime.datetime.combine(datetime.datetime.utcnow(), datetime.datetime.min.time()).isoformat()
30+
today_start_time = datetime.datetime.utcnow().isoformat()
31+
if os.getenv("CALENDAR_INCLUDE_PAST_EVENTS_FOR_TODAY", "0") == "1":
32+
today_start_time = datetime.datetime.combine(datetime.datetime.utcnow(), datetime.datetime.min.time()).isoformat()
3133
oneyearlater_iso = (datetime.datetime.now().astimezone()
3234
+ datetime.timedelta(days=365)).astimezone().isoformat()
3335
access_token = outlook_util.get_access_token()
3436
events_data = outlook_util.get_outlook_calendar_events(
3537
outlook_calendar_id,
36-
today_midnight,
38+
today_start_time,
3739
oneyearlater_iso,
3840
access_token)
3941
logging.debug(events_data)
@@ -103,11 +105,13 @@ def get_google_events(max_event_results):
103105
if is_stale(os.getcwd() + "/" + google_calendar_pickle, ttl):
104106
logging.debug("Pickle is stale, calling the Calendar API")
105107

106-
today_midnight = datetime.datetime.combine(datetime.datetime.utcnow(), datetime.datetime.min.time())
108+
today_start_time = datetime.datetime.utcnow()
109+
if os.getenv("CALENDAR_INCLUDE_PAST_EVENTS_FOR_TODAY", "0") == "1":
110+
today_start_time = datetime.datetime.combine(datetime.datetime.utcnow(), datetime.datetime.min.time())
107111
# Call the Calendar API
108112
events_result = service.events().list(
109113
calendarId=google_calendar_id,
110-
timeMin=today_midnight.isoformat() + 'Z',
114+
timeMin=today_start_time.isoformat() + 'Z',
111115
maxResults=max_event_results,
112116
singleEvents=True,
113117
orderBy='startTime').execute()

0 commit comments

Comments
 (0)