-
Notifications
You must be signed in to change notification settings - Fork 29
/
Add-TimeSpan.ps1
30 lines (23 loc) · 726 Bytes
/
Add-TimeSpan.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<#
.SYNOPSIS
Adds a timespan to DateTime values.
.DESCRIPTION
This is a more PowerShell-idiomatic, pipeline-based way to add a timespan to a datetime.
.INPUTS
System.DateTime values to add the TimeSpan value to.
.OUTPUTS
System.DateTime values with the TimeSpan added.
.FUNCTIONALITY
Date and time
.EXAMPLE
Get-Date |Add-TimeSpan.ps1 00:00:30
Adds 30 seconds to the current date and time value.
#>
#Requires -Version 3
[CmdletBinding()][OutputType([DateTime])] Param(
# The TimeSpan value to add.
[Parameter(Mandatory=$true)][TimeSpan]$TimeSpan,
# The DateTime value to add to.
[Parameter(Mandatory=$true,ValueFromPipeline=$true)][DateTime]$DateTime
)
Process{$DateTime.Add($TimeSpan)}