Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f7bb72e

Browse filesBrowse files
committed
Prefer early return and less indention
1 parent c70564f commit f7bb72e
Copy full SHA for f7bb72e

File tree

Expand file treeCollapse file tree

1 file changed

+21
-21
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+21
-21
lines changed

‎MySQLdb/times.py

Copy file name to clipboardExpand all lines: MySQLdb/times.py
+21-21Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,28 @@ def DateTime_or_None(s):
5151
try:
5252
if len(s) < 11:
5353
return Date_or_None(s)
54+
55+
micros = s[20:]
56+
57+
if len(micros) == 0:
58+
# 12:00:00
59+
micros = 0
60+
elif len(micros) < 7:
61+
# 12:00:00.123456
62+
micros = int(micros) * 10 ** (6 - len(micros))
5463
else:
55-
micros = s[20:]
56-
57-
if len(micros) == 0:
58-
# 12:00:00
59-
micros = 0
60-
elif len(micros) < 7:
61-
# 12:00:00.123456
62-
micros = int(micros) * 10 ** (6 - len(micros))
63-
else:
64-
# 12:00:00.123456789
65-
micros = int(micros)
66-
67-
return datetime(
68-
int(s[:4]), # year
69-
int(s[5:7]), # month
70-
int(s[8:10]), # day
71-
int(s[11:13] or 0), # hour
72-
int(s[14:16] or 0), # minute
73-
int(s[17:19] or 0), # second
74-
micros, # microsecond
75-
)
64+
# 12:00:00.123456789
65+
micros = int(micros)
66+
67+
return datetime(
68+
int(s[:4]), # year
69+
int(s[5:7]), # month
70+
int(s[8:10]), # day
71+
int(s[11:13] or 0), # hour
72+
int(s[14:16] or 0), # minute
73+
int(s[17:19] or 0), # second
74+
micros, # microsecond
75+
)
7676
except ValueError:
7777
return None
7878

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.