Repository: pydantic/pydantic

Issue:
Changing date format
What is the right way to do it? I used some monkeypatch:
```py
from pydantic import datetime_parse

datetime_parse.date_re = re.compile(r'(?P<day>\d{1,2}).(?P<month>\d{1,2}).(?P<year>\d{4})$')
```
but it feels rather hacky. Looks like I can do it with validators but when I return something It still tries to create date from string after that when it's not a string anymore.

```py
class CheckUserRequest(pydantic.BaseModel):
    cardNumber: str
    lastName: str
    birthday: date

    @validator("birthday", pre=True)
    def parse_birthday(cls, value):
        return datetime.strptime(
            value,
            "%d.%m.%Y"
        ).date()
```

I get:
```py
pydantic.exceptions.ValidationError: error validating input
birthday:
  int() argument must be a string, a bytes-like object or a number, not 'datetime.date' (error_type=TypeError track=date)
```


Discussion:
Not at all sure what you're trying to do. 

Please explain a little more. 
Give the input and expected output. 
@samuelcolvin I use pydantic to validate user request data for my api. I wan't my api to accept another format for dates. Like "%d.%m.%Y" instead of "%Y-%m-%d".

So "23.10.2013" would be a valid date and would be converted to datetime.date.

Resolving patch:
diff --git a/pydantic/datetime_parse.py b/pydantic/datetime_parse.py
--- a/pydantic/datetime_parse.py
+++ b/pydantic/datetime_parse.py
@@ -80,13 +80,16 @@ def from_unix_seconds(seconds: int) -> datetime:
     return dt.replace(tzinfo=timezone.utc)
 
 
-def parse_date(value: StrIntFloat) -> date:
+def parse_date(value: Union[date, StrIntFloat]) -> date:
     """
     Parse a string and return a datetime.date.
 
     Raise ValueError if the input is well formatted but not a valid date.
     Raise ValueError if the input isn't well formatted.
     """
+    if isinstance(value, date):
+        return value
+
     number = get_numeric(value)
     if number:
         return from_unix_seconds(number).date()
@@ -99,7 +102,7 @@ def parse_date(value: StrIntFloat) -> date:
     return date(**kw)
 
 
-def parse_time(value: StrIntFloat) -> time:
+def parse_time(value: Union[time, StrIntFloat]) -> time:
     """
     Parse a string and return a datetime.time.
 
@@ -108,6 +111,9 @@ def parse_time(value: StrIntFloat) -> time:
     Raise ValueError if the input is well formatted but not a valid time.
     Raise ValueError if the input isn't well formatted, in particular if it contains an offset.
     """
+    if isinstance(value, time):
+        return value
+
     match = time_re.match(value)
     if not match:
         raise ValueError('Invalid time format')
@@ -119,7 +125,7 @@ def parse_time(value: StrIntFloat) -> time:
     return time(**kw)
 
 
-def parse_datetime(value: StrIntFloat) -> datetime:
+def parse_datetime(value: Union[datetime, StrIntFloat]) -> datetime:
     """
     Parse a string and return a datetime.datetime.
 
diff --git a/pydantic/version.py b/pydantic/version.py
--- a/pydantic/version.py
+++ b/pydantic/version.py
@@ -2,4 +2,4 @@
 
 __all__ = ['VERSION']
 
-VERSION = StrictVersion('0.6.3')
+VERSION = StrictVersion('0.6.4')


Test patch:
diff --git a/tests/test_datetime_parse.py b/tests/test_datetime_parse.py
--- a/tests/test_datetime_parse.py
+++ b/tests/test_datetime_parse.py
@@ -25,6 +25,7 @@ def create_tz(minutes):
     (1494012444, date(2017, 5, 5)),
     ('2012-04-23', date(2012, 4, 23)),
     ('2012-4-9', date(2012, 4, 9)),
+    (date(2012, 4, 9), date(2012, 4, 9)),
     # Invalid inputs
     ('x20120423', ValueError),
     ('2012-04-56', ValueError),
@@ -43,6 +44,7 @@ def test_date_parsing(value, result):
     ('10:10', time(10, 10)),
     ('10:20:30.400', time(10, 20, 30, 400000)),
     ('4:8:16', time(4, 8, 16)),
+    (time(4, 8, 16), time(4, 8, 16)),
     # Invalid inputs
     ('091500', ValueError),
     ('09:15:90', ValueError),