Пример #1
0
 /**
  * {@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;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public static function offset($stamp, $offset)
 {
     return Calends::toInternalFromUnix(date_create_from_format('U.u', bcadd(0, Calends::fromInternalToUnix($stamp), 6))->modify($offset)->format('U.u'));
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public static function fromInternal($stamp)
 {
     $date = Calends::fromInternalToUnix($stamp);
     return date_create(jdtojulian(bcadd(bcdiv($date, 86400), 2440587.5)))->format('D, d M Y') . ' ' . date_create_from_format('U.u', bcadd(0, $date, 6))->format('H:i:s.u P');
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public static function fromInternal($stamp)
 {
     return Calends::fromInternalToUnix($stamp);
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function offset($stamp, $offset)
 {
     return Calends::toInternalFromUnix($this->unitsToTS($this->addUnits($this->tsToUnits(Calends::fromInternalToUnix($stamp)), $this->parseOffset($offset))));
 }
Пример #6
0
 /**
  * {@inheritdoc}
  */
 public static function fromInternal($stamp, $format = null)
 {
     $date = Calends::fromInternalToUnix($stamp);
     return date_create_from_format('n/j/Y', \JDToJulian(BC::add(BC::div($date, 86400, 18), 2440587.5, 0)))->format('D, d M Y') . ' ' . date_create_from_format('U.u', BC::add(0, $date, 6))->format('H:i:s.u P');
 }
Пример #7
0
 /**
  * {@inheritdoc}
  */
 public static function offset($stamp, $offset)
 {
     return Calends::toInternalFromUnix(date_create_from_format('Y-m-d H:i:s.u P', date('Y-m-d H:i:s.u P', BC::round(Calends::fromInternalToUnix($stamp), 6)))->modify($offset)->format('U.u'));
 }
Пример #8
0
 /**
  * {@inheritdoc}
  */
 public static function offset($stamp, $offset)
 {
     return Calends::toInternalFromUnix(bcadd(Calends::fromInternalToUnix($stamp), bcadd(Calends::fromInternalToUnix(static::toInternal($offset)), 0x4000000000000000)));
 }
Пример #9
0
 /**
  * {@inheritdoc}
  */
 public static function offset($stamp, $offset)
 {
     $date = date_create_from_format('U.u', BC::add(Calends::fromInternalToUnix($stamp), 0, 6))->modify($offset);
     return Calends::toInternalFromUnix($date->getTimestamp());
 }
Пример #10
0
 /**
  * {@inheritdoc}
  */
 public static function fromInternal($stamp)
 {
     return bcadd(bcdiv(Calends::fromInternalToUnix($stamp), 86400), 2440587.5);
 }
Пример #11
0
 /**
  * {@inheritdoc}
  */
 public static function fromInternal($stamp, $format = null)
 {
     $format = is_null($format) ? 18 : BC::max([BC::min([$format, 18], 0), 0], 0);
     return BC::round(Calends::fromInternalToUnix($stamp), $format);
 }