Conditionally accumulate rows

I have tabulatory data as follows

2020-01-01 | yes | 5
2020-01-01 | no  | 3
2020-01-02 | no  | 2
2020-01-03 | yes | 7
2020-01-10 | no  | 4
2020-01-11 | yes | 9
2020-01-12 | yes | 22

and I want to create a new “collapsed” or “accumulated” table from this.

The output should look as follows

           - 2020-01-01 | 5   //5
2020-01-01 - 2020-01-03 | 12  //3+2+7
2020-01-03 - 2020-01-11 | 13  //4+9
2020-01-11 - 2020-01-12 | 22  //22

I basically want to add all the values of rows with no to the next row with yes. And add the timeframe between these accumulated yes rows as a first column.

I’m not so experienced with spreadsheet calculations. Is this possible and if yes how?

I would prefer to have a solution that works in libre office calc, but I do also have access to microsoft excel.