settings: use 2024 as default year
having 2024 as default year will make it less annoying to configure year
Build checks have not completed. Possible reasons for this are:
- The checks need to be approved by a maintainer
- The branch has conflicts
- The firmware build has failed
One option would be using the compiler to insert the current year at time of compilation, I'm sure that's possible as the build date page in settings already exists
Edit: looks like __DATE__ + 7 works in theory? Might generate some warnings though
Edit edit: atoi(__DATE__ + 7) compiles with no warnings on GCC 13 at least, but I haven't tested if it actually works correctly
I like the idea of using the __DATE__ macro to use the current year, but something bugs me about using atoi to do the conversion as that'll run at runtime rather than compile-time. That's why it could be fun (although completely unnecessary) to write a simple constexpr atoi-like function so that all of it can be done at compile time.
This attempt at constexpr atoi looks pretty bleak https://stackoverflow.com/a/59537554 😅 Maybe we only need part of it though
constexpr int isdigit_constexpr(int c) {
return c >= '0' && c <= '9';
}
constexpr int atoi_constexpr(char const *str) {
int result = 0;
while (isdigit_constexpr(*str)) {
result = result * 10 + *str - '0';
str++;
}
return result;
}
I have no idea why that implementation looks so difficult, this is all it takes. I guess it could be that this isn't standards-compliant, and in that post they were trying to be as compliant as possible.
That looks much more reasonable and does the job here :+1:
@mark9064 thanks, good suggestions.
however i would not be able to make all those changes. my reasoning was to to make this PR because it is vary easy to change constant, instead of opening an issue about this.
please feel free to take over this PR or close it and make another one.
With #2133 this is integrated now and can be closed
@vladopajic Thank you for the idea of setting the year by default! And for the initial implementation, it was very helpful for working out the final solution.
@vladopajic Thank you for the idea of setting the year by default! And for the initial implementation, it was very helpful for working out the final solution.
🙏
kudos to you guys!