Merge pull request #139 from mocchapi/logviewer-fix
fix filename date handling in logviewer
This commit is contained in:
commit
013dd5a635
1 changed files with 10 additions and 4 deletions
14
logviewer.py
14
logviewer.py
|
@ -326,13 +326,19 @@ class PesterLogViewer(QtWidgets.QDialog):
|
|||
self.hilight.rehighlight()
|
||||
|
||||
def fileToMonthYear(self, fname):
|
||||
time = strptime(
|
||||
fname[(fname.index(".") + 1) : fname.index(".txt")], "%Y-%m-%d.%H.%M"
|
||||
)
|
||||
time = strptime(fname[-20:-4], "%Y-%m-%d.%H.%M")
|
||||
# #pesterchum.online.2023-05-27.00.54.txt
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
# Doesnt raise an exception if the memo name has one or more periods like the old one
|
||||
# But also is not as dynamic. Could also be solved by a regex or counting how many periods are in there total,
|
||||
# but this seemed like a simple approach, assuming the format doesnt change anytime soon, which seems unlikely :P
|
||||
# Also doesnt fail if a memo contains ".txt" like the old way
|
||||
# old fromat -> fname[(fname.index(".") + 1) : fname.index(".txt")], "%Y-%m-%d.%H.%M"
|
||||
# ~ (lis)anne
|
||||
return [strftime("%B", time), strftime("%Y", time)]
|
||||
|
||||
def fileToTime(self, fname):
|
||||
timestr = fname[(fname.index(".") + 1) : fname.index(".txt")]
|
||||
timestr = fname[-20:-4]
|
||||
return strftime("%a %d %b %Y %H %M", strptime(timestr, "%Y-%m-%d.%H.%M"))
|
||||
|
||||
def timeToFile(self, time):
|
||||
|
|
Loading…
Reference in a new issue