8000 Enable Get-TimeZone for *nix and Mac OS. · PowerShell/PowerShell@cfdae30 · GitHub
[go: up one dir, main page]

Skip to content

Commit cfdae30

Browse files
Enable Get-TimeZone for *nix and Mac OS.
Get-TimeZone can be enabled now as the required classes are available in .Net Standard 2.0 Address code review feedback
1 parent 6342944 commit cfdae30

File tree

5 files changed

+142
-155
lines changed

5 files changed

+142
-155
lines changed

src/Microsoft.PowerShell.Commands.Management/commands/management/TimeZoneCommands.cs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#if !UNIX
2-
31
using System;
42
using System.Collections.Generic;
53
using System.Collections.ObjectModel;
@@ -66,15 +64,7 @@ protected override void ProcessRecord()
6664
{
6765
WriteObject(TimeZoneInfo.FindSystemTimeZoneById(tzid));
6866
}
69-
#if CORECLR
70-
// TimeZoneNotFoundException is thrown by TimeZoneInfo, but not
71-
// publicly visible (so can't be caught), so for now we're catching
72-
// the parent exception time. This should be removed once the more
73-
// specific exception is available.
74-
catch (Exception e)
75-
#else
7667
catch (TimeZoneNotFoundException e)
77-
#endif
7868
{
7969
WriteError(new ErrorRecord(e, TimeZoneHelper.TimeZoneNotFoundError,
8070
ErrorCategory.InvalidArgument, "Id"));
@@ -103,14 +93,8 @@ protected override void ProcessRecord()
10393
{
10494
string message = string.Format(CultureInfo.InvariantCulture,
10595
TimeZoneResources.TimeZoneNameNotFound, tzname);
106-
#if CORECLR
107-
// Because .NET Core does not currently expose the TimeZoneNotFoundException
108-
// we need to throw the more generic parent exception class for the time being.
109-
// This should be removed once the correct exception class is available.
110-
Exception e = new Exception(message);
111-
#else
96+
11297
Exception e = new TimeZoneNotFoundException(message);
113-
#endif
11498
WriteError(new ErrorRecord(e, TimeZoneHelper.TimeZoneNotFoundError,
11599
ErrorCategory.InvalidArgument, "Name"));
116100
}
@@ -125,6 +109,7 @@ protected override void ProcessRecord()
125109
}
126110
}
127111

112+
#if !UNIX
128113

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

807-
792+
#endif
808793
/// <summary>
809794
/// static Helper class for working with system time zones.
810795
/// </summary>
@@ -862,5 +847,3 @@ internal static TimeZoneInfo[] LookupSystemTimeZoneInfoByName(string name)
862847
}
863848
}
864849
}
865-
866-
#endif

src/Modules/Unix/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ CmdletsToExport=@("Add-Content",
4848
"Rename-ItemProperty",
4949
"Resolve-Path",
5050
"Set-Content",
51-
"Set-ItemProperty")
51+
"Set-ItemProperty",
52+
"Get-TimeZone")
5253
}

0 commit comments

Comments
 (0)
0