Localized the time formats with locale module and corrected some hard coded formats to %x. After correcting dates in regard to this in the articles' txt-files everything worked wonderfully.
This commit is contained in:
parent
45c0ab82f2
commit
4c712c2e20
|
@ -1,9 +1,10 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import os,re,time,getpass,subprocess,markdown
|
||||
import os,re,locale,time,getpass,subprocess,markdown
|
||||
from string import Template
|
||||
from argparse import ArgumentParser
|
||||
|
||||
|
||||
########################################
|
||||
# UI - check for arguments and options #
|
||||
########################################
|
||||
|
@ -157,6 +158,8 @@ except:
|
|||
print("Couldn't parse localization file (%s)."%l10nconfpath)
|
||||
raise
|
||||
|
||||
locale.setlocale(locale.LC_ALL,os.environ['LANG'])
|
||||
# print(time.strftime("%x",time.localtime()))
|
||||
|
||||
########################
|
||||
# Templating functions #
|
||||
|
@ -262,7 +265,7 @@ def recent_articles(amount):
|
|||
for name in [os.path.splitext(item)[0] for item in os.listdir(artDir) if not "~" in item]:
|
||||
article = (parse_article(os.path.join(artDir, name + ".txt")))
|
||||
# Bring articles into chronological order
|
||||
t = time.mktime(time.strptime(article['DATE'] + " " + article['TIME'], "%m/%d/%y %H:%M:%S"))
|
||||
t = time.mktime(time.strptime(article['DATE'] + " " + article['TIME'], "%x %H:%M:%S"))
|
||||
articles_dict[str(t)] = article
|
||||
dates_of_creation = [float(value) for value in articles_dict.keys()]
|
||||
dates_of_creation.sort(key=None,reverse=True)
|
||||
|
@ -280,7 +283,7 @@ def archive_articles():
|
|||
for article in articles:
|
||||
aName = article["FILENAME"]
|
||||
aPath = os.path.join(article["PATH"], aName)
|
||||
aDate = time.strptime(article["DATE"],"%m/%d/%y")
|
||||
aDate = time.strptime(article["DATE"],"%x")
|
||||
aMonth = aDate.tm_mon
|
||||
aYear = aDate.tm_year
|
||||
|
||||
|
@ -330,7 +333,7 @@ def list_articles(folder):
|
|||
for name in [os.path.splitext(item)[0] for item in os.listdir(folder) if not "~" in item]:
|
||||
article = (parse_article(os.path.join(folder, name + ".txt")))
|
||||
# Bring articles into chronological order
|
||||
t = time.mktime(time.strptime(article['DATE'] + " " + article['TIME'], "%m/%d/%y %H:%M:%S"))
|
||||
t = time.mktime(time.strptime(article['DATE'] + " " + article['TIME'], "%x %H:%M:%S"))
|
||||
articles_dict[str(t)] = article
|
||||
|
||||
return articles_dict
|
||||
|
|
Loading…
Reference in New Issue