PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

[PT Run] [Time and Date plugin] Allow custom format string

Open htcfreek opened this issue 3 years ago • 5 comments

Description of the new feature / enhancement

The PR #16662 implements a new plugin for date and time values.

It might be interesting to support custom format string as user input like the wox plugin "DateTimeFormatter".

Scenario when this would be used?

If the user needs an unsupported format.

Supporting information

https://github.com/sobujbd/Wox.Plugin.DateTimeFormatter


⚠ The work on this enhancement can't begin before the plugin code is merged into main branch!!

htcfreek avatar Mar 09 '22 18:03 htcfreek

PR is merged.

htcfreek avatar Mar 17 '22 20:03 htcfreek

Hi @htcfreek , I think this is a really good idea. Even better would be to also be able to manually add custom format string in the Date and Time plugin settings. So the user could specify their own custom format and always have it appear as the very last result (hence possible to navigate directly to it by pressing up).

The reason this functionality would be pretty useful is because currently none of the include date & time formats can be directly pasted into a Windows file / directory name, since they include either forward slashes or colons. I created an issue #24911 for a proposal for a simple addition of one more date time format, but more robust solution with custom persistable format would be preferable I think.

Picazsoo avatar Mar 19 '23 21:03 Picazsoo

I have searched for this and can't find it, so apologies if it's a duplicate suggestion.

I spend a lot of time with one foot in the USA and the other in Great Britain or Europe, and that means dates being misinterpreted because of the mm/dd/yy vs dd/mm/yy thing we are all familiar with.

This multicultural issue has led me in my daily life to use the format you see on passports and some American driver licenses: DD-MMM-YYYY, for example, today is: 3 MAR 2025

It is impossible to misinterpret a date written in this format, and I've taken to formatting my dates this way in Excel and in correspondence. I mostly use a short "long form" in my correspondence when adding days of the week: Mon 3 Mar 2025

The cultural issue, which I suspect many people have, particularly Americans working overseas: Having worked on loads of US based accounting documents in my career, my habit is to enter dates on the numerical keypad in US format. So while I write today's date as Mon 3-Mar-2025, I enter today's date in Excel as 3/3/25.

So far, so good - Windows can do this, and Excel can do this, as it stores dates as numbers and we have loads of formatting options including just this issue. But that is only true if my Windows settings are set to USA, like this: Image

But I really struggle with that - I want my Windows system date to look like this: Image

Actually, I would prefer the system date to read "Mon 3 Mar 2025" but I can't find a way to produce this "short" longform

Problem #1 When you dig into the "English (world) settings, there is no short or long form option that abbreviates the days of the week to Mon, Tue, Wed, Thu, Fri, Sat and Sun. The longform system date that includes the day of the week uses too much real estate.

It would be terrific if we could add an abbreviated day of week to the short date option.

Problem #2 When you have set the system date parameters to the "world" settings, your excel spreadsheets no longer provide a formatting option which permits data entry in mm/dd/yy format. Your entire Excel world is now expecting data entry in dd/mm/yy format and its derivatives.

I cannot for the life of me sort out how use the international system date format I prefer in combination with Excel accepting date entry in standard US format of mm/dd/yy with the option of displaying those dates in the "International Passport" format.

Perhaps I'm missing something despite having played around with Excel date and custom format options for ages.

Is this something that could be done? Or have I completely missed the standard options available to me?

Thanks

YankeeGeordie avatar Mar 03 '25 21:03 YankeeGeordie

Well you bring me to an idea that could be the best solution. We add a multilline text setting that allows the following:

MyFormat1=YYYY-DD-MM
MyFormat2=DD-MMM-YYYY
....

The format definition then can be used in DateTime.ToString(<definition>).


Implement idea:

  • Two settings: One for results based on local time and one for formats based on UTC time. [Icon type = DateTime]
  • try-catch and on error show error result like "invalid format definition" and write log with exception. [Result icon type is new type error.]
  • Alternativ tags: Custom date, Custom time[, UTC, Universal Time Convention]
  • Format syntax: https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

htcfreek avatar Mar 03 '25 21:03 htcfreek

Thank you.

Since my programming days pretty much ended with COBOL, FORTRAN and dBase III with a touch of SQL in the 1980s, I'll not annoy you with code related suggestions, but perhaps this clarification helps:

  1. Excel appears to derive what it expects as date entry formats from the system date setting.
  2. Excel offers different date formatting options based on the formatting of the system date.
  3. A logical fork which allows formatting the displayed system date to be different from the instructions Excel receives might prove useful in getting the end result I'm suggesting.
  4. Adding more examples to include day of week to your multiline text:

MyFormat3=DOW-DD-MMM-YYYY MyFormat4=DOW_DD_MMM_YYYY

So put another way, what I'm suggesting is a separation between the system date format as shown on the Windows taskbar and the system date format as read by Excel (and likely other Microsoft products). Either that, or modify the date options code in Excel that permits the same level of customization.

To follow any of this, one must understand something that I find very odd and might be missed at first reading, so I'll repeat it:

While Excel stores dates as numbers and can format their display in many different ways, Excel does not appear to offer options as to how those dates are entered. So if the system date is set to "World", Excel expects you to enter dates in dd/mm/yy sequence. I propose a bifurcated approach, allowing display of system date in World format and data entry of dates in US format.

I hope that is clear! And if you got all that the first time, I apologize for repeating it. Thank you again.

YankeeGeordie avatar Mar 04 '25 01:03 YankeeGeordie

this is part of the 0.91.0 release

htcfreek avatar May 19 '25 07:05 htcfreek