| 70 | return datetime.date(*map(int, val.split(b"-"))) |
| 71 | |
| 72 | def convert_timestamp(val): |
| 73 | warn(msg.format(what="timestamp converter"), DeprecationWarning, stacklevel=2) |
| 74 | datepart, timepart = val.split(b" ") |
| 75 | year, month, day = map(int, datepart.split(b"-")) |
| 76 | timepart_full = timepart.split(b".") |
| 77 | hours, minutes, seconds = map(int, timepart_full[0].split(b":")) |
| 78 | if len(timepart_full) == 2: |
| 79 | microseconds = int('{:0<6.6}'.format(timepart_full[1].decode())) |
| 80 | else: |
| 81 | microseconds = 0 |
| 82 | |
| 83 | val = datetime.datetime(year, month, day, hours, minutes, seconds, microseconds) |
| 84 | return val |
| 85 | |
| 86 | |
| 87 | register_adapter(datetime.date, adapt_date) |