Repository: microsoft/PowerToys
File: src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.TimeDate/Helpers/TimeAndDateHelper.cs (C#)

Code before:
                    throw new ArgumentOutOfRangeException("Not a valid Excel date.", innerException: null);
                }

                return v;
            default:
                // OLE Automation date: Return as is.
                return v;
        }
    }

    /// <summary>
    /// Convert input string to a <see cref="DateTime"/> object in local time
    /// </summary>
    /// <param name="input">String with date/time</param>
    /// <param name="timestamp">The new <see cref="DateTime"/> object</param>
    /// <param name="inputParsingErrorMsg">Error message shown to the user</param>
    /// <returns>True on success, otherwise false</returns>
    internal static bool ParseStringAsDateTime(in string input, out DateTime timestamp, out string inputParsingErrorMsg)
    {
        inputParsingErrorMsg = string.Empty;
        CompositeFormat errorMessage = CompositeFormat.Parse(Resources.Microsoft_plugin_timedate_InvalidInput_SupportedRange);

        if (DateTime.TryParse(input, out timestamp))
        {
            // Known date/time format
            Logger.LogInfo($"Successfully parsed standard date/time format: '{input}' as {timestamp}");
            return true;
        }
        else if (Regex.IsMatch(input, @"^u[\+-]?\d+$"))
        {
            // Unix time stamp
            // We use long instead of int, because int is too small after 03:14:07 UTC 2038-01-19
            var canParse = long.TryParse(input.TrimStart('u'), out var secondsU);

            // Value has to be in the range from -62135596800 to 253402300799
            if (!canParse || secondsU < UnixTimeSecondsMin || secondsU > UnixTimeSecondsMax)
            {
                inputParsingErrorMsg = string.Format(CultureInfo.CurrentCulture, errorMessage, Resources.Microsoft_plugin_timedate_Unix, UnixTimeSecondsMin, UnixTimeSecondsMax);
                timestamp = new DateTime(1, 1, 1, 1, 1, 1);
                Logger.LogError($"Failed to parse unix timestamp: '{input}'. Value out of range.");
                return false;
            }

            timestamp = DateTimeOffset.FromUnixTimeSeconds(secondsU).LocalDateTime;
            Logger.LogInfo($"Successfully parsed unix timestamp: '{input}' as {timestamp}");
            return true;
        }
        else if (Regex.IsMatch(input, @"^ums[\+-]?\d+$"))
        {
            // Unix time stamp in milliseconds
            // We use long instead of int because int is too small after 03:14:07 UTC 2038-01-19

Review comment (bug):
thank you for adding logging. For me the LogInfo on success parsing feels to much. I think this will only spam the log file. I suggest to either remove or to use `LogDebug`.

Code after:
                    throw new ArgumentOutOfRangeException("Not a valid Excel date.", innerException: null);
                }

                return v;
            default:
                // OLE Automation date: Return as is.
                return v;
        }
    }

    /// <summary>
    /// Convert input string to a <see cref="DateTime"/> object in local time
    /// </summary>
    /// <param name="input">String with date/time</param>
    /// <param name="timestamp">The new <see cref="DateTime"/> object</param>
    /// <param name="inputParsingErrorMsg">Error message shown to the user</param>
    /// <returns>True on success, otherwise false</returns>
    internal static bool ParseStringAsDateTime(in string input, out DateTime timestamp, out string inputParsingErrorMsg)
    {
        inputParsingErrorMsg = string.Empty;
        CompositeFormat errorMessage = CompositeFormat.Parse(Resources.Microsoft_plugin_timedate_InvalidInput_SupportedRange);

        if (DateTime.TryParse(input, out timestamp))
        {
            // Known date/time format
            Logger.LogDebug($"Successfully parsed standard date/time format: '{input}' as {timestamp}");
            return true;
        }
        else if (Regex.IsMatch(input, @"^u[\+-]?\d+$"))
        {
            // Unix time stamp
            // We use long instead of int, because int is too small after 03:14:07 UTC 2038-01-19
            var canParse = long.TryParse(input.TrimStart('u'), out var secondsU);

            // Value has to be in the range from -62135596800 to 253402300799
            if (!canParse || secondsU < UnixTimeSecondsMin || secondsU > UnixTimeSecondsMax)
            {
                inputParsingErrorMsg = string.Format(CultureInfo.CurrentCulture, errorMessage, Resources.Microsoft_plugin_timedate_Unix, UnixTimeSecondsMin, UnixTimeSecondsMax);
                timestamp = new DateTime(1, 1, 1, 1, 1, 1);
                Logger.LogError($"Failed to parse unix timestamp: '{input}'. Value out of range.");
                return false;
            }

            timestamp = DateTimeOffset.FromUnixTimeSeconds(secondsU).LocalDateTime;
            Logger.LogDebug($"Successfully parsed unix timestamp: '{input}' as {timestamp}");
            return true;
        }
        else if (Regex.IsMatch(input, @"^ums[\+-]?\d+$"))
        {
            // Unix time stamp in milliseconds
            // We use long instead of int because int is too small after 03:14:07 UTC 2038-01-19