Add filename-compatible date & time format (#25020)

* enable the functionality to have filename-compatible date & time

* fix PowerToys.sln

* fix DateTime format

* remove unrelated code

* modify date time format

* fix tests

* fix hours to 24h format and modify tests to cover the case better. Simplify tests slightly
This commit is contained in:
Jachym Metlicka
2023-03-28 14:52:21 +02:00
committed by GitHub
parent 543d5d1b6d
commit b2b7dc3ccf
6 changed files with 76 additions and 41 deletions

View File

@@ -256,6 +256,13 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.Components
AlternativeSearchTag = ResultHelper.SelectStringFromResources(isSystemDateTime, "Microsoft_plugin_timedate_SearchTagFormat"),
IconType = ResultIconType.DateTime,
},
new AvailableResult()
{
Value = dateTimeNow.ToString("yyyy-MM-dd_HH-mm-ss", CultureInfo.InvariantCulture),
Label = Resources.Microsoft_plugin_timedate_filename_compatible,
AlternativeSearchTag = ResultHelper.SelectStringFromResources(isSystemDateTime, "Microsoft_plugin_timedate_SearchTagFormat"),
IconType = ResultIconType.DateTime,
},
});
}

View File

@@ -177,6 +177,15 @@ namespace Microsoft.PowerToys.Run.Plugin.TimeDate.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Date and time in filename-compatible format.
/// </summary>
internal static string Microsoft_plugin_timedate_filename_compatible {
get {
return ResourceManager.GetString("Microsoft_plugin_timedate_filename_compatible", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Hour.
/// </summary>

View File

@@ -175,6 +175,10 @@
<value>ISO 8601 UTC with time zone</value>
<comment>'UTC' means here 'Universal Time Convention'</comment>
</data>
<data name="Microsoft_plugin_timedate_filename_compatible" xml:space="preserve">
<value>Date and time in filename-compatible format</value>
<comment>The format allows for embedding in filenames</comment>
</data>
<data name="Microsoft_plugin_timedate_Millisecond" xml:space="preserve">
<value>Millisecond</value>
</data>