├── .github
└── workflows
│ └── build.yml
├── .gitignore
├── LICENSE
├── Publish
└── PublishToPSGallery.ps1
├── README.md
├── Source
├── Classes
│ ├── DateTimeExtended.ps1
│ ├── DateTimeFormats.ps1
│ ├── GroupTimeSpan.ps1
│ ├── SunTime.ps1
│ ├── TimeSpanMeasureInfo.ps1
│ └── TimeZoneConversion.ps1
├── Formatting
│ ├── DateTimeExtended.format.ps1
│ ├── SunTime.format.ps1
│ └── TimeSpanMeasureInfo.format.ps1
├── PSDates.EzFormat.ps1
├── PSDates.format.ps1xml
├── PSDates.psd1
├── PSDates.psm1
├── Public
│ ├── Convert-TimeZone.ps1
│ ├── Convert-ToDateTime.ps1
│ ├── ConvertFrom-UnixTime.ps1
│ ├── ConvertFrom-WmiDateTime.ps1
│ ├── ConvertTo-UnixTime.ps1
│ ├── ConvertTo-WmiDateTime.ps1
│ ├── Find-TimeZone.ps1
│ ├── Get-CronDescription.ps1
│ ├── Get-CronNextOccurrence.ps1
│ ├── Get-DateExtended.ps1
│ ├── Get-DateFormat.ps1
│ ├── Get-Easter.ps1
│ ├── Get-PatchTuesday.ps1
│ ├── Get-SunTime.ps1
│ ├── Group-TimeSpan.ps1
│ ├── Measure-TimeSpan.ps1
│ ├── New-Duration.ps1
│ └── Test-CrontabSchedule.ps1
├── Resources
│ ├── ArgumentCompleters.ps1
│ ├── CronExpressionDescriptor.dll
│ ├── DateTimeExtensions.format.ps1xml
│ ├── NCrontab.dll
│ ├── cronexpressiondescriptor.2.33.0
│ │ ├── .signature.p7s
│ │ ├── CronExpressionDescriptor.nuspec
│ │ ├── [Content_Types].xml
│ │ ├── _rels
│ │ │ └── .rels
│ │ ├── cronexpressiondescriptor.2.33.0.nupkg
│ │ ├── icon.png
│ │ ├── lib
│ │ │ ├── net6.0
│ │ │ │ ├── CronExpressionDescriptor.dll
│ │ │ │ ├── cs-CZ
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── da
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── de
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── es-MX
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── es
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── fa
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── fi
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── fr
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── he-IL
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── hu
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── it
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── ja
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── ko
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── nb
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── nl
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── pl
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── pt
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── ro
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── ru
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── sl
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── sv
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── tr
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── uk
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── vi
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── zh-Hans
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ └── zh-Hant
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ ├── netstandard1.1
│ │ │ │ ├── CronExpressionDescriptor.dll
│ │ │ │ ├── cs-CZ
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── da
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── de
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── es-MX
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── es
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── fa
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── fi
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── fr
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── he-IL
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── hu
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── it
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── ja
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── ko
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── nb
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── nl
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── pl
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── pt
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── ro
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── ru
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── sl
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── sv
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── tr
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── uk
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── vi
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── zh-Hans
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ └── zh-Hant
│ │ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ └── netstandard2.0
│ │ │ │ ├── CronExpressionDescriptor.dll
│ │ │ │ ├── cs-CZ
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── da
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── de
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── es-MX
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── es
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── fa
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── fi
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── fr
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── he-IL
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── hu
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── it
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── ja
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── ko
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── nb
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── nl
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── pl
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── pt
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── ro
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── ru
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── sl
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── sv
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── tr
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── uk
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── vi
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ ├── zh-Hans
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ │ │ └── zh-Hant
│ │ │ │ └── CronExpressionDescriptor.resources.dll
│ │ └── package
│ │ │ └── services
│ │ │ └── metadata
│ │ │ └── core-properties
│ │ │ └── 35b01ef7a16d4028afa8d3b651d30093.psmdcp
│ └── ncrontab.3.3.0
│ │ ├── COPYING.txt
│ │ ├── lib
│ │ ├── net35
│ │ │ └── NCrontab.dll
│ │ └── netstandard1.0
│ │ │ └── NCrontab.dll
│ │ ├── lic
│ │ └── OpenSymphony.txt
│ │ └── ncrontab.3.3.0.nupkg
└── Test
│ ├── Public
│ ├── Convert-TimeZone.Tests.ps1
│ ├── Convert-ToDateTime.Tests.ps1
│ ├── ConvertFrom-UnixTime.Tests.ps1
│ ├── ConvertFrom-WmiDateTime.Tests.ps1
│ ├── ConvertTo-UnixTime.Tests.ps1
│ ├── ConvertTo-WmiDateTime.Tests.ps1
│ ├── Find-TimeZone.Tests.ps1
│ ├── Get-CronDescription.Tests.ps1
│ ├── Get-CronNextOccurrence.Tests.ps1
│ ├── Get-DateExtended.Tests.ps1
│ ├── Get-DateFormat.Tests.ps1
│ ├── Get-Easter.Tests.ps1
│ ├── Get-PatchTuesday.Tests.ps1
│ ├── Get-SunTime.Tests.ps1
│ ├── Group-TimeSpan.Tests.ps1
│ ├── Measure-TimeSpan.Tests.ps1
│ ├── New-Duration.Tests.ps1
│ └── Test-CrontabSchedule.Tests.ps1
│ └── ScriptAnalyzer
│ ├── PSScriptAnalyzerSettings.psd1
│ └── ScriptAnalyzer.Linter.ps1
├── build-docs.ps1
├── build.ps1
├── docs
├── Convert-TimeZone.md
├── Convert-ToDateTime.md
├── ConvertFrom-UnixTime.md
├── ConvertFrom-WmiDateTime.md
├── ConvertTo-UnixTime.md
├── ConvertTo-WmiDateTime.md
├── Find-TimeZone.md
├── Get-CronDescription.md
├── Get-CronNextOccurrence.md
├── Get-DateExtended.md
├── Get-DateFormat.md
├── Get-Easter.md
├── Get-PatchTuesday.md
├── Get-SunTime.md
├── Group-TimeSpan.md
├── Measure-TimeSpan.md
├── New-Duration.md
└── Test-CrontabSchedule.md
└── test-build.ps1
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: build module
2 |
3 | on:
4 | push:
5 | branches: [ "main" ]
6 | pull_request:
7 | branches: [ "main" ]
8 |
9 | jobs:
10 | build-module:
11 | name: Run build and upload artifacts
12 | runs-on: windows-latest
13 | steps:
14 | - uses: actions/checkout@v4
15 | with:
16 | fetch-tags: true
17 | fetch-depth: 0
18 |
19 | - name: Install Modules
20 | shell: pwsh
21 | run: |
22 | Set-PSRepository PSGallery -InstallationPolicy Trusted
23 | Install-Module ModuleBuilder,PSScriptAnalyzer,EZOut
24 | Install-Module Pester -MinimumVersion 5.5.0
25 |
26 | - name: Run build
27 | shell: pwsh
28 | run: |
29 | $Version = git describe --tags --abbrev=0
30 | Write-Host "Version : $Version"
31 | .\build.ps1 -Version $Version
32 |
33 | - name: Upload artifacts
34 | uses: actions/upload-artifact@v3
35 | with:
36 | name: my-build
37 | path: Build
38 |
39 | test-module:
40 | needs: build-module
41 | name: Test Module
42 | runs-on: ${{ matrix.os }}
43 | strategy:
44 | matrix:
45 | os: [ubuntu-latest, windows-latest]
46 | steps:
47 | - uses: actions/checkout@v4
48 | - uses: actions/download-artifact@v3
49 | with:
50 | name: my-build
51 | path: Build
52 |
53 | - name: Install Modules
54 | shell: pwsh
55 | run: |
56 | Set-PSRepository PSGallery -InstallationPolicy Trusted
57 | Install-Module Pester -MinimumVersion 5.5.0
58 |
59 | - name: Test build
60 | shell: pwsh
61 | run: .\test-build.ps1
62 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Publish/APIKey.json
2 | Publish/PSDates/
3 | Build/
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Matthew Dowst
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Publish/PublishToPSGallery.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | Run build.ps1 first
3 | #>
4 |
5 | # Script variables
6 | $TopLevel = (Split-Path $PSScriptRoot)
7 | $NugetAPIKey = Get-Content (Join-Path $PSScriptRoot 'APIKey.json')
8 |
9 | Set-Location $TopLevel
10 |
11 | $testResultsXML = Join-Path $TopLevel 'Build\testResults.xml'
12 | $config = New-PesterConfiguration
13 | $config.Run.Path = (Join-Path $TopLevel 'Source\Test')
14 | $config.TestResult.Enabled = $true
15 | $config.TestResult.OutputPath = $testResultsXML
16 | Invoke-Pester -Configuration $config
17 | [xml]$testResults = Get-Content -LiteralPath $testResultsXML -Raw
18 | if($testResults.'test-results'.'test-suite'.result -eq 'Failure'){
19 | $testResults.'test-results'.'test-suite'.results.'test-suite' | Select-Object Name, result
20 | throw "Failed Pester tests"
21 | }
22 |
23 | # Get the module manifest
24 | $psd1File = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
25 | $psd1 = Test-ModuleManifest $psd1File
26 | Read-Host "Publish version '$($psd1.Version)'"
27 |
28 | # Publish to powershell gallery
29 | Publish-Module -Path $psd1File.DirectoryName -NugetAPIKey $NugetAPIKey -Verbose
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PSDates
2 |
3 | PSDates provides you all the tools you need when working with dates and times in PowerShell. It contains function to help you find specific date formats, get certain dates based on other dates (first/last day of the month or year, patch Tuesday, etc). I also has functions for working with timezones, unix time, WMI time, crontabs.
4 |
5 | # Installation
6 |
7 | ```powershell
8 | Install-Module PSDates
9 | ```
10 |
11 | # Commands
12 |
13 | | Cmdlet | Synopsis |
14 | | ------ | -------- |
15 | | [Convert-TimeZone](docs/Convert-TimeZone.md) | Convert a datetime value from one time zone to another |
16 | | [Convert-ToDateTime](docs/Convert-ToDateTime.md) | Converts various input objects to a DateTime object. |
17 | | [ConvertFrom-UnixTime](docs/ConvertFrom-UnixTime.md) | Converts a Unix Time value to a datetime value |
18 | | [ConvertFrom-WmiDateTime](docs/ConvertFrom-WmiDateTime.md) | Converts a Wmi Time value to a datetime value |
19 | | [ConvertTo-UnixTime](docs/ConvertTo-UnixTime.md) | Converts a datetime value to Unix Time |
20 | | [ConvertTo-WmiDateTime](docs/ConvertTo-WmiDateTime.md) | Converts a datetime value to a Wmi datetime string |
21 | | [Find-TimeZone](docs/Find-TimeZone.md) | Returns Time Zone information |
22 | | [Get-CronDescription](docs/Get-CronDescription.md) | Convert a cron expression into a human readable description |
23 | | [Get-CronNextOccurrence](docs/Get-CronNextOccurrence.md) | Get the next occurrence for a crontab |
24 | | [Get-DateExtended](docs/Get-DateExtended.md) | Gets additional extended date values that are not included by default with the Get-Date cmdlet |
25 | | [Get-DateFormat](docs/Get-DateFormat.md) | Returns common date and time formats |
26 | | [Get-Easter](docs/Get-Easter.md) | This function offers a generic Easter computing method for any given year, using Western, Orthodox or Julian algorithms. |
27 | | [Get-PatchTuesday](docs/Get-PatchTuesday.md) | Returns the second Tuesday of the month |
28 | | [Get-SunTime](docs/Get-SunTime.md) | Find sunrise and sunset times for any location on planet Earth. |
29 | | [Group-TimeSpan](docs/Group-TimeSpan.md) | Groups objects by a specified time span. |
30 | | [Measure-TimeSpan](docs/Measure-TimeSpan.md) | Measures statistical properties (such as sum, average, and maximum) of a specified property within grouped time spans. |
31 | | [New-Duration](docs/New-Duration.md) | Calculates the time span between two dates and returns the duration in the ISO 8601 format |
32 | | [Test-CrontabSchedule](docs/Test-CrontabSchedule.md) | Tests that a crontab string is valid |
33 |
34 |
--------------------------------------------------------------------------------
/Source/Classes/DateTimeExtended.ps1:
--------------------------------------------------------------------------------
1 | class DateTimeExtended {
2 | [datetime]$DateTime
3 | [datetime]$FirstDayOfYear
4 | [datetime]$LastDayOfYear
5 | [datetime]$StartOfWeek
6 | [datetime]$EndOfWeek
7 | [datetime]$StartOfMonth
8 | [datetime]$EndOfMonth
9 | [string]$WeekOfYear
10 | [System.TimeZoneInfo]$TimeZone
11 | [int]$Quarter
12 | [datetime]$Date
13 | [int]$Day
14 | [System.DayOfWeek]$DayOfWeek
15 | [int]$DayOfYear
16 | [int]$Hour
17 | [System.DateTimeKind]$Kind
18 | [int]$Millisecond
19 | [int]$Minute
20 | [int]$Month
21 | [int]$Second
22 | [long]$Ticks
23 | [timespan]$TimeOfDay
24 | [int]$Year
25 |
26 | DateTimeExtended(
27 | [DateTime]$Date
28 | ) {
29 | $local:StartOfWeek = Get-Date $date -hour 0 -minute 0 -second 0
30 | $local:EndOfWeek = Get-Date $date -hour 23 -minute 59 -second 59
31 | $local:StartOfMonth = Get-Date $date -day 1 -hour 0 -minute 0 -second 0
32 |
33 | $this.DateTime = $Date
34 | $this.FirstDayOfYear = (Get-Date $date -hour 0 -minute 0 -second 0 -Day 1 -Month 1)
35 | $this.LastDayOfYear = (Get-Date $date -hour 0 -minute 0 -second 0 -Day 31 -Month 12)
36 | $this.StartOfWeek = ($StartOfWeek.AddDays( - ($StartOfWeek).DayOfWeek.value__))
37 | $this.EndOfWeek = ($EndOfWeek.AddDays(6 - ($StartOfWeek).DayOfWeek.value__))
38 | $this.StartOfMonth = ($StartOfMonth)
39 | $this.EndOfMonth = ((($StartOfMonth).AddMonths(1).AddSeconds(-1)))
40 | $this.WeekOfYear = (Get-Date $date -uformat %V)
41 | $this.TimeZone = ([System.TimeZoneInfo]::Local)
42 | $this.Quarter = [Math]::ceiling($Date.Month / 3)
43 | $this.Date = $Date.Date
44 | $this.Day = $Date.Day
45 | $this.DayOfWeek = $Date.DayOfWeek
46 | $this.DayOfYear = $Date.DayOfYear
47 | $this.Hour = $Date.Hour
48 | $this.Kind = $Date.Kind
49 | $this.Millisecond = $Date.Millisecond
50 | $this.Minute = $Date.Minute
51 | $this.Month = $Date.Month
52 | $this.Second = $Date.Second
53 | $this.Ticks = $Date.Ticks
54 | $this.TimeOfDay = $Date.TimeOfDay
55 | $this.Year = $Date.Year
56 | }
57 |
58 | # wrapper for the different datetime methods
59 | # had to be don this way since the datetime struct is sealed
60 | [DateTimeExtended] Add([timespan] $value) {
61 | Return [DateTimeExtended]::New($this.DateTime.Add($value))
62 | }
63 |
64 | [DateTimeExtended] AddDays([double] $value) {
65 | Return [DateTimeExtended]::New($this.DateTime.AddDays($value))
66 | }
67 |
68 | [DateTimeExtended] AddHours([double] $value) {
69 | Return [DateTimeExtended]::New($this.DateTime.AddHours($value))
70 | }
71 |
72 | [DateTimeExtended] AddMilliseconds([double] $value) {
73 | Return [DateTimeExtended]::New($this.DateTime.AddMilliseconds($value))
74 | }
75 |
76 | [DateTimeExtended] AddMinutes([double] $value) {
77 | Return [DateTimeExtended]::New($this.DateTime.AddMinutes($value))
78 | }
79 |
80 | [DateTimeExtended] AddMonths([int] $value) {
81 | Return [DateTimeExtended]::New($this.DateTime.AddMonths($value))
82 | }
83 |
84 | [DateTimeExtended] AddSeconds([double] $value) {
85 | Return [DateTimeExtended]::New($this.DateTime.AddSeconds($value))
86 | }
87 |
88 | [DateTimeExtended] AddTicks([long] $value) {
89 | Return [DateTimeExtended]::New($this.DateTime.AddTicks($value))
90 | }
91 |
92 | [DateTimeExtended] AddYears([int] $value) {
93 | Return [DateTimeExtended]::New($this.DateTime.AddYears($value))
94 | }
95 |
96 | [DateTimeExtended] ToLocalTime() {
97 | Return [DateTimeExtended]::New($this.DateTime.ToLocalTime())
98 | }
99 |
100 | [DateTimeExtended] ToUniversalTime() {
101 | Return [DateTimeExtended]::New($this.DateTime.ToUniversalTime())
102 | }
103 | }
--------------------------------------------------------------------------------
/Source/Classes/DateTimeFormats.ps1:
--------------------------------------------------------------------------------
1 | class DateTimeFormats {
2 | [string] $24HourTime
3 | [datetime] $DateTime
4 | [int32] $Day
5 | [string] $DayAbrv
6 | [string] $DayName
7 | [int32] $DayOfWeek
8 | [Int64] $FileTime
9 | [string] $FullDateShortTime
10 | [string] $FullDateTime
11 | [string] $GeneralDateShortTime
12 | [string] $GeneralDateTime
13 | [Boolean] $IsDaylightSavingTime
14 | [Boolean] $IsLeapYear
15 | [string] $ISO8601
16 | [string] $ISO8601UTC
17 | [string] $LongDate
18 | [string] $LongDateNoDay
19 | [string] $LongTime
20 | [int32] $Month
21 | [string] $MonthAbrv
22 | [string] $MonthDay
23 | [string] $MonthName
24 | [int32] $Quater
25 | [string] $RFC1123
26 | [string] $RFC1123UTC
27 | [string] $RoundTrip
28 | [string] $ShortDate
29 | [string] $ShortTime
30 | [string] $SortableDateTime
31 | [string] $SQL
32 | [string] $UniversalFullDateTime
33 | [string] $UniversalSortableDateTime
34 | [int32] $UnixEpochTime
35 | [string] $WimDatetime
36 | [int32] $Year
37 | [string] $YearMonth
38 | [string] $YearQuater
39 |
40 | [string] getStringProperty() {
41 | return $this.StringProperty
42 | }
43 | }
--------------------------------------------------------------------------------
/Source/Classes/GroupTimeSpan.ps1:
--------------------------------------------------------------------------------
1 | class TimeSpanGroupInfo {
2 | [int] $Count
3 | [datetime] $DateTime
4 | [object] $Group
5 |
6 | TimeSpanGroupInfo([Int64]$Ticks, [int]$Count) {
7 | $this.Count = $Count
8 | $this.DateTime = (Get-Date 1/1/0001).AddTicks($Ticks)
9 | $this.Group = @()
10 | }
11 | TimeSpanGroupInfo([Microsoft.PowerShell.Commands.GroupInfo]$GroupInfo) {
12 | $this.Count = $GroupInfo.Count
13 | $this.DateTime = (Get-Date 1/1/0001).AddTicks($GroupInfo.Name)
14 | $this.Group = $GroupInfo.Group.Object
15 | }
16 | }
--------------------------------------------------------------------------------
/Source/Classes/SunTime.ps1:
--------------------------------------------------------------------------------
1 | class SunTime {
2 | [double] $Latitude
3 | [double] $Longitude
4 | [int64] $Now
5 | [double] $JulianDate
6 | [double] $JulianDay
7 | [double] $MeanSolarTime
8 | [double] $SolarMeanAnomaly
9 | [double] $EquationOfTheCenter
10 | [double] $EclipticLongitude
11 | [double] $SolarTransitTime
12 | [double] $HourAngle
13 | [DateTime] $Sunrise
14 | [DateTime] $Sunset
15 | [double] $DayLength
16 | [TimeZoneInfo] $TimeZone
17 |
18 | [string] ToDegreeString([double] $value) {
19 | $x = [math]::Round($value * 3600)
20 | $num = "∠{0:N3}°" -f $value
21 | $rad = "∠{0:N3}rad" -f ($value * ([math]::PI / 180))
22 | $human = "∠{0}°{1}′{2}″" -f ($x / 3600), ($x / 60 % 60), ($x % 60)
23 | return "$rad = $human = $num"
24 | }
25 |
26 | [string] FromTimestamp([double]$Timestamp,
27 | [System.TimeZoneInfo]$TimeZone = $null) {
28 | $datetime = ConvertFrom-UnixTime $Timestamp
29 | if ($TimeZone) {
30 | $datetime = [System.TimeZoneInfo]::ConvertTimeFromUtc($datetime, $TimeZone)
31 | }
32 | return $datetime.ToString()
33 | }
34 |
35 | [double] JulianToTimestamp(
36 | [double]$Julian
37 | ) {
38 | return ($Julian - 2440587.5) * 86400
39 | }
40 |
41 | [double] TimestampToJulian (
42 | [double]$Timestamp
43 | ) {
44 | return $Timestamp / 86400.0 + 2440587.5
45 | }
46 | }
--------------------------------------------------------------------------------
/Source/Classes/TimeSpanMeasureInfo.ps1:
--------------------------------------------------------------------------------
1 | class TimeSpanMeasureInfo {
2 | [datetime] $DateTime
3 | [int] $Count
4 | [Nullable[System.Double]] $Average
5 | [Nullable[System.Double]] $Sum
6 | [Nullable[System.Double]] $Maximum
7 | [Nullable[System.Double]] $Minimum
8 | [string] $Property
9 |
10 | TimeSpanMeasureInfo([datetime]$DateTime, [Microsoft.PowerShell.Commands.GenericMeasureInfo]$Measure) {
11 | $this.DateTime = $DateTime
12 | $this.Property = $Measure.Property
13 | $this.Count = $Measure.Count
14 | if($null -ne $Measure.Average){$this.Average = $Measure.Average}
15 | if($null -ne $Measure.Sum){$this.Sum = $Measure.Sum}
16 | if($null -ne $Measure.Maximum){$this.Maximum = $Measure.Maximum}
17 | if($null -ne $Measure.Minimum){$this.Minimum = $Measure.Minimum}
18 | }
19 |
20 | TimeSpanMeasureInfo([datetime]$DateTime, [string]$Property, [int]$count) {
21 | $this.DateTime = $DateTime
22 | $this.Property = $Property
23 | $this.Count = $count
24 | }
25 | }
--------------------------------------------------------------------------------
/Source/Classes/TimeZoneConversion.ps1:
--------------------------------------------------------------------------------
1 | class TimeZoneConversion {
2 | [DateTime] $FromDateTime
3 | [String] $FromTimeZone
4 | [DateTime] $ToDateTime
5 | [String] $ToTimeZone
6 | [TimeSpan] $Offset
7 |
8 | TimeZoneConversion ($ToTimeZone, $Date, $FromTimeZone) {
9 | $DateTime = [DateTime]::SpecifyKind($Date, [DateTimeKind]::Unspecified)
10 | $from = [System.TimeZoneInfo]::FindSystemTimeZoneById($FromTimeZone)
11 | $to = [System.TimeZoneInfo]::FindSystemTimeZoneById($ToTimeZone)
12 | $utc = [System.TimeZoneInfo]::ConvertTimeToUtc($DateTime, $from)
13 | $newTime = [System.TimeZoneInfo]::ConvertTime($utc, $to)
14 |
15 | $this.FromDateTime = $Date
16 | $this.FromTimeZone = $FromTimeZone
17 | $this.ToDateTime = $newTime
18 | $this.ToTimeZone = $ToTimeZone
19 | $this.Offset = (New-TimeSpan -Start $date -End $newTime)
20 | }
21 | }
--------------------------------------------------------------------------------
/Source/Formatting/DateTimeExtended.format.ps1:
--------------------------------------------------------------------------------
1 | $PropertiesAndWidths = [ordered]@{
2 | Date = 25
3 | WeekOfYear = 10
4 | DayOfWeek = 15
5 | StartOfWeek = 15
6 | EndOfWeek = 15
7 | StartOfMonth = 15
8 | EndOfMonth = 15
9 | }
10 | $VirtualProperties = [ordered]@{
11 | "StartOfWeek"= {$_.EndOfWeek.ToShortDateString()}
12 | "EndOfWeek"={$_.EndOfWeek.ToShortDateString()}
13 | "StartOfMonth"={$_.StartOfMonth.ToShortDateString()}
14 | "EndOfMonth"={$_.EndOfMonth.ToShortDateString()}
15 | }
16 |
17 | $Property = $PropertiesAndWidths.GetEnumerator() | ForEach-Object { $_.Name }
18 | $Width = $PropertiesAndWidths.GetEnumerator() | ForEach-Object { $_.Value }
19 | Write-FormatView -TypeName DateTimeExtended -Property $Property -Width $Width -VirtualProperty $VirtualProperties
--------------------------------------------------------------------------------
/Source/Formatting/SunTime.format.ps1:
--------------------------------------------------------------------------------
1 | $VirtualProperties = [ordered]@{
2 | "Date" = { $_.Sunrise.ToString('d') }
3 | "Sunrise" = { $_.Sunrise.ToString('t') }
4 | "Sunset" = { $_.Sunset.ToString('t') }
5 | "DayLength" = { "{0:N3} hours" -f $_.DayLength }
6 | }
7 | $Property = $VirtualProperties.GetEnumerator() | ForEach-Object { $_.Name }
8 | Write-FormatView -TypeName SunTime -Property $Property -VirtualProperty $VirtualProperties
9 |
10 | $VirtualProperties = [ordered]@{
11 | Date = { $_.Sunrise.ToString('d') }
12 | Sunrise = { $_.Sunrise.ToString('t') }
13 | Sunset = { $_.Sunset.ToString('t') }
14 | DayLength = { "{0:N3} hours" -f $_.DayLength }
15 | Latitude = { $_.ToDegreeString($_.Latitude) }
16 | Longitude = { $_.ToDegreeString($_.Longitude) }
17 | Now = { $_.FromTimestamp($_.Now, $_.TimeZone) }
18 | JulianDate = { "{0:N3} days" -f $_.JulianDate }
19 | JulianDay = { "{0:N3} days" -f $_.JulianDay }
20 | MeanSolarTime = { "{0:N9} days" -f $_.MeanSolarTime }
21 | SolarMeanAnomaly = { $_.ToDegreeString($_.SolarMeanAnomaly) }
22 | EquationOfTheCenter = { $_.ToDegreeString($_.EquationOfTheCenter) }
23 | EclipticLongitude = { $_.ToDegreeString($_.EclipticLongitude) }
24 | SolarTransitTime = { $_.FromTimestamp($_.JulianToTimestamp($_.SolarTransitTime), $_.TimeZone) }
25 | HourAngle = { $_.ToDegreeString($_.HourAngle) }
26 | }
27 |
28 | $Property = $VirtualProperties.GetEnumerator() | ForEach-Object { $_.Name }
29 | Write-FormatView -TypeName SunTime -Property $Property -VirtualProperty $VirtualProperties -AsList
--------------------------------------------------------------------------------
/Source/Formatting/TimeSpanMeasureInfo.format.ps1:
--------------------------------------------------------------------------------
1 | $VirtualProperties = [ordered]@{
2 | "DateTime" = { $_.DateTime }
3 | "Count" = { $_.Count }
4 | "Average" = { if ($_.Average -eq [math]::Floor($_.Average)) {
5 | # If the number is a whole number, format without decimals
6 | "{0:N0}" -f $_.Average
7 | } else {
8 | # If the number is not a whole number, format with decimals
9 | "{0:N2}" -f $_.Average
10 | } }
11 | "Sum" = { if ($_.Sum -eq [math]::Floor($_.Sum)) {
12 | # If the number is a whole number, format without decimals
13 | "{0:N0}" -f $_.Sum
14 | } else {
15 | # If the number is not a whole number, format with decimals
16 | "{0:N2}" -f $_.Sum
17 | } }
18 | "Maximum" = { if ($_.Maximum -eq [math]::Floor($_.Maximum)) {
19 | # If the number is a whole number, format without decimals
20 | "{0:N0}" -f $_.Maximum
21 | } else {
22 | # If the number is not a whole number, format with decimals
23 | "{0:N2}" -f $_.Maximum
24 | } }
25 | "Minimum" = { if ($_.Minimum -eq [math]::Floor($_.Minimum)) {
26 | # If the number is a whole number, format without decimals
27 | "{0:N0}" -f $_.Minimum
28 | } else {
29 | # If the number is not a whole number, format with decimals
30 | "{0:N2}" -f $_.Minimum
31 | } }
32 | "Property" = { $_.Property }
33 | }
34 | $Property = $VirtualProperties.GetEnumerator() | ForEach-Object { $_.Name }
35 | Write-FormatView -TypeName TimeSpanMeasureInfo -Property $Property -VirtualProperty $VirtualProperties
--------------------------------------------------------------------------------
/Source/PSDates.EzFormat.ps1:
--------------------------------------------------------------------------------
1 | #requires -Module EZOut
2 | # Install-Module EZOut or https://github.com/StartAutomating/EZOut
3 | $myFile = $MyInvocation.MyCommand.ScriptBlock.File
4 | $myModuleName = $($myFile | Split-Path -Leaf) -replace '\.ezformat\.ps1', '' -replace '\.ezout\.ps1', ''
5 | $myRoot = $myFile | Split-Path
6 | Push-Location $myRoot
7 | $formatting = @(
8 | # Add your own Write-FormatView here,
9 | # or put them in a Formatting or Views directory
10 | foreach ($potentialDirectory in 'Formatting','Views','Types') {
11 | Join-Path $myRoot $potentialDirectory |
12 | Get-ChildItem -ea ignore |
13 | Import-FormatView -FilePath {$_.Fullname}
14 | }
15 | )
16 |
17 | $destinationRoot = $myRoot
18 |
19 | if ($formatting) {
20 | $myFormatFilePath = Join-Path $destinationRoot "$myModuleName.format.ps1xml"
21 | # You can also output to multiple paths by passing a hashtable to -OutputPath.
22 | $formatting | Out-FormatData -Module $MyModuleName -OutputPath $myFormatFilePath
23 | }
24 |
25 | $types = @(
26 | # Add your own Write-TypeView statements here
27 | # or declare them in the 'Types' directory
28 | Join-Path $myRoot Types |
29 | Get-Item -ea ignore |
30 | Import-TypeView
31 |
32 | )
33 |
34 | if ($types) {
35 | $myTypesFilePath = Join-Path $destinationRoot "$myModuleName.types.ps1xml"
36 | # You can also output to multiple paths by passing a hashtable to -OutputPath.
37 | $types | Out-TypeData -OutputPath $myTypesFilePath
38 | }
39 | Pop-Location
40 |
--------------------------------------------------------------------------------
/Source/PSDates.psd1:
--------------------------------------------------------------------------------
1 | #
2 | # Module manifest for module 'PSDates'
3 | #
4 | # Generated by: Matthew Dowst
5 | #
6 | # Generated on: 7/13/2020
7 | #
8 |
9 | @{
10 |
11 | # Script module or binary module file associated with this manifest.
12 | RootModule = '.\PSDates.psm1'
13 |
14 | # Version number of this module.
15 | ModuleVersion = '1.0.5'
16 |
17 | # Supported PSEditions
18 | # CompatiblePSEditions = @()
19 |
20 | # ID used to uniquely identify this module
21 | GUID = 'f11eb88e-9ab3-4ad2-834c-5a9db8eb3ecb'
22 |
23 | # Author of this module
24 | Author = 'Matthew Dowst'
25 |
26 | # Company or vendor of this module
27 | CompanyName = 'Dowst Labs'
28 |
29 | # Copyright statement for this module
30 | Copyright = '(c) 2024 Dowst Labs. All rights reserved.'
31 |
32 | # Description of the functionality provided by this module
33 | Description = 'PSDates provides you all the tools you need when working with dates and times in PowerShell. It contains function to help you find specific date formats, get certain dates based on other dates (first/last day of the month or year, patch Tuesday, etc). I also has functions for working with timezones, unix time, WMI time, crontabs.'
34 |
35 | # Minimum version of the PowerShell engine required by this module
36 | PowerShellVersion = '2.0'
37 |
38 | # Name of the PowerShell host required by this module
39 | # PowerShellHostName = ''
40 |
41 | # Minimum version of the PowerShell host required by this module
42 | # PowerShellHostVersion = ''
43 |
44 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45 | # DotNetFrameworkVersion = ''
46 |
47 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
48 | # ClrVersion = ''
49 |
50 | # Processor architecture (None, X86, Amd64) required by this module
51 | ProcessorArchitecture = 'Amd64'
52 |
53 | # Modules that must be imported into the global environment prior to importing this module
54 | # RequiredModules = @()
55 |
56 | # Assemblies that must be loaded prior to importing this module
57 | RequiredAssemblies = @('.\Resources\NCrontab.dll','.\Resources\CronExpressionDescriptor.dll')
58 |
59 | # Script files (.ps1) that are run in the caller's environment prior to importing this module.
60 | # ScriptsToProcess = '.\Classes\DateTimeFormats.ps1', '.\Classes\DateTimeExtended.ps1'
61 |
62 | # Type files (.ps1xml) to be loaded when importing this module
63 | # TypesToProcess = @()
64 |
65 | # Format files (.ps1xml) to be loaded when importing this module
66 | FormatsToProcess = '.\PSDates.format.ps1xml'
67 |
68 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
69 | # NestedModules = @()
70 |
71 | # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
72 | FunctionsToExport = '*'
73 |
74 | # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
75 | CmdletsToExport = @()
76 |
77 | # Variables to export from this module
78 | VariablesToExport = @()
79 |
80 | # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
81 | AliasesToExport = 'Get-DateFormats'
82 |
83 | # DSC resources to export from this module
84 | # DscResourcesToExport = @()
85 |
86 | # List of all modules packaged with this module
87 | # ModuleList = @()
88 |
89 | # List of all files packaged with this module
90 | # FileList = @()
91 |
92 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
93 | PrivateData = @{
94 |
95 | PSData = @{
96 |
97 | # Tags applied to this module. These help with module discovery in online galleries.
98 | Tags = @('date','dates','datetime','time','cron','crontab','wmi','unix')
99 |
100 | # A URL to the license for this module.
101 | LicenseUri = 'https://github.com/mdowst/PSDates/blob/main/LICENSE'
102 |
103 | # A URL to the main website for this project.
104 | ProjectUri = 'https://github.com/mdowst/PSDates'
105 |
106 | # A URL to an icon representing this module.
107 | # IconUri = ''
108 |
109 | # ReleaseNotes of this module
110 | # ReleaseNotes = ''
111 |
112 | # Prerelease string of this module
113 | # Prerelease = ''
114 |
115 | # Flag to indicate whether the module requires explicit user acceptance for install/update/save
116 | # RequireLicenseAcceptance = $false
117 |
118 | # External dependent modules of this module
119 | # ExternalModuleDependencies = @()
120 |
121 | } # End of PSData hashtable
122 |
123 | } # End of PrivateData hashtable
124 |
125 | # HelpInfo URI of this module
126 | # HelpInfoURI = ''
127 |
128 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
129 | # DefaultCommandPrefix = ''
130 |
131 | }
132 |
--------------------------------------------------------------------------------
/Source/PSDates.psm1:
--------------------------------------------------------------------------------
1 | $ScriptsToImport = @( Get-ChildItem -Path (Join-Path $PSScriptRoot 'Public\*.ps1') -Recurse -ErrorAction SilentlyContinue ) +
2 | @( Get-ChildItem -Path (Join-Path $PSScriptRoot 'Private\*.ps1') -Recurse -ErrorAction SilentlyContinue )
3 |
4 | #Dot source the files
5 | Foreach ($import in $ScriptsToImport) {
6 | Try {
7 | Write-Verbose "dot-sourcing file '$($import.fullname)'"
8 | . $import.fullname
9 | }
10 | Catch {
11 | Write-Error -Message "Failed to import function $($import.fullname): $_"
12 | }
13 | }
--------------------------------------------------------------------------------
/Source/Public/Convert-TimeZone.ps1:
--------------------------------------------------------------------------------
1 | Function Convert-TimeZone {
2 | <#
3 | .SYNOPSIS
4 | Convert a datetime value from one time zone to another
5 |
6 | .DESCRIPTION
7 | This function will allows you to pass a date to convert from one time zone to another.
8 | If no date is specified the local time is used. If no FromTimeZone is passed then the
9 | local time zone is used.
10 | If you don't know the time zone ID you can use the Find-TimeZone cmdlet.
11 |
12 | .PARAMETER ToTimeZone
13 | The time zone ID of the time zone you want to convert the date to
14 |
15 | .PARAMETER date
16 | The date to convert. If not specified the current time will be used
17 |
18 | .PARAMETER FromTimeZone
19 | The time zone ID of the time zone you want to convert the date from. If not specified the local time zone will be used
20 |
21 | .EXAMPLE
22 | Convert-TimeZone -ToTimeZone "GMT Standard Time"
23 |
24 | Convert the local system time to GMT Standard Time
25 |
26 | .EXAMPLE
27 | Convert-TimeZone -date '11/17/2017 12:34 AM' -FromTimeZone "China Standard Time" -ToTimeZone "US Mountain Standard Time"
28 |
29 | Converts the date and time 11/17/2017 12:34 AM from 'China Standard Time' to 'US Mountain Standard Time'
30 |
31 | .OUTPUTS
32 | A PSObject object containing the time zone conversion data
33 | #>
34 | [CmdletBinding()]
35 | [OutputType([TimeZoneConversion])]
36 | param(
37 | [parameter(Mandatory = $True)]
38 | [Validatescript( { try { $id = $_; [System.TimeZoneInfo]::FindSystemTimeZoneById($_) }
39 | catch { throw("'$Id' is not a valid time zone Id. Use the Find-TimeZone cmdlet to find the valid time zone Id.") } })]
40 | [string]$ToTimeZone,
41 |
42 | [Parameter(Mandatory = $false)]
43 | [datetime]$Date = $(Get-Date),
44 |
45 | [parameter(Mandatory = $false)]
46 | [Validatescript( { try { $id = $_; [System.TimeZoneInfo]::FindSystemTimeZoneById($_) }
47 | catch { throw("'$Id' is not a valid time zone Id. Use the Find-TimeZone cmdlet to find the valid time zone Id.") } })]
48 | [string]$FromTimeZone = [System.TimeZoneInfo]::Local.Id.ToString()
49 | )
50 |
51 | [TimeZoneConversion]::new($ToTimeZone, $Date, $FromTimeZone)
52 | }
53 |
--------------------------------------------------------------------------------
/Source/Public/Convert-ToDateTime.ps1:
--------------------------------------------------------------------------------
1 | function Convert-ToDateTime {
2 | <#
3 | .SYNOPSIS
4 | Converts various input objects to a DateTime object.
5 |
6 | .DESCRIPTION
7 | The `Convert-ToDateTime` function attempts to convert different types of input objects into a DateTime object.
8 | It supports input from various data types such as strings and objects that can be cast or converted to a DateTime.
9 |
10 | .PARAMETER InputObject
11 | Specifies the input object to be converted to a DateTime. This parameter accepts pipeline input and is mandatory.
12 |
13 | The input can be of any type:
14 | - If the input is already a DateTime, it will be returned as-is.
15 | - If the input is a string, it attempts to parse it into a DateTime.
16 | - Other input types will be processed accordingly, if possible.
17 |
18 | .EXAMPLE
19 | '2024-08-29' | Convert-ToDateTime
20 |
21 | Converts the string '2024-08-29' into a DateTime object representing the 29th of August, 2024.
22 |
23 | .INPUTS
24 | System.Object
25 | The function accepts objects from the pipeline, which are attempted to be converted to DateTime.
26 |
27 | .OUTPUTS
28 | System.DateTime
29 | The function outputs a DateTime object if the conversion is successful.
30 | #>
31 |
32 | [CmdletBinding()]
33 | param (
34 | [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
35 | [Object]$InputObject
36 | )
37 |
38 | process {
39 | $Return = $null
40 | try {
41 | # Attempt to convert directly if input is already a DateTime or string
42 | if ($InputObject -is [DateTime]) {
43 | $Return = $InputObject
44 | }
45 | elseif ($InputObject -is [string]) {
46 | try{
47 | $Return = Get-Date $InputObject -ErrorAction Stop
48 | }
49 | catch{
50 | # Attempt to parse string input to DateTime
51 | $Return = [DateTime]::ParseExact($InputObject,
52 | [System.Globalization.CultureInfo]::InvariantCulture.DateTimeFormat.GetAllDateTimePatterns(),
53 | [System.Globalization.CultureInfo]::InvariantCulture,
54 | [System.Globalization.DateTimeStyles]::None) -as [DateTime]
55 | }
56 | }
57 | else {
58 | # Attempt conversion for other types using their string representation
59 | $Return = [DateTime]::Parse($InputObject.ToString(),
60 | [System.Globalization.CultureInfo]::InvariantCulture) -as [DateTime]
61 | }
62 | }
63 | catch {
64 | # Return error if conversion fails
65 | Write-Error "Unable to convert '$InputObject' to DateTime."
66 | }
67 | $Return
68 | }
69 | }
--------------------------------------------------------------------------------
/Source/Public/ConvertFrom-UnixTime.ps1:
--------------------------------------------------------------------------------
1 | Function ConvertFrom-UnixTime {
2 | <#
3 | .SYNOPSIS
4 | Converts a Unix Time value to a datetime value
5 |
6 | .DESCRIPTION
7 | This function will return the datetime based on the unix epoch time.
8 |
9 | .PARAMETER UnixTime
10 | The UnixTime value to return the datetime for
11 |
12 | .EXAMPLE
13 | ConvertFrom-UnixTime -UnixTime 1509512400
14 | Gets datetime for the Unix time 1509512400
15 |
16 | .OUTPUTS
17 | The datetime value based on the unix time
18 |
19 | #>
20 | [CmdletBinding()]
21 | [OutputType([datetime])]
22 | param(
23 | [Parameter(Mandatory = $true)]
24 | [double]$UnixTime
25 | )
26 |
27 | (Get-Date '1970-01-01T00:00:00.000Z').ToUniversalTime().AddSeconds($UnixTime)
28 | }
29 |
--------------------------------------------------------------------------------
/Source/Public/ConvertFrom-WmiDateTime.ps1:
--------------------------------------------------------------------------------
1 | Function ConvertFrom-WmiDateTime {
2 | <#
3 | .SYNOPSIS
4 | Converts a Wmi Time value to a datetime value
5 |
6 | .DESCRIPTION
7 | This function will return the datetime based on a WMI datetime string.
8 |
9 | .PARAMETER WmiTime
10 | The WmiTime value to return the datetime for
11 |
12 | .EXAMPLE
13 | ConvertFrom-WmiDateTime -WmiTime '20190912173652.000000-300'
14 | Gets datetime for the Wmi time 20190912173652.000000-300
15 |
16 | .OUTPUTS
17 | The datetime value based on the wmi time
18 | #>
19 | [CmdletBinding()]
20 | [OutputType([datetime])]
21 | param(
22 | [Parameter(Mandatory = $true)]
23 | [string]$WmiTime
24 | )
25 |
26 | # Extract individual components from the WMI DateTime string
27 | $year = [int]$WmiTime.Substring(0, 4)
28 | $month = [int]$WmiTime.Substring(4, 2)
29 | $day = [int]$WmiTime.Substring(6, 2)
30 | $hour = [int]$WmiTime.Substring(8, 2)
31 | $minute = [int]$WmiTime.Substring(10, 2)
32 | $second = [int]$WmiTime.Substring(12, 2)
33 | $millisecond = [int]$WmiTime.Substring(15, 6)
34 |
35 | # Create a DateTime object
36 | $dateTime = [datetime]::SpecifyKind(([datetime]"$year-$month-$day $($hour):$($minute):$second.$millisecond"), 'Utc')
37 |
38 | # Create a TimeSpan object for the UTC offset
39 | if ($WmiTime -match '\+') {
40 | $offsetMinutes = [int]$WmiTime.Split('+')[-1]
41 | $offset = New-TimeSpan -Minutes $offsetMinutes
42 | # Adjust for the UTC offset
43 | $dateTime = $dateTime.Add(-$offset)
44 | }
45 | elseif ($WmiTime -match '\-') {
46 | $offsetMinutes = [int]$WmiTime.Split('-')[-1]
47 | $offset = New-TimeSpan -Minutes $offsetMinutes
48 | # Adjust for the UTC offset
49 | $dateTime = $dateTime.Add($offset)
50 | }
51 |
52 | # Convert to local time and output
53 | $dateTime.ToLocalTime()
54 | }
55 |
--------------------------------------------------------------------------------
/Source/Public/ConvertTo-UnixTime.ps1:
--------------------------------------------------------------------------------
1 | Function ConvertTo-UnixTime {
2 | <#
3 | .SYNOPSIS
4 | Converts a datetime value to Unix Time
5 | .DESCRIPTION
6 | This function will return the unix time based on the unix epoch time. If no date is passed in the current date and time is used.
7 | .PARAMETER Date
8 | The datetime value to return the unix time for
9 | .EXAMPLE
10 | ConvertTo-UnixTime
11 | Gets unix time for the current time
12 | .EXAMPLE
13 | ConvertTo-UnixTime -date "11/17/2017"
14 | Gets unix time for a specific date
15 | .OUTPUTS
16 | The int32 value of the unix time
17 | #>
18 | [CmdletBinding()]
19 | [OutputType([int32])]
20 | param(
21 | [Parameter(Mandatory = $false)]
22 | [datetime]$date = $(Get-Date)
23 | )
24 |
25 | [int][double]::Parse((Get-Date ($date).touniversaltime() -UFormat %s))
26 | }
27 |
--------------------------------------------------------------------------------
/Source/Public/ConvertTo-WmiDateTime.ps1:
--------------------------------------------------------------------------------
1 | Function ConvertTo-WmiDateTime {
2 | <#
3 | .SYNOPSIS
4 | Converts a datetime value to a Wmi datetime string
5 |
6 | .DESCRIPTION
7 | This function will return the WMI datetime string based on a datetime passed.
8 |
9 | .PARAMETER Date
10 | Specifies a date and time.
11 |
12 | .EXAMPLE
13 | ConvertTo-WmiDateTime -Date '06/25/2019 16:17'
14 |
15 | Return the WMI datetime string for the datetime of "06/25/2019 16:17"
16 |
17 | .OUTPUTS
18 | The string value based on the datetime
19 | #>
20 | [CmdletBinding()]
21 | [OutputType([string])]
22 | param(
23 | [Parameter(Mandatory = $false)]
24 | [datetime]$Date = (Get-Date)
25 | )
26 |
27 | $wmiString = $Date.ToString("yyyyMMddHHmmss.ffffff")
28 | if($Date.Kind -eq 'Utc'){
29 | $wmiString += '+000'
30 | }
31 | else{
32 | $offset = ([System.TimeZoneInfo]::Local).BaseUtcOffset.TotalMinutes
33 | $wmiString += "$($offset)"
34 | }
35 | $wmiString
36 | }
37 |
--------------------------------------------------------------------------------
/Source/Public/Find-TimeZone.ps1:
--------------------------------------------------------------------------------
1 | Function Find-TimeZone {
2 | <#
3 | .SYNOPSIS
4 | Returns Time Zone information
5 |
6 | .DESCRIPTION
7 | This function will return the information for the system time zones. You can search by name and/or hour offsets.
8 | You can also return the local time zone.
9 |
10 | .PARAMETER Name
11 | All or part of the time zone name. Will be used to perform a wildcard search on the time zones
12 |
13 | .PARAMETER Offset
14 | The number of hours the time zone is offset from UTC
15 |
16 | .PARAMETER local
17 | Use to return the time zone of the current system
18 |
19 | .PARAMETER OutGrid
20 | Use to output time zone selects to Grid View
21 |
22 | .EXAMPLE
23 | Find-TimeZone -local
24 | Return the time zone of the local system
25 |
26 | .EXAMPLE
27 | Find-TimeZone -Name "GMT"
28 | Search for time zones with 'GMT' in the name
29 |
30 | .EXAMPLE
31 | Find-TimeZone -Name "central" -Offset -6
32 | Search for time zones with 'Central' in the name and have a UTC offset of -6 hours
33 |
34 | .OUTPUTS
35 | The TimeZoneInfo value or values found
36 | #>
37 | [CmdletBinding()]
38 | [OutputType([System.TimeZoneInfo])]
39 | param(
40 | [parameter(Mandatory = $false)][string]$Name,
41 | [parameter(Mandatory = $false)][int]$Offset,
42 | [parameter(Mandatory = $false)][switch]$Local,
43 | [parameter(Mandatory = $false)][switch]$OutGrid
44 | )
45 |
46 | if ($Local) {
47 | [System.TimeZoneInfo]::Local
48 | }
49 | else {
50 | $TimeZones = [System.TimeZoneInfo]::GetSystemTimeZones()
51 |
52 | if ($Name) {
53 | $TimeZones = $TimeZones | Where-Object { $_.DisplayName -like "*$($Name)*" -or $_.DaylightName -like "*$($Name)*" -or
54 | $_.StandardName -like "*$($Name)*" -or
55 | $_.Id -like "*$($Name)*" }
56 | }
57 |
58 | if ($Offset) {
59 | $TimeZones = $TimeZones | Where-Object { $_.BaseUtcOffset.Hours -eq $Offset }
60 | }
61 |
62 | if ($OutGrid) {
63 | $TimeZones | Out-Gridview -Title "Select the timezone(s) to return" -PassThru
64 | }
65 | else {
66 | $TimeZones
67 | }
68 |
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Source/Public/Get-CronDescription.ps1:
--------------------------------------------------------------------------------
1 | Function Get-CronDescription {
2 | <#
3 | .SYNOPSIS
4 | Convert a cron expression into a human readable description
5 |
6 | .DESCRIPTION
7 | Uses the .NET library CronExpressionDescriptor to convert cron expressions into human readable descriptions.
8 |
9 | .PARAMETER Crontab
10 | A valid crontab string
11 |
12 | .PARAMETER DayOfWeekStartIndexOne
13 | When used Sunday will equal 1, otherwise Sunday will be 0. (Default: Sunday = 0)
14 |
15 | .PARAMETER Use24HourTimeFormat
16 | If true, descriptions will use a 24-hour clock (Default: false but some translations will default to true)
17 |
18 | .PARAMETER Locale
19 | The locale to use (Default: "en")
20 | Supported values: cs-CZ, da, de, es, es-MX, fa, fi, fr, he-IL, hu, it, ja, ko, nb, nl, pl, pt, ro, ru, sl, sv, tr, uk, vi, zh-Hans, zh-Hant
21 |
22 | .EXAMPLE
23 | Get-CronDescription -Crontab '0 17 * * 1'
24 |
25 | Results with default options:
26 | At 05:00 PM, only on Monday
27 |
28 | .EXAMPLE
29 | Get-CronDescription -Crontab '0 17 * * 1' -DayOfWeekStartIndexOne
30 |
31 | Results with DayOfWeekStartIndexOne switch returns Sunday for the 1 instead of Monday:
32 | At 05:00 PM, only on Sunday
33 |
34 | .EXAMPLE
35 | Get-CronDescription -Crontab '0 17 * * 1' -Use24HourTimeFormat
36 |
37 | Results with Use24HourTimeFormat options:
38 | At 17:00, only on Monday
39 |
40 | .EXAMPLE
41 | Get-CronDescription -Crontab '0 17 * * 1' -Locale 'fr'
42 |
43 | Results with fr Locale options:
44 | At 05:00 PM, only on lundi
45 |
46 | .OUTPUTS
47 | A psobject that contains the crontable, a validation value, and any error messages returned
48 | #>
49 | [CmdletBinding()]
50 | [OutputType([string])]
51 | param(
52 | [Parameter(Mandatory = $true)]
53 | [string]$Crontab,
54 | [Parameter(Mandatory = $false)]
55 | [switch]$DayOfWeekStartIndexOne = $false,
56 | [Parameter(Mandatory = $false)]
57 | [switch]$Use24HourTimeFormat = $false,
58 | [Parameter(Mandatory = $false)]
59 | [ValidateSet('cs-CZ','da','de','es','es-MX','fa','fi','fr','he-IL','hu','it','ja','ko','nb','nl','pl','pt','ro','ru','sl','sv','tr','uk','vi','zh-Hans','zh-Hant')]
60 | [string]$Locale = 'en'
61 | )
62 |
63 | # Set options
64 | $options = [CronExpressionDescriptor.Options]::new()
65 | if($DayOfWeekStartIndexOne){
66 | $options.DayOfWeekStartIndexZero = $false
67 | }
68 | $options.Use24HourTimeFormat = $Use24HourTimeFormat
69 | $options.Locale = $Locale
70 |
71 | # Get Description
72 | [CronExpressionDescriptor.ExpressionDescriptor]::GetDescription($Crontab, $options)
73 | }
--------------------------------------------------------------------------------
/Source/Public/Get-CronNextOccurrence.ps1:
--------------------------------------------------------------------------------
1 | Function Get-CronNextOccurrence {
2 | <#
3 | .SYNOPSIS
4 | Get the next occurrence for a crontab
5 |
6 | .DESCRIPTION
7 | This function will either return the next occurrence, or if an end date is supplied, it will return
8 | all the occurrences between the start and end date.
9 |
10 | .PARAMETER Crontab
11 | A valid crontab string
12 |
13 | .PARAMETER StartTime
14 | The datetime object to find the next occurrence from. Uses current time if not supplied.
15 |
16 | .PARAMETER EndTime
17 | The datetime object to stop finding occurrences for from the StartTime
18 |
19 | .EXAMPLE
20 | Get-CronNextOccurrence -Crontab '0 17 * * *'
21 |
22 | Will return the next occurrence of the crontab from the current time
23 |
24 | .EXAMPLE
25 | $Date = Get-Date '12/14/2032'
26 | Get-CronNextOccurrence -Crontab '0 17 * * *' -StartTime $Date
27 |
28 | Will return the next occurrence of the crontab from the time provided
29 |
30 | .EXAMPLE
31 | Get-CronNextOccurrence -Crontab '0 17 * * *' -StartTime $Date -EndTime $Date.AddDays(3)
32 |
33 | Will return the all occurrences of the crontab between the two times
34 |
35 | .OUTPUTS
36 | A datetime object for every occurrence returned
37 | #>
38 | [CmdletBinding()]
39 | [OutputType('datetime')]
40 | param(
41 | [Parameter(Mandatory = $true)]
42 | [string]$Crontab,
43 | [Parameter(Mandatory = $false)]
44 | [datetime]$StartTime = (Get-Date),
45 | [Parameter(Mandatory = $false)]
46 | [datetime]$EndTime
47 | )
48 | # validat crontab
49 | $Schedule = Test-CrontabSchedule -Crontab $Crontab
50 |
51 | # if no end date, just get next occurrence, else find all occurrences between start and end
52 | if ($Schedule.valid -eq $true -and $null -eq $EndTime) {
53 | $schedule.schedule.GetNextOccurrence($StartTime)
54 | }
55 | elseif ($Schedule.valid -eq $true) {
56 | $schedule.schedule.GetNextOccurrences($StartTime, $EndTime)
57 | }
58 | else {
59 | throw $Schedule.ErrorMsg
60 | }
61 |
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/Source/Public/Get-DateExtended.ps1:
--------------------------------------------------------------------------------
1 | Function Get-DateExtended {
2 | <#
3 | .SYNOPSIS
4 | Gets additional extended date values that are not included by default with the Get-Date cmdlet
5 |
6 | .DESCRIPTION
7 | This function includes added values for:
8 | FirstDayOfYear : First day of the year
9 | LastDayOfYear : Last day of the year
10 | StartOfWeek : First day of the week
11 | EndOfWeek : Last day of the week
12 | StartOfMonth : First day of the month
13 | EndOfMonth : Last day of the month
14 | TimeZone : Current machine timezone
15 | Quater : The quarter of the year.
16 |
17 | All dates are based on the date passed. If no date is passed in the current date and time are used.
18 |
19 | .PARAMETER Date
20 | The datetime value to return the information for
21 |
22 | .PARAMETER UnixTimeSeconds
23 | Date and time represented in seconds since January 1, 1970, 0:00:00.
24 |
25 | .PARAMETER Year
26 | Specifies the year that is displayed. Enter a value from 1 to 9999
27 |
28 | .PARAMETER Month
29 | Specifies the month that is displayed. Enter a value from 1 to 12
30 |
31 | .PARAMETER Day
32 | Specifies the day of the month that is displayed. Enter a value from 1 to 31.
33 |
34 | .PARAMETER Hour
35 | Specifies the hour that is displayed. Enter a value from 0 to 23.
36 |
37 | .PARAMETER Minute
38 | Specifies the minute that is displayed. Enter a value from 0 to 59.
39 |
40 | .PARAMETER Second
41 | Specifies the second that is displayed. Enter a value from 0 to 59.
42 |
43 | .PARAMETER Millisecond
44 | Specifies the milliseconds in the date. Enter a value from 0 to 999.
45 |
46 | .PARAMETER DisplayHint
47 | Determines which elements of the date and time are displayed.
48 |
49 | The accepted values are as follows:
50 |
51 | Date: displays only the date
52 | Time: displays only the time
53 | DateTime: displays the date and time
54 |
55 | .EXAMPLE
56 | Get-DateExtended
57 | Gets extended date and time information based on the current time
58 |
59 | .EXAMPLE
60 | Get-DateExtended "11/17/2017"
61 | Gets extended date and time information for a specific date
62 |
63 | .OUTPUTS
64 | A PSObject containing extended values for the date.
65 | #>
66 | [CmdletBinding()]
67 | [OutputType('DateTimeExtended')]
68 | param(
69 | [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
70 | [Alias("LastWriteTime")]
71 | [DateTime]$Date = [DateTime]::Now,
72 |
73 | [Parameter()]
74 | [switch] $UnixTimeSeconds,
75 |
76 | [Parameter()]
77 | [ValidateRange(1, 9999)]
78 | [int] $Year,
79 |
80 | [Parameter()]
81 | [ValidateRange(1, 12)]
82 | [int] $Month,
83 |
84 | [Parameter()]
85 | [ValidateRange(1, 31)]
86 | [int] $Day,
87 |
88 | [Parameter()]
89 | [ValidateRange(0, 23)]
90 | [int] $Hour,
91 |
92 | [Parameter()]
93 | [ValidateRange(0, 59)]
94 | [int] $Minute,
95 |
96 | [Parameter()]
97 | [ValidateRange(0, 59)]
98 | [int] $Second,
99 |
100 | [Parameter()]
101 | [ValidateRange(0, 999)]
102 | [int] $Millisecond,
103 |
104 | [Parameter()]
105 | [ValidateSet('Date', 'Time', 'DateTime')]
106 | [string] $DisplayHint
107 | )
108 |
109 | process {
110 | [DateTimeExtended]::New((Get-Date @PSBoundParameters))
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/Source/Public/Get-DateFormat.ps1:
--------------------------------------------------------------------------------
1 | Function Get-DateFormat {
2 | <#
3 | .SYNOPSIS
4 | Returns common date and time formats
5 |
6 | .DESCRIPTION
7 | This function format date and time values into multiple different common formats. All dates are based on the date passed.
8 | If no date is passed in the current date and time are used.
9 |
10 | .PARAMETER Date
11 | The datetime value to return the formats for
12 |
13 | .EXAMPLE
14 | Get-DateFormats
15 |
16 | Gets formatted date and time information based on the current time
17 | .EXAMPLE
18 | Get-DateFormats -Date "11/17/2017"
19 |
20 | Gets formatted date and time information for a specific date
21 |
22 | .OUTPUTS
23 | A PSObject containing the diffent values for the datetime formats.
24 | #>
25 | [alias("Get-DateFormats")]
26 | [CmdletBinding(DefaultParameterSetName = "Full")]
27 | [OutputType([DateTimeFormats], ParameterSetName = "ID")]
28 | [OutputType([object], ParameterSetName = "Format")]
29 | param(
30 | [Parameter(Mandatory = $false, ParameterSetName = "Full")]
31 | [Parameter(Mandatory = $false, ParameterSetName = "Format")]
32 | [datetime]$Date = $(Get-Date),
33 |
34 | [Parameter(Mandatory = $false, ParameterSetName = "Format")]
35 | [string]$Format
36 | )
37 |
38 | $offset = ([System.TimeZoneInfo]::Local).BaseUtcOffset.ToString()
39 | $offset = $offset.Substring(0, $offset.LastIndexOf(':'))
40 |
41 | $dateFormats = [DateTimeFormats]@{
42 | DateTime = $Date.DateTime
43 | RFC1123UTC = $Date.ToUniversalTime().ToString('r')
44 | SQL = $Date.ToString("yyyy-MM-dd HH:mm:ss.fff")
45 | ISO8601UTC = $Date.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ")
46 | ISO8601 = $Date.ToString("yyyy-MM-ddTHH:mm:ss.fff") + $offset
47 | ShortDate = $Date.ToString('d')
48 | LongDate = $Date.ToString('D')
49 | LongDateNoDay = $Date.ToString('D').Substring($Date.ToString('D').IndexOf(',') + 2)
50 | FullDateShortTime = $Date.ToString('f')
51 | FullDateTime = $Date.ToString('F')
52 | GeneralDateShortTime = $Date.ToString('g')
53 | GeneralDateTime = $Date.ToString('G')
54 | MonthDay = $Date.ToString('M')
55 | RoundTrip = $Date.ToString('o')
56 | RFC1123 = $Date.ToString('r')
57 | SortableDateTime = $Date.ToString('s')
58 | ShortTime = $Date.ToString('t')
59 | LongTime = $Date.ToString('T')
60 | UniversalSortableDateTime = $Date.ToString('u')
61 | UniversalFullDateTime = $Date.ToString('U')
62 | YearMonth = $Date.ToString('Y')
63 | "24HourTime" = $Date.ToString("HH:mm")
64 | Day = $Date.Day
65 | DayAbrv = (Get-Culture).DateTimeFormat.GetAbbreviatedDayName($Date.DayOfWeek.value__)
66 | DayName = $Date.DayOfWeek.ToString()
67 | DayOfWeek = $Date.DayOfWeek.value__
68 | Month = $Date.Month
69 | MonthName = (Get-Culture).DateTimeFormat.GetMonthName($Date.Month)
70 | MonthAbrv = (Get-Culture).DateTimeFormat.GetAbbreviatedMonthName($Date.Month)
71 | Quater = [Math]::ceiling($Date.Month / 3)
72 | YearQuater = "$($Date.Year)$("{0:00}" -f [Math]::ceiling($Date.Month/3) )"
73 | Year = $Date.Year
74 | WimDatetime = (ConvertTo-WmiDateTime $Date)
75 | UnixEpochTime = (ConvertTo-UnixTime $Date)
76 | IsDaylightSavingTime = $Date.IsDaylightSavingTime()
77 | IsLeapYear = [datetime]::IsLeapYear($Date.Year)
78 | FileTime = $Date.ToFileTime()
79 | }
80 |
81 | if ([string]::IsNullOrEmpty($PSBoundParameters['Format'])) {
82 | $dateFormats
83 | }
84 | else {
85 | $dateFormats."$($PSBoundParameters['Format'])"
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/Source/Public/Get-Easter.ps1:
--------------------------------------------------------------------------------
1 | Function Get-Easter {
2 | <#
3 | .SYNOPSIS
4 | This function offers a generic Easter computing method for any given year, using Western, Orthodox or Julian algorithms.
5 |
6 | .DESCRIPTION
7 | Shamelessly stolen from python dateutil (https://github.com/dateutil/dateutil/blob/master/src/dateutil/easter.py)
8 |
9 | .PARAMETER Year
10 | The year to get Easter from
11 |
12 | .PARAMETER Calendar
13 | Gregorian : is the default and valid from 1583 to 4099
14 | Orthodox : valid from 1583 to 4099
15 | Julian : valid from 326
16 |
17 | .EXAMPLE
18 | Get-Easter -Year 2024
19 |
20 | #>
21 | [CmdletBinding()]
22 | [OutputType([datetime])]
23 | param(
24 | [Parameter(Mandatory = $false)]
25 | [int]$year = (Get-Date).Year,
26 |
27 | [Parameter(Mandatory = $false)]
28 | [ValidateSet('Gregorian', 'Julian', 'Orthodox')]
29 | [string]$Calendar = 'Gregorian'
30 | )
31 |
32 | # Golden year - 1
33 | $g = $year % 19
34 | $e = 0
35 | if ($Calendar -ne 'Gregorian') {
36 | # Old method
37 | $i = (19 * $g + 15) % 30
38 | $j = ($year + [math]::floor($year / 4) + $i) % 7
39 | if ($Calendar -eq 'Orthodox') {
40 | # Extra dates to convert Julian to Gregorian date
41 | $e = 10
42 | if ($year -gt 1600) {
43 | $e = $e + [math]::floor([math]::floor($year / 100) - 16 - ([math]::floor($year / 100) - 16) / 4)
44 | }
45 | }
46 | }
47 | else {
48 | # Century
49 | $c = [math]::floor($year / 100)
50 | # (23 - Epact) mod 30
51 | $h = ($c - [math]::floor($c / 4) - [math]::floor((8 * $c + 13) / 25) + 19 * $g + 15) % 30
52 | # Number of days from March 21 to Paschal Full Moon
53 | $i = $h - ([math]::floor($h / 28)) * (1 - ([math]::floor($h / 28)) * ([math]::floor(29 / ($h + 1))) * ([math]::floor((21 - $g) / 11)))
54 | # Weekday for PFM (0=Sunday, etc)
55 | $j = ($year + [math]::floor($year / 4) + $i + 2 - $c + [math]::floor($c / 4)) % 7
56 | }
57 |
58 |
59 |
60 | # Number of days from March 21 to Sunday on or before PFM
61 | $p = $i - $j + $e
62 | $d = 1 + ($p + 27 + [math]::floor(($p + 6) / 40)) % 31
63 | $m = 3 + [math]::floor(($p + 26) / 30)
64 |
65 | [datetime]::new($year, $m, $d)
66 | }
67 |
--------------------------------------------------------------------------------
/Source/Public/Get-PatchTuesday.ps1:
--------------------------------------------------------------------------------
1 | Function Get-PatchTuesday {
2 | <#
3 | .SYNOPSIS
4 | Returns the second Tuesday of the month
5 |
6 | .DESCRIPTION
7 | This function allow you to pass a date, or a month/year combination to find the second Tuesday (aka Patch Tuesday) of any month
8 |
9 | .PARAMETER Date
10 | The datetime value to return the second Tuesday for the month
11 |
12 | .PARAMETER Month
13 | The month to return the second Tuesday for. Enter a value from 1 to 12.
14 |
15 | .PARAMETER Year
16 | The year to return the second Tuesday for. Enter a value from 1 to 9999
17 |
18 | .EXAMPLE
19 | Get-PatchTuesday
20 | Returns the second Tuesday for the current month
21 |
22 | .EXAMPLE
23 | Get-PatchTuesday -Date "11/17/2021"
24 | Returns the second Tuesday for November 2021
25 |
26 | .EXAMPLE
27 | Get-PatchTuesday -Month 6 -Year 2020
28 | Returns the second Tuesday for June 2020
29 |
30 | .EXAMPLE
31 | Get-PatchTuesday -Month 4
32 | Returns the second Tuesday for April of the current year
33 |
34 | .OUTPUTS
35 | A datetime object of the second Tuesday.
36 | #>
37 | [CmdletBinding(DefaultParameterSetName = 'Date')]
38 | [OutputType([datetime])]
39 | param(
40 | [Parameter(Mandatory = $false, ParameterSetName = "Date")]
41 | [datetime]$Date = $(Get-Date),
42 | [Parameter(Mandatory = $false, ParameterSetName = "MonthYear")]
43 | [ValidateRange(1, 12)]
44 | [int]$Month = $(Get-Date).Month,
45 | [Parameter(Mandatory = $false, ParameterSetName = "MonthYear")]
46 | [ValidateRange(1, 9999)]
47 | [int]$Year = $(Get-Date).Year
48 | )
49 |
50 | if ($PsCmdlet.ParameterSetName -eq "MonthYear") {
51 | $date = (Get-Date -Day 1 -Month $Month -Year $Year).Date
52 | }
53 |
54 | # Get the first day of the month
55 | $StartOfMonth = Get-Date $date.Date -Day 1
56 |
57 | # Get every Tuesday, and return the second one
58 | $ptdate = (0..30 | Foreach-Object { $StartOfMonth.adddays($_) } | Where-Object { $_.dayofweek.value__ -eq 2 })[1]
59 | $ptdate.Date
60 | }
61 |
--------------------------------------------------------------------------------
/Source/Public/Get-SunTime.ps1:
--------------------------------------------------------------------------------
1 | function Get-SunTime {
2 | <#
3 | .SYNOPSIS
4 | Find sunrise and sunset times for any location on planet Earth.
5 |
6 | .DESCRIPTION
7 | This function finds the time of day for sunrise, sunset based on the given latitude and longitude. You can also specify time zone and elevation.
8 |
9 | .PARAMETER Date
10 | The day to find the sunrise and sunset for.
11 |
12 | .PARAMETER Latitude
13 | The Latitude entered as a decimal number representing degrees and minutes
14 |
15 | .PARAMETER Longitude
16 | The Longitude entered as a decimal number representing degrees and minutes
17 |
18 | .PARAMETER Elevation
19 | The Elevation in meters
20 |
21 | .PARAMETER TimeZone
22 | The time zone for the final results
23 |
24 | .EXAMPLE
25 | Get-SunTime -Latitude 51.501005 -Longitude -0.1445479
26 |
27 | # Get the sunrise and sunset for the given coordinates for the current day
28 |
29 | .EXAMPLE
30 | $address = '1600 Pennsylvania Avenue NW'
31 | $addr = Invoke-RestMethod "https://nominatim.openstreetmap.org/search?q=$($address)&format=json" | Select-Object -First 1
32 | Get-SunTime -Latitude $addr.lat -Longitude $addr.lon
33 |
34 | # Use the free Nominatim API get the coordinates for an address, then use those results to get the sunrise and sunset for that location.
35 |
36 | .NOTES
37 | Use can use Google Maps to find the latitude and longitude coordinates.
38 | Right click a specific point on the Google map and you will see the latitude and longitude coordinates displayed, for example 45.51421, -122.68462.
39 |
40 | #>
41 | [CmdletBinding()]
42 | param (
43 | [Parameter(Mandatory = $false)]
44 | [datetime]$Date = $(Get-Date),
45 | [Parameter(Mandatory = $true)]
46 | [double]$Latitude,
47 | [Parameter(Mandatory = $true)]
48 | [double]$Longitude,
49 | [Parameter(Mandatory = $false)]
50 | [double]$Elevation = 0.0,
51 | [Parameter(Mandatory = $false)]
52 | [string]$TimeZone = $null
53 | )
54 | $suntime = [SunTime]::new()
55 | $datetimeOffset = [DateTimeOffset]::new($Date)
56 | $CurrentTimestamp = $datetimeOffset.ToUniversalTime().ToUnixTimeSeconds()
57 |
58 | $TimeZoneInfo = [System.TimeZoneInfo]::Local
59 | if(-not [string]::IsNullOrEmpty($TimeZone)){
60 | $TimeZoneInfo = [System.TimeZoneInfo]::FindSystemTimeZoneById($TimeZone)
61 | }
62 |
63 |
64 | Write-Verbose "Latitude f = $($suntime.ToDegreeString($Latitude))"
65 | Write-Verbose "Longitude l_w = $($suntime.ToDegreeString($Longitude))"
66 | Write-Verbose "Now ts = $($suntime.FromTimestamp($CurrentTimestamp, $TimeZoneInfo))"
67 |
68 |
69 | $J_date = $suntime.TimestampToJulian($CurrentTimestamp)
70 | Write-Verbose ("Julian date j_date = {0:N3} days" -f $J_date)
71 |
72 | # Julian day
73 | $n = [math]::Ceiling($J_date - (2451545.0 + 0.0009) + 69.184 / 86400.0)
74 | Write-Verbose ("Julian day n = {0:N3} days" -f $n)
75 |
76 | # Mean solar time
77 | $J_ = $n + 0.0009 - $Longitude / 360.0
78 | Write-Verbose ("Mean solar time J_ = {0:N9} days" -f $J_)
79 |
80 | # Solar mean anomaly
81 | $M_degrees = [math]::IEEERemainder(357.5291 + 0.98560028 * $J_, 360)
82 | $M_radians = ($M_degrees * ([math]::PI / 180))
83 | Write-Verbose "Solar mean anomaly M = $($suntime.ToDegreeString($M_degrees))"
84 |
85 | # Equation of the center
86 | $C_degrees = 1.9148 * [math]::Sin($M_radians) + 0.02 * [math]::Sin(2 * $M_radians) + 0.0003 * [math]::Sin(3 * $M_radians)
87 | Write-Verbose "Equation of the center C = $($suntime.ToDegreeString($C_degrees))"
88 |
89 | # Ecliptic longitude
90 | $L_degrees = [math]::IEEERemainder($M_degrees + $C_degrees + 180.0 + 102.9372, 360)
91 | Write-Verbose "Ecliptic longitude L = $($suntime.ToDegreeString($L_degrees))"
92 |
93 | $Lambda_radians = ($L_degrees * ([math]::PI / 180))
94 |
95 | # Solar transit (julian date)
96 | $J_transit = 2451545.0 + $J_ + 0.0053 * [math]::Sin($M_radians) - 0.0069 * [math]::Sin(2 * $Lambda_radians)
97 | Write-Verbose "Solar transit time J_trans = $($suntime.FromTimestamp( $suntime.JulianToTimestamp($J_transit), $TimeZoneInfo))"
98 |
99 | # Declination of the Sun
100 | $sin_d = [math]::Sin($Lambda_radians) * [math]::Sin((23.4397 * ([math]::PI / 180)))
101 | $cos_d = [math]::Cos([math]::Asin($sin_d))
102 |
103 | # Hour angle
104 | $some_cos = ([math]::Sin(-0.833 * [math]::PI / 180 - 2.076 * [math]::Sqrt($Elevation) / 60.0 * [math]::PI / 180) - [math]::Sin($Latitude * [math]::PI / 180) * $sin_d) / ([math]::Cos($Latitude * [math]::PI / 180) * $cos_d)
105 | $w0_radians = [math]::Acos($some_cos)
106 |
107 |
108 | $w0_degrees = $w0_radians * 180 / [math]::PI
109 | Write-Verbose "Hour angle w0 = $($suntime.ToDegreeString($w0_degrees))"
110 |
111 | $j_rise = $J_transit - $w0_degrees / 360
112 | $j_set = $J_transit + $w0_degrees / 360
113 |
114 | Write-Verbose "Sunrise j_rise = $($suntime.FromTimestamp( $suntime.JulianToTimestamp($j_rise), $TimeZoneInfo))"
115 | Write-Verbose "Sunset j_set = $($suntime.JulianToTimestamp($j_rise)) = $($suntime.FromTimestamp($suntime.JulianToTimestamp($j_set), $TimeZoneInfo))"
116 | Write-Verbose ("Day length {0:N3} hours" -f ($w0_degrees / (180 / 24)))
117 |
118 | [SunTime]@{
119 | Latitude = $Latitude
120 | Longitude = $Longitude
121 | Now = $CurrentTimestamp
122 | JulianDate = $J_date
123 | JulianDay = $n
124 | MeanSolarTime = $J_
125 | SolarMeanAnomaly = $M_degrees
126 | EquationOfTheCenter = $C_degrees
127 | EclipticLongitude = $L_degrees
128 | SolarTransitTime = $J_transit
129 | HourAngle = $w0_degrees
130 | Sunrise = (Get-Date $($suntime.FromTimestamp($suntime.JulianToTimestamp($j_rise), $TimeZoneInfo)))
131 | Sunset = (Get-Date $($suntime.FromTimestamp($suntime.JulianToTimestamp($j_set), $TimeZoneInfo)))
132 | DayLength = ($w0_degrees / (180 / 24))
133 | TimeZone = $TimeZoneInfo
134 | }
135 | }
--------------------------------------------------------------------------------
/Source/Public/Group-TimeSpan.ps1:
--------------------------------------------------------------------------------
1 | Function Group-TimeSpan {
2 | <#
3 | .SYNOPSIS
4 | Groups objects by a specified time span.
5 |
6 | .DESCRIPTION
7 | The `Group-TimeSpan` function takes a collection of objects and groups them based on a specified time span.
8 | It supports grouping by properties such as days, hours, minutes, etc., allowing for flexible data grouping.
9 |
10 | .PARAMETER InputObject
11 | Specifies the input objects to be grouped. This parameter accepts pipeline input.
12 |
13 | .PARAMETER Property
14 | Specifies the property name of the InputObject to use for grouping. The property should be of a DateTime type.
15 |
16 | .PARAMETER Years
17 | Specifies the number of years to group by.
18 |
19 | .PARAMETER Months
20 | Specifies the number of months to group by.
21 |
22 | .PARAMETER Days
23 | Specifies the number of days to group by.
24 |
25 | .PARAMETER Hours
26 | Specifies the number of hours to group by.
27 |
28 | .PARAMETER Minutes
29 | Specifies the number of minutes to group by.
30 |
31 | .PARAMETER Seconds
32 | Specifies the number of seconds to group by.
33 |
34 | .EXAMPLE
35 | Get-ChildItem $PSHOME | Group-TimeSpan -Property CreationTime -Hours 1
36 |
37 | Groups the files by each hour based on their CreationTime.
38 |
39 | .EXAMPLE
40 | Get-ChildItem $PSHOME | Group-TimeSpan -Property CreationTime -Days 7
41 |
42 | Groups the files by 7 days based on their CreationTime.
43 |
44 | .OUTPUTS
45 | TimeSpanGroupInfo[]
46 | Returns an array of TimeSpanGroupInfo objects.
47 | #>
48 | [CmdletBinding()]
49 | [OutputType([TimeSpanGroupInfo[]])]
50 | param (
51 | [Parameter(
52 | ValueFromPipeline = $true,
53 | ValueFromPipelineByPropertyName = $true,
54 | Mandatory = $true
55 | )]
56 | [Alias("PSObject")]
57 | [object]$InputObject,
58 |
59 | [Parameter(Mandatory = $false)]
60 | [string]$Property = $null,
61 |
62 | [Parameter(Mandatory = $false)]
63 | [switch]$IncludeAllTimes = $false,
64 |
65 | [Parameter(Mandatory = $true, ParameterSetName = "Years")]
66 | [int]$Years,
67 | [Parameter(Mandatory = $true, ParameterSetName = "Months")]
68 | [int]$Months,
69 | [Parameter(Mandatory = $true, ParameterSetName = "Days")]
70 | [int]$Days,
71 | [Parameter(Mandatory = $true, ParameterSetName = "Hours")]
72 | [int]$Hours,
73 | [Parameter(Mandatory = $true, ParameterSetName = "Minutes")]
74 | [int]$Minutes,
75 | [Parameter(Mandatory = $true, ParameterSetName = "Seconds")]
76 | [int]$Seconds
77 | )
78 |
79 | begin {
80 | $Null = $Years, $Months # Prevent PSReviewUnusedParameter false positive
81 | [Collections.Generic.List[PSObject]] $objects = @()
82 | switch ($PsCmdlet.ParameterSetName) {
83 | "Days" { $ticks = 36000000000 * 24 * $Days }
84 | "Hours" { $ticks = 36000000000 * $Hours }
85 | "Minutes" { $ticks = 600000000 * $Minutes }
86 | "Seconds" { $ticks = 10000000 * $Seconds }
87 | }
88 | }
89 |
90 |
91 | process {
92 | $InputObject | Foreach-Object {
93 | if (-not [string]::IsNullOrEmpty( $Property )) {
94 | $timeValue = $_.$Property
95 | }
96 | else {
97 | $timeValue = $_
98 | }
99 | $objects.Add([pscustomobject]@{
100 | TimeProperty = $timeValue | Convert-ToDateTime
101 | Object = $_
102 | })
103 | }
104 | }
105 |
106 |
107 | end {
108 | $min = [datetime]::MinValue
109 | $groupedDates = $objects | Group-Object {
110 | if ($PSBoundParameters['Months']) {
111 | # Monthly
112 | $monthsDifference = (($_.TimeProperty.Year - $min.Year) * 12 + $_.TimeProperty.Month - $min.Month)
113 | $groupStartMonth = [math]::Floor($monthsDifference / $Months) * $Months
114 | $month = $min.AddMonths($groupStartMonth)
115 | (Get-Date -Year $month.Year -Month $month.Month -day 1 -hour 0 -minute 0 -second 0 -Millisecond 0).Ticks
116 | }
117 | elseif ($PSBoundParameters['Years']) {
118 | # Yearly
119 | $yearDifference = $_.TimeProperty.Year - $min.Year
120 | $groupStartYear = [math]::Floor($yearDifference / $Years) * $Years
121 | $year = $min.AddMonths($groupStartYear * 12)
122 | (Get-Date -Year $year.Year -Month 1 -day 1 -hour 0 -minute 0 -second 0 -Millisecond 0).Ticks
123 | }
124 | else {
125 | $min.Ticks - (($min.Ticks - $_.TimeProperty.Ticks) - (($min.Ticks - $_.TimeProperty.Ticks) % $ticks))
126 | }
127 | }
128 |
129 | [TimeSpanGroupInfo[]]$output = $groupedDates | ForEach-Object {
130 | [TimeSpanGroupInfo]::new($_)
131 | }
132 |
133 | if($IncludeAllTimes){
134 | $FirstTime = $output | Sort-Object DateTime | Select-Object -First 1 -ExpandProperty DateTime | Select-Object -ExpandProperty Ticks
135 | $LastTime = $output | Sort-Object DateTime | Select-Object -Last 1 -ExpandProperty DateTime | Select-Object -ExpandProperty Ticks
136 | $blankTimes = while($FirstTime -lt $LastTime){
137 | $toAdd = [TimeSpanGroupInfo]::new($FirstTime, 0)
138 | if($output.DateTime -notcontains $toAdd.DateTime){
139 | $toAdd
140 | }
141 | if ($PSBoundParameters['Months']) {
142 | $FirstTime = $toAdd.DateTime.AddMonths($Months).Ticks
143 | }
144 | elseif ($PSBoundParameters['Years']) {
145 | $FirstTime = $toAdd.DateTime.AddMonths($Years * 12).Ticks
146 | }
147 | else{
148 | $FirstTime += $ticks
149 | }
150 | }
151 | $output = @($output) + $($blankTimes)
152 | }
153 |
154 | $output | Sort-Object DateTime
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/Source/Public/Measure-TimeSpan.ps1:
--------------------------------------------------------------------------------
1 | Function Measure-TimeSpan {
2 | <#
3 | .SYNOPSIS
4 | Measures statistical properties (such as sum, average, and maximum) of a specified property within grouped time spans.
5 |
6 | .DESCRIPTION
7 | The `Measure-TimeSpan` function calculates various statistical measures (sum, average, maximum, minimum) for a specified property across a collection of grouped time spans.
8 | It is designed to work with objects grouped by the `Group-TimeSpan` function, focusing on numerical properties for aggregation.
9 |
10 | .PARAMETER TimeSpanGroupInfo
11 | Specifies the input objects that represent grouped time spans. This parameter accepts pipeline input and is mandatory.
12 |
13 | .PARAMETER Property
14 | Specifies the property name of the TimeSpanGroupInfo objects to measure. This property should be numeric and is mandatory.
15 |
16 | .PARAMETER Sum
17 | Switch parameter that, when specified, calculates the sum of the specified property across all input objects.
18 |
19 | .PARAMETER Average
20 | Switch parameter that, when specified, calculates the average of the specified property across all input objects.
21 |
22 | .PARAMETER Maximum
23 | Switch parameter that, when specified, calculates the maximum value of the specified property across all input objects.
24 |
25 | .PARAMETER Minimum
26 | Switch parameter that, when specified, calculates the minimum value of the specified property across all input objects.
27 |
28 | .EXAMPLE
29 | $groupedData = Get-EventLog -LogName System | Group-TimeSpan -Property TimeGenerated -Days 1
30 | $groupedData | Measure-TimeSpan -Property Count -Sum
31 |
32 | Measures the sum of the 'Count' property for each grouped time span in the system event log.
33 |
34 | .EXAMPLE
35 | $groupedData = Get-ChildItem $PSHOME | Group-TimeSpan -Property CreationTime -Hours 1
36 | $groupedData | Measure-TimeSpan -Property Length -Average -Sum
37 |
38 | Measures the sum and average size of files grouped by each hour based on their CreationTime.
39 |
40 | .INPUTS
41 | TimeSpanGroupInfo[]
42 | The function accepts grouped time span objects from the pipeline.
43 |
44 | .OUTPUTS
45 | TimeSpanMeasureInfo[]
46 | Returns the calculated statistical value(s) based on the input and specified parameters.
47 | #>
48 |
49 | [CmdletBinding()]
50 | [OutputType([TimeSpanMeasureInfo[]])]
51 | param (
52 | [Parameter(
53 | ValueFromPipeline = $true,
54 | Mandatory = $true
55 | )]
56 | [TimeSpanGroupInfo[]]$TimeSpanGroupInfo,
57 |
58 | [Parameter(Mandatory = $true)]
59 | [string]$Property,
60 |
61 | [Parameter(Mandatory = $false)]
62 | [switch]$Sum = $false,
63 | [Parameter(Mandatory = $false)]
64 | [switch]$Average = $false,
65 | [Parameter(Mandatory = $false)]
66 | [switch]$Maximum = $false,
67 | [Parameter(Mandatory = $false)]
68 | [switch]$Minimum = $false
69 | )
70 |
71 | begin {
72 | [Collections.Generic.List[TimeSpanMeasureInfo]] $objects = @()
73 | $MeasureParameters = @{}
74 | $PSBoundParameters.GetEnumerator() | Where-Object { $_.Key -ne 'TimeSpanGroupInfo' } | ForEach-Object {
75 | $MeasureParameters.Add($_.Key, $_.Value)
76 | }
77 | }
78 |
79 | process {
80 | $TimeSpanGroupInfo | Foreach-Object {
81 | $m = $_.Group | Measure-Object @MeasureParameters
82 | if($m){
83 | $objects.Add([TimeSpanMeasureInfo]::new($_.DateTime, $m))
84 | }
85 | else{
86 | $blankFill = [TimeSpanMeasureInfo]::new($_.DateTime, $Property, $_.Count)
87 | if($Average){$blankFill.Average = 0}
88 | if($Sum){$blankFill.Sum = 0}
89 | if($Maximum){$blankFill.Maximum = 0}
90 | if($Minimum){$blankFill.Minimum = 0}
91 | $objects.Add($blankFill)
92 | }
93 |
94 |
95 | }
96 | }
97 |
98 | end {
99 | $objects
100 | }
101 | }
--------------------------------------------------------------------------------
/Source/Public/New-Duration.ps1:
--------------------------------------------------------------------------------
1 | Function New-Duration {
2 | <#
3 | .SYNOPSIS
4 | Calculates the time span between two dates and returns the duration in the ISO 8601 format
5 |
6 | .DESCRIPTION
7 | Calculates the timespan between two dates and returns the duration in the ISO 8601 format
8 |
9 | https://en.wikipedia.org/wiki/ISO_8601#Durations
10 |
11 | .PARAMETER Start
12 | Specifies the start of a time span.
13 |
14 | .PARAMETER End
15 | Specifies the end of a time span. End date must be greater than the start date
16 |
17 | .PARAMETER Years
18 | Specifies the number for yearly interval
19 |
20 | .PARAMETER Months
21 | Specifies the number for monthly interval
22 |
23 | .PARAMETER Days
24 | Specifies the number for daily interval
25 |
26 | .PARAMETER Hours
27 | Specifies the number for hourly interval
28 |
29 | .PARAMETER Minutes
30 | Specifies the number for minute interval
31 |
32 | .PARAMETER Seconds
33 | Specifies the number for second interval
34 |
35 | .PARAMETER Weeks
36 | Specifies the number for weekly interval
37 |
38 | .EXAMPLE
39 | New-Duration -Start '2/3/2023' -End (Get-Date)
40 |
41 | .EXAMPLE
42 | New-Duration -Days 1 -Hours 4
43 |
44 | .EXAMPLE
45 | New-Duration -Weeks 3
46 | #>
47 | [CmdletBinding()]
48 | [OutputType([string])]
49 | param(
50 | [Parameter(Mandatory = $true,
51 | ParameterSetName = "datetime")]
52 | [datetime]$Start,
53 |
54 | [Parameter(Mandatory = $true,
55 | ParameterSetName = "datetime")]
56 | [datetime]$End,
57 |
58 | [Parameter(Mandatory = $false,
59 | ParameterSetName = "numbers")]
60 | [int]$Years = 0,
61 |
62 | [Parameter(Mandatory = $false,
63 | ParameterSetName = "numbers")]
64 | [int]$Months = 0,
65 |
66 | [Parameter(Mandatory = $false,
67 | ParameterSetName = "numbers")]
68 | [int]$Days = 0,
69 |
70 | [Parameter(Mandatory = $false,
71 | ParameterSetName = "numbers")]
72 | [int]$Hours = 0,
73 |
74 | [Parameter(Mandatory = $false,
75 | ParameterSetName = "numbers")]
76 | [int]$Minutes = 0,
77 |
78 | [Parameter(Mandatory = $false,
79 | ParameterSetName = "numbers")]
80 | [int]$Seconds = 0,
81 |
82 | [Parameter(Mandatory = $false,
83 | ParameterSetName = "week")]
84 | [int]$Weeks = 0
85 | )
86 |
87 | if ($Start -gt $End) {
88 | throw "Start date must be before the end date"
89 | }
90 | if ($PSCmdlet.ParameterSetName -eq 'datetime') {
91 | # If start date is later in the month offset by 1
92 | $daysOffset = if ($start.Day -gt $End.Day) { 1 }else { 0 }
93 | # Get the total months between dates
94 | $TotalMonths = ($End.Month - $start.Month - $daysOffset) + ($End.Year - $start.Year) * 12
95 | # Get the number of years
96 | $Years = [math]::floor($TotalMonths / 12)
97 | # Get the number of months less the years
98 | $Months = $TotalMonths % 12
99 | # Calculate the remaining timespan
100 | $TimeSpan = New-TimeSpan -Start $start.AddYears($Years).AddMonths($Months) -End $End
101 |
102 | # Set variables to build the string
103 | $Days = $TimeSpan.Days
104 | $Hours = $TimeSpan.Hours
105 | $Minutes = $TimeSpan.Minutes
106 | $Seconds = $TimeSpan.Seconds
107 | }
108 |
109 | $Duration = 'P'
110 | if ($Years -ne 0) { $Duration += "$($Years)Y" }
111 | if ($Weeks -ne 0) { $Duration += "$($Weeks)W" }
112 | if ($Months -ne 0) { $Duration += "$($Months)M" }
113 | if ($Days -ne 0) { $Duration += "$($Days)D" }
114 | if (($Hours + $Minutes + $Seconds) -ne 0) {
115 | $Duration += "T"
116 | if ($Hours -ne 0) { $Duration += "$($Hours)H" }
117 | if ($Minutes -ne 0) { $Duration += "$($Minutes)M" }
118 | if ($Seconds -ne 0) { $Duration += "$($Seconds)S" }
119 | }
120 |
121 | if($Duration -eq 'P'){
122 | $Duration = 'PT0S'
123 | }
124 |
125 | $Duration
126 | }
127 |
--------------------------------------------------------------------------------
/Source/Public/Test-CrontabSchedule.ps1:
--------------------------------------------------------------------------------
1 | Function Test-CrontabSchedule {
2 | <#
3 | .SYNOPSIS
4 | Tests that a crontab string is valid
5 |
6 | .DESCRIPTION
7 | This function attempts to parse a crontab string to ensure it is valid.
8 |
9 | .PARAMETER Crontab
10 | The datetime value to return the second Tuesday for the month
11 |
12 | .EXAMPLE
13 | Test-CrontabSchedule -crontab '0 17 * * *'
14 |
15 | Valid schedule that returns:
16 | Crontab Valid
17 | ------- -----
18 | 0 17 * * * True
19 |
20 | .EXAMPLE
21 | Test-CrontabSchedule -crontab '0 17 * 13 *'
22 |
23 | Invalid schedule that returns:
24 | Crontab Valid ErrorMsg
25 | ------- ----- --------
26 | 0 17 * 13 * False 13 is higher than the maximum allowable value for the [Month] field. Value must be between 1 and 12 (all inclusive).
27 |
28 | .OUTPUTS
29 | A psobject that contains the crontable, a validation value, and any error messages returned
30 | #>
31 | [CmdletBinding()]
32 | [OutputType([string])]
33 | param(
34 | [Parameter(Mandatory = $true)]
35 | [string]$Crontab
36 | )
37 |
38 | $Result = [ordered]@{
39 | Schedule = $Crontab
40 | Valid = $false
41 | }
42 |
43 | try {
44 | $Result['Schedule'] = [NCrontab.CrontabSchedule]::Parse($Crontab)
45 | $Result['Valid'] = $true
46 | }
47 | catch {
48 | $ErrorMsg = $_.Exception.ErrorRecord.ToString()
49 | $ErrorMsg = $ErrorMsg.Substring($ErrorMsg.IndexOf(': "') + 3)
50 | $ErrorMsg = $ErrorMsg.Substring(0, $ErrorMsg.Length - 1)
51 | $Result.Add('ErrorMsg', $ErrorMsg)
52 | }
53 |
54 | [PSCustomObject]$Result
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/Source/Resources/ArgumentCompleters.ps1:
--------------------------------------------------------------------------------
1 | function GetDateFormatsCompletionResult {
2 | param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
3 | [DateTimeFormats]::new().psobject.Properties.Name | foreach-object {
4 | New-Object -TypeName System.Management.Automation.CompletionResult -ArgumentList "'$_'",
5 | $_ , ([System.Management.Automation.CompletionResultType]::ParameterValue) , $_
6 | }
7 | }
8 |
9 | function GetTimeZoneCompletionResult {
10 | param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
11 | foreach ($dt in [System.TimeZoneInfo]::GetSystemTimeZones()) {
12 | if ($dt.id, $dt.displayname -match $wordToComplete) {
13 | [Management.Automation.CompletionResult]::new(
14 | ("'{0}'" -f $dt.id),
15 | $dt.DisplayName,
16 | "ParameterValue",
17 | ("{0}/{1} (DST:{2})" -f @(
18 | $dt.StandardName
19 | $dt.DaylightName
20 | $dt.SupportsDaylightSavingTime
21 | ))
22 | )
23 | }
24 | }
25 | }
26 |
27 | if(Get-Command -ErrorAction SilentlyContinue -name Register-ArgumentCompleter) {
28 | Register-ArgumentCompleter -CommandName Get-DateFormat -ParameterName Format -ScriptBlock $Function:GetDateFormatsCompletionResult
29 | Register-ArgumentCompleter -CommandName Convert-TimeZone -ParameterName ToTimeZone -ScriptBlock $Function:GetTimeZoneCompletionResult
30 | Register-ArgumentCompleter -CommandName Convert-TimeZone -ParameterName FromTimeZone -ScriptBlock $Function:GetTimeZoneCompletionResult
31 | Register-ArgumentCompleter -CommandName Get-SunTime -ParameterName TimeZone -ScriptBlock $Function:GetTimeZoneCompletionResult
32 | }
--------------------------------------------------------------------------------
/Source/Resources/CronExpressionDescriptor.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/CronExpressionDescriptor.dll
--------------------------------------------------------------------------------
/Source/Resources/DateTimeExtensions.format.ps1xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | DateTimeExtended
6 |
7 | DateTimeExtended
8 |
9 |
10 |
11 |
12 |
13 | 25
14 |
15 |
16 |
17 | 10
18 |
19 |
20 |
21 | 15
22 |
23 |
24 |
25 | 15
26 |
27 |
28 |
29 | 15
30 |
31 |
32 |
33 | 15
34 |
35 |
36 |
37 | 15
38 |
39 |
40 |
41 |
42 |
43 |
44 | DateTime
45 |
46 |
47 | WeekOfYear
48 |
49 |
50 | DayOfWeek
51 |
52 |
53 | $_.StartOfWeek.ToShortDateString()
54 |
55 |
56 | $_.EndOfWeek.ToShortDateString()
57 |
58 |
59 | $_.StartOfMonth.ToShortDateString()
60 |
61 |
62 | $_.EndOfMonth.ToShortDateString()
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | DateFormats
71 |
72 | DateFormats
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | 15
88 |
89 |
90 |
91 | 15
92 |
93 |
94 |
95 | 15
96 |
97 |
98 |
99 |
100 |
101 |
102 | DateTime
103 |
104 |
105 | RFC1123UTC
106 |
107 |
108 | ISO8601
109 |
110 |
111 | ShortDate
112 |
113 |
114 | ShortTime
115 |
116 |
117 | MonthName
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/Source/Resources/NCrontab.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/NCrontab.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/.signature.p7s:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/.signature.p7s
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/CronExpressionDescriptor.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CronExpressionDescriptor
5 | 2.33.0
6 | Brady Holt
7 | MIT
8 | https://licenses.nuget.org/MIT
9 | icon.png
10 | https://github.com/bradymholt/cron-expression-descriptor
11 | A library that converts cron expressions into human readable descriptions. Supports multiple languages including: English, Brazillian, Spanish, Norwgian, Turkish, Dutch, Chinese Simplified, Russian, French, German, Ukrainian, Persian (Farsi), Polish, Romanian Italian, Swedish, Slovenian, Danish, Finnish and Japanese.
12 | See https://github.com/bradymholt/cron-expression-descriptor/releases for release notes
13 | cron, schedule, quartz, quartz.net, cron expression
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/[Content_Types].xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/_rels/.rels:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/cronexpressiondescriptor.2.33.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/cronexpressiondescriptor.2.33.0.nupkg
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/icon.png
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/CronExpressionDescriptor.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/CronExpressionDescriptor.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/cs-CZ/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/cs-CZ/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/da/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/da/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/de/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/de/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/es-MX/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/es-MX/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/es/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/es/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/fa/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/fa/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/fi/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/fi/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/fr/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/fr/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/he-IL/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/he-IL/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/hu/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/hu/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/it/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/it/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/ja/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/ja/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/ko/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/ko/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/nb/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/nb/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/nl/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/nl/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/pl/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/pl/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/pt/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/pt/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/ro/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/ro/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/ru/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/ru/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/sl/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/sl/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/sv/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/sv/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/tr/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/tr/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/uk/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/uk/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/vi/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/vi/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/zh-Hans/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/zh-Hans/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/zh-Hant/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/net6.0/zh-Hant/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/CronExpressionDescriptor.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/CronExpressionDescriptor.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/cs-CZ/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/cs-CZ/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/da/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/da/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/de/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/de/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/es-MX/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/es-MX/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/es/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/es/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/fa/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/fa/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/fi/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/fi/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/fr/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/fr/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/he-IL/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/he-IL/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/hu/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/hu/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/it/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/it/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/ja/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/ja/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/ko/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/ko/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/nb/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/nb/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/nl/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/nl/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/pl/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/pl/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/pt/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/pt/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/ro/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/ro/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/ru/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/ru/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/sl/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/sl/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/sv/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/sv/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/tr/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/tr/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/uk/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/uk/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/vi/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/vi/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/zh-Hans/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/zh-Hans/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/zh-Hant/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard1.1/zh-Hant/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/CronExpressionDescriptor.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/CronExpressionDescriptor.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/cs-CZ/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/cs-CZ/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/da/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/da/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/de/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/de/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/es-MX/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/es-MX/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/es/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/es/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/fa/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/fa/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/fi/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/fi/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/fr/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/fr/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/he-IL/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/he-IL/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/hu/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/hu/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/it/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/it/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/ja/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/ja/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/ko/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/ko/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/nb/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/nb/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/nl/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/nl/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/pl/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/pl/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/pt/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/pt/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/ro/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/ro/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/ru/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/ru/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/sl/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/sl/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/sv/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/sv/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/tr/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/tr/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/uk/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/uk/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/vi/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/vi/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/zh-Hans/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/zh-Hans/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/zh-Hant/CronExpressionDescriptor.resources.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/cronexpressiondescriptor.2.33.0/lib/netstandard2.0/zh-Hant/CronExpressionDescriptor.resources.dll
--------------------------------------------------------------------------------
/Source/Resources/cronexpressiondescriptor.2.33.0/package/services/metadata/core-properties/35b01ef7a16d4028afa8d3b651d30093.psmdcp:
--------------------------------------------------------------------------------
1 |
2 |
3 | Brady Holt
4 | A library that converts cron expressions into human readable descriptions. Supports multiple languages including: English, Brazillian, Spanish, Norwgian, Turkish, Dutch, Chinese Simplified, Russian, French, German, Ukrainian, Persian (Farsi), Polish, Romanian Italian, Swedish, Slovenian, Danish, Finnish and Japanese.
5 | CronExpressionDescriptor
6 | 2.33.0
7 | cron, schedule, quartz, quartz.net, cron expression
8 | NuGet.Build.Tasks.Pack, Version=6.9.1.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35;.NET Standard 2.0
9 |
--------------------------------------------------------------------------------
/Source/Resources/ncrontab.3.3.0/lib/net35/NCrontab.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/ncrontab.3.3.0/lib/net35/NCrontab.dll
--------------------------------------------------------------------------------
/Source/Resources/ncrontab.3.3.0/lib/netstandard1.0/NCrontab.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/ncrontab.3.3.0/lib/netstandard1.0/NCrontab.dll
--------------------------------------------------------------------------------
/Source/Resources/ncrontab.3.3.0/lic/OpenSymphony.txt:
--------------------------------------------------------------------------------
1 | /* ====================================================================
2 | * The OpenSymphony Software License, Version 1.1
3 | *
4 | * (this license is derived and fully compatible with the Apache Software
5 | * License - see http://www.apache.org/LICENSE.txt)
6 | *
7 | * Copyright (c) 2001 The OpenSymphony Group. All rights reserved.
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions
11 | * are met:
12 | *
13 | * 1. Redistributions of source code must retain the above copyright
14 | * notice, this list of conditions and the following disclaimer.
15 | *
16 | * 2. Redistributions in binary form must reproduce the above copyright
17 | * notice, this list of conditions and the following disclaimer in
18 | * the documentation and/or other materials provided with the
19 | * distribution.
20 | *
21 | * 3. The end-user documentation included with the redistribution,
22 | * if any, must include the following acknowledgment:
23 | * "This product includes software developed by the
24 | * OpenSymphony Group (http://www.opensymphony.com/)."
25 | * Alternately, this acknowledgment may appear in the software itself,
26 | * if and wherever such third-party acknowledgments normally appear.
27 | *
28 | * 4. The names "OpenSymphony" and "The OpenSymphony Group"
29 | * must not be used to endorse or promote products derived from this
30 | * software without prior written permission. For written
31 | * permission, please contact license@opensymphony.com .
32 | *
33 | * 5. Products derived from this software may not be called "OpenSymphony"
34 | * or "OSCore", nor may "OpenSymphony" or "OSCore" appear in their
35 | * name, without prior written permission of the OpenSymphony Group.
36 | *
37 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
41 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48 | * SUCH DAMAGE.
49 | * ====================================================================
50 | */
51 |
--------------------------------------------------------------------------------
/Source/Resources/ncrontab.3.3.0/ncrontab.3.3.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mdowst/PSDates/f7a882501eb0e39908b8b6cb13d50972794b8934/Source/Resources/ncrontab.3.3.0/ncrontab.3.3.0.nupkg
--------------------------------------------------------------------------------
/Source/Test/Public/Convert-TimeZone.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | }
7 |
8 | Describe 'Convert-TimeZone Tests' {
9 | It 'Convert-TimeZone Test' {
10 | $conversion = Convert-TimeZone -Date '11/17/2017 12:34 AM' -FromTimeZone "China Standard Time" -ToTimeZone "US Mountain Standard Time"
11 | $conversion.FromDateTime | Should -Be (Get-Date '11/17/2017 12:34:00 AM')
12 | $conversion.FromTimeZone | Should -Be 'China Standard Time'
13 | $conversion.ToDateTime | Should -Be (Get-Date '11/16/2017 9:34:00 AM')
14 | $conversion.ToTimeZone | Should -Be 'US Mountain Standard Time'
15 | $conversion.Offset | Should -Be '-15:00:00'
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Source/Test/Public/Convert-ToDateTime.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | }
7 |
8 | Describe 'Convert-ToDateTime' {
9 |
10 | Context 'Valid DateTime Conversion' {
11 | It 'Should convert a valid date string to a DateTime object' {
12 | # Arrange
13 | $input = '2024-08-29'
14 |
15 | # Act
16 | $result = $input | Convert-ToDateTime
17 |
18 | # Assert
19 | $result | Should -BeOfType 'DateTime'
20 | $result | Should -Be ([datetime]'2024-08-29T00:00:00.0000000')
21 | }
22 |
23 | It 'Should return a DateTime object unchanged if input is already a DateTime' {
24 | # Arrange
25 | $input = Get-Date
26 |
27 | # Act
28 | $result = $input | Convert-ToDateTime
29 |
30 | # Assert
31 | $result | Should -BeOfType 'DateTime'
32 | $result | Should -Be $input
33 | }
34 | }
35 |
36 | Context 'Invalid DateTime Conversion' {
37 | It 'Should throw an error for an invalid date string' {
38 | # Arrange
39 | $invalidInput = 'InvalidDateString'
40 |
41 | # Act & Assert
42 | { $invalidInput | Convert-ToDateTime -ErrorAction Stop } | Should -Throw
43 | }
44 |
45 | It 'Should throw an error for non-convertible input' {
46 | # Arrange
47 | $nonConvertibleInput = @{ Name = 'Test' }
48 |
49 | # Act & Assert
50 | { $nonConvertibleInput | Convert-ToDateTime -ErrorAction Stop } | Should -Throw
51 | }
52 | }
53 |
54 | Context 'Null and Empty Input' {
55 | It 'Should throw an error when input is $null' {
56 | # Arrange
57 | $nullInput = $null
58 |
59 | # Act & Assert
60 | { $nullInput | Convert-ToDateTime -ErrorAction Stop } | Should -Throw
61 | }
62 |
63 | It 'Should throw an error when input is an empty string' {
64 | # Arrange
65 | $emptyInput = ''
66 |
67 | # Act & Assert
68 | { $emptyInput | Convert-ToDateTime -ErrorAction Stop } | Should -Throw
69 | }
70 | }
71 |
72 | Context 'Edge Cases' {
73 | It 'Should handle a leap year date correctly' {
74 | # Arrange
75 | $input = '2024-02-29'
76 |
77 | # Act
78 | $result = $input | Convert-ToDateTime
79 |
80 | # Assert
81 | $result | Should -BeOfType 'DateTime'
82 | $result | Should -Be ([datetime]'2024-02-29T00:00:00.0000000')
83 | }
84 |
85 | It 'Should handle different date formats correctly' {
86 | # Arrange
87 | $input = '08/29/2024'
88 |
89 | # Act
90 | $result = $input | Convert-ToDateTime
91 |
92 | # Assert
93 | $result | Should -BeOfType 'DateTime'
94 | $result | Should -Be ([datetime]'2024-08-29T00:00:00.0000000')
95 | }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/Source/Test/Public/ConvertFrom-UnixTime.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | }
7 |
8 | Describe 'ConvertFrom-UnixTime Tests' {
9 | It 'ConvertFrom-UnixTime Test' {
10 | ConvertFrom-UnixTime -UnixTime 1510876800 | Should -Be (Get-Date '2017-11-17T00:00:00.000Z').ToUniversalTime()
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Source/Test/Public/ConvertFrom-WmiDateTime.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | }
7 |
8 | Describe 'ConvertFrom-WmiDateTime Tests' {
9 | It 'ConvertFrom-WmiDateTime Test' {
10 | ConvertFrom-WmiDateTime -WmiTime '20190912173652.000000-000' | Should -Be (Get-Date '2019-09-12T17:36:52.000Z').ToLocalTime()
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Source/Test/Public/ConvertTo-UnixTime.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | }
7 |
8 | Describe 'ConvertTo-UnixTime Tests' {
9 | It 'ConvertTo-UnixTime Test' {
10 | ConvertTo-UnixTime -Date (Get-Date '2017-11-17T00:00:00.000Z').ToUniversalTime() | Should -Be 1510876800
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Source/Test/Public/ConvertTo-WmiDateTime.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | }
7 |
8 | Describe 'ConvertTo-WmiDateTime Tests' {
9 | It 'ConvertTo-WmiDateTime Test' {
10 | ConvertTo-WmiDateTime -Date (Get-Date '2017-06-25T16:17:00.000Z').ToUniversalTime() | Should -Be '20170625161700.000000+000'
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Source/Test/Public/Find-TimeZone.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | }
7 |
8 | Describe 'Find-TimeZone Tests' {
9 | It 'Find-TimeZone Test' {
10 | $london = 'GMT Standard Time'
11 | if($IsLinux){
12 | $london = 'Europe/London'
13 | }
14 | (Find-TimeZone -Name "London").Id | Should -Be $london
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Source/Test/Public/Get-CronNextOccurrence.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | }
7 |
8 | Describe 'Get-CronNextOccurrence Tests' {
9 | It 'Get-CronNextOccurrence Test' {
10 | $fivePM = Get-Date '17:00'
11 | if($fivePM -lt (Get-Date)){
12 | $fivePM = $fivePM.AddDays(1)
13 | }
14 | Get-CronNextOccurrence -Crontab '0 17 * * *' | Should -Be $fivePM
15 | }
16 | It 'Get-CronNextOccurrence Specific Date Test' {
17 | $StartTime = Get-Date '12/14/2032'
18 | Get-CronNextOccurrence -Crontab '0 17 * * *' -StartTime $StartTime | Should -Be (Get-Date '12/14/2032 17:00')
19 | }
20 | It 'Get-CronNextOccurrence Multiple Occurrences Test' {
21 | $StartTime = Get-Date '12/14/2032'
22 | $threeDays = 14..16 | ForEach-Object{
23 | Get-Date "12/$($_)/2032 17:00"
24 | }
25 | Get-CronNextOccurrence -Crontab '0 17 * * *' -StartTime $StartTime -EndTime $StartTime.AddDays(3) | Should -Be $threeDays
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/Test/Public/Get-DateExtended.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | }
7 |
8 | Describe 'Get-DateExtended Tests' {
9 | It 'Get-DateExtended Test' {
10 | $dateExt = Get-DateExtended "11/17/2017"
11 | $dateExt.DateTime | Should -Be (Get-Date '11/17/2017 00:00:00')
12 | $dateExt.FirstDayOfYear | Should -Be (Get-Date '01/01/2017 00:00:00')
13 | $dateExt.LastDayOfYear | Should -Be (Get-Date '12/31/2017 00:00:00')
14 | $dateExt.StartOfWeek | Should -Be (Get-Date '11/12/2017 00:00:00')
15 | $dateExt.EndOfWeek | Should -Be (Get-Date '11/18/2017 23:59:59')
16 | $dateExt.StartOfMonth | Should -Be (Get-Date '11/01/2017 00:00:00')
17 | $dateExt.EndOfMonth | Should -Be (Get-Date '11/30/2017 23:59:59')
18 | $dateExt.WeekOfYear | Should -Be 46
19 | $dateExt.TimeZone | Should -Be ([System.TimeZoneInfo]::Local)
20 | $dateExt.Quarter | Should -Be 4
21 | $dateExt.Date | Should -Be (Get-Date '11/17/2017 00:00:00')
22 | $dateExt.Day | Should -Be 17
23 | $dateExt.DayOfWeek | Should -Be 'Friday'
24 | $dateExt.DayOfYear | Should -Be 321
25 | $dateExt.Hour | Should -Be 0
26 | $dateExt.Kind | Should -Be 'Unspecified'
27 | $dateExt.Millisecond | Should -Be 0
28 | $dateExt.Minute | Should -Be 0
29 | $dateExt.Month | Should -Be 11
30 | $dateExt.Second | Should -Be 0
31 | $dateExt.Ticks | Should -Be 636464736000000000
32 | $dateExt.TimeOfDay | Should -Be 00:00:00
33 | $dateExt.Year | Should -Be 2017
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Source/Test/Public/Get-DateFormat.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | [cultureinfo]::CurrentCulture = 'en-US'
7 | }
8 |
9 | Describe 'Get-DateFormat Tests' {
10 | It 'Get-DateFormat Test' {
11 | $dateFormat = Get-DateFormat -Date (Get-Date '2017-11-17T00:00:00.000Z').ToUniversalTime()
12 | $dateFormat.'24HourTime' | Should -Be '00:00'
13 | $dateFormat.DateTime | Should -Be '11/17/2017 00:00:00'
14 | $dateFormat.Day | Should -Be '17'
15 | $dateFormat.DayAbrv | Should -Be 'Fri'
16 | $dateFormat.DayName | Should -Be 'Friday'
17 | $dateFormat.DayOfWeek | Should -Be '5'
18 | $dateFormat.FileTime | Should -Be '131553504000000000'
19 | $dateFormat.FullDateShortTime | Should -Be 'Friday, November 17, 2017 12:00 AM'
20 | $dateFormat.FullDateTime | Should -Be 'Friday, November 17, 2017 12:00:00 AM'
21 | $dateFormat.GeneralDateShortTime | Should -Be '11/17/2017 12:00 AM'
22 | $dateFormat.GeneralDateTime | Should -Be '11/17/2017 12:00:00 AM'
23 | $dateFormat.IsDaylightSavingTime | Should -Be 'False'
24 | $dateFormat.IsLeapYear | Should -Be 'False'
25 | $dateFormat.ISO8601 | Should -Match '2017-11-17T00:00:00.000'
26 | $dateFormat.ISO8601UTC | Should -Be '2017-11-17T00:00:00.000Z'
27 | $dateFormat.LongDate | Should -Be 'Friday, November 17, 2017'
28 | $dateFormat.LongDateNoDay | Should -Be 'November 17, 2017'
29 | $dateFormat.LongTime | Should -Be '12:00:00 AM'
30 | $dateFormat.Month | Should -Be '11'
31 | $dateFormat.MonthAbrv | Should -Be 'Nov'
32 | $dateFormat.MonthDay | Should -Be 'November 17'
33 | $dateFormat.MonthName | Should -Be 'November'
34 | $dateFormat.Quater | Should -Be '4'
35 | $dateFormat.RFC1123 | Should -Be 'Fri, 17 Nov 2017 00:00:00 GMT'
36 | $dateFormat.RFC1123UTC | Should -Be 'Fri, 17 Nov 2017 00:00:00 GMT'
37 | $dateFormat.RoundTrip | Should -Be '2017-11-17T00:00:00.0000000Z'
38 | $dateFormat.ShortDate | Should -Be '11/17/2017'
39 | $dateFormat.ShortTime | Should -Be '12:00 AM'
40 | $dateFormat.SortableDateTime | Should -Be '2017-11-17T00:00:00'
41 | $dateFormat.SQL | Should -Be '2017-11-17 00:00:00.000'
42 | $dateFormat.UniversalFullDateTime | Should -Be 'Friday, November 17, 2017 12:00:00 AM'
43 | $dateFormat.UniversalSortableDateTime | Should -Be '2017-11-17 00:00:00Z'
44 | $dateFormat.UnixEpochTime | Should -Be '1510876800'
45 | $dateFormat.WimDatetime | Should -Be '20171117000000.000000+000'
46 | $dateFormat.Year | Should -Be '2017'
47 | $dateFormat.YearMonth | Should -Be 'November 2017'
48 | $dateFormat.YearQuater | Should -Be '201704'
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Source/Test/Public/Get-Easter.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | }
7 |
8 | Describe 'Get-Easter Tests' {
9 | It ' Gregorian Test' -ForEach @(
10 | @{Year = '1583'; Easter = '1583-04-10'; }
11 | @{Year = '1612'; Easter = '1612-04-22'; }
12 | @{Year = '1722'; Easter = '1722-04-05'; }
13 | @{Year = '1784'; Easter = '1784-04-11'; }
14 | @{Year = '1892'; Easter = '1892-04-17'; }
15 | @{Year = '2075'; Easter = '2075-04-07'; }
16 | @{Year = '2096'; Easter = '2096-04-15'; }
17 | @{Year = '2221'; Easter = '2221-04-15'; }
18 | @{Year = '2369'; Easter = '2369-03-30'; }
19 | @{Year = '2387'; Easter = '2387-04-05'; }
20 | @{Year = '2553'; Easter = '2553-04-01'; }
21 | @{Year = '2599'; Easter = '2599-04-07'; }
22 | @{Year = '2715'; Easter = '2715-04-11'; }
23 | @{Year = '2861'; Easter = '2861-04-17'; }
24 | @{Year = '2933'; Easter = '2933-04-05'; }
25 | @{Year = '3078'; Easter = '3078-04-21'; }
26 | @{Year = '3125'; Easter = '3125-04-12'; }
27 | @{Year = '3229'; Easter = '3229-04-08'; }
28 | @{Year = '3372'; Easter = '3372-04-12'; }
29 | @{Year = '3457'; Easter = '3457-04-05'; }
30 | @{Year = '3510'; Easter = '3510-04-24'; }
31 | @{Year = '3681'; Easter = '3681-04-20'; }
32 | @{Year = '3695'; Easter = '3695-04-17'; }
33 | @{Year = '3783'; Easter = '3783-04-06'; }
34 | @{Year = '3947'; Easter = '3947-04-20'; }
35 | @{Year = '3988'; Easter = '3988-04-17'; }
36 | @{Year = '4099'; Easter = '4099-04-19'; }
37 | ) {
38 | Get-Easter $Year | Should -Be (Get-Date $Easter)
39 | }
40 | }
--------------------------------------------------------------------------------
/Source/Test/Public/Get-PatchTuesday.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | }
7 |
8 | Describe 'Get-PatchTuesday Tests' {
9 | It 'Get-PatchTuesday Test' {
10 | Get-PatchTuesday -Date "11/17/2021" | Should -Be (Get-Date '2021-11-09')
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Source/Test/Public/Get-SunTime.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | }
7 |
8 | Describe 'Get-SunTime Tests' {
9 | It ' Test' -ForEach @(
10 | @{Name = 'Buckingham Palace'; Latitude = 51.501005; Longitude = -0.1445479; Elevation = 0; Sunrise = '03:52'; Sunset = '20:20' }
11 | @{Name = 'The Great Pyramid of Giza'; Latitude = 29.9791705; Longitude = 31.1316297; Elevation = 0; Sunrise = '03:00'; Sunset = '17:01' }
12 | @{Name = 'Imperial Palace'; Latitude = 35.6778452; Longitude = 139.7547335; Elevation = 0; Sunrise = '19:31'; Sunset = '10:01' }
13 | @{Name = 'The White House'; Latitude = 38.8976763; Longitude = -77.0365298; Elevation = 0; Sunrise = '09:49'; Sunset = '00:37' }
14 | @{Name = 'The Eiffel Tower'; Latitude = 48.8583701; Longitude = 2.2919064; Elevation = 0; Sunrise = '03:55'; Sunset = '19:57' }
15 | @{Name = 'Sydney Opera House'; Latitude = -33.8531432; Longitude = 151.1764362; Elevation = 0; Sunrise = '21:01'; Sunset = '07:00' }
16 | @{Name = 'Pier 39'; Latitude = 37.7917995; Longitude = -122.4352178; Elevation = 0; Sunrise = '12:54'; Sunset = '03:36' }
17 | @{Name = 'The Zocalo'; Latitude = 19.4326018; Longitude = -99.1357798; Elevation = 0; Sunrise = '12:04'; Sunset = '01:20' }
18 | @{Name = 'Pike Place Market'; Latitude = 47.6096619; Longitude = -122.344816; Elevation = 0; Sunrise = '12:19'; Sunset = '04:10' }
19 | @{Name = 'Tsim Sha Tsui Waterfront'; Latitude = 22.2974716; Longitude = 114.1772887; Elevation = 0; Sunrise = '21:45'; Sunset = '11:12' }
20 | @{Name = 'Grand Bazaar'; Latitude = 41.0179762; Longitude = 28.9450643; Elevation = 0; Sunrise = '02:39'; Sunset = '17:40' }
21 | @{Name = 'The Forbidden City'; Latitude = 39.9168038; Longitude = 116.3945872; Elevation = 0; Sunrise = '20:52'; Sunset = '11:47' }
22 | @{Name = 'Niagara Falls'; Latitude = 43.0535092; Longitude = -79.3998494; Elevation = 0; Sunrise = '09:45'; Sunset = '01:00' }
23 | @{Name = 'The Colosseum'; Latitude = 41.8902101; Longitude = 12.48736; Elevation = 0; Sunrise = '03:42'; Sunset = '18:49' }
24 | @{Name = 'Times Square'; Latitude = 40.7579747; Longitude = -73.9881175; Elevation = 0; Sunrise = '09:31'; Sunset = '00:31' }
25 | ) {
26 | $TimeZone = [System.TimeZoneInfo]::Utc.Id
27 | $Date = Get-Date '2024-07-05'
28 | $CalculateSunTimesParam = @{
29 | Date = $Date
30 | Latitude = $Latitude
31 | Longitude = $Longitude
32 | Elevation = $Elevation
33 | TimeZone = $TimeZone
34 | }
35 | $Result = Get-SunTime @CalculateSunTimesParam
36 | $Result.Sunrise.ToString('HH:mm') | Should -Be $Sunrise
37 | $Result.Sunset.ToString('HH:mm') | Should -Be $Sunset
38 | }
39 | }
--------------------------------------------------------------------------------
/Source/Test/Public/Measure-TimeSpan.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | }
7 |
8 | Describe 'Measure-TimeSpan' {
9 |
10 | # Sample data to be used in tests
11 | BeforeAll {
12 | # Mock TimeSpanGroupInfo data for testing
13 | $TestDates = @(
14 | [PSCustomObject]@{ Property = 10; TimeSpan = "2024-08-01T00:00:00" },
15 | [PSCustomObject]@{ Property = 20; TimeSpan = "2024-08-01T01:00:00" },
16 | [PSCustomObject]@{ Property = 30; TimeSpan = "2024-08-01T02:00:00" }
17 | )
18 | $groupedData = $TestDates | Group-TimeSpan -Property 'TimeSpan' -Days 1
19 | }
20 |
21 | Context 'Sum Calculation' {
22 | It 'Should calculate the correct sum of the specified property' {
23 | # Mocking the function Group-TimeSpan output
24 | $result = $groupedData | Measure-TimeSpan -Property 'Property' -Sum
25 | $expectedSum = 60
26 |
27 | # Assertion
28 | $result.Sum | Should -BeExactly $expectedSum
29 | }
30 | }
31 |
32 | Context 'Average Calculation' {
33 | It 'Should calculate the correct average of the specified property' {
34 | # Mocking the function Group-TimeSpan output
35 | $result = $groupedData | Measure-TimeSpan -Property 'Property' -Average
36 | $expectedAverage = 20
37 |
38 | # Assertion
39 | $result.Average | Should -BeExactly $expectedAverage
40 | }
41 | }
42 |
43 | Context 'Maximum Calculation' {
44 | It 'Should calculate the correct maximum of the specified property' {
45 | # Mocking the function Group-TimeSpan output
46 | $result = $groupedData | Measure-TimeSpan -Property 'Property' -Maximum
47 | $expectedMax = 30
48 |
49 | # Assertion
50 | $result.Maximum | Should -BeExactly $expectedMax
51 | }
52 | }
53 |
54 | Context 'Minimum Calculation' {
55 | It 'Should calculate the correct minimum of the specified property' {
56 | # Mocking the function Group-TimeSpan output
57 | $result = $groupedData | Measure-TimeSpan -Property 'Property' -Minimum
58 | $expectedMin = 10
59 |
60 | # Assertion
61 | $result.Minimum | Should -BeExactly $expectedMin
62 | }
63 | }
64 |
65 | Context 'IncludeAllTimes Calculations' {
66 | It 'Should calculate the correct sum of the specified properties' {
67 | $AllTestDates = @(
68 | [pscustomobject]@{TimeSpan = [dateTime]::new(2023, 1, 5, 0, 10, 57, 0, 0, 1); Property = 10 }
69 | [pscustomobject]@{TimeSpan = [dateTime]::new(2023, 1, 5, 3, 59, 37, 0, 0, 1); Property = 20 }
70 | [pscustomobject]@{TimeSpan = [dateTime]::new(2023, 1, 5, 5, 21, 36, 0, 0, 1); Property = 30 }
71 | )
72 | $AllGrouping = $AllTestDates | Group-TimeSpan -Property 'TimeSpan' -Hours 1 -Verbose -IncludeAllTimes
73 | $Results = $AllGrouping | Measure-TimeSpan -Property 'Property' -Sum
74 | $Results[0].DateTime | Should -Be ([datetime]'2023-01-05T00:00:00.0000000')
75 | $Results[0].Count | Should -Be 1
76 | $Results[0].Sum | Should -Be 10
77 | $Results[1].DateTime | Should -Be ([datetime]'2023-01-05T01:00:00.0000000')
78 | $Results[1].Count | Should -Be 0
79 | $Results[1].Sum | Should -Be 0
80 | $Results[2].DateTime | Should -Be ([datetime]'2023-01-05T02:00:00.0000000')
81 | $Results[2].Count | Should -Be 0
82 | $Results[2].Sum | Should -Be 0
83 | $Results[3].DateTime | Should -Be ([datetime]'2023-01-05T03:00:00.0000000')
84 | $Results[3].Count | Should -Be 1
85 | $Results[3].Sum | Should -Be 20
86 | $Results[4].DateTime | Should -Be ([datetime]'2023-01-05T04:00:00.0000000')
87 | $Results[4].Count | Should -Be 0
88 | $Results[4].Sum | Should -Be 0
89 | $Results[5].DateTime | Should -Be ([datetime]'2023-01-05T05:00:00.0000000')
90 | $Results[5].Count | Should -Be 1
91 | $Results[5].Sum | Should -Be 30
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/Source/Test/Public/New-Duration.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | }
7 |
8 | Describe 'New-Duration Tests' {
9 | It 'New-Duration Test' {
10 | New-Duration -Start '2/3/2023' -End '2/5/2023' | Should -Be 'P2D'
11 | New-Duration -Days 1 -Hours 4 | Should -Be 'P1DT4H'
12 | New-Duration -Weeks 3 | Should -Be 'P3W'
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Source/Test/Public/Test-CrontabSchedule.Tests.ps1:
--------------------------------------------------------------------------------
1 | BeforeAll {
2 | # Import the module
3 | $TopLevel = (Split-Path(Split-Path(Split-Path $PSScriptRoot)))
4 | $ModulePath = Get-ChildItem -Path (Join-Path $TopLevel 'Build\PSDates') -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
5 | Import-Module $ModulePath.FullName -Force
6 | }
7 |
8 | Describe 'Test-CrontabSchedule Tests' {
9 | It 'Test-CrontabSchedule Valid Test' {
10 | $valid = Test-CrontabSchedule -crontab '0 17 * * *'
11 | $valid.Schedule | Should -Be '0 17 * * *'
12 | $valid.Valid | Should -BeTrue
13 | }
14 |
15 | It 'Test-CrontabSchedule Invalid Test' {
16 | $invalid = Test-CrontabSchedule -crontab '0 17 * 13 *'
17 | $invalid.Schedule | Should -Be '0 17 * 13 *'
18 | $invalid.Valid | Should -BeFalse
19 | $invalid.ErrorMsg | Should -Be '13 is higher than the maximum allowable value for the [Month] field. Value must be between 1 and 12 (all inclusive).'
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/Test/ScriptAnalyzer/PSScriptAnalyzerSettings.psd1:
--------------------------------------------------------------------------------
1 | @{
2 | Severity=@('Error','Warning')
3 | ExcludeRules=@('PSUseShouldProcessForStateChangingFunctions')
4 | }
--------------------------------------------------------------------------------
/Source/Test/ScriptAnalyzer/ScriptAnalyzer.Linter.ps1:
--------------------------------------------------------------------------------
1 | Import-Module PSScriptAnalyzer
2 | $Public = Join-Path (Split-Path(Split-Path $PSScriptRoot)) 'Public'
3 | $Settings = Join-Path $PSScriptRoot 'PSScriptAnalyzerSettings.psd1'
4 | Invoke-ScriptAnalyzer -Path $Public -Recurse -Settings $Settings
--------------------------------------------------------------------------------
/build-docs.ps1:
--------------------------------------------------------------------------------
1 | Set-Location $PSScriptRoot
2 |
3 | if(-not (Test-Path .\Build)){
4 | throw "Project must be built first"
5 | }
6 |
7 | $psd1 = Get-ChildItem .\Build -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
8 | Import-Module $psd1.FullName -Force
9 |
10 | Get-ChildItem .\docs -Filter '*.md' | Remove-Item -Force
11 |
12 | New-MarkdownHelp -Module PSDates -OutputFolder .\docs
13 |
14 | $readme = Get-Content .\README.md
15 | $docs = Get-ChildItem .\docs -Filter '*.md' | ForEach-Object{
16 | $content = Get-Content -LiteralPath $_.FullName
17 | "| [$($_.BaseName)](docs/$($_.Name)) | $($content[$content.IndexOf('## SYNOPSIS')+2]) |"
18 | }
19 |
20 |
21 |
22 | $commands = $false
23 | $readmeupdate = foreach($line in $readme){
24 | if($line -eq '# Commands'){
25 | $commands = $true
26 | $line
27 | ''
28 | '| Cmdlet | Synopsis |'
29 | '| ------ | -------- |'
30 | $docs
31 | ''
32 | }
33 | elseif($commands -and $line -match '^#'){
34 | $commands = $false
35 | }
36 |
37 | if(-not $commands){
38 | $line
39 | }
40 | }
41 |
42 | $readmeupdate | Out-File .\README.md
--------------------------------------------------------------------------------
/build.ps1:
--------------------------------------------------------------------------------
1 | param(
2 | [Parameter(Mandatory = $false)]
3 | [string]$Version = 'v1.0.1'
4 | )
5 |
6 | $VersionNumber = [version]::parse($Version.Split('/')[-1].TrimStart('v'))
7 | Set-Location $PSScriptRoot
8 |
9 | if(Test-Path .\Build){
10 | Get-ChildItem -Path .\Build | Remove-Item -Recurse -Force
11 | }
12 |
13 | # Generate EzOut formaters
14 | . '.\Source\PSDates.EzFormat.ps1'
15 |
16 | $linter = . '.\Source\Test\ScriptAnalyzer\ScriptAnalyzer.Linter.ps1'
17 | if ($linter) {
18 | $linter
19 | throw "Failed linter tests"
20 | }
21 |
22 | Build-Module -SourcePath .\Source -OutputDirectory ..\Build -Version $VersionNumber
23 |
24 | $psd1 = Get-ChildItem .\Build -Filter 'PSDates.psd1' -Recurse | Select-Object -Last 1
25 | $psm1 = Get-ChildItem .\Build -Filter 'PSDates.psm1' -Recurse | Select-Object -Last 1
26 |
27 | $ResourceFolder = Join-Path $psd1.DirectoryName 'Resources'
28 | New-Item -Path $ResourceFolder -ItemType Directory | Out-Null
29 | Copy-Item -Path '.\Source\Resources\CronExpressionDescriptor.dll' -Destination $ResourceFolder
30 | Copy-Item -Path '.\Source\Resources\ncrontab.3.3.0\lib\net35\NCrontab.dll' -Destination $ResourceFolder
31 | Copy-Item -Path '.\Source\Resources\ArgumentCompleters.ps1' -Destination $ResourceFolder
32 |
33 | @'
34 | # Argument Completers
35 | $ArgumentCompleters = Join-Path $PSScriptRoot 'Resources\ArgumentCompleters.ps1'
36 | . $ArgumentCompleters
37 | '@ | Out-File -LiteralPath $psm1.FullName -Append
38 |
39 | #$nuspec = Copy-Item -Path .\Source\PSDates.nuspec -Destination $psd1.DirectoryName -PassThru
40 | #.'nuget.exe' pack "$($nuspec.FullName)" -OutputDirectory .\Build -Version "$($VersionNumber)"
--------------------------------------------------------------------------------
/docs/Convert-TimeZone.md:
--------------------------------------------------------------------------------
1 | ---
2 | external help file: PSDates-help.xml
3 | Module Name: PSDates
4 | online version:
5 | schema: 2.0.0
6 | ---
7 |
8 | # Convert-TimeZone
9 |
10 | ## SYNOPSIS
11 |
12 | Convert a datetime value from one time zone to another
13 |
14 | ## SYNTAX
15 |
16 | ### __AllParameterSets
17 |
18 | ```
19 | Convert-TimeZone [-ToTimeZone] [[-Date ]] [[-FromTimeZone ]] [-ProgressAction ] []
20 | ```
21 |
22 | ## DESCRIPTION
23 |
24 | This function will allows you to pass a date to convert from one time zone to another.
25 | If no date is specified the local time is used.
26 | If no FromTimeZone is passed then the
27 | local time zone is used.
28 | If you don't know the time zone ID you can use the Find-TimeZone cmdlet.
29 |
30 |
31 | ## EXAMPLES
32 |
33 | ### Example 1: EXAMPLE 1
34 |
35 | ```
36 | Convert-TimeZone -ToTimeZone "GMT Standard Time"
37 | ```
38 |
39 | Convert the local system time to GMT Standard Time
40 |
41 |
42 |
43 |
44 |
45 | ### Example 2: EXAMPLE 2
46 |
47 | ```
48 | Convert-TimeZone -date '11/17/2017 12:34 AM' -FromTimeZone "China Standard Time" -ToTimeZone "US Mountain Standard Time"
49 | ```
50 |
51 | Converts the date and time 11/17/2017 12:34 AM from 'China Standard Time' to 'US Mountain Standard Time'
52 |
53 |
54 |
55 |
56 |
57 |
58 | ## PARAMETERS
59 |
60 | ### -Date
61 |
62 | The date to convert.
63 | If not specified the current time will be used
64 |
65 | ```yaml
66 | Type: DateTime
67 | Parameter Sets: (All)
68 | Aliases:
69 | Accepted values:
70 |
71 | Required: True (None) False (All)
72 | Position: 1
73 | Default value: $(Get-Date)
74 | Accept pipeline input: False
75 | Accept wildcard characters: False
76 | DontShow: False
77 | ```
78 |
79 | ### -FromTimeZone
80 |
81 | The time zone ID of the time zone you want to convert the date from.
82 | If not specified the local time zone will be used
83 |
84 | ```yaml
85 | Type: String
86 | Parameter Sets: (All)
87 | Aliases:
88 | Accepted values:
89 |
90 | Required: True (None) False (All)
91 | Position: 2
92 | Default value: [System.TimeZoneInfo]::Local.Id.ToString()
93 | Accept pipeline input: False
94 | Accept wildcard characters: False
95 | DontShow: False
96 | ```
97 |
98 | ### -ProgressAction
99 |
100 | {{ Fill ProgressAction Description }}
101 |
102 | ```yaml
103 | Type: ActionPreference
104 | Parameter Sets: (All)
105 | Aliases: proga
106 | Accepted values:
107 |
108 | Required: True (None) False (All)
109 | Position: Named
110 | Default value:
111 | Accept pipeline input: False
112 | Accept wildcard characters: False
113 | DontShow: False
114 | ```
115 |
116 | ### -ToTimeZone
117 |
118 | The time zone ID of the time zone you want to convert the date to
119 |
120 | ```yaml
121 | Type: String
122 | Parameter Sets: (All)
123 | Aliases:
124 | Accepted values:
125 |
126 | Required: True (All) False (None)
127 | Position: 0
128 | Default value:
129 | Accept pipeline input: False
130 | Accept wildcard characters: False
131 | DontShow: False
132 | ```
133 |
134 |
135 | ### CommonParameters
136 |
137 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
138 |
139 | ## OUTPUTS
140 |
141 | ### A PSObject object containing the time zone conversion data
142 |
143 |
144 |
## NOTES
145 |
146 |
147 |
148 | ## RELATED LINKS
149 |
150 | Fill Related Links Here
151 |
152 |
--------------------------------------------------------------------------------
/docs/Convert-ToDateTime.md:
--------------------------------------------------------------------------------
1 | ---
2 | external help file: PSDates-help.xml
3 | Module Name: PSDates
4 | online version:
5 | schema: 2.0.0
6 | ---
7 |
8 | # Convert-ToDateTime
9 |
10 | ## SYNOPSIS
11 |
12 | Converts various input objects to a DateTime object.
13 |
14 | ## SYNTAX
15 |
16 | ### __AllParameterSets
17 |
18 | ```
19 | Convert-ToDateTime [-InputObject]