Created
May 2, 2026 21:03
-
-
Save xv/e7c625f21752bbba2a41af7a2af374ba to your computer and use it in GitHub Desktop.
Better (subjective?) C/C++ __DATE__ (Mmm dd yyyy) macro that adds a zero to dd instead of the default space if the value is less than 10.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define BUILD_DATE (const char[]) { \ | |
| __DATE__[0], __DATE__[1], __DATE__[2], __DATE__[3], \ | |
| (__DATE__[4] == ' ' ? '0' : __DATE__[4]), __DATE__[5], \ | |
| __DATE__[6], __DATE__[7], __DATE__[8], \ | |
| __DATE__[9], __DATE__[10], '\0' \ | |
| } | |
| // Use: | |
| // printf("%s\n", BUILD_DATE); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment