month-size

wkov/colony/month-size

No description
month-size
@/month-size
YEARnumber
Year number, from 0.
MONnumber
Month number [1-12].
month-size
YEAR
MON
LEAP
SIZE
SIZEnumber
Month size, in days.
LEAPboolean
True, if year of leap.
To use the node in your project you should have the wkov/colony library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#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);
    }
}

Tabular tests

YEARMONLEAPSIZE
20232false28
20233false31
20234false30
20235false31
20236false30
20237false31
20238false31
20239false30
202310false31
202311false30
202312false31
20241true31
20242true29