| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | #pragma once | |||
| 2 | ||||
| 3 | // https://stackoverflow.com/questions/46899202/how-to-split-date-and-time-macros-into-individual-components-for-variabl | |||
| 4 | 1174 | constexpr int compilationDatePortion(const int startIndex, const int totalChars) { | ||
| 5 | ||||
| 6 | 1174 | int result = 0; | ||
| 7 | 1174 | for (int i = startIndex + totalChars - 1, multiplier = 1; | ||
| 8 |
2/2✓ Branch 0 taken 3522 times.
✓ Branch 1 taken 1174 times.
|
4696 | i >= startIndex; | |
| 9 | 3522 | i--, multiplier *= 10) { | ||
| 10 | 3522 | const char c = __DATE__[i]; | ||
| 11 |
1/2✓ Branch 0 taken 3522 times.
✗ Branch 1 not taken.
|
1/2✓ Decision 'true' taken 3522 times.
✗ Decision 'false' not taken.
|
3522 | if (c != ' ') { |
| 12 | 3522 | result += (c - '0') * multiplier; | ||
| 13 | } | |||
| 14 | } | |||
| 15 | ||||
| 16 | 1174 | return result; | ||
| 17 | } | |||
| 18 | ||||
| 19 | 587 | constexpr int compilationYear() { | ||
| 20 | 587 | return compilationDatePortion(7, 4); | ||
| 21 | } | |||
| 22 | ||||
| 23 | 587 | constexpr int compilationDay() { | ||
| 24 | 587 | return compilationDatePortion(4, 2); | ||
| 25 | } | |||
| 26 | ||||
| 27 | // https://stackoverflow.com/questions/19760221/c-get-the-month-as-number-at-compile-time | |||
| 28 | ||||
| 29 | #define __COMPILATION_MONTH__ (\ | |||
| 30 | __DATE__ [2] == 'n' ? (__DATE__ [1] == 'a' ? 1 : 6) \ | |||
| 31 | : __DATE__ [2] == 'b' ? 2 \ | |||
| 32 | : __DATE__ [2] == 'r' ? (__DATE__ [0] == 'M' ? 3 : 4) \ | |||
| 33 | : __DATE__ [2] == 'y' ? 5 \ | |||
| 34 | : __DATE__ [2] == 'l' ? 7 \ | |||
| 35 | : __DATE__ [2] == 'g' ? 8 \ | |||
| 36 | : __DATE__ [2] == 'p' ? 9 \ | |||
| 37 | : __DATE__ [2] == 't' ? 10 \ | |||
| 38 | : __DATE__ [2] == 'v' ? 11 \ | |||
| 39 | : 12) | |||
| 40 | ||||
| 41 | 587 | constexpr int compilationMonth() { | ||
| 42 |
8/22✗ Branch 0 not taken.
✓ Branch 1 taken 587 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 587 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 587 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 587 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 587 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 587 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 587 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 587 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
587 | return __COMPILATION_MONTH__; | |
| 43 | } | |||
| 44 |