tunnit

calculates number of hours for a text file

Usage no npm install needed!

<script type="module">
  import tunnit from 'https://cdn.skypack.dev/tunnit';
</script>

README

tunnit Build Status npm version

calculates number of hours for a text file

npm install -g tunnit

intro

assuming work.txt

22.01.2014 09:30-16:45
23.01.2014 09:30-14:30
24.01.2014 08:30-17:00
$ tunnit < work.txt
22.01.2014 09:30-16:45 7:15
23.01.2014 09:30-14:30 5:00
24.01.2014 08:30-17:00 8:30

customization

you can easily add custom rules and logic

~/.config/tunnit.js

module.exports = {
  // :: adjust(mins: Number, line: String): Number
  adjust: function(mins, line) {
    // you can parse `line` here and adjust `mins` based on that.
    // subtract 30 minutes for each day because i had lunch
    return mins - 30;
  },

  // :: mapOutputLine(line: String): String
  mapOutputLine: function(line) {
    // make changes to line right before it is printed.
    // line contains duration at this point
    return line;
  }
};

see another, more involved example config