Skip to content

Instantly share code, notes, and snippets.

@WincerChan
Created July 23, 2018 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WincerChan/6a37304b08ff223fe3a9de110a4772c0 to your computer and use it in GitHub Desktop.
Save WincerChan/6a37304b08ff223fe3a9de110a4772c0 to your computer and use it in GitHub Desktop.
from os import listdir
def main():
for file in listdir("./"):
if file.endswith('.md'):
single(file)
def single(file):
with open(file, 'r') as f:
lines = date_fmt(f.readlines())
with open(file, 'w') as f:
f.writelines(lines)
def date_fmt(lines):
for line in lines:
print(line)
if line.startswith('date:'):
time = line[6:].replace('\n', '').replace(
'\'', '').replace('/', '-').split(' ')
lines[lines.index(
line)] = "date: {}T{}+08:00\n".format(time[0], time[1])
return lines
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment