Given a date , returns number of days elapsed from the beginning of the current year ( 1 stjan ) .
int offsetDays ( int d , int m , int y ) { int offset = d ; switch ( m - 1 ) { case 11 : offset += 30 ; case 10 : offset += 31 ; case 9 : offset += 30 ; case 8 : offset += 31 ; case 7 : offset += 31 ; case 6 : offset += 30 ; case 5 : offset += 31 ; case 4 : offset += 30 ; case 3 : offset += 31 ; case 2 : offset += 28 ; case 1 : offset += 31 ; } if ( isLeap ( y ) && m > 2 ) offset += 1 ; return offset ; }