Eventboard_v_2.0/digit_converter.py
2022-02-17 15:56:49 +01:00

22 lines
604 B
Python

# Digit converter
import json
def digit_convert(filename):
with open(filename, 'r') as file:
data = json.load(file)
for i in data:
if len(i['date']['day']) != 2:
i['date']['day'] = str('{:02d}'.format(i['date']['day']))
with open('events.json', 'w') as file:
json.dump(data, file, indent=2)
if len(i['date']['month']) != 2:
i['date']['month'] = str('{:02d}'.format(i['date']['month']))
with open('events.json', 'w') as file:
json.dump(data, file, indent=2)
digit_convert('events.json')