PasteIntoFile icon indicating copy to clipboard operation
PasteIntoFile copied to clipboard

Format specifier for day of the year

Open Crunchbits opened this issue 1 year ago • 5 comments

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!

Crunchbits avatar Jun 28 '24 00:06 Crunchbits

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.

eltos avatar Jun 28 '24 18:06 eltos

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"?

faizahfarzana avatar Jul 01 '24 12:07 faizahfarzana

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.

eltos avatar Jul 01 '24 20:07 eltos

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.

Crunchbits avatar Jul 02 '24 01:07 Crunchbits

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

faizahfarzana avatar Jul 02 '24 09:07 faizahfarzana