Microsoft Virtualization Discussions
Microsoft Virtualization Discussions
I've noticed a strange issue in the latest versions of the Powershell ONTAP toolkit. When I return the AccessTimeDT of a snapshot using Get-NaSnapshot, the Kind property of the DateTime property is set to local. I can confirm in older versions (1.7 to be precise), it would return the default value of unspecified (which assumes UTC).
What this is doing is causing the .ToLocalTime() method to NOT work on AccessTimeDT. For instance, I'm located in UTC -4 (EST) time zone. Basically, I can only return UTC times.
For example: When I get the AccessTimeDT property of snapshots, they are shown in the UTC time zone. A snapshot shows an AccessTimeDT of 11/1/2012 4:00 PM. In my time, it's actually 11/1/2012 12:00 PM. In past versions, if I call:
$snapshot.AccessTimeDT
# Displays 11/1/2012 4:00 PM
$snapshot.AccessTimeDT.ToLocalTime()
# Displays 11/1/2012 12:00 PM
$snapshot.AccessTimeDT.Kind
# Displays "unspecified"
SInce Upgrading to version 2.2, I get the following results:
$snapshot.AccessTimeDT
# Displays 11/1/2012 4:00 PM
$snapshot.AccessTimeDT.ToLocalTime()
# Displays 11/1/2012 4:00 PM
$snapshot.AccessTimeDT.Kind
# Displays "local"
There is something different going on in the handling of the DateTime objects for snapshots. Are you specifically setting the Kind property to "local" for some reason?
I've verified t his works in 1.7, but not in versions 2.1 and on. I don't have version 2.0 to test with.
Thanks!
Solved! See The Solution
Thanks for bringing this to our attention. We'll look into what caused this change. In the meantime, you can construct a new DateTime object with an unspecified kind using New-Object DateTime @($snapshot.AccessTimeDT.Ticks).
Thanks,
Steven
Thanks for bringing this to our attention. We'll look into what caused this change. In the meantime, you can construct a new DateTime object with an unspecified kind using New-Object DateTime @($snapshot.AccessTimeDT.Ticks).
Thanks,
Steven
Thanks for the suggestion! I look foward to a resolution.
Please tell me, how to handle snapshots created in daylight saving time!
I see two options:
1) Go to version 1.7 or before.
2) Use this instead:
([DateTime]($snapshot.AccessTimeDT.Ticks)).ToLocalTime()
Thanks, that works localy, how does it work for remotely managed NetApps of other timezones?
I think you'd need to omit the ToLocalTime() method call so it returns UTC if you are querying controllers outside your timezone.
Yes, but for example, Pacific Standard Time (PST) becomes Pacific Daylight Time (PDT)!
If you are working with UTC I'm not sure how that matters. I may be missing the scenario you are describing...