Skip to content

Commit 81e90ba

Browse files
Merge pull request #20 from bjoernhaeuser/master
MySQL Broken Dates :(
2 parents b674611 + 64dd660 commit 81e90ba

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pymysqlreplication/row_event.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,17 @@ def __read_date(self):
203203
if time == 0: # nasty mysql 0000-00-00 dates
204204
return None
205205

206+
year = (time & ((1 << 15) - 1) << 9) >> 9
207+
if year == 0:
208+
return None
209+
210+
month = (time & ((1 << 4) - 1) << 5) >> 5
211+
day = (time & ((1 << 5) - 1))
212+
206213
date = datetime.date(
207-
year=(time & ((1 << 15) - 1) << 9) >> 9,
208-
month=(time & ((1 << 4) - 1) << 5) >> 5,
209-
day=(time & ((1 << 5) - 1))
214+
year=year,
215+
month=month,
216+
day=day
210217
)
211218
return date
212219

0 commit comments

Comments
 (0)