{"id":16566930,"url":"https://github.com/codaamok/psbusinesstime","last_synced_at":"2025-08-14T08:47:07.598Z","repository":{"id":44491050,"uuid":"479830193","full_name":"codaamok/PSBusinessTime","owner":"codaamok","description":"A PowerShell module with functions to help calculate working hours, and for generally working with or calculating business hours / date times.","archived":false,"fork":false,"pushed_at":"2022-10-05T13:26:31.000Z","size":86,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-05T21:06:32.462Z","etag":null,"topics":["business-hours","business-ti","calendar","dates","datetime","powershell","time","working-days","working-hours","working-time"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codaamok.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-09T19:56:53.000Z","updated_at":"2023-09-27T21:27:25.000Z","dependencies_parsed_at":"2023-01-19T06:45:32.662Z","dependency_job_id":null,"html_url":"https://github.com/codaamok/PSBusinessTime","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codaamok%2FPSBusinessTime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codaamok%2FPSBusinessTime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codaamok%2FPSBusinessTime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codaamok%2FPSBusinessTime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codaamok","download_url":"https://codeload.github.com/codaamok/PSBusinessTime/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238743961,"owners_count":19523209,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["business-hours","business-ti","calendar","dates","datetime","powershell","time","working-days","working-hours","working-time"],"created_at":"2024-10-11T21:05:07.532Z","updated_at":"2025-02-13T22:31:47.330Z","avatar_url":"https://github.com/codaamok.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PSBusinessTime\n\n| Branch | Build status | Last commit | Latest release | PowerShell Gallery | GitHub |\n|-|-|-|-|-|-|\n| `main` | [![GitHub Workflow Status (main)](https://img.shields.io/github/workflow/status/codaamok/PSBusinessTime/Pipeline/main)](https://github.com/codaamok/PSBusinessTime/actions) | [![GitHub last commit (branch)](https://img.shields.io/github/last-commit/codaamok/PSBusinessTime/main?color=blue)](https://github.com/codaamok/PSBusinessTime/commits/main) | [![GitHub release (latest by date)](https://img.shields.io/github/v/release/codaamok/PSBusinessTime?color=blue)](https://github.com/codaamok/PSBusinessTime/releases/latest) [![GitHub Release Date](https://img.shields.io/github/release-date/codaamok/PSBusinessTime?color=blue)](https://github.com/codaamok/PSBusinessTime/releases/latest) | [![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/PSBusinessTime?color=blue)](https://www.powershellgallery.com/packages/PSBusinessTime) | [![GitHub all releases](https://img.shields.io/github/downloads/codaamok/PSBusinessTime/total?color=blue)](https://github.com/codaamok/PSBusinessTime/releases) |\n\nA PowerShell module with functions to help calculate working hours, and for generally working with or calculating business hours / date times.\n\nInspired by https://pleasework.robbievance.net/howto-calculate-elapsed-business-hours-using-powershell/.\n\n## Functions\n\n- [Add-WorkingDays](docs/Add-WorkingDays.md)\n- [New-BusinessTimeSpan](docs/New-BusinessTimeSpan.md)\n- [Get-WorkingDates](docs/Get-WorkingDates.md)\n- [Test-WorkingDay](docs/Test-WorkingDay.md)\n\n## Requirements\n\n- PowerShell 5.1 or newer\n\n## Getting started\n\nInstall and import:\n\n```powershell\nInstall-Module PSBusinessTime -Scope CurrentUser\nImport-Module PSBusinessTime\n```\n\nSee the below examples and use `Get-Help` to learn more about the functions with examples. You can discover all functions in the module by running:\n\n```powershell\nGet-Command -Module PSBusinessTime\n```\n\n## Examples\n\n```powershell\nNew-BusinessTimeSpan -Start (Get-Date '2022-04-01 00:00:00') -End (Get-Date '2022-04-30 23:59:59') -NonWorkingDates (Get-Date '2022-04-15'), (Get-Date '2022-04-18')\n```\n\nThe function will return a timespan object of 171 hours:\n\n```powershell\nDays              : 7\nHours             : 3\nMinutes           : 0\nSeconds           : 0\nMilliseconds      : 0\nTicks             : 6156000000000\nTotalDays         : 7.125\nTotalHours        : 171\nTotalMinutes      : 10260\nTotalSeconds      : 615600\nTotalMilliseconds : 615600000\n```\n\n2022-04-01 through 2022-04-30 is an entire calendar month, and only 171 hours is considered \"working hours\" within the defined parameters. '2022-04-15' and '2022-04-18' are considered non-working dates.\n\n___\n\n```powershell\nTest-WorkingDay -Date (Get-Date '2022-04-11 09:00:00')\n```\n\nThe function will return `true` because the datetime is within the default parameters. 2022-04-11 is a Monday, and 09:00 is between 08:00 and 17:00.\n\n___\n\n```powershell\nGet-WorkingDates -Start (Get-Date '2022-04-04') -End (Get-Date '2022-04-17') -NonWorkingDaysOfWeek 'Saturday','Sunday','Monday'\n```\n\nThe function will return an array of 8 datetime objects for '2022-04-05' through to '2022-04-08', and '2022-04-12' through to '2022-04-15':\n\n```powershell\n05 April 2022 00:00:00\n06 April 2022 00:00:00\n07 April 2022 00:00:00\n08 April 2022 00:00:00\n12 April 2022 00:00:00\n13 April 2022 00:00:00\n14 April 2022 00:00:00\n15 April 2022 00:00:00\n```\n\nThese are considered working dates within the defined parameters. Saturdays, Sundays, and Mondays, are considered non-working days, therefore every other date inbetween the range is considered a working date.\n\n## To-do\n\n- Use some public API for public holidays\n- Allow configurable 'lunch hour' and so it respects the designated time period, too, e.g.\n  - if start date is 8am and end date is 5pm, and 'lunch hour' time period is 12pm - 1pm, then working hours is 8.\n  - if start date is 12pm and end date is 5pm, and 'lunch hour' time period is 12pm - 1pm, then working hours is 4.\n- Allow config for specifying days with different working hours, e.g. perhaps specific dates of the month or year might be 4 or 5 working hours rather than 8 or 9, which is generally days like Christmas Eve is most western countries\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodaamok%2Fpsbusinesstime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodaamok%2Fpsbusinesstime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodaamok%2Fpsbusinesstime/lists"}