summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Brox <tobias@redpill-linpro.com>2020-06-06 21:08:20 +0200
committerTobias Brox <tobias@redpill-linpro.com>2020-06-06 21:08:20 +0200
commitc8fcb2e743274553274334e24cc8e508ec7c6be2 (patch)
treee95648150512ca7edcf82ade0172645c2c5f5d28
parent2f1fdbb13175535e4b52f75616cbaf11a81181d3 (diff)
downloadcalendar-cli-c8fcb2e743274553274334e24cc8e508ec7c6be2.zip
bugfix for https://github.com/tobixen/calendar-cli/issues/11 - timezone was not honored when doing an agenda date search
-rwxr-xr-xcalendar-cli.py2
-rwxr-xr-xtests/tests.sh5
2 files changed, 5 insertions, 2 deletions
diff --git a/calendar-cli.py b/calendar-cli.py
index be4a609..3bedae1 100755
--- a/calendar-cli.py
+++ b/calendar-cli.py
@@ -468,10 +468,12 @@ def calendar_agenda(caldav_conn, args):
if args.from_time:
dtstart = dateutil.parser.parse(args.from_time)
+ dtstart = _tz(args.timezone).localize(dtstart)
else:
dtstart = _now()
if args.to_time:
dtend = dateutil.parser.parse(args.to_time)
+ dtend = _tz(args.timezone).localize(dtend)
elif args.agenda_mins:
dtend = dtstart + timedelta(minutes=args.agenda_mins)
elif args.agenda_days:
diff --git a/tests/tests.sh b/tests/tests.sh
index 4ab51e8..b429cfd 100755
--- a/tests/tests.sh
+++ b/tests/tests.sh
@@ -104,7 +104,8 @@ uid=$(echo $output | perl -ne '/uid=(.*)$/ && print $1')
[ -n "$uid" ] || error "got no UID back"
echo "## fetching the UTC-event, as ical data"
-calendar_cli --icalendar calendar agenda --from-time=2010-10-08 --agenda-days=3
+calendar_cli --icalendar --timezone=UTC calendar agenda --from-time='2010-10-09 11:59' --agenda-mins=3
+[ -n "$output" ] || error "failed to find the event that was just added"
echo "$output" | grep -q "20101009T120000Z" || error "failed to find the UTC timestamp. Perhaps the server is yielding timezone data for the UTC timezone? In that case, the assert in the test code should be adjusted"
echo "## cleanup, delete it"
@@ -116,7 +117,7 @@ uid=$(echo $output | perl -ne '/uid=(.*)$/ && print $1')
[ -n "$uid" ] || error "got no UID back"
echo "## fetching the UTC-event, as ical data"
-calendar_cli --icalendar calendar agenda --from-time=2010-10-08 --agenda-days=3
+calendar_cli --icalendar --timezone=UTC calendar agenda --from-time='2010-10-09 13:59' --agenda-mins=3
echo "$output" | grep -q "TZID=Brazil" || error "failed to find the Brazilian timezone. perhaps the server is yielding an UTC timestamp? In that case, the assert in the test code should be adjusted."
echo "## cleanup, delete it"