Skip to content

Commit

Permalink
Fixing datetime issues
Browse files Browse the repository at this point in the history
  • Loading branch information
syne0 committed Sep 15, 2024
1 parent 363231a commit fa52c70
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Osprey/functions/General/Start-Osprey.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 284,8 @@ Function Start-Osprey {

# Determine if the input was a date time
# True means it was NOT a datetime
if ($Null -eq $StartRead) {

if ([string]::IsNullOrEmpty($StartRead)) {
# if we have a null entry (just hit enter) then set startread to the default of 90
$StartRead = 90
# Calculate our startdate setting it to midnight
Expand All @@ -297,6 298,13 @@ Function Start-Osprey {
$StartDate = ((Get-Date).AddDays(-$StartRead)).Date
Write-Information ("Setting StartDate by Calculation to " $StartDate "`n")
}
elseif ($StartRead -ge 180) {
Write-Information "That's too far ahead. Defaulting to 180 days."
$StartRead = 180
Write-Information ("Calculating Start Date from current date minus " $StartRead " days.")
$StartDate = ((Get-Date).AddDays(-$StartRead)).Date
Write-Information ("Setting StartDate by Calculation to " $StartDate "`n")
}
elseif ($StartRead -as [DateTime]) {
#### DATE TIME Provided ####
# Convert the input to a date time object
Expand All @@ -315,7 323,7 @@ Function Start-Osprey {

$EndRead = Read-Host "`nLast Day of search Window (0-179, date, Default Today)"

if ($Null -eq $EndRead -or $EndRead -eq 0) {
if ([string]::IsNullOrEmpty($EndRead) -or $EndRead -eq 0) {
# if we have a null entry (just hit enter) then set endread to the default of 1
Write-Information ("Setting End Date to Today")
$EndDate = ((Get-Date).AddDays(1)).Date
Expand Down

0 comments on commit fa52c70

Please sign in to comment.