events
= await CalendarEvent
.today()
var found
= false
var count
= 0
var m_dict
= {
"time":0,
"tomato":0,
"detail":{}
}
var reg
= /\d+/
var allDayevent
= null
var cal
= null
for (e
of events
)
{
console
.log(e
.title
)
if(e
.title
.indexOf("⏰") != -1 || e
.title
.indexOf("♨️") != -1)
{
e
.remove()
}
if(e
.title
.indexOf("🍅") != -1 )
{
cal
= e
.calendar
num
= parseInt(reg
.exec(e
.notes
))
minute
= (e
.endDate
-e
.startDate
)/1000/60
m_dict
["time"] += minute
if(!m_dict
["detail"][e
.title
])
{
m_dict
["detail"][e
.title
] = minute
}
else
{
m_dict
["detail"][e
.title
]+= minute
}
}
if(e
.title
=="🌈今日番茄统计")
{
found
= true
allDayevent
=e
}
}
if(!found
)
{
allDayevent
= new CalendarEvent()
allDayevent
.title
= "🌈今日番茄统计"
allDayevent
.isAllDay
= true
}
console
.log(m_dict
)
var str
= ""
str
+= "今日专注时长:"+m_dict
["time"]+"min\n"
tomato
= Math
.trunc(m_dict
["time"]/20)
str
+= "获得番茄数:"+tomato
+"个🍅\n"
str
+= "详情🔎:"+"\n"
for(item
in m_dict
["detail"])
{
str
+=item
+":"+m_dict
["detail"][item
]+"min\n"
}
console
.log("\n"+str
)
allDayevent
.notes
= str
if(cal
)
{
allDayevent
.calendar
= cal
allDayevent
.save()
}
Script
.complete()
转载请注明原文地址:https://tech.qufami.com/read-1718.html