Microsoft Virtualization Discussions

Get-NaSnapshot AccessTimeDT property Kind is set to local

bsti

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!

8 REPLIES 8

Re: Get-NaSnapshot AccessTimeDT property Kind is set to local

beam

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

View solution in original post

Re: Get-NaSnapshot AccessTimeDT property Kind is set to local

bsti

Thanks for the suggestion!  I look foward to a resolution.

Re: Get-NaSnapshot AccessTimeDT property Kind is set to local

wippel

Please tell me, how to handle snapshots created in daylight saving time!

Re: Get-NaSnapshot AccessTimeDT property Kind is set to local

bsti

I see two options:

1)  Go to version 1.7 or before.

2)  Use this instead:

([DateTime]($snapshot.AccessTimeDT.Ticks)).ToLocalTime()

Re: Get-NaSnapshot AccessTimeDT property Kind is set to local

wippel

Thanks, that works localy, how does it work for remotely managed NetApps of other timezones?

Re: Get-NaSnapshot AccessTimeDT property Kind is set to local

bsti

I think you'd need to omit the ToLocalTime() method call so it returns UTC if you are querying controllers outside your timezone.

Re: Get-NaSnapshot AccessTimeDT property Kind is set to local

wippel

Yes, but for example, Pacific Standard Time (PST) becomes Pacific Daylight Time (PDT)!

Re: Get-NaSnapshot AccessTimeDT property Kind is set to local

bsti

If you are working with UTC I'm not sure how that matters.  I may be missing the scenario you are describing...

Earn Rewards for Your Review!
GPI Review Banner
All Community Forums
Public