Easily get info about your work time and when you can go home


Keywords
timer, gohome, work time, saldo, hours, minutes, time, work, working, works
License
MIT
Install
npm install gohome@3.2.7

Documentation

gohome

This project can calculate your actual work time and show you when you can go home. Your first run will save your start working time and the next run will load time from the saved previous time.

demo

NPM npm npm GitHub code size in bytes GitHub repo size Coverage badge


Installation:

npm i gohome -g

Example running:

gohome 8:00
gohome 08:00
gohome 12:11

You can use this package for your next solution like this:

const { gohome } = require('gohome');
const output = gohome(
  '8:00', // timeStartWork,
  8, // timeWorkMaxHours,
  6, // timeWorkMinHours,
  30 // timeLaunchMinutes
);

If you want define your current hours and minutes it is possible like this:

const { gohome } = require('gohome');
const output = gohome(
  '8:00', // timeStartWork,
  8, // timeWorkMaxHours,
  6, // timeWorkMinHours,
  30, // timeLaunchMinutes,
  10, // actual hours,
  0 // actual minutes,
);

If you want check your start working time before running gohome function you can use this:

const { gohome, isValidInput } = require('gohome');
const timeStartWork = '8:00';
const isValid = isValidInput(timeStartWork);

isValid
  ? gohome(
      timeStartWork, // timeStartWork,
      8, // timeWorkMaxHours,
      6, // timeWorkMinHours,
      30 // timeLaunchMinutes
    )
  : console.error(`This start working time is not valid: ${timeStartWork}`);

Expected incorrect result will be show in your console like this:

Alt 1

Expected correct result if you defined correct start working time:

Alt 2

Expected correct result if you worked 6 hours:

Alt 2

Expected correct result if you worked more than 8 hours:

Alt 2