Calculate work hours with Dataview based on inline-metadata in daily notes

What I’m trying to do

I’m trying to calculate my working hours based on my daily notes and dv-metadata for every different project and time-tracking bullet point.

This is what my time-tracking section in daily notes looks like:

:clock5: Zeiterfassung

  • 08:15-08:45 Did some stuff (project::“project1”)
  • 08:45-10:15 Did something (project::“project2”)
  • 08:45-10:15 Did another thing (project::“project3”)

Things I have tried

I’ve tried to modify the dataviejs-block here: How to calculate my work hours - #9 by xiuix

I’ve invested quite some time, but im not familiar with js. I got the right regex:

const project = x.text.match(/^\d{2}:\d{2}-\d{2}:\d{2}.project::(.)/)

But I don’t get all of the scripts functionality to embed the required feature.

I know it’s a lot, but maybe someone has some ideas?

I’m on mobile, so sorry if this is a little short, but to be able to get stuff out of the regex you’ll need to add grouping parentheses into it.

So if you do this:

const project =
x.text.match(/^(\d{2}:\d{2})-(\d{2}:\d{2}).project::(.*)/)

You’ll get an array back if it matches:

  • project[0] – The entire match
  • project[1] – The first match, the starting time
  • project[2] – The second match, the end time
  • project[3] – The third match, the rest of the line, related to the project field

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.