Given a year and days elapsed in it , finds date by storing results in d and m .
void revoffsetDays ( int offset , int y , int * d , int * m ) { int month [ 13 ] = { 0 , 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 } ; if ( isLeap ( y ) ) month [ 2 ] = 29 ; int i ; for ( i = 1 ; i <= 12 ; i ++ ) { if ( offset <= month [ i ] ) break ; offset = offset - month [ i ] ; } * d = offset ; * m = i ; }