Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#if !UNIX

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand Down Expand Up @@ -66,15 +64,7 @@ protected override void ProcessRecord()
{
WriteObject(TimeZoneInfo.FindSystemTimeZoneById(tzid));
}
#if CORECLR
// TimeZoneNotFoundException is thrown by TimeZoneInfo, but not
// publicly visible (so can't be caught), so for now we're catching
// the parent exception time. This should be removed once the more
// specific exception is available.
catch (Exception e)
#else
catch (TimeZoneNotFoundException e)
#endif
{
WriteError(new ErrorRecord(e, TimeZoneHelper.TimeZoneNotFoundError,
ErrorCategory.InvalidArgument, "Id"));
Expand Down Expand Up @@ -103,14 +93,8 @@ protected override void ProcessRecord()
{
string message = string.Format(CultureInfo.InvariantCulture,
TimeZoneResources.TimeZoneNameNotFound, tzname);
#if CORECLR
// Because .NET Core does not currently expose the TimeZoneNotFoundException
// we need to throw the more generic parent exception class for the time being.
// This should be removed once the correct exception class is available.
Exception e = new Exception(message);
#else

Exception e = new TimeZoneNotFoundException(message);
#endif
WriteError(new ErrorRecord(e, TimeZoneHelper.TimeZoneNotFoundError,
ErrorCategory.InvalidArgument, "Name"));
}
Expand All @@ -125,6 +109,7 @@ protected override void ProcessRecord()
}
}

#if !UNIX

/// <summary>
/// A cmdlet to set the system's local time zone.
Expand Down Expand Up @@ -804,7 +789,7 @@ public struct TOKEN_PRIVILEGES
#endregion Win32 interop helper
}


#endif
/// <summary>
/// static Helper class for working with system time zones.
/// </summary>
Expand Down Expand Up @@ -862,5 +847,3 @@ internal static TimeZoneInfo[] LookupSystemTimeZoneInfoByName(string name)
}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ CmdletsToExport=@("Add-Content",
"Rename-ItemProperty",
"Resolve-Path",
"Set-Content",
"Set-ItemProperty")
"Set-ItemProperty",
"Get-TimeZone")
}
Loading