Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format specifier for day of the year #49

Open
Crunchbits opened this issue Jun 28, 2024 · 5 comments
Open

Format specifier for day of the year #49

Crunchbits opened this issue Jun 28, 2024 · 5 comments
Labels
enhancement New feature or request good first issue Indicates a good issue for first-time contributors

Comments

@Crunchbits
Copy link

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 Crunchbits added the enhancement New feature or request label Jun 28, 2024
@eltos eltos added the good first issue Indicates a good issue for first-time contributors label Jun 28, 2024
@eltos
Copy link
Owner

eltos commented Jun 28, 2024

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
Copy link

faizahfarzana commented Jul 1, 2024

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
Copy link
Owner

eltos commented Jul 1, 2024

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
Copy link
Author

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Indicates a good issue for first-time contributors
Projects
None yet
Development

No branches or pull requests

3 participants