eltos / PasteIntoFile

Paste clipboard data into files and copy file contents directly via hotkey or context menu
MIT License
84 stars 6 forks source link

Format specifier for day of the year #49

Open Crunchbits opened 3 weeks ago

Crunchbits commented 3 weeks ago

Description A new format specifier for the day of the year (1-365). This would be very useful to use instead of using month+day of the month. It's shorter most of the time throughout the year and so it's easier to read at a glance.

Specification and constraints I've seen some programs use j as the variable for the day of the year but I don't know if that's a common standard. Also would prefer if there was no leading zeros on single and double digits, but I suppose two versions could be made if desired.

Thanks for the useful program!

eltos commented 3 weeks ago

The program uses the format specifiers provided by .NET framework as described here: https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

Day-of-year is not part of this standard and would require some custom implementation.

This is the relevant code in Dialog.cs:

public static string formatFilenameTemplate(string template, DateTime timestamp, int count) {
    return String.Format(template, timestamp, count);
}

Feel free to submit a PR if anybody likes to implement this.

faizahfarzana commented 3 weeks ago

Hi, I'm interested to work on this issue. For clarification, the current default file name format is like "2024-07-01 17-53-00" and you want to remove the mm-dd part and use the day of year like this "2024-156 17-53-00"?

eltos commented 3 weeks ago

Hi @faizahfarzana, I appreciate your intended contribution. From my point of view the default format should be kept, rather you could add an additional format to the list of predefined templates in TemplateEdit.cs. @Crunchbits suggested j as a character, so the template could be something like "{0:yyyy-j HH-mm-ss}" or maybe jjj with zero padding. Feel free to use a different character or uppercase as you find most appropriate. Once support for these characters has been implemented, the temple can easily be adopted as @Crunchbits prefers.

Crunchbits commented 3 weeks ago

Agreed that the default template should stay the same. Day of year would just be a variable that could be added to the custom template.

faizahfarzana commented 3 weeks ago

Thank you both for the clarification. I'll assess this and get to work.