0) { $uniyear=$result[0]; if (count($result)>1) { $uniday=$result[1]; } } if ($uniday<0) $uniday=0; //enforce validity if ($uniday>359) $uniday=359; //enforce validity if ($uniyear==0 and $uniday==0) { return 0.5; } elseif (($uniyear==='-0') or ($uniyear<0)) { return -(float)((abs($uniyear)*360)+(360-$uniday)-0.5); } else { return (float)($uniyear*360)+$uniday+0.5; } } function gregorian_to_unidate($month,$day,$year) { return jd_to_unidate(gregoriantojd($month,$day,$year)-0.5); //PHP's functions really simplify this one thankfully! } function unidate_to_gregorian($unidate) { return jdtogregorian(unidate_to_jd($unidate)+0.5); //again PHP's functions really simplify this one! } function unidate() { //returns time() in seconds since the unix epoch that starts at midnight 1.1.1970, //2440587.5 (1.1.1970) is the JDN of that date which we need to add to get the total JDN since 0, //we do this since there exist no native JDN, and PHP unixtojd() returns a rounded integer which is not satisfactory. //The result is similar to those by http://aa.usno.navy.mil/data/docs/JulianDate.html $jdn=2440587.5+(time()/86400); return jd_to_unidate($jdn); } function unidate_full() { // **** The following is just to give month/day, week/weekday in µDate // **** to make the concept of µDate not that alien to current systems // **** and the fact that people like to use months/weeks etc. // **** µYear.Day is the only true µDate time storage format. //incomplete example, only handles positive years for now. //weekday names $dayname[0]='Sunday'; $dayname[1]='Monday'; $dayname[2]='Tuesday'; $dayname[3]='Wednesday'; $dayname[4]='Thursday'; $dayname[5]='Friday'; $dayname[6]='Saturday'; //month names $monthname[0]='January'; $monthname[1]='February'; $monthname[2]='Mars'; $monthname[3]='April'; $monthname[4]='May'; $monthname[5]='June'; $monthname[6]='july'; $monthname[7]='August'; $monthname[8]='September'; $monthname[9]='October'; $monthname[10]='November'; $monthname[11]='December'; $unidate=unidate(); $jd=unidate_to_jd($unidate); list($uyear,$udays)=explode('.',$unidate); $uweekday=(int)fmod($jd,7); $umonth=(int)floor($udays/30); $uday=($udays-($umonth*30))+1; return 'µ'.$unidate.' '.gmdate('H:i:s').' ('.$dayname[$uweekday].', '.$monthname[$umonth].' '.$uday.', Year '.$uyear.')'; } ?>