﻿# 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..."
}
