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 | 1172 | constexpr int compilationDatePortion(const int startIndex, const int totalChars) { | ||
5 | ||||
6 | 1172 | int result = 0; | ||
7 | 1172 | for (int i = startIndex + totalChars - 1, multiplier = 1; | ||
8 |
2/2✓ Branch 0 taken 3516 times.
✓ Branch 1 taken 1172 times.
|
4688 | i >= startIndex; | |
9 | 3516 | i--, multiplier *= 10) { | ||
10 | 3516 | const char c = __DATE__[i]; | ||
11 |
2/2✓ Branch 0 taken 2930 times.
✓ Branch 1 taken 586 times.
|
2/2✓ Decision 'true' taken 2930 times.
✓ Decision 'false' taken 586 times.
|
3516 | if (c != ' ') { |
12 | 2930 | result += (c - '0') * multiplier; | ||
13 | } | |||
14 | } | |||
15 | ||||
16 | 1172 | return result; | ||
17 | } | |||
18 | ||||
19 | 586 | constexpr int compilationYear() { | ||
20 | 586 | return compilationDatePortion(7, 4); | ||
21 | } | |||
22 | ||||
23 | 586 | constexpr int compilationDay() { | ||
24 | 586 | 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 | 586 | constexpr int compilationMonth() { | ||
42 |
8/22✗ Branch 0 not taken.
✓ Branch 1 taken 586 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 586 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 586 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 586 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 586 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 586 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 586 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 586 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
586 | return __COMPILATION_MONTH__; | |
43 | } | |||
44 |