weekday

wkov/colony/weekday

No description
weekday
@/weekday
YEARnumber
Year number, from 0.
MONnumber
Month number [1-12].
DAYnumber
Day number [1-31].
weekday
YEAR
MON
DAY
WDAY
WDAYnumber
Day of week [1-7], from Monday.
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 {
    void evaluate(Context ctx) {
        static uint8_t t[] = {0,3,2,5,0,3,5,1,4,6,2,4};

        uint32_t y = getValue<input_YEAR>(ctx);
        uint8_t m = getValue<input_MON>(ctx);
        uint8_t d = getValue<input_DAY>(ctx);

        y -= m < 3;

        uint8_t wday = (y + y / 4 - y / 100 + y / 400 + t[m - 1] + d) % 7;

        emitValue<output_WDAY>(ctx, wday > 0 ? wday : 7);
    }
}