From a1600663926893d53a933788c08a42a7b31f72f3 Mon Sep 17 00:00:00 2001 From: Christian Geier Date: Tue, 31 Oct 2023 16:59:50 +0100 Subject: [PATCH] printformats leans to print current date and time --- khal/cli.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/khal/cli.py b/khal/cli.py index 51ad78b92..0c797476c 100644 --- a/khal/cli.py +++ b/khal/cli.py @@ -400,6 +400,11 @@ def printcalendars(ctx, include_calendar, exclude_calendar): @cli.command() @click.pass_context +@click.option( + '--now', + help=('Print the current date and time in the local timezone instead.'), + is_flag=True, +) def printformats(ctx): '''Print a date in all formats. @@ -407,6 +412,10 @@ def printformats(ctx): formats to check if these locale settings are configured to ones liking.''' time = dt.datetime(2013, 12, 21, 21, 45) + if now: + import pytz + time = dt.datetime.utcnow() + time = pytz.UTC.localize(time).astimezone(ctx.obj['conf']['locale']['local_timezone']) try: for strftime_format in [ 'longdatetimeformat', 'datetimeformat', 'longdateformat', @@ -567,3 +576,4 @@ def configure(ctx): main_khal, main_ikhal = cli, interactive_cli +