mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 04:37:30 +02:00
[PTRun][DateTime]Fix and improvements for Windows File Time and Unix Epoch Time (#29900)
* improvements and fixes for unix time and windows file time * spell fix
This commit is contained in:
@@ -260,7 +260,7 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UnixTimestampFormat()
|
||||
public void UnixTimestampSecondsFormat()
|
||||
{
|
||||
// Setup
|
||||
string formatLabel = "Unix epoch time";
|
||||
@@ -275,6 +275,22 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
|
||||
Assert.AreEqual(expectedResult.ToString(CultureInfo.CurrentCulture), result?.Value);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UnixTimestampMillisecondsFormat()
|
||||
{
|
||||
// Setup
|
||||
string formatLabel = "Unix epoch time in milliseconds";
|
||||
DateTime timeValue = DateTime.Now.ToUniversalTime();
|
||||
var helperResults = AvailableResultsList.GetList(true, false, false, timeValue);
|
||||
var expectedResult = (long)timeValue.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds;
|
||||
|
||||
// Act
|
||||
var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(expectedResult.ToString(CultureInfo.CurrentCulture), result?.Value);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void WindowsFileTimeFormat()
|
||||
{
|
||||
@@ -282,7 +298,7 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
|
||||
string formatLabel = "Windows file time (Int64 number)";
|
||||
DateTime timeValue = DateTime.Now;
|
||||
var helperResults = AvailableResultsList.GetList(true, false, false, timeValue);
|
||||
var expectedResult = timeValue.Ticks.ToString(CultureInfo.CurrentCulture);
|
||||
var expectedResult = timeValue.ToFileTime().ToString(CultureInfo.CurrentCulture);
|
||||
|
||||
// Act
|
||||
var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
Reference in New Issue
Block a user