当前位置: 首页>>代码示例>>PHP>>正文


PHP jdtogregorian函数代码示例

本文整理汇总了PHP中jdtogregorian函数的典型用法代码示例。如果您正苦于以下问题:PHP jdtogregorian函数的具体用法?PHP jdtogregorian怎么用?PHP jdtogregorian使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了jdtogregorian函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: julianDateValue

 /**
  * Get Julian date value and return it as Gregorian date
  *
  * @param string $dateValue
  *
  * @return string|null Value compatible with xsd:dateTime type, null if we failed to parse
  */
 private function julianDateValue($dateValue)
 {
     try {
         list($minus, $y, $m, $d, $time) = $this->parseDateValue($dateValue);
     } catch (IllegalValueException $e) {
         return null;
     }
     // We accept here certain precision loss since we will need to do calculations anyway,
     // and we can't calculate with dates that don't fit in int.
     $y = $minus ? -(int) $y : (int) $y;
     // cal_to_jd needs int year
     // If it's too small it's fine, we'll get 0
     // If it's too big, it doesn't make sense anyway,
     // since who uses Julian with day precision in year 2 billion?
     $jd = cal_to_jd(CAL_JULIAN, $m, $d, (int) $y);
     if ($jd == 0) {
         // that means the date is broken
         return null;
     }
     // PHP API for Julian/Gregorian conversions is kind of awful
     list($m, $d, $y) = explode('/', jdtogregorian($jd));
     if ($this->xsd11 && $y < 0) {
         // To make year match XSD 1.1 we need to bump up the negative years by 1
         // We know we have precision here since otherwise we wouldn't convert
         $y++;
     }
     // This is a bit weird since xsd:dateTime requires >=4 digit always,
     // and leading 0 is not allowed for 5 digits, but sprintf counts - as digit
     // See: http://www.w3.org/TR/xmlschema-2/#dateTime
     return sprintf('%s%04d-%02d-%02dT%s', $y < 0 ? '-' : '', abs($y), $m, $d, $time);
 }
开发者ID:Benestar,项目名称:mediawiki-extensions-Wikibase,代码行数:38,代码来源:JulianDateTimeValueCleaner.php

示例2: getTrackerStats

 public function getTrackerStats()
 {
     $data = array('datasets' => array());
     $start = Request::get('start', 'int') ?: -30;
     $end = Request::get('end', 'int') ?: 0;
     $sub_id = -1;
     $user_id = -1;
     $tracker = NULL;
     foreach ($_GET['sets'] as $set) {
         $tracker = isset($set['tracker']) ? intval($set['tracker']) : $tracker;
         $sub_id = isset($set['sub_id']) ? intval($set['sub_id']) : $sub_id;
         $user_id = isset($set['user_id']) ? intval($set['user_id']) : $user_id;
         if (empty($tracker)) {
             throw new \Exception('Invalid tracker');
         }
         $data['datasets'][] = array('data' => array_values(Tracker::getHistory($tracker, $start, $end, $sub_id, $user_id)), 'label' => Tracker::getName($tracker));
     }
     $data['labels'] = array();
     $start += Time::today();
     $end += Time::today();
     for ($i = $start; $i <= $end; $i++) {
         $data['labels'][] = jdtogregorian($i);
     }
     Output::json($data);
 }
开发者ID:kemosabhay,项目名称:Lightning,代码行数:25,代码来源:AdminTracker.php

示例3: GetNextDate

 function GetNextDate($beginDate, $repeat)
 {
     //explode the date by "-" and storing to array
     $date_parts1 = explode("-", $beginDate);
     //gregoriantojd() Converts a Gregorian date to Julian Day Count
     $start_date = gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
     return jdtogregorian($start_date + $repeat);
 }
开发者ID:ankaau,项目名称:GathBandhan,代码行数:8,代码来源:ajaxcalendar.php

示例4: convertDate

 /**
  * This will convert given Hijri date (Islamic calendar) into Gregorian date.
  *
  * @param int $Y Hijri year (Islamic calendar)
  * @param int $M Hijri month (Islamic calendar)
  * @param int $D Hijri day (Islamic calendar)
  *
  * @return array Gregorian date [int Year, int Month, int Day]
  *
  * @author Khaled Al-Sham'aa <khaled@ar-php.org>
  */
 protected function convertDate($Y, $M, $D)
 {
     if (function_exists('GregorianToJD')) {
         $str = jdtogregorian($this->islamicToJd($Y, $M, $D));
     } else {
         $str = $this->jdToGreg($this->islamicToJd($Y, $M, $D));
     }
     list($month, $day, $year) = explode('/', $str);
     return [$year, $month, $day];
 }
开发者ID:buzzylab,项目名称:aip,代码行数:21,代码来源:MakeTime.php

示例5: dateThisYear

function dateThisYear($ahebdate)
{
    $atodayhebrew = explode("/", strGregToHeb(date("M d, Y")));
    //Anyone born in addar should celebrate their birthday in in Adar II on a leap year.
    if ($ahebdate[0] == 6 && !isLeapYear($ahebdate[2]) && isLeapYear($atodayhebrew[2])) {
        $ahebdate[0] = 7;
    }
    $date = strtotime(jdtogregorian(jewishtojd($ahebdate[0], $ahebdate[1], $atodayhebrew[2])));
    $today = strtotime("today");
    if ($date < $today) {
        $datethisyear = date("M d, Y", strtotime(jdtogregorian(jewishtojd($ahebdate[0], $ahebdate[1], $atodayhebrew[2] + 1))));
    } else {
        $datethisyear = date("M d, Y", $date);
    }
    return $datethisyear;
}
开发者ID:BGCX067,项目名称:facebook-jewishdates-svn-to-git,代码行数:16,代码来源:jDateFunctions.php

示例6: calculateMoonPhases

function calculateMoonPhases($year, $month = 1)
{
    $s = '';
    // Formatted Output String.
    $U = false;
    $K0 = intval(($year - 1900) * 12.3685) + ($month - 1);
    $R1 = 3.14159265 / 180;
    $T = ($year - 1899.5) / 100;
    $T2 = $T * $T;
    $T3 = $T * $T * $T;
    $J0 = 2415020 + 29 * $K0;
    $F0 = 0.0001178 * $T2 - 1.55E-7 * $T3 + (0.7593299999999999 + 0.53058868 * $K0) - (0.000837 * $T + 0.000335 * $T2);
    $M0 = $K0 * 0.08084821133;
    $M0 = 360 * ($M0 - intval($M0)) + 359.2242 - 3.33E-5 * $T2 - 3.47E-6 * $T3;
    $M1 = $K0 * 0.07171366127999999;
    $M1 = 360 * ($M1 - intval($M1)) + 306.0253 + 0.0107306 * $T2 + 1.236E-5 * $T3;
    $B1 = $K0 * 0.08519585128;
    $B1 = 360 * ($B1 - intval($B1)) + 21.2964 - 0.0016528 * $T2 - 2.39E-6 * $T3;
    for ($K9 = 0; $K9 < 7; $K9 += 0.5) {
        $J = $J0 + 14 * $K9;
        $K = $K9 / 2;
        $B6 = ($B1 + $K * 390.67050646) * $R1;
        $M5 = ($M0 + $K * 29.10535608) * $R1;
        $M6 = ($M1 + $K * 385.81691806) * $R1;
        $F = $F0 + 0.765294 * $K9 - 0.4068 * sin($M6) + (0.1734 - 0.000393 * $T) * sin($M5) + 0.0161 * sin(2 * $M6) + 0.0104 * sin(2 * $B6) - 0.0074 * sin($M5 - $M6) - 0.0051 * sin($M5 + $M6) + 0.0021 * sin(2 * $M5) + 0.001 * sin(2 * $B6 - $M6) + 0.5 / 1440;
        $J += intval($F);
        $F -= intval($F);
        //.
        // Convert from JD to Calendar Date.
        $julian = $J + round($F);
        $s = function_exists('jdtogregorian') ? date('Ymd', strtotime(jdtogregorian($julian))) : jd_to_greg($julian);
        // .
        // half K
        if ($K9 - floor($K9) > 0) {
            $phases[$s] = $U ? 'first' : 'last';
        } else {
            $phases[$s] = $U ? 'full' : 'new';
            $U = !$U;
        }
    }
    // Next
    return $phases;
}
开发者ID:rhertzog,项目名称:lcs,代码行数:43,代码来源:moon_phases.php

示例7: view_dates


//.........这里部分代码省略.........
         if (!isteacherinanycourse($USER->id) and !isadmin() and isset($reservation[$rday][$rslot])) {
             if ($uid != $UID) {
                 // return;  // assume an attempt to phreak the system with params
             }
         }
         $sql = 'DELETE FROM ' . $CFG->prefix . 'bookings_calendar WHERE eventtype="reservation" AND slot=' . $rslot . ' AND day=' . $rday . ' AND julday=' . ($jday + $rday) . '
                     AND userid=' . $UID . ' AND itemid=' . $r->id;
         execute_sql($sql, 0);
         /// this removes multiple bookings by one person for a given slot
         if (isset($resid)) {
             $sql = 'DELETE FROM ' . $CFG->prefix . 'bookings_calendar WHERE id=' . $resid;
             execute_sql($sql, 0);
         }
         if (!isset($delete)) {
             $sql = 'INSERT INTO ' . $CFG->prefix . 'bookings_calendar (name,value,userid,eventtype,itemid,slot,day,julday) 
                 VALUES ("' . $r->name . '","' . $username . '",' . $UID . ',"reservation",' . $r->id . ',' . $rslot . ',' . $rday . ',' . ($jday + $rday) . ')';
             execute_sql($sql, 0);
         }
         // have to refetch data
         $sql = 'SELECT * FROM ' . $CFG->prefix . 'bookings_calendar 
             WHERE eventtype="reservation" 
             AND itemid=' . $r->id . '
             AND julday >= ' . $jday . '
             AND julday <= ' . ($jday + sizeof($days) - 1);
         $reservation = array();
         if ($res = get_records_sql($sql)) {
             foreach ($res as $re) {
                 $reservation[$re->day][$re->slot][] = $re;
             }
         }
     }
     // navigation (next/prev) week
     $week = bookings_week($jday);
     list($m, $d, $y) = explode("/", jdtogregorian($jday));
     list($m1, $d1, $y1) = explode("/", jdtogregorian($jday + sizeof($days) - 1));
     if (bookings_week($jday + sizeof($days) - 1) != $week) {
         $week .= '-' . bookings_week($jday + sizeof($days) - 1);
     }
     $html .= '<div id="all"><h2>' . $r->name . ' (' . $r->type . ')</h2>';
     $html .= '<div class="mod-bookings navigate" ><input type="submit"  name="prev" value="&lt;&lt;">';
     $html .= get_string('week') . " {$week} &nbsp; <span id=\"date\">{$d}.{$m} - {$d1}.{$m1} {$y}</span>";
     $html .= '<input type="submit" name="next" value="&gt;&gt;"></div>';
     $html .= $link2room;
     // now we draw up the table
     $table = array();
     if ($can_edit) {
         $baselink = '<a href="view.php?id=' . $cmid . '&jday=' . $jday . '&itemid=' . $itemid;
     } else {
         $baselink = '';
     }
     $table[] = '<table border=1 width=100%>';
     $table[] = '<tr><th width=5%>&nbsp;</th>';
     foreach ($days as $day) {
         if ($day == '') {
             continue;
         }
         $table[] = '<th>' . $day . '</th>';
     }
     $table[] = '</tr>';
     $time = 0;
     foreach ($slots as $slottime) {
         $t = $time + 1;
         $table[] = "<tr><th><span class=\"number\">{$slottime}</span></th>";
         $dag = 0;
         foreach ($days as $day) {
             $class = 'normal';
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:67,代码来源:bookings.class.php

示例8: JDtoDate

 public static function JDtoDate($jd)
 {
     $dateTimeString = jdtogregorian($jd);
     return new DateTime($dateTimeString);
 }
开发者ID:vothienhoa,项目名称:tuvi,代码行数:5,代码来源:MoonPhase.php

示例9: cal_date

 private static function cal_date($tjd, &$year, &$month, &$day, &$hour)
 {
     $djd = $tjd + 0.5;
     $jd = $djd;
     $hour = $djd % 1.0 * 24.0;
     $dateTimeString = jdtogregorian($jd);
     $datetime = new DateTime($dateTimeString);
     $datetime->format('w');
     $month = $datetime->format('m');
     $day = $datetime->format('d');
     $year = $datetime->format('y');
 }
开发者ID:vothienhoa,项目名称:tuvi,代码行数:12,代码来源:Novas.php

示例10: convert

 /**
  * Parse the Date object and return a result based on format.
  *
  * @param string $delimiter
  * @return string
  */
 public function convert($delimiter = '/')
 {
     $julianDate = $this->toJulianDate();
     $gregorianDate = $this->applyFormat(explode('/', jdtogregorian($julianDate)));
     return is_array($gregorianDate) ? implode($delimiter, $gregorianDate) : $gregorianDate;
 }
开发者ID:kfirba,项目名称:hebdate,代码行数:12,代码来源:JewishDate.php

示例11: getValue

 /**
  * Return the timestamp of the entry.
  *
  * The timestamp held by this entry is returned in one of three
  * formats: as a standard UNIX timestamp (default), as a fractional
  * Julian Day Count, or as a string.
  *
  * @param int the type of the timestamp. This must be one of
  * {@link UNIX_TIMESTAMP}, {@link EXIF_STRING}, or
  * {@link JULIAN_DAY_COUNT}.
  *
  * @return int the timestamp held by this entry in the correct form
  * as indicated by the type argument. For {@link UNIX_TIMESTAMP}
  * this is an integer counting the number of seconds since January
  * 1st 1970, for {@link EXIF_STRING} this is a string of the form
  * 'YYYY:MM:DD hh:mm:ss', and for {@link JULIAN_DAY_COUNT} this is a
  * floating point number where the integer part denotes the day
  * count and the fractional part denotes the time of day (0.25 means
  * 6:00, 0.75 means 18:00).
  */
 function getValue($type = self::UNIX_TIMESTAMP)
 {
     switch ($type) {
         case self::UNIX_TIMESTAMP:
             $seconds = jdtounix($this->day_count);
             if ($seconds === false) {
                 /* jdtounix() return false if the Julian Day Count is outside
                  * the range of a UNIX timestamp. */
                 return false;
             } else {
                 return $seconds + $this->seconds;
             }
         case self::EXIF_STRING:
             list($month, $day, $year) = explode('/', jdtogregorian($this->day_count));
             $hours = (int) ($this->seconds / 3600);
             $minutes = (int) ($this->seconds % 3600 / 60);
             $seconds = $this->seconds % 60;
             return sprintf('%04d:%02d:%02d %02d:%02d:%02d', $year, $month, $day, $hours, $minutes, $seconds);
         case self::JULIAN_DAY_COUNT:
             return $this->day_count + $this->seconds / 86400;
         default:
             throw new PelInvalidArgumentException('Expected UNIX_TIMESTAMP (%d), ' . 'EXIF_STRING (%d), or ' . 'JULIAN_DAY_COUNT (%d) for $type, ' . 'got %d.', self::UNIX_TIMESTAMP, self::EXIF_STRING, self::JULIAN_DAY_COUNT, $type);
     }
 }
开发者ID:jdrzaic,项目名称:joomla-dummy,代码行数:44,代码来源:PelEntryAscii.php

示例12: calculateRiseTransitSettingTimeCommon


//.........这里部分代码省略.........
             $toAdd = 0;
         }
         if ($minutes < 10) {
             $minutes = "0" . $minutes;
         }
         $ris_tra_set[1] = floor($ris_tra_set[1]) + $toAdd . ":" . $minutes;
     }
     $set = $ris_tra_set[2];
     if ($ris_tra_set[2] > 48 || $ris_tra_set[2] < -24) {
         $ris_tra_set[2] = "-";
     } else {
         $ris_tra_set[2] = $ris_tra_set[2] + $timedifference;
         if ($ris_tra_set[2] < 0) {
             $ris_tra_set[2] = $ris_tra_set[2] + 24;
         }
         if ($ris_tra_set[2] > 24) {
             $ris_tra_set[2] = $ris_tra_set[2] - 24;
         }
         $minutes = round(($ris_tra_set[2] - floor($ris_tra_set[2])) * 60);
         if ($minutes == 60) {
             $minutes = 0;
             $toAdd = 1;
         } else {
             $toAdd = 0;
         }
         if ($minutes < 10) {
             $minutes = "0" . $minutes;
         }
         $ris_tra_set[2] = floor($ris_tra_set[2]) + $toAdd . ":" . $minutes;
     }
     $ris_tra_set[4] = 0;
     $ra2 = $ra2 / 15;
     date_default_timezone_set("UTC");
     $temptime = jdtogregorian($jd + 1);
     $temppos = strpos($temptime, "/");
     $tempmonth = substr($temptime, 0, $temppos);
     $temptime = substr($temptime, $temppos + 1);
     $temppos = strpos($temptime, "/");
     $tempday = substr($temptime, 0, $temppos);
     $tempyear = substr($temptime, $temppos + 1);
     $timestr = $tempyear . "-" . $tempmonth . "-" . $tempday;
     $sun_info = date_sun_info(strtotime($timestr), $latitude, -$longitude);
     $astrobegin = date("H:i", $sun_info["astronomical_twilight_begin"]);
     sscanf($astrobegin, "%d:%d", $hour, $minute);
     $astrobegin = $hour + $minute / 60.0;
     $astroend = date("H:i", $sun_info["astronomical_twilight_end"]);
     sscanf($astroend, "%d:%d", $hour, $minute);
     $astroend = $hour + $minute / 60.0;
     $nautbegin = date("H:i", $sun_info["nautical_twilight_begin"]);
     sscanf($nautbegin, "%d:%d", $hour, $minute);
     $nautbegin = $hour + $minute / 60.0;
     $nautend = date("H:i", $sun_info["nautical_twilight_end"]);
     sscanf($nautend, "%d:%d", $hour, $minute);
     $nautend = $hour + $minute / 60.0;
     if ($transit > 0) {
         $transit = $transit % 24.0 + ($transit - floor($transit));
     } else {
         $toAdd = floor(-$transit / 24.0) + 1;
         $transit = $transit + 24.0 * $toAdd;
     }
     if ($astroend > 0 && $astrobegin > 0) {
         $tocompare = -999;
         if ($astrobegin > 12) {
             $toCheck = $astrobegin;
         } else {
             $toCheck = $astrobegin + 24;
开发者ID:ChrisWauters,项目名称:DeepskyLog,代码行数:67,代码来源:astrocalc.php

示例13: explode

        $var_temp .= '0';
    }
    $var_temp .= '1';
    $_day = $_day * $var_temp;
    $_day = $_day * 29.53;
    $_day = explode('.', $_day);
    $day = $_day[0];
    $date_time->setDate($year, $month, $day);
    return $date_time;
}, 'convert_from' => function ($date_time) {
    $config = (include 'Hijri.php');
    $year = $date_time->format('Y');
    $month = $date_time->format('m');
    $day = $date_time->format('d');
    $jd = (int) ((11 * $year + 3) / 30) + 354 * $year + 30 * $month - (int) (($month - 1) / 2) + $day + 1948440 - 385;
    $result = explode('/', jdtogregorian($jd));
    $month = $result[0];
    $day = $result[1];
    $year = $result[2];
    $date_time->setDate($year, $month, $day);
    return $date_time;
}, 'shorthand' => 'sh', 'month' => array('Muharram', 'Safar', 'Rabi I', 'Rabi II', 'Jumada I', 'Jumada II', 'Rajab', 'Shaban', 'Ramadan', 'Shawwal', 'Dhu al_Qadah', 'Dhu al_Hijjah'), 'days_of_week' => array('al-Aḥad', 'al-Ithnayn', 'ath-Thulatha\'', 'al-Arbi\'a', 'al-Khamees', 'al-Jumu\'ah', 'as-Sabt'), 'numbers' => array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'), 'am_time' => 'AM', 'pm_time' => 'PM', 'end_of_days' => array('th', 'st', 'nd', 'rd'), 'month_days_number' => array(1 => 30, 2 => 29, 3 => 30, 4 => 30, 5 => 29, 6 => 29, 7 => 30, 8 => 29, 9 => 30, 10 => 29, 11 => 30, 12 => 30), 'day_of_year' => function ($date_time) {
    $result = null;
    $config = (include 'Hijri.php');
    $month = $date_time->format('n');
    $day = $date_time->format('d');
    foreach ($config['month_days_number'] as $_month => $value) {
        if ($_month < $month) {
            $result += $value;
        }
    }
开发者ID:opencafe,项目名称:datium,代码行数:31,代码来源:Hijri.php

示例14: findLastDate

 function findLastDate()
 {
     $this->date = date("Ymd");
     $query_statement = "SELECT * FROM `" . DB_LUNCHSPECIALMENUS . "` WHERE `date` = '" . $this->date . "';";
     $query = mysql_query($query_statement);
     if (mysql_num_rows($query) != 1) {
         $query_statement = "SELECT * FROM `" . DB_LUNCHSPECIALMENUS . "` WHERE `date` < '" . date("Ymd") . "';";
         $query = mysql_query($query_statement);
         while ($rec = mysql_fetch_assoc($query)) {
             $buildDate[$rec["date"]] = 1;
         }
         for ($i = 0; $i <= 1000; $i++) {
             $jd_date = gregoriantojd(substr($this->date, 4, 2), substr($this->date, 6, 2), substr($this->date, 0, 4)) - $i;
             $exp = explode("/", jdtogregorian($jd_date));
             $nextdate = date("Ymd", mktime(0, 0, 0, $exp[0], $exp[1], $exp[2]));
             if ($buildDate[$nextdate] == 1) {
                 $nextAvail = $nextdate;
                 break;
             }
         }
         $return = "That date is already taken.<br>The next available date is " . fixDate($nextAvail) . ".";
     } else {
         $nextAvail = $this->date;
     }
     return $nextAvail;
 }
开发者ID:jboydston,项目名称:shop.getlocal.net,代码行数:26,代码来源:lunch_special.class.php

示例15: convertBirthdate

 /**
  * Prepare and sanitise the table prior to saving.
  *
  * @since   1.6
  */
 public static function convertBirthdate($birthday)
 {
     // Convert Solar date to Gregorian date
     $lang = JFactory::getLanguage();
     if ($lang->getTag() == 'fa-IR') {
         require_once JPATH_ROOT . '/language/fa-IR/fa-IR.localise.php';
         $faDate = new fa_IRDate();
         $faBirthday = is_array($birthday) ? $birthday : explode('-', $table->birthday);
         $birthday = jdtogregorian($faDate->persian_to_jd($faBirthday['1'], $faBirthday['2'], $faBirthday['0']));
         $birthday = explode('/', $birthday);
         $birthday = $birthday[2] . '-' . $birthday[0] . '-' . $birthday[1];
     }
     return $birthday;
 }
开发者ID:smhnaji,项目名称:sdnet,代码行数:19,代码来源:sibdiet.php


注:本文中的jdtogregorian函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。