Find the first day of a given year from a base year having first day as Monday | Function to find the day of 1 st January of Y year ; Count years between years Y and B ; Count leap years ; Non leap years ; Total number of days in the years lying between the years Y and B ; Actual day ; Driver Code
function findDay ( Y , B ) { let lyear , rest , totaldays , day ; Y = ( Y - 1 ) - B ; lyear = Math . floor ( Y / 4 ) ; rest = Y - lyear ; totaldays = ( rest * 365 ) + ( lyear * 366 ) + 1 ; day = ( totaldays % 7 ) ; if ( day == 0 ) document . write ( " " ) ; else if ( day == 1 ) document . write ( " " ) ; else if ( day == 2 ) document . write ( " " ) ; else if ( day == 3 ) document . write ( " " ) ; else if ( day == 4 ) document . write ( " " ) ; else if ( day == 5 ) document . write ( " " ) ; else if ( day == 6 ) document . write ( " " ) ; else document . write ( " " ) ; } let Y = 2020 , B = 1900 ; findDay ( Y , B ) ;