/**
  * {@inheritdoc}
  */
 public static function fromInternal($stamp, $format = null)
 {
     if (!in_array(strtolower($format), ['jd', 'gjd', 'geo', 'geo-centric', 'rjd', 'reduced', 'mjd', 'modified', 'tjd', 'truncated', 'djd', 'dublin', 'j1900', 'j2000', 'lilian', 'rata-die', 'mars-sol'])) {
         $format = 'gjd';
     }
     $jdc = BC::add(BC::div(Calends::fromInternalToUnix($stamp), 86400, 18), 2440587.5, 18);
     if (in_array(strtolower($format), ['jd', 'gjd', 'geo', 'geo-centric'])) {
         $output = $jdc;
     } elseif (in_array(strtolower($format), ['rjd', 'reduced'])) {
         $output = BC::sub($jdc, '2400000', 18);
     } elseif (in_array(strtolower($format), ['mjd', 'modified'])) {
         $output = BC::sub($jdc, '2400000.5', 18);
     } elseif (in_array(strtolower($format), ['tjd', 'truncated'])) {
         $output = BC::intval(BC::sub($jdc, '2440000.5', 18), 0);
     } elseif (in_array(strtolower($format), ['djd', 'dublin', 'j1900'])) {
         $output = BC::sub($jdc, '2415020', 18);
     } elseif (in_array(strtolower($format), ['j2000'])) {
         $output = BC::sub($jdc, '2451545', 18);
     } elseif (in_array(strtolower($format), ['lilian'])) {
         $output = BC::intval(BC::sub($jdc, '2299159.5', 18), 0);
     } elseif (in_array(strtolower($format), ['rata-die'])) {
         $output = BC::intval(BC::sub($jdc, '1721424.5', 18), 0);
     } elseif (in_array(strtolower($format), ['mars-sol'])) {
         $output = BC::div(BC::sub($jdc, '2405522', 18), '1.02749', 18);
     }
     return $output;
 }
Exemple #2
0
 /**
  * Gets the number of seconds between the start and end times
  *
  * @api
  *
  * @return float|integer
  **/
 public function getDuration($scale = 18)
 {
     return BC::round($this->duration, BC::intval($scale, 0));
 }