Skip to content

Commit

Permalink
printformats leans to print current date and time
Browse files Browse the repository at this point in the history
  • Loading branch information
geier committed Apr 14, 2024
1 parent f5f1235 commit a160066
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions khal/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,22 @@ 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.
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',
Expand Down Expand Up @@ -567,3 +576,4 @@ def configure(ctx):


main_khal, main_ikhal = cli, interactive_cli

0 comments on commit a160066

Please sign in to comment.