rendered paste bodybirthTime=[1989, 9 ,04, 20, 00, 00]nowTime=[2007,04,27,19,33,00 ]def secondsSinceMidnight( hour, minute, second ) hour = hour % 24 # you cant be 24 or more! .. lies! return ( hour * 60 * 60) + (minute * 60 ) + secondenddef secondsToMidnight( hour, minute, second ) 24 * 60 * 60 - secondsSinceMidnight( hour, minute, second ) enddef daysInYear( year ) isleap = false if ( year % 4 != 0 ) isleap = false elsif ( year % 400 == 0 ) isleap = true elsif ( year % 100 == 0) isleap = false else isleap = true end return ( isleap )?(366):(365)end def calendarForYear( year ) return {1=> 31, 2=> daysInYear( year ) - 337, 3=> 31, 4=> 30, 5=> 31, 6=> 30, 7=> 31, 8=> 31, 9=> 30, 10=>31, 11=>30, 12=>31 }enddef daysToMonthEnd( year, month, day ) calendar = calendarForYear( year ); daysInMonth = calendar[month] return daysInMonth - dayenddef daysToYearEnd( year, month, day ) calendar = calendarForYear( year ) days = daysToMonthEnd(year,month,day) (month+1).upto(12){ |thisMonth| days += calendar[thisMonth] } return daysenddef daysSinceYearStart( year, month, day ) return daysInYear(year) - daysToYearEnd( year, month, day )end def secondsSinceYearStart( year, month, day, hour, minute, second ) return ((daysSinceYearStart( year, month, day ) -1 ) * 24 * 60 * 60 ) + secondsSinceMidnight( hour, minute, second )enddef secondsToYearEnd( year, month, day, hour, minute, second ) return (daysInYear( year ) * 24 * 60 * 60 ) - secondsSinceYearStart(year, month, day, hour, minute, second )enddef secondsInyearsBetween( yeara, yearb ) seconds = 0 yeara.upto( yearb ){ |currentyear| seconds = seconds + (daysInYear( currentyear ) * 24 * 60 * 60) } return secondsenddef secondsOfAge( birthYear, birthMonth, birthDay, birthHour, birthMinute, birthSecond, nowYear, nowMonth, nowDay, nowHour, nowMinute, nowSecond ) seconds =0 seconds += secondsSinceYearStart( nowYear, nowMonth, nowDay, nowHour, nowMinute, nowSecond ) seconds += secondsToYearEnd( birthYear, birthMonth, birthDay, birthHour, birthMinute, birthSecond ) seconds += secondsInyearsBetween( birthYear + 1, nowYear - 1)endprint secondsOfAge( birthTime[0], birthTime[1], birthTime[2], birthTime[3], birthTime[4], birthTime[5], nowTime[0], nowTime[1], nowTime[2], nowTime[3], nowTime[4], nowTime[5] )