The moon type is calculated based on the number of in-game days (WM_NumberOfDays). The exact formula is (numberOfDays + x + 1) % 8[1], where x is equal to 1 if the current time is > 180.0 (noon) and % is the modulo operator.
(numberOfDays + x + 1) % 8