Пример #1
0
 /**
  * {@inheritdoc}
  */
 public static function toInternal($date, $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';
     }
     if (in_array(strtolower($format), ['jd', 'gjd', 'geo', 'geo-centric'])) {
         $jdc = $date;
     } elseif (in_array(strtolower($format), ['rjd', 'reduced'])) {
         $jdc = BC::add($date, '2400000', 18);
     } elseif (in_array(strtolower($format), ['mjd', 'modified'])) {
         $jdc = BC::add($date, '2400000.5', 18);
     } elseif (in_array(strtolower($format), ['tjd', 'truncated'])) {
         $jdc = BC::add($date, '2440000.5', 18);
     } elseif (in_array(strtolower($format), ['djd', 'dublin', 'j1900'])) {
         $jdc = BC::add($date, '2415020', 18);
     } elseif (in_array(strtolower($format), ['j2000'])) {
         $jdc = BC::add($date, '2451545', 18);
     } elseif (in_array(strtolower($format), ['lilian'])) {
         $jdc = BC::add($date, '2299159.5', 18);
     } elseif (in_array(strtolower($format), ['rata-die'])) {
         $jdc = BC::add($date, '1721424.5', 18);
     } elseif (in_array(strtolower($format), ['mars-sol'])) {
         $jdc = BC::add(BC::mul($date, '1.02749', 18), '2405522', 18);
     }
     return Calends::toInternalFromUnix(BC::mul(BC::sub($jdc, 2440587.5, 18), 86400, 18));
 }
Пример #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 toInternal($date)
 {
     $greg = new DateTime($date);
     return Calends::toInternalFromUnix(bcadd(bcmul(bcsub(juliantojd($greg->format('m'), $greg->format('d'), $greg->format('Y')), 2440587), 86400), bcmod($greg->getTimestamp(), 86400)));
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public static function toInternal($date)
 {
     return Calends::toInternalFromUnix($date);
 }
Пример #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 toInternal($date, $format = null)
 {
     $greg = new DateTime($date);
     return Calends::toInternalFromUnix(BC::add(BC::mul(BC::sub(\JulianToJD($greg->format('n'), $greg->format('j'), $greg->format('Y')), 2440587, 18), 86400, 18), BC::mod($greg->getTimestamp(), 86400, 18), 18));
 }
Пример #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 toInternal($date)
 {
     return Calends::toInternalFromUnix(bcmul(bcsub($date, 2440587.5), 86400));
 }
Пример #11
0
 /**
  * {@inheritdoc}
  */
 public static function toInternal($date, $format = null)
 {
     $format = is_null($format) ? 18 : BC::max([BC::min([$format, 18], 0), 0], 0);
     return Calends::toInternalFromUnix(BC::round($date, $format));
 }