/**
  * 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);
 }
Example #2
0
 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);
 }
Example #3
0
 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);
 }
Example #4
0
 /**
  * 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 <*****@*****.**>
  */
 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];
 }
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;
}
Example #6
0
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;
}
 function view_dates()
 {
     global $CFG, $USER;
     $showcombo = optional_param('showcombo', NULL, PARAM_INT);
     $komboroom = optional_param('komboroom', NULL, PARAM_ALPHAEXT);
     $prev = optional_param('prev', NULL, PARAM_ALPHAEXT);
     $next = optional_param('next', NULL, PARAM_ALPHAEXT);
     $jday = optional_param('jday', NULL, PARAM_INT);
     $rday = optional_param('rday', NULL, PARAM_INT);
     $rslot = optional_param('rslot', NULL, PARAM_INT);
     $delete = optional_param('delete', NULL, PARAM_INT);
     $resid = optional_param('resid', NULL, PARAM_INT);
     $uid = optional_param('uid', NULL, PARAM_INT);
     require_once "../../config.php";
     $cmid = $this->cm->id;
     /// require_once($CFG->dirroot.'/blocks/timetable/locallib.php');
     $itemid = $this->bookings->itemid;
     $username = $USER->username;
     $UID = $USER->id;
     $firstname = $USER->firstname;
     $lastname = $USER->lastname;
     ///$prover = mineprover();
     ///$fridager = Fridager();
     if ($firstname == '' or $lastname == '') {
         return "";
     }
     $html .= '<form name=myform id=myform method=post action="view.php?id=' . $cmid . '">';
     //// show combo is used if we don't already know which room/item is to be scheduled
     if (isset($showcombo)) {
         if (isset($komboroom)) {
             $itemid = $komboroom;
         }
         $sql = 'SELECT r.id, r.name
                 FROM ' . $CFG->prefix . 'bookings_item r,
                     ' . $CFG->prefix . 'bookings_item_property p
                 WHERE p.itemid = r.id
                     AND p.name="scheduled"
                     AND p.value="yes"
                 ORDER BY r.name';
         if ($roomlist = get_records_sql($sql)) {
             $kombo = "<select name=\"komboroom\" onchange=\"document.myform.reload.click()\">";
             $kombo .= "<option value=\" \"> -- Select -- </option>\n ";
             foreach ($roomlist as $room) {
                 $selected = "";
                 if ($room->id == $itemid) {
                     $selected = "selected";
                     $rname = $room->name;
                 }
                 $kombo .= '<option value="' . $room->id . '" ' . $selected . '>' . $room->name . '</option>' . "\n ";
             }
             $kombo .= '</select>' . "\n";
         }
         $html .= $kombo;
         $html .= '<input id="reload" type="submit" name="reload">';
         $html .= '<input type="hidden" name="showcombo" value="yes">';
     }
     ///////////////////////////
     // fetch out any timetable-data for this item
     $sql = 'SELECT r.id,r.name,r.type FROM ' . $CFG->prefix . 'bookings_item r WHERE r.id=' . $itemid;
     $r = get_record_sql($sql);
     $sql = "SELECT concat(c.id,t.day,t.slot),c.id,c.shortname, r.type, r.name, t.day, t.slot  \n                    FROM {$CFG->prefix}bookings_calendar t,\n                        {$CFG->prefix}bookings_item r left join\n                        {$CFG->prefix}course c  on c.id = t.courseid\n                WHERE r.id={$itemid}\n                    AND t.eventtype = 'timetable'\n                    AND r.id = t.itemid\n                ORDER BY day,slot";
     $tp = array();
     if ($tplan = get_records_sql($sql)) {
         foreach ($tplan as $tpelm) {
             $shortshortname = $tpelm->shortname;
             $tp[$tpelm->day][$tpelm->slot] = "<a href=\"/moodle/course/view.php?id={$tpelm->id}\">{$shortshortname}</a>";
         }
     }
     // build array of props for this item (room)
     $proplist = bookings_item_properties($itemid);
     $days = explode(',', 'Mon,Tue,Wed,Thu,Fri,,');
     if (isset($proplist['days'])) {
         $days = explode(',', $proplist['days']);
     }
     $widthprcent = (int) (95 / count($days));
     // default width
     $slots = array(8, 9, 10, 11, 12, 13, 14, 15, 16);
     if (isset($proplist['slots'])) {
         $slots = explode(',', $proplist['slots']);
     }
     $lookahead = 700;
     // limit on number of weeks you can move from present week (100 weeks +/-)
     if (isset($proplist['lookahead'])) {
         $lookahead = 7 * (int) $proplist['lookahead'];
     }
     // decide if user can edit timetable
     $can_edit = isteacherinanycourse($USER->id) ? 1 : 0;
     // default is that teachers can edit
     $link2room = '';
     if (isset($proplist['edit_group'])) {
         $can_edit = 0;
         // default is no edit (that is: edit_group != teacher|student )
         if ($proplist['edit_group'] == 'teachers' and isteacherinanycourse($USER->id)) {
             $can_edit = 1;
             $link2room = ' <a href="itemeditor.php?id=' . $cmid . '&newid=' . $itemid . '">' . get_string('edit') . ' ' . $r->type . '</a>';
         } else {
             if ($proplist['edit_group'] == 'students') {
                 $can_edit = 1;
             }
         }
     }
     // intended to give edit-rights to named students
     if (isset($proplist['edit_list'])) {
         if (strstr($proplist['edit_list'], $username)) {
             $can_edit = 1;
         }
     }
     // a multiple resource has a property that is counted down on each reservation
     // so long as number of resevations is less than this values, then user can make a
     // reservation
     if (isset($proplist['multiple'])) {
         $multiple = (int) $proplist['multiple'];
     }
     // calculate week and day
     list($ty, $tm, $td) = explode("/", strftime("%Y/%m/%d", time()));
     $tjday = gregoriantojd($tm, $td, $ty);
     $tweek = bookings_week($tjday);
     if (!isset($jday)) {
         $jday = $tjday;
     }
     // a list of days that isn't a week (7 days) or doesn't start on the first day of the week
     // should have this property, otherwise the schedule wont tile over the year
     list($ys, $ms, $ds) = explode(',', $proplist['startsched']);
     $start = gregoriantojd($ms, $ds, $ys) or 0;
     $jday = $start + sizeof($days) * (int) (($jday - $start) / sizeof($days));
     // $jday = 7 * (int)($jday/7);
     if (isset($prev) and $jday > $tjday - $lookahead) {
         $jday -= sizeof($days);
     }
     if (isset($next) and $jday < $tjday + $lookahead - 7) {
         $jday += sizeof($days);
     }
     list($ey, $em, $ed) = explode("/", strftime("%Y/%m/%d", $this->bookings->enddate));
     $ejday = gregoriantojd($em, $ed, $ey);
     if ($jday > $ejday) {
         $can_edit = 0;
     }
     if ($jday + sizeof($days) < $tjday) {
         $can_edit = 0;
     }
     if (isadmin()) {
         /// no matter what, admin can edit - even past dates
         $can_edit = 1;
         $link2room = ' <a href="itemeditor.php?id=' . $cmid . '&newid=' . $itemid . '">' . get_string('edit') . ' ' . $r->type . '</a>';
     }
     /// here we fetch out all reservations
     // list($m,$d,$y) = explode('/',jdtogregorian($jday));
     // $start = gmmktime(0, 0, 0, $m, $d, $y);
     // $stop = $start + 604800;   // weekofseconds
     $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;
             if ($res->userid == $UID) {
                 $reservation[$re->day][$re->slot]->res = $re;
             }
         }
     }
     /// this is where we make the reservation or delete reservations
     if ((isset($resid) and isset($uid) or isset($rday) and isset($rslot)) and $can_edit) {
         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';
             if ($day != '') {
                 if ($tp[$dag][$time] == '') {
                     $class = 'free';
                     $tp[$dag][$time] = $can_edit ? $baselink . '&rday=' . $dag . '&rslot=' . $time . '">' . get_string('free', 'bookings') . '</a>' : get_string('free', 'bookings');
                 }
                 if (isset($reservation[$dag][$time])) {
                     $tp[$dag][$time] = '';
                     foreach ($reservation[$dag][$time] as $myres) {
                         $class = 'reserved';
                         $linktext = 'Reserved ' . $myres->value;
                         if ($myres->userid == $UID) {
                             $linktext = 'M';
                         } else {
                             if (sizeof($reservation[$dag][$time] > 1)) {
                                 $linktext = isteacherinanycourse($myres->userid) ? 'T' : 'S';
                             }
                         }
                         // admin can override any, teacher can override student
                         if ($myres->userid == $UID or isadmin() or isteacherinanycourse($USER->id) and !isteacherinanycourse($myres->userid)) {
                             $tp[$dag][$time] .= $can_edit ? $baselink . '&delete=1&resid=' . $myres->id . '&uid=' . $myres->userid . '"
                         title="' . $myres->value . '" >' . $linktext . '</a> ' : $linktext . $myres->value;
                         } else {
                             $tp[$dag][$time] .= '<span title="' . $myres->value . '">' . $linktext . ' </span>';
                         }
                     }
                     if (isset($multiple) and $multiple > sizeof($reservation[$dag][$time])) {
                         $tp[$dag][$time] .= ' ' . $reservation[$dag][$time]->count . ' ';
                         $tp[$dag][$time] .= $can_edit ? $baselink . '&rday=' . $dag . '&rslot=' . $time . '">' . get_string('free', 'bookings') . '</a>' : get_string('free', 'bookings');
                     }
                 }
                 $table[] = "<td width=\"{$widthprcent}%\" class=\"{$class}\" >" . $tp[$dag][$time] . "&nbsp;</td>\n";
             }
             $dag++;
         }
         $table[] = "</tr>\n";
         $idx++;
         $time += 1;
     }
     $table[] = "</table>\n";
     $html .= implode("", $table);
     $html .= '<input type="hidden" name="itemid" value="' . $itemid . '">';
     $html .= '<input type="hidden" name="jday" value="' . $jday . '">';
     $html .= '</div>';
     // end div=all
     print $html;
     print "</form>";
     return;
 }
Example #8
0
 public static function JDtoDate($jd)
 {
     $dateTimeString = jdtogregorian($jd);
     return new DateTime($dateTimeString);
 }
Example #9
0
 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');
 }
Example #10
0
 /**
  * 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;
 }
Example #11
0
 /**
  * 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);
     }
 }
Example #12
0
 private function calculateRiseTransitSettingTimeCommon($jd, $longitude, $latitude, $ra1, $ra2, $ra3, $dec1, $dec2, $dec3, $moonHorParallax, $timedifference)
 {
     // Step 1 : Calculate the apparent siderial time at Greenwich at 0h UT.
     $jd = floor($jd) - 0.5;
     $T = ($jd - 2451545.0) / 36525.0;
     $theta0 = 100.46061837 + 36000.770053608 * $T + 0.000387933 * $T * $T - $T * $T * $T / 38710000.0;
     if ($theta0 < 0.0) {
         $a = -floor($theta0 / 360.0) + 1;
         $theta0 = $theta0 + $a * 360.0;
     }
     if ($theta0 > 360.0) {
         $a = floor($theta0 / 360.0);
         $theta0 = $theta0 - $a * 360.0;
     }
     $theta0 = $theta0 / 15.0;
     $nutat = $this->calculateNutation($jd);
     $theta0 = $theta0 + $nutat[0] * cos(deg2rad($nutat[3])) / 15.0 / 3600.0;
     // STEP 2 : Calculating the rise, transit and set time of the object
     $ra1 = $ra1 * 15.0;
     $ra2 = $ra2 * 15.0;
     $ra3 = $ra3 * 15.0;
     // Tests when the object passes ra 24 and goes back to 0
     if ($ra3 - $ra2 < -50.0) {
         $ra3 = $ra3 + 360.0;
     } else {
         if ($ra2 - $ra1 < -50.0) {
             $ra3 = $ra3 + 360.0;
             $ra2 = $ra2 + 360.0;
         } else {
             if ($ra2 - $ra3 < -50.0) {
                 $ra1 = $ra1 + 360.0;
                 $ra2 = $ra2 + 360.0;
             } else {
                 if ($ra1 - $ra2 < -50.0) {
                     $ra1 = $ra1 + 360.0;
                 }
             }
         }
     }
     $longitude = -$longitude;
     if ($moonHorParallax == -99.98999999999999) {
         $h0 = -0.5667;
     } else {
         $h0 = 0.7275 * $moonHorParallax - 0.566667;
     }
     $Hcap0 = rad2deg(acos((sin(deg2rad($h0)) - sin(deg2rad($latitude)) * sin(deg2rad($dec2))) / (cos(deg2rad($latitude)) * cos(deg2rad($dec2)))));
     $m0 = ($ra2 + $longitude - $theta0 * 15.0) / 360.0;
     $m0 = $m0 - floor($m0);
     if (is_nan($Hcap0)) {
         $m1 = 99;
         $m2 = 99;
     } else {
         $m1 = $m0 - $Hcap0 / 360.0;
         $m1 = $m1 - floor($m1);
         $m2 = $m0 + $Hcap0 / 360.0;
         $m2 = $m2 - floor($m2);
     }
     // STEP 3 : Extra calculation to work for moving bodies...
     // 3.1 : transit time
     $theta = $theta0 * 15.0 + 360.985647 * $m0;
     $theta = $theta / 360.0;
     $theta = $theta - floor($theta);
     $theta = $theta * 360.0;
     // deltaT is 70 for 2010
     $n = $m0 + 70 / 86400;
     $a = $ra2 - $ra1;
     $b = $ra3 - $ra2;
     $c = $b - $a;
     $alphaInterpol = $ra2 + $n / 2.0 * ($a + $b + $n * $c);
     $H = $theta - $longitude - $alphaInterpol;
     $deltaM = -$H / 360.0;
     $m0 = ($deltaM + $m0) * 24.0;
     if (is_nan($Hcap0)) {
     } else {
         // 3.2 : rise time
         $theta = $theta0 * 15.0 + 360.985647 * $m1;
         $theta = $theta / 360.0;
         $theta = $theta - floor($theta);
         $theta = $theta * 360.0;
         $n = $m1 + 56 / 86400;
         $a = $ra2 - $ra1;
         $b = $ra3 - $ra2;
         $c = $b - $a;
         $alphaInterpol = $ra2 + $n / 2.0 * ($a + $b + $n * $c);
         $a = $dec2 - $dec1;
         $b = $dec3 - $dec2;
         $c = $b - $a;
         $deltaInterpol = $dec2 + $n / 2.0 * ($a + $b + $n * $c);
         $H = $theta - $longitude - $alphaInterpol;
         $h = rad2deg(asin(sin(deg2rad($latitude)) * sin(deg2rad($deltaInterpol)) + cos(deg2rad($latitude)) * cos(deg2rad($deltaInterpol)) * cos(deg2rad($H))));
         $deltaM = ($h - $h0) / (360.0 * cos(deg2rad($deltaInterpol)) * cos(deg2rad($latitude)) * sin(deg2rad($H)));
         $m1 = ($deltaM + $m1) * 24.0;
         // 3.3 : set time
         $theta = $theta0 * 15.0 + 360.985647 * $m2;
         $theta = $theta / 360.0;
         $theta = $theta - floor($theta);
         $theta = $theta * 360.0;
         $n = $m2 + 56 / 86400;
         $a = $ra2 - $ra1;
         $b = $ra3 - $ra2;
         $c = $b - $a;
         $alphaInterpol = $ra2 + $n / 2.0 * ($a + $b + $n * $c);
         $a = $dec2 - $dec1;
         $b = $dec3 - $dec2;
         $c = $b - $a;
         $deltaInterpol = $dec2 + $n / 2.0 * ($a + $b + $n * $c);
         $H = $theta - $longitude - $alphaInterpol;
         $h = rad2deg(asin(sin(deg2rad($latitude)) * sin(deg2rad($deltaInterpol)) + cos(deg2rad($latitude)) * cos(deg2rad($deltaInterpol)) * cos(deg2rad($H))));
         $deltaM = ($h - $h0) / (360.0 * cos(deg2rad($deltaInterpol)) * cos(deg2rad($latitude)) * sin(deg2rad($H)));
         $m2 = ($deltaM + $m2) * 24.0;
     }
     $ris_tra_set[0] = $m1;
     $ris_tra_set[1] = $m0;
     $ris_tra_set[2] = $m2;
     $rise = $ris_tra_set[0];
     if ($ris_tra_set[0] > 48 || $ris_tra_set[0] < -24) {
         $ris_tra_set[0] = "-";
     } else {
         $ris_tra_set[0] = $ris_tra_set[0] + $timedifference;
         if ($ris_tra_set[0] < 0) {
             $ris_tra_set[0] = $ris_tra_set[0] + 24;
         }
         if ($ris_tra_set[0] > 24) {
             $ris_tra_set[0] = $ris_tra_set[0] - 24;
         }
         $minutes = round(($ris_tra_set[0] - floor($ris_tra_set[0])) * 60);
         if ($minutes == 60) {
             $minutes = 0;
             $toAdd = 1;
         } else {
             $toAdd = 0;
         }
         if ($minutes < 10) {
             $minutes = "0" . $minutes;
         }
         $ris_tra_set[0] = floor($ris_tra_set[0]) + $toAdd . ":" . $minutes;
     }
     $transit = $ris_tra_set[1];
     if ($ris_tra_set[1] > 48 || $ris_tra_set[1] < -24) {
         $ris_tra_set[1] = "-";
     } else {
         $ris_tra_set[1] = $ris_tra_set[1] + $timedifference;
         if ($ris_tra_set[1] < 0) {
             $ris_tra_set[1] = $ris_tra_set[1] + 24;
         }
         if ($ris_tra_set[1] > 24) {
             $ris_tra_set[1] = $ris_tra_set[1] - 24;
         }
         $minutes = round(($ris_tra_set[1] - floor($ris_tra_set[1])) * 60);
         if ($minutes == 60) {
             $minutes = 0;
             $toAdd = 1;
         } else {
             $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;
         }
         if ($transit + 24 < $astroend + 24 && $transit + 24 > $toCheck) {
             // The transit is during the day
             // Check the rise time for $astroend and for $astrobegin
             $theta0w = $theta0 + $astrobegin * 1.00273790935;
             if ($theta0w > 0) {
                 $theta0w = $theta0w % 24.0 + ($theta0w - floor($theta0w));
             } else {
                 $toAdd = floor(-$theta0w / 24.0) + 1;
                 $theta0w = $theta0w + 24.0 * $toAdd;
             }
             $H = ($theta0w - $longitude / 15 - $ra2) * 15.0;
             if ($H > 0) {
                 $H = $H % 360.0 + ($H - floor($H));
             } else {
                 $toAdd = floor(-$H / 360.0) + 1;
                 $H = $H + 360.0 * $toAdd;
             }
             $tocompare = rad2deg(asin(sin(deg2rad($latitude)) * sin(deg2rad($dec2)) + cos(deg2rad($latitude)) * cos(deg2rad($dec2)) * cos(deg2rad($H))));
             $transit = $astroend;
         }
         $theta0 = $theta0 + $transit * 1.00273790935;
         if ($theta0 > 0) {
             $theta0 = $theta0 % 24.0 + ($theta0 - floor($theta0));
         } else {
             $toAdd = floor(-$theta0 / 24.0) + 1;
             $theta0 = $theta0 + 24.0 * $toAdd;
         }
         $H = ($theta0 - $longitude / 15 - $ra2) * 15.0;
         if ($H > 0) {
             $H = $H % 360.0 + ($H - floor($H));
         } else {
             $toAdd = floor(-$H / 360.0) + 1;
             $H = $H + 360.0 * $toAdd;
         }
         $ris_tra_set[3] = rad2deg(asin(sin(deg2rad($latitude)) * sin(deg2rad($dec2)) + cos(deg2rad($latitude)) * cos(deg2rad($dec2)) * cos(deg2rad($H))));
         if ($tocompare != -999) {
             if ($tocompare > $ris_tra_set[3]) {
                 $ris_tra_set[3] = $tocompare;
                 $ris_tra_set[4] = $astrobegin;
             } else {
                 $ris_tra_set[4] = $astroend;
             }
         } else {
             $ris_tra_set[4] = $transit;
         }
         $minutes = round(($ris_tra_set[3] - floor($ris_tra_set[3])) * 60);
         if ($minutes == 60) {
             $minutes = 0;
             $toAdd = 1;
         } else {
             $toAdd = 0;
         }
         if ($minutes < 10) {
             $minutes = "0" . $minutes;
         }
         if ($ris_tra_set[3] < 0) {
             $ris_tra_set[3] = "-";
         } else {
             $ris_tra_set[3] = floor($ris_tra_set[3]) + $toAdd . "&deg;" . $minutes . "'";
         }
         if ($ris_tra_set[4] > 24 || $ris_tra_set[4] < 0 || $ris_tra_set[3] == "-") {
             $ris_tra_set[4] = "-";
         } else {
             $ris_tra_set[4] = $ris_tra_set[4] + $timedifference;
             if ($ris_tra_set[4] < 0) {
                 $ris_tra_set[4] = $ris_tra_set[4] + 24;
             }
             if ($ris_tra_set[4] > 24) {
                 $ris_tra_set[4] = $ris_tra_set[4] - 24;
             }
             $minutes = round(($ris_tra_set[4] - floor($ris_tra_set[4])) * 60);
             if ($minutes == 60) {
                 $minutes = 0;
                 $toAdd = 1;
             } else {
                 $toAdd = 0;
             }
             if ($minutes < 10) {
                 $minutes = "0" . $minutes;
             }
             $ris_tra_set[4] = floor($ris_tra_set[4]) + $toAdd . ":" . $minutes;
         }
     } else {
         $ris_tra_set[3] = "-";
         $ris_tra_set[4] = "-";
     }
     // if no astro twilight, or no best astro time for object
     //   if($ris_tra_set[3]=="-")
     if (!($astroend > 0 && $astrobegin > 0)) {
         if ($nautend > 0 && $nautbegin > 0) {
             $tocompare = -999;
             if ($nautbegin > 12) {
                 $toCheck = $nautbegin;
             } else {
                 $toCheck = $nautbegin + 24;
             }
             if ($transit + 24 < $nautend + 24 && $transit + 24 > $toCheck) {
                 // The transit is during the day
                 // Check the rise time for $nautend and for $nautbegin
                 $theta0w = $theta0 + $nautbegin * 1.00273790935;
                 if ($theta0w > 0) {
                     $theta0w = $theta0w % 24.0 + ($theta0w - floor($theta0w));
                 } else {
                     $toAdd = floor(-$theta0w / 24.0) + 1;
                     $theta0w = $theta0w + 24.0 * $toAdd;
                 }
                 $H = ($theta0w - $longitude / 15 - $ra2) * 15.0;
                 if ($H > 0) {
                     $H = $H % 360.0 + ($H - floor($H));
                 } else {
                     $toAdd = floor(-$H / 360.0) + 1;
                     $H = $H + 360.0 * $toAdd;
                 }
                 $tocompare = rad2deg(asin(sin(deg2rad($latitude)) * sin(deg2rad($dec2)) + cos(deg2rad($latitude)) * cos(deg2rad($dec2)) * cos(deg2rad($H))));
                 $transit = $nautend;
             }
             $theta0 = $theta0 + $transit * 1.00273790935;
             if ($theta0 > 0) {
                 $theta0 = $theta0 % 24.0 + ($theta0 - floor($theta0));
             } else {
                 $toAdd = floor(-$theta0 / 24.0) + 1;
                 $theta0 = $theta0 + 24.0 * $toAdd;
             }
             $H = ($theta0 - $longitude / 15 - $ra2) * 15.0;
             if ($H > 0) {
                 $H = $H % 360.0 + ($H - floor($H));
             } else {
                 $toAdd = floor(-$H / 360.0) + 1;
                 $H = $H + 360.0 * $toAdd;
             }
             $ris_tra_set[3] = rad2deg(asin(sin(deg2rad($latitude)) * sin(deg2rad($dec2)) + cos(deg2rad($latitude)) * cos(deg2rad($dec2)) * cos(deg2rad($H))));
             if ($tocompare != -999) {
                 if ($tocompare > $ris_tra_set[3]) {
                     $ris_tra_set[3] = $tocompare;
                     $ris_tra_set[4] = $nautbegin;
                 } else {
                     $ris_tra_set[4] = $nautend;
                 }
             } else {
                 $ris_tra_set[4] = $transit;
             }
             $minutes = round(($ris_tra_set[3] - floor($ris_tra_set[3])) * 60);
             if ($minutes == 60) {
                 $minutes = 0;
                 $toAdd = 1;
             } else {
                 $toAdd = 0;
             }
             if ($minutes < 10) {
                 $minutes = "0" . $minutes;
             }
             if ($ris_tra_set[3] < 0) {
                 $ris_tra_set[3] = "-";
             } else {
                 $ris_tra_set[3] = floor($ris_tra_set[3]) + $toAdd . "&deg;" . $minutes . "'";
             }
             if ($ris_tra_set[4] > 24 || $ris_tra_set[4] < 0 || $ris_tra_set[3] == "-") {
                 $ris_tra_set[4] = "-";
             } else {
                 $ris_tra_set[4] = $ris_tra_set[4] + $timedifference;
                 if ($ris_tra_set[4] < 0) {
                     $ris_tra_set[4] = $ris_tra_set[4] + 24;
                 }
                 if ($ris_tra_set[4] > 24) {
                     $ris_tra_set[4] = $ris_tra_set[4] - 24;
                 }
                 $minutes = round(($ris_tra_set[4] - floor($ris_tra_set[4])) * 60);
                 if ($minutes == 60) {
                     $minutes = 0;
                     $toAdd = 1;
                 } else {
                     $toAdd = 0;
                 }
                 if ($minutes < 10) {
                     $minutes = "0" . $minutes;
                 }
                 $ris_tra_set[4] = floor($ris_tra_set[4]) + $toAdd . ":" . $minutes;
             }
         } else {
             $ris_tra_set[3] = "-";
             $ris_tra_set[4] = "-";
         }
         if ($ris_tra_set[3] != "-") {
             $ris_tra_set[3] = "(" . $ris_tra_set[3] . ")";
         }
     }
     return $ris_tra_set;
 }
Example #13
0
        $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;
        }
    }
 function view_dates()
 {
     global $CFG, $USER;
     $showcombo = optional_param('showcombo', NULL, PARAM_INT);
     $komboroom = optional_param('komboroom', NULL, PARAM_ALPHAEXT);
     $jday = optional_param('jday', NULL, PARAM_INT);
     $subitemid = optional_param('subitemid', NULL, PARAM_INT);
     $tidx = optional_param('tidx', NULL, PARAM_INT);
     $delete = optional_param('delete', NULL, PARAM_INT);
     $edit = optional_param('edit', NULL, PARAM_INT);
     $save = optional_param('save', NULL, PARAM_INT);
     $restore = optional_param('restore', NULL, PARAM_INT);
     $resid = optional_param('resid', NULL, PARAM_INT);
     $uid = optional_param('uid', NULL, PARAM_INT);
     $value = optional_param('value');
     $cmid = $this->cm->id;
     $itemid = $this->bookings->itemid;
     $username = $USER->username;
     // $bookings = get_record('bookings', 'id', $this->bookings->id);
     /// get start and end julian day number
     list($ey, $em, $ed) = explode("/", strftime("%Y/%m/%d", $this->bookings->enddate));
     $ejday = 7 * (int) (gregoriantojd($em, $ed, $ey) / 7);
     list($ey, $em, $ed) = explode("/", strftime("%Y/%m/%d", $this->bookings->startdate));
     $sjday = 7 * (int) (gregoriantojd($em, $ed, $ey) / 7);
     $UID = $USER->id;
     $firstname = $USER->firstname;
     $lastname = $USER->lastname;
     if ($firstname == '' or $lastname == '') {
         return "";
     }
     print '<form name=myform id=myform method=post action="view.php?id=' . $cmid . '">';
     // fetch out data for this item
     $sql = 'SELECT id,name,type,parent
             FROM ' . $CFG->prefix . 'bookings_item i
             WHERE i.parent = ' . $itemid . '
             ORDER BY i.name';
     $idx = 0;
     $main_reservation = array();
     $iteminfo = array();
     $itemid_list = array();
     if (!($childlist = get_records_sql($sql))) {
         $sql = 'SELECT r.id,r.name,r.type,r.parent FROM ' . $CFG->prefix . 'bookings_item r WHERE r.id=' . $itemid;
         $childlist = get_records_sql($sql);
     }
     foreach ($childlist as $child) {
         // build array of props for this item (room)
         $itemid_list[] = $child->id;
         $proplist = bookings_item_properties($child->id);
         if (isset($proplist['image'])) {
             $childlist[$child->id]->image = '<br>' . '<img src="' . $proplist['image'] . '">';
         }
         /// here we fetch out all reservations
         $reservation = array();
         $sql = 'SELECT * FROM ' . $CFG->prefix . 'bookings_calendar 
                 WHERE eventtype="reservation" 
                 AND itemid=' . $child->id . '
                 AND julday >= ' . $sjday . '
                 AND julday <= ' . $ejday;
         if ($res = get_records_sql($sql)) {
             foreach ($res as $re) {
                 $reservation[7 * (int) ($re->julday / 7)] = $re;
             }
         }
         $childlist[$child->id]->proplist = $proplist;
         $main_reservation[$idx] = $reservation;
         $iteminfo[$idx] = $child;
         /// $childlist[$child->id]->reservation = $reservation;
         $idx++;
     }
     /// if there are children, then we must fetch out properties for parent
     /// these props decide if teachers or students can make bookings
     if ($idx > 1) {
         $proplist = bookings_item_properties($itemid);
     }
     // decide if user can edit timetable
     // 0 = view only, 1 = add items, delete/edit own, 2 add/delete/edit any
     $can_edit = isteacherinanycourse($USER->id) ? 1 : 0;
     // default is that teachers can edit
     $link2room = '';
     if (isset($proplist['edit_group'])) {
         $can_edit = 0;
         // default is no edit (that is: edit_group != teacher|student )
         if ($proplist['edit_group'] == 'teachers' and isteacherinanycourse($USER->id)) {
             $can_edit = 1;
             $link2room = ' <a href="itemeditor.php?id=' . $cmid . '&newid=' . $itemid . '">Edit Item</a>';
         } else {
             if ($proplist['edit_group'] == 'students') {
                 $can_edit = 1;
             }
         }
     }
     // intended to give edit-rights to named users
     // these users have admin rights, can delete/edit any booking
     if (isset($proplist['edit_list'])) {
         if (strstr($proplist['edit_list'], $username)) {
             $can_edit = 2;
         }
     }
     if (isadmin()) {
         /// no matter what, admin can edit - even past dates
         $can_edit = 2;
         $link2room = ' <a href="itemeditor.php?id=' . $cmid . '&newid=' . $itemid . '">Edit Item</a>';
     }
     /// this is where we make the reservation or delete reservations
     if (isset($subitemid) and $can_edit) {
         $orig_res = $main_reservation[$tidx][$jday];
         // print_r($orig_res);
         // print "UID = $UID<p>";
         $value = isset($value) ? $value : $username;
         if (isset($edit) and ($can_edit == 2 or $UID == $orig_res->userid)) {
             print "<table><tr><td>";
             print '<script type="text/javascript" src="http://localhost/moodle/lib/editor/htmlarea.php?id=3"></script>
             <script type="text/javascript" src="http://localhost/moodle/lib/editor/lang/en.php"></script>';
             helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
             echo "<br />";
             helpbutton("questions", get_string("helpquestions"), "moodle", true, true);
             echo "<br />";
             if ($usehtmleditor) {
                 helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
             } else {
                 emoticonhelpbutton("form", "description");
             }
             echo "</td><td>";
             print_textarea($usehtmleditor, 20, 60, 680, 400, "value", $orig_res->value);
             if ($usehtmleditor) {
                 echo '<input type="hidden" name="format" value="' . FORMAT_HTML . '" />';
             } else {
                 echo '<div align="right">';
                 helpbutton("textformat", get_string("formattexttype"));
                 print_string("formattexttype");
                 echo ':&nbsp;';
                 if (!$form->format) {
                     $form->format = $defaultformat;
                 }
                 choose_from_menu(format_text_menu(), "format", $form->format, "");
                 echo '</div>';
             }
             print "<script language=\"javascript\" type=\"text/javascript\" defer=\"defer\">\n                var config = new HTMLArea.Config();\n                config.pageStyle = \"body { background-color: #ffffff; font-family: Trebuchet MS,Verdana,Arial,Helvetica,sans-serif; }\";\n                config.killWordOnPaste = true;\n                config.fontname = {\n                \"Trebuchet\":    'Trebuchet MS,Verdana,Arial,Helvetica,sans-serif',\n                \"Arial\":    'arial,helvetica,sans-serif',\n                \"Courier New\":  'courier new,courier,monospace',\n                \"Georgia\":  'georgia,times new roman,times,serif',\n                \"Tahoma\":   'tahoma,arial,helvetica,sans-serif',\n                \"Times New Roman\":  'times new roman,times,serif',\n                \"Verdana\":  'verdana,arial,helvetica,sans-serif',\n                \"Impact\":   'impact',\n                \"Wingdings\":    'wingdings'};\n                HTMLArea.replaceAll(config);\n                </script>";
             print '<input type="submit" name="save" value="save" />';
             print "</td></tr></table>";
             print '<input type="hidden" name="subitemid" value="' . $subitemid . '" />';
             print '<input type="hidden" name="tidx" value="' . $tidx . '" />';
             print '<input type="hidden" name="jday" value="' . $jday . '" />';
             print '<input type="hidden" name="resid" value="' . $resid . '" />';
             print "</form>";
             return;
         }
         if (isset($resid) and ($orig_res->userid == $UID or $can_edit == 2)) {
             $sql = 'DELETE FROM ' . $CFG->prefix . 'bookings_calendar 
                     WHERE id=' . $resid;
             execute_sql($sql, 0);
             unset($main_reservation[$tidx][$jday]);
         }
         unset($res);
         if (isset($restore)) {
             $res->start = 0;
             $value = $orig_res->value;
         }
         if (isset($delete) and ($orig_res->userid == $UID or $can_edit == 2)) {
             if ($orig_res->start != -1) {
                 $res->start = -1;
                 $value = $orig_res->value;
                 unset($delete);
             }
         }
         if (!isset($delete)) {
             $res->name = $username;
             $res->value = $value;
             $res->bookingid = $this->bookings->id;
             $res->userid = $UID;
             $res->eventtype = 'reservation';
             $res->itemid = $iteminfo[$tidx]->id;
             $res->julday = $jday;
             if ($returnid = insert_record("bookings_calendar", $res)) {
                 $res->id = $returnid;
                 $main_reservation[$tidx][$jday] = $res;
             }
         }
     }
     $html = $link2room;
     // now we draw up the table
     // print_r($childlist);
     $html .= '<table border=2><tr><th>' . get_string('week') . '</th>';
     foreach ($childlist as $child) {
         $html .= '<th>' . $child->name . ' ' . $child->image . '</th>';
     }
     $html .= '</tr>';
     $count = count($childlist);
     /// $widthprcent = (int)(95 / $count ) ;    // default width
     $julday = $sjday;
     $date = jdtogregorian($julday);
     list($m1, $d1, $y) = explode('/', $date);
     $time = mktime(12, 0, 0, $m1, $d1, $y);
     while ($julday < $ejday) {
         $baselink = '<a href="view.php?id=' . $cmid . '&jday=' . $julday;
         $date = jdtogregorian($julday);
         list($m, $d, $y) = explode('/', $date);
         $date = jdtogregorian($julday + 6);
         list($m1, $d1, $y) = explode('/', $date);
         $monthname = userdate($time, '%b');
         $date = sprintf("%02d.%02d-%02d.%02d", $d, $m, $d1, $m1);
         $html .= "<tr><th><a name=\"jd{$julday}\">" . bookings_week($julday) . "</a><div class='mod-bookings tiny'>{$monthname} {$date}<div></th>";
         for ($idx = 0; $idx < $count; $idx++) {
             if (isset($main_reservation[$idx][$julday])) {
                 $res = $main_reservation[$idx][$julday];
                 $class = 'reserved';
                 if ($can_edit and ($res->userid == $UID or $can_edit == 2)) {
                     // $linktext = $main_reservation[$idx][$julday]->value;
                     $resid = $res->id;
                     $link = $res->value . '<br>';
                     if ($res->start == -1) {
                         $class = 'deleted';
                         $link .= $baselink . '&tidx=' . $idx . '&subitemid=' . $iteminfo[$idx]->id . '&restore=1&resid=' . $resid . '#jd' . $julday . '" title="Restore" ><img src="' . $CFG->pixpath . '/i/restore.gif" ' . ' height="14" width="14" border="0" alt="Restore" /></a> ';
                     } else {
                         $link .= $baselink . '&tidx=' . $idx . '&subitemid=' . $iteminfo[$idx]->id . '&edit=1&resid=' . $resid . '#jd' . $julday . '" title="Edit" ><img src="' . $CFG->pixpath . '/t/edit.gif" ' . ' height="12" width="12" border="0" alt="Edit" /></a> ';
                     }
                     $link .= $baselink . '&tidx=' . $idx . '&subitemid=' . $iteminfo[$idx]->id . '&delete=1&resid=' . $resid . '#jd' . $julday . '" title="Delete" ><img src="' . $CFG->pixpath . '/t/delete.gif" ' . ' height="12" width="12" border="0" alt="Delete" /></a>';
                 } else {
                     $link = get_string('reserved', 'bookings');
                     if ($can_edit) {
                         $link = $res->value;
                     }
                 }
             } else {
                 $linktext = 'free';
                 $class = 'free';
                 $link = $can_edit ? $baselink . '&tidx=' . $idx . '&subitemid=' . $iteminfo[$idx]->id . '#jd' . $julday . '">' . get_string('free', 'bookings') . '</a>' : get_string('free', 'bookings');
             }
             $html .= "<td class='{$class}'>{$link}</td>\n";
         }
         $julday += 7;
         $time += WEEKSECS;
         $html .= "</tr>";
     }
     $html .= "</table>";
     $html .= '<input type="hidden" name="itemid" value="' . $itemid . '">';
     print $html;
     if ($can_edit > 0) {
         unset($table);
         $table->head = array('&nbsp;', get_string('bookedby', 'bookings'));
         $table->align = array('center', 'left');
         $table->wrap = array('nowrap', 'nowrap');
         $table->width = '100%';
         $table->size = array(10, '*');
         $table->head[] = get_string('week');
         $table->align[] = 'center';
         $table->wrap[] = 'nowrap';
         $table->size[] = '*';
         $table->head[] = get_string('date');
         $table->align[] = 'center';
         $table->wrap[] = 'nowrap';
         $table->size[] = '*';
         $table->head[] = get_string('reservation', 'bookings');
         $table->align[] = 'center';
         $table->wrap[] = 'nowrap';
         $table->size[] = '*';
         $table->head[] = get_string('item', 'bookings');
         $table->align[] = 'center';
         $table->wrap[] = 'nowrap';
         $table->size[] = '*';
         // $books = get_records('calendar', 'bookingid', $this->bookings->id);
         $itemid_list = implode(',', $itemid_list);
         /// WHERE r.bookingid = '{$this->bookings->id}'
         if ($books = get_records_sql("SELECT r.*, u.firstname, u.lastname, u.picture, u.email\n                                FROM {$CFG->prefix}bookings_calendar r,\n                                    {$CFG->prefix}user u\n                                WHERE r.itemid in ( {$itemid_list} )\n                                AND r.julday >= {$sjday}\n                                AND r.julday <= {$ejday}\n                                AND r.userid = u.id ORDER BY r.itemid,r.julday")) {
             foreach ($books as $request) {
                 $row = array();
                 $row[] = print_user_picture($request->userid, $course->id, $request->picture, 0, true);
                 $row[] = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $request->userid . '&course=' . $course->id . '">' . $request->lastname . ' ' . $request->firstname . '</a>';
                 $date = jdtogregorian($request->julday);
                 list($m1, $d1, $y) = explode('/', $date);
                 $time = mktime(12, 0, 0, $m1, $d1, $y);
                 $monthname = userdate($time, '%b');
                 $date = jdtogregorian($request->julday + 6);
                 list($m1, $d1, $y) = explode('/', $date);
                 $date = sprintf("%02d.%02d-%02d.%02d", $d, $m, $d1, $m1);
                 $row[] = get_string('week') . bookings_week($request->julday);
                 $row[] = " {$monthname} " . $date;
                 $row[] = $request->value;
                 $row[] = $childlist[$request->itemid]->name;
                 $table->data[] = $row;
             }
             print "<p>";
             print_table($table);
         }
     }
     print "</form>";
     return;
 }
 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;
 }
Example #16
0
 /**
  * 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;
 }
Example #17
0
 public static function datePop($field, $value, $allow_zero, $first_year = 0)
 {
     if (!$allow_zero && ($value == 0 || $value == '')) {
         $date = array(date('m'), date('d'), date('Y'));
     } else {
         $date = explode('/', jdtogregorian($value));
     }
     $output = self::monthPop($field . '_m', $date[0], $allow_zero);
     $output .= ' / ';
     $output .= self::dayPop($field . '_d', $date[1], $allow_zero);
     $output .= ' / ';
     $output .= self::yearPop($field . '_y', $date[2], $allow_zero, $first_year);
     return $output;
 }
Example #18
0
 /**
  * @return string
  */
 public function get_sql_datetime()
 {
     $date = explode('/', jdtogregorian($this->jd));
     //m/d/y
     foreach ($date as $i => $_d) {
         $date[$i] = intval(ltrim($_d, '0'));
     }
     return sprintf("%04d-%02d-%02d %02d:%02d:%02d", $date[2], $date[0], $date[1], $this->h, $this->m, $this->s);
 }
Example #19
0
    $debug = $hebdate;
    list($hmnum, $hd, $hy) = explode("/", $hebdate, 3);
    $hm = $hnum_to_str[$hmnum];
    //    $hmstr = jdmonthname($jd,4);
} else {
    $hmnum = $hmstr_to_num[$hm];
    if ($hmnum == 6 && !is_leap_year($hy)) {
        $hmnum = 7;
        $hm = "Adar";
    }
    $max_hd = cal_days_in_month(CAL_JEWISH, $hmnum, $hy);
    if ($hd > $max_hd) {
        form(true, "Hebrew day {$hd} out of valid range 1-{$max_hd} for {$hm} in year {$hy}", "");
    }
    $jd = jewishtojd($hmnum, $hd, $hy);
    $greg = jdtogregorian($jd);
    $debug = $greg;
    list($gm, $gd, $gy) = explode("/", $greg, 3);
}
// remove leading zeros, if any
if ($gm[0] == "0") {
    $gm = $gm[1];
}
if ($gd[0] == "0") {
    $gd = $gd[1];
}
$dow = jddayofweek($jd, 2);
if (strncmp("Adar", $hm, 4) == 0 && !is_leap_year($hy)) {
    $hm = "Adar";
} elseif ($hm == "Adar" && is_leap_year($hy)) {
    $hm = "Adar1";
Example #20
0
<?php

echo jdtogregorian(0) . "\n";
echo jdtogregorian(2298874) . "\n";
echo jdtogregorian(2299151) . "\n";
echo jdtogregorian(2440588) . "\n";
echo jdtogregorian(2816423) . "\n";
Example #21
0
 /**
  * Checks if the jdtogregorian function exists, and if not
  * calculates the gregorian date manually.
  *
  * @param int $julian The julian date
  *
  * @access public
  * @return string m/d/Y
  */
 function _jdtogregorian($julian)
 {
     if (function_exists('jdtogregorian')) {
         return jdtogregorian($julian);
     } else {
         // From http://php.net/manual/en/function.jdtogregorian.php
         $julian = $julian - 1721119;
         $calc1 = 4 * $julian - 1;
         $year = floor($calc1 / 146097);
         $julian = floor($calc1 - 146097 * $year);
         $day = floor($julian / 4);
         $calc2 = 4 * $day + 3;
         $julian = floor($calc2 / 1461);
         $day = $calc2 - 1461 * $julian;
         $day = floor(($day + 4) / 4);
         $calc3 = 5 * $day - 3;
         $month = floor($calc3 / 153);
         $day = $calc3 - 153 * $month;
         $day = floor(($day + 5) / 5);
         $year = 100 * $year + $julian;
         if ($month < 10) {
             $month = $month + 3;
         } else {
             $month = $month - 9;
             $year = $year + 1;
         }
         return "{$day}/{$month}/{$year}";
     }
 }
Example #22
0
 } else {
     // toevoegen nieuw blok
     $result = mysql_query(sprintf('SELECT MAX(Wedstrijdblok) AS MaxId FROM %s', $opzoektabel));
     if ($row = mysql_fetch_assoc($result)) {
         $blok_id = $row['MaxId'] + 1;
     } else {
         $blok_id = 1;
     }
 }
 $day_tmp = explode("-", $startdate_db);
 $c_start = gregoriantojd($day_tmp[1], $day_tmp[2], $day_tmp[0]);
 $day_tmp = explode("-", $enddate_db);
 $c_end = gregoriantojd($day_tmp[1], $day_tmp[2], $day_tmp[0]);
 for ($c = $c_start; $c <= $c_end; $c++) {
     // Datum
     $day_tmp = jdtogregorian($c);
     $day_tmp2 = explode("/", $day_tmp);
     $date_ins_db = $day_tmp2[2] . "-" . $day_tmp2[0] . "-" . $day_tmp2[1];
     // Tijden
     if ($c == $c_start) {
         $start_time_tmp = $start_time;
     } else {
         $start_time_tmp = '6:00';
     }
     if ($c == $c_end) {
         $end_time_tmp = $end_time;
     } else {
         $end_time_tmp = '23:45';
     }
     // Check inschrijving tegen de database
     $result = mysql_query('SELECT * 
Example #23
0
         foreach ($deviceStatus as $deviceIndex => $timeOfDay) {
             drawBar($deviceIndex, $timeOfDay, $now, 1);
         }
     } else {
         foreach ($deviceStatus as $deviceIndex => $timeOfDay) {
             drawBar($deviceIndex, $timeOfDay, 24 * 60 * 60);
             $deviceStatus[$deviceIndex] = 0;
             // midnight
         }
     }
     print " </div></td>\n";
     print "</tr>\n";
 }
 if ($day < $today && count($deviceStatus) > 0) {
     for (; $day < $today; ++$day) {
         preg_match("!(\\d+)/(\\d+)/(\\d+)!", jdtogregorian($day), $matched);
         print "<tr>\n";
         printf(" <td>%04d-%02d-%02d</td>\n", $matched[3], $matched[1], $matched[2]);
         print " <td colspan=\"24\"><div class=\"bar\">\n";
         foreach ($deviceStatus as $deviceIndex => $timeOfDay) {
             drawBar($deviceIndex, 0, 24 * 60 * 60);
         }
         print " </div></td>\n";
         print "</tr>\n";
     }
     print "<tr>\n";
     print strftime(" <td>%G-%m-%d</td>\n");
     print " <td colspan=\"24\"><div class=\"bar\">\n";
     foreach ($deviceStatus as $deviceIndex => $timeOfDay) {
         drawBar($deviceIndex, 0, $now, 1);
     }
function bookings_week($jd = 0)
{
    if ($jd == 0) {
        list($y, $m, $d) = explode("/", strftime("%Y/%m/%d", time()));
    } else {
        list($m, $d, $y) = explode("/", jdtogregorian($jd));
    }
    $base = gregoriantojd(1, 1, $y);
    $rest = $base % 7;
    $start = $base - $rest;
    if ($rest > 3) {
        $start += 7;
    }
    if ($jd < $start) {
        return 0;
    }
    return 1 + (int) (($jd - $start) / 7);
}
Example #25
0
function ConvertJDtoDateandTime($Result_JD, $current_tz)
{
    //returns date and time in local time, e.g. 9/3/2007 4:59 am
    //get calendar day - must adjust for the way the PHP function works by adding 0.5 days to the JD of interest
    $jd_to_use = $Result_JD + $current_tz / 24;
    $JDDate = jdtogregorian($jd_to_use + 0.5);
    $fraction = $jd_to_use - floor($jd_to_use);
    if ($fraction < 0.5) {
        $am_pm = "pm";
    } else {
        $fraction = $fraction - 0.5;
        $am_pm = "am";
    }
    $hh = $fraction * 24;
    if ($hh < 1) {
        $hh = $hh + 12;
    }
    $mm = $hh - floor($hh);
    $mins = floor($mm * 60);
    $secs = floor(($mm * 60 - floor($mm * 60)) * 60);
    if ($secs == 30) {
        $secs = "30";
    } else {
        $secs = "00";
    }
    if ($mins < 10) {
        return $JDDate . " " . floor($hh) . ":0" . floor($mm * 60) . ":" . $secs . " " . $am_pm;
    } else {
        return $JDDate . " " . floor($hh) . ":" . floor($mm * 60) . ":" . $secs . " " . $am_pm;
    }
}
Example #26
0
 function parsePDB()
 {
     fseek($this->handle, $this->description_block_offset);
     $this->description_block['divider'] = $this->readHalfWord(true);
     //HW 10
     $this->description_block['latitude'] = $this->readWord() / 1000;
     //HW 11 - 12
     $this->description_block['longitude'] = $this->readWord(true) / 1000;
     //HW 13 - 14
     $this->description_block['height'] = $this->readHalfWord(true);
     //HW 15
     $this->description_block['code'] = $this->readHalfWord(true);
     //HW 16
     $this->description_block['mode'] = $this->readHalfWord();
     //HW 17
     $this->description_block['volumecoveragepattern'] = $this->readHalfWord();
     //HW 18
     $this->description_block['sequencenumber'] = $this->readHalfWord();
     //HW 19
     $this->description_block['scannumber'] = $this->readHalfWord();
     //HW 20
     $this->description_block['scandate'] = jdtogregorian($this->readHalfWord() + 2440586.5);
     //HW 21
     $this->description_block['scantime'] = $this->sec2hms($this->readWord(), true);
     //HW 22 - 23
     $this->description_block['generationdate'] = jdtogregorian($this->readHalfWord() + 2440586.5);
     //HW 24
     $this->description_block['generationtime'] = $this->sec2hms($this->readWord(), true);
     //HW 25 - 26
     $this->description_block['productspecific_1'] = $this->readHalfWord();
     //HW 27
     $this->description_block['productspecific_2'] = $this->readHalfWord();
     //HW 28
     $this->description_block['elevationnumber'] = $this->readHalfWord();
     //HW 29
     $this->description_block['productspecific_3'] = $this->readHalfWord() / 10;
     //HW 30
     $this->description_block['threshold_1'] = $this->readHalfWord();
     //HW 31
     $this->description_block['threshold_2'] = $this->readHalfWord();
     //HW 32
     $this->description_block['threshold_3'] = $this->readHalfWord();
     //HW 33
     $this->description_block['threshold_4'] = $this->readHalfWord();
     //HW 34
     $this->description_block['threshold_5'] = $this->readHalfWord();
     //HW 35
     $this->description_block['threshold_6'] = $this->readHalfWord();
     //HW 36
     $this->description_block['threshold_7'] = $this->readHalfWord();
     //HW 37
     $this->description_block['threshold_8'] = $this->readHalfWord();
     //HW 38
     $this->description_block['threshold_9'] = $this->readHalfWord();
     //HW 39
     $this->description_block['threshold_10'] = $this->readHalfWord();
     //HW 40
     $this->description_block['threshold_11'] = $this->readHalfWord();
     //HW 41
     $this->description_block['threshold_12'] = $this->readHalfWord();
     //HW 42
     $this->description_block['threshold_13'] = $this->readHalfWord();
     //HW 43
     $this->description_block['threshold_14'] = $this->readHalfWord();
     //HW 44
     $this->description_block['threshold_15'] = $this->readHalfWord();
     //HW 45
     $this->description_block['threshold_16'] = $this->readHalfWord();
     //HW 46
     $this->description_block['productspecific_4'] = $this->readHalfWord();
     //HW 47
     $this->description_block['productspecific_5'] = $this->readHalfWord();
     //HW 48
     $this->description_block['productspecific_6'] = $this->readHalfWord();
     //HW 49
     $this->description_block['productspecific_7'] = $this->readHalfWord();
     //HW 50
     $this->description_block['productspecific_8'] = $this->readHalfWord();
     //HW 51
     $this->description_block['productspecific_9'] = $this->readHalfWord();
     //HW 52
     $this->description_block['productspecific_10'] = $this->readHalfWord();
     //HW 53
     $this->description_block['version'] = $this->readByte();
     //HW 54
     $this->description_block['spot_blank'] = $this->readByte();
     //HW 54
     $this->description_block['symbologyoffset'] = $this->readWord();
     //HW 55 - 56
     $this->description_block['graphicoffset'] = $this->readWord();
     //HW 57 - 58
     $this->description_block['tabularoffset'] = $this->readWord();
     //HW 59 - 60
     return $this->description_block;
 }
$allUsers = true;
$activeDate = isset($_REQUEST['date']) ? strtotime($_REQUEST['date']) : strtotime("now");
$title = "Its your friend's Jewish Birthday";
$message = "Today (%1\$s) is %2\$s's Jewish Birthday. \n" . "You can buy %3\$s a Jewish Gift at http://www.judaism.com/index.asp?aref=mplotkin \n" . "or send %3\$s a message on Facebook at http://apps.facebook.com/jewishdates/birthdayInfo.php?id=%4\$s\n\n" . 'If you do not wish to receive these messages. Please set your preferences at http://apps.facebook.com/jewishdates/messageSettings.php.';
$messageHTML = 'Today (%1$s) is <a href="http://apps.facebook.com/jewishdates/birthdayInfo.php?id=%4$s">%2$s</a>\'s Jewish Birthday. ' . '<br />You can buy %3$s a <a href="http://www.judaism.com/index.asp?aref=mplotkin">Jewish Gift</a> ' . ' or send %3$s <a href="http://apps.facebook.com/jewishdates/birthdayInfo.php?id=%4$s">a message on Facebook</a>.<br /><br />' . '	<hr />  ' . 'Support Chabad Of New Paltz & the Jewish Facebook applications and win 10 Thousand $$$.<br>' . '<a href=http://www.JewPaltz.com/raffle>Buy a raffle ticket or ten NOW</a>.';
$one_line_story = array('{*actor*} has {*ammount*} friends whose <a href="http://apps.facebook.com/jewishdates/">Jewish Birthdays</a> are today({*today*}).', '{*actor*} has friends whose <a href="http://apps.facebook.com/jewishdates/">Jewish Birthdays</a> are today({*today*}).');
$short_story = array(array('template_title' => '{*actor*} has {*ammount*} friends whose <a href="http://apps.facebook.com/jewishdates/">Jewish Birthdays</a> are today({*today*}).', 'template_body' => 'You can add your <a href="http://apps.facebook.com/jewishdates/">Jewish Birthday</a>, the current Hebrew Date and other <a href="http://apps.facebook.com/jewishdates/">Jewish Dates</a> to your profile and get notified about your friends\' Jewish Bithdays with the <a href="http://apps.facebook.com/jewishdates/">Jewish Date Application</a>.'), array('template_title' => '{*actor*} has friends whose Jewish Birthdays are today({*today*}).', 'template_body' => 'You can add your <a href="http://apps.facebook.com/jewishdates/">Jewish Birthday</a>, the current Hebrew Date and other <a href="http://apps.facebook.com/jewishdates/">Jewish Dates</a> to your profile and get notified about your friends\' Jewish Bithdays with the <a href="http://apps.facebook.com/jewishdates/">Jewish Date Application</a>.'));
$full_story = $short_story;
$templateBundleId = $facebook->api_client->feed_registerTemplateBundle($one_line_story, $short_story, $full_story);
$picture = 'http://www2.newpaltz.edu/~plotkinm/php/facebook/jewishdates/Icon75x75.gif';
$pLink = 'http://apps.facebook.com/jewishdates/supportChabadOfNewPaltz.php';
//generate coresponding dates
$cDates = array();
$aTodayHebrew = explode("/", strGregToHeb(date("M d, Y", $activeDate)));
for ($i = 10; $i < 70; $i++) {
    $cdate = date("F d, Y", strtotime(jdtogregorian(jewishtojd($aTodayHebrew[0], $aTodayHebrew[1], $aTodayHebrew[2] - $i))));
    $cDates[$i] = $cdate;
}
$cDatesStr = join("','", $cDates);
$activeDateStr = date("l M d, Y", $activeDate);
$iLimit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : 0;
$iStopLimit = isset($_REQUEST['toLimit']) ? $_REQUEST['toLimit'] : 300;
$sql = "SELECT * FROM fbUsers WHERE sessionId is not null AND `current`=1 AND appId='{$appapikey}' " . ($allUsers ? "" : "AND id='{$user}'") . " Limit {$iLimit}, {$iStopLimit}";
trace($sql . '<br />Time Started: ');
$conn = dbConnect();
$results = mysql_query($sql, $conn);
$i = 0;
$actualPosts = 0;
?>
<h1><a href="?limit=<?php 
echo $iLimit + $iStopLimit;
Example #28
0
 public function toDateTime()
 {
     return new DateTime(jdtogregorian(jewishtojd($this->month, $this->day, $this->year)));
 }
Example #29
0
 /**
  * Converts number of days since 24th November, 4714 B.C. (in the proleptic
  * Gregorian calendar, which is year -4713 using 'Astronomical' year
  * numbering) to Gregorian calendar date.
  *
  * Returned date belongs to the proleptic Gregorian calendar, using
  * 'Astronomical' year numbering.
  *
  * The algorithm is valid for all years (positive and negative), and
  * also for years preceding 4714 B.C. (i.e. for negative 'Julian Days'),
  * and so the only limitation is platform-dependent (for 32-bit systems
  * the maximum year would be something like about 1,465,190 A.D.).
  *
  * N.B. Monday, 24th November, 4714 B.C. is Julian Day '0'.
  *
  * Algorithm is from PEAR::Date_Calc
  *
  * @author Monte Ohrt <*****@*****.**>
  * @author Pierre-Alain Joye <*****@*****.**>
  * @author Daniel Convissor <*****@*****.**>
  * @author C.A. Woodcock <*****@*****.**>
  *
  * @param int    $days   the number of days since 24th November, 4714 B.C.
  * @param string $format the string indicating how to format the output
  *
  * @return  Horde_Date  A Horde_Date object representing the date.
  */
 public static function fromDays($days)
 {
     if (function_exists('jdtogregorian')) {
         list($month, $day, $year) = explode('/', jdtogregorian($days));
     } else {
         $days = intval($days);
         $days -= 1721119;
         $century = floor((4 * $days - 1) / 146097);
         $days = floor(4 * $days - 1 - 146097 * $century);
         $day = floor($days / 4);
         $year = floor((4 * $day + 3) / 1461);
         $day = floor(4 * $day + 3 - 1461 * $year);
         $day = floor(($day + 4) / 4);
         $month = floor((5 * $day - 3) / 153);
         $day = floor(5 * $day - 3 - 153 * $month);
         $day = floor(($day + 5) / 5);
         $year = $century * 100 + $year;
         if ($month < 10) {
             $month += 3;
         } else {
             $month -= 9;
             ++$year;
         }
     }
     return new Horde_Date($year, $month, $day);
 }
Example #30
0
 static function julianToDate($dt1)
 {
     $date = jdtogregorian($dt1);
     $date = strtotime($date);
     return date("Y-m-d", $date);
 }