Skip to content

Commit

Permalink
Fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Dawson R committed Sep 9, 2024
1 parent 4470a4f commit 5c28bc1
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions click_datetime/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

import click
from datetime import datetime


class Datetime(click.ParamType):
'''
"""
A datetime object parsed via datetime.strptime.
Format specifiers can be found here :
https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior
'''
"""

name = 'date'
name = "date"

def __init__(self, format):
self.format = format
Expand All @@ -26,5 +26,12 @@ def convert(self, value, param, ctx):
datetime_value = datetime.strptime(value, self.format)
return datetime_value
except ValueError as ex:
self.fail('Could not parse datetime string "{datetime_str}" formatted as {format} ({ex})'.format(
datetime_str=value, format=self.format, ex=ex,), param, ctx)
self.fail(
'Could not parse datetime string "{datetime_str}" formatted as {format} ({ex})'.format(
datetime_str=value,
format=self.format,
ex=ex,
),
param,
ctx,
)

0 comments on commit 5c28bc1

Please sign in to comment.