#! /usr/bin/env python3
# Tinylog RFC: https://codeberg.org/bacardi55/gemini-tinylog-rfc
# Should work better with some "weird" date formats than the built-ins
from dateutil import parser
# Test
#dt = parser.parse("Wed 16 Apr 2025 08:35 PM CEST")
#print(dt.strftime("%Y-%m-%d %H:%M %z"))
olines = []
# I copied my tinylog.gmi to tli.gmi (TL input) The result will be
# stored in tlo.gmi (TL output) and I copied it back into my gemini
# folder
with open("tli.gmi", "r") as ifile:
ilines = ifile.readlines()
for iline in ilines:
if iline.startswith("## "):
dt = parser.parse(iline.rstrip().replace('## ',''))
olines.append(dt.strftime("## %Y-%m-%d %H:%M %z"))
else:
olines.append(iline.rstrip())
with open("tlo.gmi", "w") as ofile:
ofile.write("\n".join(olines))