Ejemplo n.º 1
0
 /**
  * Create a new time dataItem from a specified Julian Day number,
  * calendar model, presicion.
  *
  * @param double $jdValue
  * @param integer|null $calendarmodel
  * @param integer|null $precision
  *
  * @return DITime object
  */
 public static function newFromJD($jdValue, $calendarModel = null, $precision = null, $timezone = false)
 {
     $hour = $minute = $second = false;
     $year = $month = $day = false;
     if ($precision === null) {
         $precision = strpos(strval($jdValue), '.5') !== false ? self::PREC_YMD : self::PREC_YMDT;
     }
     list($calendarModel, $year, $month, $day) = JulianDay::JD2Date($jdValue, $calendarModel);
     if ($precision <= self::PREC_YM) {
         $day = false;
         if ($precision === self::PREC_Y) {
             $month = false;
         }
     }
     if ($precision === self::PREC_YMDT) {
         list($hour, $minute, $second) = JulianDay::JD2Time($jdValue);
     }
     return new self($calendarModel, $year, $month, $day, $hour, $minute, $second, $timezone);
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider valueProvider
  */
 public function testConvert($calendarModel, $seralization, $jdValue)
 {
     list($year, $month, $day, $hour, $minute, $second) = explode('/', $seralization);
     $this->assertEquals($jdValue, JulianDay::getJD($calendarModel, $year, $month, $day, $hour, $minute, $second));
 }