-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Days of the Week evaluated as UTC and not the configured Time Zone #20
Comments
Hello aclarkot, Thanks for reporting, what version of the script are you running? Make sure you test with the latest, 3.9.0. Regards, |
I've tested with 3.9.0 and 3.9.2, the behavior is the same with both. The workaround I implemented above is resolving the issue in my case. So, the script doesn't evaluate 'day of the week' with the correct time zone, it only uses UTC. |
Hi Tom, |
Hi @aclarkot and @tomasrudh, I believe the code segment if ($TimeRange -eq (Get-Date).DayOfWeek) { Should be changed to if ($TimeRange -eq [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId([DateTime]::Now,$tz).dayofweek) { Where ever the logic written by using Get-Date in the code, I think we need to consider using ConvertTimeBySystemTimeZoneId by passing the $tx variable. @aclarkot , in your workaround, I believe $parsedDay = (Get-Date "00:00").Addhours(13) might have an issue. Because parseday variable is using to get the range for 24 hours of the day which needs to be start at 12:00 AM . Cheers, |
Describe the bug
When you specify a tag that includes days of the week E.g., '18:00->07:00,Saturday,Sunday'. The time-range (18:00->-7:00) is correctly evaluated using the time zone configured in the TZ variable. However, the days of the week (Saturday, Sunday) ignore the time zone and are evaluated as UTC. In my case TZ is set to 'New Zealand Standard Time' (UTC+13) so this is a major issue, the VMs don't shutdown until 1PM on Saturday.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The VM should shutdown at 00:00 according to the time zone in TZ on the specified day.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
The problem code block is below. Notice that 'Get-Date' will always return UTC unless it is modified with Get-Date.AddHours(X).
I have hacked it to work for my scenario as below by adding 13 hours for NZST.
A proper solution is needed to always adjust Get-Date output according to the UTC offset required by the configured time zone.
The text was updated successfully, but these errors were encountered: