19 lines
601 B
Python
19 lines
601 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') |