PoshCode Archive  Artifact [fd460548e2]

Artifact fd460548e291ae3d75c0a2682358adf3a832559b5a69e1c75f0e81f5d4b18ec3:

  • File Productivity-Calculator.ps1 — part of check-in [33d6d04e7f] at 2018-06-10 13:01:52 on branch trunk — This short script converts Time settings and displays a “productivity” Report with a goal of 81%. (user: mazakane size: 1463)

# encoding: utf-8
# api: powershell
# title: Productivity Calculator
# description: This short script converts Time settings and displays a “productivity” Report with a goal of 81%.
# version: 0.1
# type: script
# author: mazakane
# license: CC0
# function: get-Productivity
# x-poshcode-id: 1833
# x-archived: 2015-08-05T01:27:16
# x-published: 2010-05-11T07:24:00
#
# Feel free to modify and adapt to your demands.
#
<#
Author: mazakane
This short script converts Time settings and displays a "productivity" Report with a goal of 81%

Example:
get-productivity -Start 8:00 -End 17:00
#>

function get-Productivity{
  param(
     $start,
     $end
     )
$a = ([datetime]::Parse("$start"))
$b = ([datetime]::Parse("$end"))
$lb = "0:30" #(Half an hour Break for lunch)
$Wrk = ($b-$a)

if (($Wrk.TotalHours) -gt "6") { $worktime = (($b - $a) - $lb)		#this is special in my company, if you work less than 6 hours the lunch break isn´t going to be substracted.
Write-Host "`nTotal working hours without Lunch break: $worktime`n" 
                              }
else {$worktime = ($b - $a)
Write-Host "`nTotal working hours including Lunch break: $worktime`n" 
      }
$total = [int]$worktime.TotalMinutes 

# This formula gets the minimum hours at which count you are at least 81% productive.
 
$prod = (($total*81)/100)/60 
 
Write-warning "`nTo be 81% productive you need to work at least: $prod hours..."
}