#pragma XOD dirtieness disable
node {
uint8_t leap(uint32_t year) {
return (year % 400 == 0) || (year % 100 != 0) && (year % 4 == 0);
}
void evaluate(Context ctx) {
uint8_t l = leap(getValue<input_YEAR>(ctx));
switch ((uint8_t) getValue<input_MON>(ctx)) {
case 2:
emitValue<output_SIZE>(ctx, 28 + l);
break;
case 4:
case 6:
case 9:
case 11:
emitValue<output_SIZE>(ctx, 30);
break;
default:
emitValue<output_SIZE>(ctx, 31);
break;
}
emitValue<output_LEAP>(ctx, l);
}
}
YEAR | MON | LEAP | SIZE |
---|---|---|---|
2023 | 2 | false | 28 |
2023 | 3 | false | 31 |
2023 | 4 | false | 30 |
2023 | 5 | false | 31 |
2023 | 6 | false | 30 |
2023 | 7 | false | 31 |
2023 | 8 | false | 31 |
2023 | 9 | false | 30 |
2023 | 10 | false | 31 |
2023 | 11 | false | 30 |
2023 | 12 | false | 31 |
2024 | 1 | true | 31 |
2024 | 2 | true | 29 |