Skip to content

Commit 3a4298b

Browse files
committed
printformats learn to print current date and time
1 parent 2f93ccd commit 3a4298b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

khal/cli.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,13 +544,22 @@ def printcalendars(ctx, include_calendar, exclude_calendar):
544544

545545
@cli.command()
546546
@click.pass_context
547-
def printformats(ctx):
547+
@click.option(
548+
'--now',
549+
help=('Print the current date and time in the local timezone instead.'),
550+
is_flag=True,
551+
)
552+
def printformats(ctx, now):
548553
'''Print a date in all formats.
549554
550555
Print the date 2013-12-21 21:45 in all configured date(time)
551556
formats to check if these locale settings are configured to ones
552557
liking.'''
553558
time = dt.datetime(2013, 12, 21, 21, 45)
559+
if now:
560+
import pytz
561+
time = dt.datetime.utcnow()
562+
time = pytz.UTC.localize(time).astimezone(ctx.obj['conf']['locale']['local_timezone'])
554563
try:
555564
for strftime_format in [
556565
'longdatetimeformat', 'datetimeformat', 'longdateformat',

0 commit comments

Comments
 (0)