Skip to content

Commit 89d0919

Browse files
author
atollk
committed
fs._ftp_parse, removed some code that was only assumed to be necessary due to incomplete documentation
The standard library function `time.strptime` using the format "%H" was falsely assumed to require a two-digit number (00-23). As it turns out, one-digit numbers (0-9) are also valid, so we don't have to manually prepend a zero.
1 parent d1997ba commit 89d0919

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

fs/_ftp_parse.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,8 @@ def decode_linux(line, match):
149149
return raw_info
150150

151151

152-
def _decode_windowsnt_time(mdate, mtime):
153-
if len(mtime.split(":")[0]) == 1:
154-
mtime = "0" + mtime
155-
return _parse_time(
156-
mdate + " " + mtime, formats=["%d-%m-%y %I:%M%p", "%d-%m-%y %H:%M"]
157-
)
152+
def _decode_windowsnt_time(mtime):
153+
return _parse_time(mtime, formats=["%d-%m-%y %I:%M%p", "%d-%m-%y %H:%M"])
158154

159155

160156
def decode_windowsnt(line, match):
@@ -183,7 +179,7 @@ def decode_windowsnt(line, match):
183179
raw_info["details"]["size"] = int(match.group("size"))
184180

185181
modified = _decode_windowsnt_time(
186-
match.group("modified_date"), match.group("modified_time")
182+
match.group("modified_date") + " " + match.group("modified_time")
187183
)
188184
if modified is not None:
189185
raw_info["details"]["modified"] = modified

0 commit comments

Comments
 (0)