From 2a6efffec5624c50aa0bbfd10a703b229a139b36 Mon Sep 17 00:00:00 2001 From: Christian Geier Date: Tue, 31 Oct 2023 16:59:50 +0100 Subject: [PATCH] printformats learns to print current date and time --- khal/cli.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/khal/cli.py b/khal/cli.py index 51ad78b92..755955863 100644 --- a/khal/cli.py +++ b/khal/cli.py @@ -400,13 +400,22 @@ def printcalendars(ctx, include_calendar, exclude_calendar): @cli.command() @click.pass_context -def printformats(ctx): +@click.option( + '--now', + help=('Print the current date and time in the local timezone instead.'), + is_flag=True, +) +def printformats(ctx, now: bool): '''Print a date in all formats. Print the date 2013-12-21 21:45 in all configured date(time) 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 +