Skip to content

Commit

Permalink
chore: wakatime script
Browse files Browse the repository at this point in the history
  • Loading branch information
zaida04 authored Jul 25, 2024
1 parent 7592e1a commit 9856254
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions waka/index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import json

## download from https://wakatime.com/settings/account?export=true

json_file_path = './data.json'
with open(json_file_path, 'r') as file:
data = json.load(file)

# { "2023": { "hours": 10, "minutes": 10 } }
d = {}
for obj in data["days"]:
year = obj["date"].split("-")[0]
grand_total = obj["grand_total"]

if year not in d:
d[year] = {
"hours": grand_total["hours"],
"minutes": grand_total["minutes"]
}
else:
d[year]["hours"] += grand_total["hours"]
d[year]["minutes"] += grand_total["minutes"]

for year in d:
hours = d[year]["hours"]
minutes = d[year]["minutes"]

hours += minutes // 60
minutes %= 60

d[year]["hours"] = hours
d[year]["minutes"] = minutes

print(d)

0 comments on commit 9856254

Please sign in to comment.