[PT Run][Time and Date] Add friendly date/time result (#16809)#46803
Open
RealPratham21 wants to merge 1 commit intomicrosoft:mainfrom
Open
[PT Run][Time and Date] Add friendly date/time result (#16809)#46803RealPratham21 wants to merge 1 commit intomicrosoft:mainfrom
RealPratham21 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
This PR adds a Friendly date/time result to the Time and Date PT Run plugin.
The plugin now shows a human-readable representation (e.g. “Today”, “Yesterday”, “in 3 hours”, “4 hours ago”) alongside the existing formats when the user queries the current system time or a specific timestamp. The change is localized, documented, and covered by unit tests in the TimeDate plugin test project.
PR Checklist
Detailed Description of the Pull Request / Additional comments
New Friendly result
Friendlyresult inAvailableResultsList.GetListthat is shown together with the existing formats (Time, Date, Now, Unix, ISO 8601, etc.) when returning the full result list.TimeAndDateHelper.GetFriendlyDateTime(DateTime target, DateTime referenceNow), which:DateTimeKind(UTC values are converted to local for comparison).Integration and localization
AvailableResultsList.GetListgained an optionalnowparameter so tests can inject a stable reference time; callers in production continue to use current system time whennowis not specified.Resources.resxwith corresponding properties inResources.Designer.cs.Tests and docs
TimeAndDateHelperTests: added a data-driven test that verifies typical Friendly outputs (e.g. “4 hours ago”, “in 3 hours”, “Today”, “Yesterday”, “Tomorrow”) for a fixednowand different targets.TimeDateResultTests: updated to call the newGetListsignature and to ensure existing format values remain unchanged.ImageTests: extended to assert that the Friendly result uses the expected DateTime icon in both dark and light themes.QueryTests: adjusted expected counts for keyword queries that now include the Friendly result, and confirmed that Friendly participates in the same matching logic as other formats.doc/devdocs/modules/launcher/plugins/timedate.md: added the Friendly format to the “List of available formats” table with an example like “Yesterday”.Note on tests: due to tooling constraints on my current machine (Visual Studio workloads / Windows SDK installation blocked by disk space), I was not able to run the TimeDate test project end-to-end locally. The changes are intentionally scoped to the TimeDate plugin and its tests, and I would appreciate CI and at least one local maintainer run of
Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTestsbefore merge.Validation Steps Performed
Automated (intended):
dotnet test src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests.csproj -c Release(I could not complete this locally due to missing VS workloads / SDK; please run in CI or on a fully provisioned dev machine.)
Suggested manual validation:
now(or just the keyword, depending on configuration).10:00vs an assumed13:00now, or specific dates).friendly,relative,yesterday.