function isHoliday($date) { // insert your favorite holidays here $this->JDtoYMD($date, $year, $month, $day); if ($date == easter_days($year) + $this->MDYtoJD(3, 21, $year)) { $noSchool = false; return "Easter"; } if ($date == easter_days($year) + $this->MDYtoJD(3, 21, $year) - 2) { $noSchool = false; return "Good Friday"; } $jewishDate = explode("/", jdtojewish(gregoriantojd($month, $day, $year))); $month = $jewishDate[0]; $day = $jewishDate[1]; if ($month == 1 && $day == 1) { return "Rosh Hashanah"; } if ($month == 1 && $day == 2) { return "Rosh Hashanah"; } if ($month == 1 && $day == 10) { return "Yom Kippur"; } if ($month == 3 && $day == 25) { return "Chanukkah"; } if ($month == 8 && $day == 15) { return "Passover"; } // call the base class for USA holidays return parent::isHoliday($date); }
/** * Returns the current date in gregorian and hebrew * * The $params array can receive the parameters as follows: * ['gregorianDate'] -> Timestamped Gregorian Date * ['hebrewCaracters'] -> Returns the date in hebrew caracters. The param must be a boolean (true or false) * * @param array $params * @return string */ function getDateJewishCalendar(array $params) { $gregorianDate = date('d/m/Y', $params['gregorianDate']); list($gregorianDay, $gregorianMonth, $gregorianYear) = explode('/', $gregorianDate); // Converting gregorian to julian date $julianDate = gregoriantojd($gregorianMonth, $gregorianDay, $gregorianYear); // Getting the Hebrew Month name $hebrewMonthName = jdmonthname($julianDate, 4); // Converting the date from Julian to Jewish. $jewishDate = jdtojewish($julianDate); list($jewishMonth, $jewishDay, $jewishYear) = explode('/', $jewishDate); $jewishDateStr = ""; $jewishDateStr = "{$gregorianDate} - "; $jewishDateStr .= "{$jewishDay} {$hebrewMonthName} {$jewishYear}"; if ($params['hebrewCaracters'] === true) { // Converting the date from Julian to Jewish, but in hebrew caracters $hebrewDate = jdtojewish($julianDate, true); /* * This plugin is UTF8 only and the jdtojewish function only return iso, * so we need to convert it with mb_string, mb_convert_encoding function. */ $jewishDateStr .= " - " . mb_convert_encoding(jdtojewish($julianDate, true), "UTF-8", "ISO-8859-8"); } return $jewishDateStr; }
public function __construct(DateTime $date = null) { if (!$date) { $date = new DateTime(); } list($month, $day, $year) = explode('-', $date->format('m-d-Y')); list($this->month, $this->day, $this->year) = explode('/', jdtojewish(gregoriantojd($month, $day, $year))); }
/** * {@inheritdoc} */ public static function fromInternal($stamp, $format = null) { $date = Calends::fromInternalToUnix($stamp); list($m, $d, $y) = explode('/', \jdtojewish(BC::add(BC::div($date, 86400, 18), 2440587.5, 0))); if (\JewishToJD(6, 1, $y) == \JewishToJD(7, 1, $y)) { $m = $m == 6 ? '6L' : ($m == 7 ? '7L' : $m); } return "{$d} " . static::$months[str_pad($m, 2, '0', STR_PAD_LEFT)] . " {$y} " . date_create_from_format('U.u', BC::add(BC::mod($date, 86400, 18), 0, 6))->format('H:i:s.u P'); }
function strGregToHeb($strDate, $hebrew = false, $bornAtNight = false) { if ($bornAtNight) { $strDate = date("M d, Y", strtotime($strDate . " +1 day")); } $tDate = getdate(strtotime($strDate)); $hebdate = jdtojewish(gregoriantojd($tDate['mon'], $tDate['mday'], $tDate['year']), $hebrew); if ($hebrew) { return iconv("ISO-8859-8", "UTF-8", $hebdate); } else { return $hebdate; } }
public function loadHolidays() { $jdDate = cal_to_jd(CAL_GREGORIAN, date('m'), date('d'), date('Y')); $hebrewDate = jdtojewish($jdDate); list($hebrewMonth, $hebrewDay, $hebrewYear) = explode('/', $hebrewDate); $holidays = array(); $currYear = $hebrewYear - 1; // subtract a year for some reason $nextYear = $currYear + 1; foreach ($this->holidays as $key => $val) { $julianDate = jewishtojd($val[0], $val[1], $currYear); if (jdtounix($julianDate) < time()) { $julianDate = jewishtojd($val[0], $val[1], $nextYear); if (jdtounix($julianDate) < time()) { $julianDate = jewishtojd($val[0], $val[1], $nextYear + 1); } } $unixTime = jdtounix($julianDate); $unixTime += 86400; // add 1 day for some reason $holidays[$key] = '@' . $unixTime; } return $holidays; }
function hebdate($datestr) { global $language; $hebdate = ''; $year = NULL; $month = NULL; $day = NULL; $year = search_year($datestr); if ($year) { $month = search_month($datestr); if ($month) { $day = search_day($datestr); } } if ($year != NULL and $month != NULL and $day != NULL) { $str = jdtojewish(gregoriantojd($month, $day, $year), false); $string = explode("/", $str); if ($language["dir"] == "rtl") { if ($string[0] == 1) { $month = "תשרי"; } if ($string[0] == 2) { $month = "חשון"; } if ($string[0] == 3) { $month = "כסלו"; } if ($string[0] == 4) { $month = "טבת"; } if ($string[0] == 5) { $month = "שבט"; } if ($string[0] == 6) { $month = "אדר"; } if ($string[0] == 7) { $month = "אדר שני"; } if ($string[0] == 8) { $month = "ניסן"; } if ($string[0] == 9) { $month = "אייר"; } if ($string[0] == 10) { $month = "סיון"; } if ($string[0] == 11) { $month = "תמוז"; } if ($string[0] == 12) { $month = "אב"; } if ($string[0] == 13) { $month = "אלול"; } } else { if ($string[0] == 1) { $month = "Tishrei"; } if ($string[0] == 2) { $month = "Cheshvan"; } if ($string[0] == 3) { $month = "Kislev"; } if ($string[0] == 4) { $month = "Tevet"; } if ($string[0] == 5) { $month = "Shevat"; } if ($string[0] == 6) { $month = "Adar"; } if ($string[0] == 7) { $month = "Adar II"; } if ($string[0] == 8) { $month = "Nisan"; } if ($string[0] == 9) { $month = "Iyar"; } if ($string[0] == 10) { $month = "Sivan"; } if ($string[0] == 11) { $month = "Tamuz"; } if ($string[0] == 12) { $month = "Av"; } if ($string[0] == 13) { $month = "Ellul"; } } $hebdate = " (" . $string[1] . " " . $month . " " . $string[2] . ")"; } return $hebdate; }
public static function getJewishDate($timestamp) { $d = jdtojewish(gregoriantojd(date('n', $timestamp), date('j', $timestamp), date('Y', $timestamp)), false, CAL_JEWISH_ADD_GERESHAYIM + CAL_JEWISH_ADD_ALAFIM + CAL_JEWISH_ADD_ALAFIM_GERESH); list($month_name, $day, $year) = explode('/', $d); $leap = $year % 19 == 0 || $year % 19 == 3 || $year % 19 == 6 || $year % 19 == 8 || $year % 19 == 11 || $year % 19 == 14 || $year % 19 == 17; $months = array("Tishri" => 1, "Heshvan" => 2, "Kislev" => 3, "Tevet" => 4, "Shevat" => 5, "Adar" => 6, "Adar I" => 6, "Adar II" => 7, "Nisan" => 8, "Iyar" => 9, "Sivan" => 10, "Tammuz" => 11, "Av" => 12, "Elul" => 13); if (is_numeric($month_name)) { $month = $month_name; if (!$leap && $month == 7) { $month == 6; } } else { $month = $months[$month_name]; } return array($day, $month, $year, $leap); }
$fast_day = true; } if (isset($other_holidays[$subj])) { $chag_sameach = $subj; } } } function format_greg_date_for_erev($hmonth, $hday, $hyear) { $jd = jewishtojd($hmonth, $hday, $hyear); $greg_cal = cal_from_jd($jd, CAL_GREGORIAN); return sprintf("%s, %s %s %s", $greg_cal["abbrevdayname"], $greg_cal["day"], $greg_cal["monthname"], $greg_cal["year"]); } // Yamim Nora'im $jd = gregoriantojd($gm, $gd, $gy); $hebdate = jdtojewish($jd); list($hmnum, $hd, $hy) = explode("/", $hebdate, 3); // With PHP 5.5, the functionality changed regarding Adar in a non-leap year. // Prior to 5.5, the month was returned as 6. // In 5.5 and 5.6, the month is returned as 7. $purim_month_num = 7; if ($hmnum == 13 && $hd >= 1) { $shana_tova = true; // month 13 == Elul $erev_rh = format_greg_date_for_erev(13, 29, $hy); } elseif ($hmnum == 1 && $hd <= 10) { // month 1 == Tishrei. Gmar Tov! $erev_yk = format_greg_date_for_erev(1, 9, $hy); } elseif ($hmnum == $purim_month_num && $hd >= 2 && $hd <= 13) { // for two weeks before Purim, show greeting $erev_purim = format_greg_date_for_erev($purim_month_num, 13, $hy);
/** * Get the hebrew date for a given unixtime. * * @param type $unixtime * @param type $asArray ((optional) default to false) * * @return type The jewish date as a string in the form "month/day/year" */ public static function getHebrewDate($unixtime, $asArray = false) { $date = jdtojewish(gregoriantojd(date('m', $unixtime), date('d', $unixtime), date('Y', $unixtime))); return $asArray ? split("/", $date) : $date; }
if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); $info['rank'] = $row['rank']; } else { $info['rank'] = 1; } $rank = $info['rank']; $sql = "select medals_required from ranks where rank_ord = " . ++$rank; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $info['medalsNeeded'] = $row['medals_required']; $medals = array(); $sql = "select medal_ord, subject_id, profile_photo_id, date_awarded \n\t\tfrom medal_marks \n\t\tjoin medals_subjects using (subject_id, medal_ord) \n\t\twhere user_id = " . $user_id . " \n\t\torder by date_awarded, medal_ord"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $jdate = jdtojewish($row['date_awarded'], true, CAL_JEWISH_ADD_GERESHAYIM); $awarded = $str1 = iconv('WINDOWS-1255', 'UTF-8', $jdate); // convert to utf-8 //$pos = strrpos($awarded, ' '); //$awarded = substr($awarded, 0, $pos); $medals[] = array('subject' => $row['subject_id'], 'medal' => $row['medal_ord'], 'photo' => $row['profile_photo_id'], 'awarded' => $awarded); } $info['totalMedals'] = mysql_num_rows($result); $info['medals'] = $medals; $medalsInfo = array(); $sql = "select rank_ord, medals_required from ranks order by rank_ord"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $medalsInfo[$row['rank_ord']] = $row['medals_required']; } $info['medalsInfo'] = $medalsInfo;
public function get_hebrew_date_numeric($htimes = null) { $jd = $this->jd; if (!empty($htimes)) { if ($htimes->now >= $htimes->sunset) { $jd += 1; } // jewish day begins with a sunset! } $data = explode('/', jdtojewish($jd)); $is_leap = self::is_leap_year($data[2]); if ($is_leap && ($data[0] == 6 || $data[0] == 7)) { $data[0] += 8; } return $data; }
<?php var_dump(jdtojewish(gregoriantojd(10, 28, 2002)) . "\r\n" . jdtojewish(gregoriantojd(10, 28, 2002), true) . "\r\n" . jdtojewish(gregoriantojd(10, 28, 2002), true, CAL_JEWISH_ADD_ALAFIM_GERESH) . "\r\n" . jdtojewish(gregoriantojd(10, 28, 2002), true, CAL_JEWISH_ADD_ALAFIM) . "\r\n" . jdtojewish(gregoriantojd(10, 28, 2002), true, CAL_JEWISH_ADD_ALAFIM_GERESH + CAL_JEWISH_ADD_ALAFIM) . "\r\n" . jdtojewish(gregoriantojd(10, 28, 2002), true, CAL_JEWISH_ADD_GERESHAYIM) . "\r\n" . jdtojewish(gregoriantojd(10, 8, 2002), true, CAL_JEWISH_ADD_GERESHAYIM) . "\r\n" . jdtojewish(gregoriantojd(10, 8, 2002), true, CAL_JEWISH_ADD_GERESHAYIM + CAL_JEWISH_ADD_ALAFIM_GERESH) . "\r\n" . jdtojewish(gregoriantojd(10, 8, 2002), true, CAL_JEWISH_ADD_GERESHAYIM + CAL_JEWISH_ADD_ALAFIM) . "\r\n" . jdtojewish(gregoriantojd(10, 8, 2002), true, CAL_JEWISH_ADD_GERESHAYIM + CAL_JEWISH_ADD_ALAFIM + CAL_JEWISH_ADD_ALAFIM_GERESH) . "\r\n" . jdtojewish(gregoriantojd(3, 10, 2007)) . "\r\n");
/** * Parse the Date object and return a result based on format. * * @param string $delimiter * @return string */ public function convert($delimiter = " ") { $julianDate = $this->toJulianDate(); $jewishDate = $this->applyFormat(explode('/', jdtojewish($julianDate))); return implode($delimiter, $jewishDate); }
function get_content() { global $USER, $CFG, $SESSION, $COURSE; $cal_m = optional_param('cal_m', 0, PARAM_INT); $cal_y = optional_param('cal_y', 0, PARAM_INT); require_once $CFG->dirroot . '/calendar/lib.php'; if ($this->content !== NULL) { return $this->content; } // Reset the session variables calendar_session_vars($COURSE); $this->content = new stdClass(); $this->content->text = ''; $this->content->footer = ''; // [pj] To me it looks like this if would never be needed, but Penny added it // when committing the /my/ stuff. Reminder to discuss and learn what it's about. // It definitely needs SOME comment here! $courseshown = $COURSE->id; if ($courseshown == SITEID) { // Being displayed at site level. This will cause the filter to fall back to auto-detecting // the list of courses it will be grabbing events from. $filtercourse = NULL; $groupeventsfrom = NULL; $SESSION->cal_courses_shown = calendar_get_default_courses(true); calendar_set_referring_course(0); } else { // Forcibly filter events to include only those from the particular course we are in. $filtercourse = array($courseshown => $COURSE); $groupeventsfrom = array($courseshown => 1); } // We 'll need this later calendar_set_referring_course($courseshown); // MDL-9059, set to show this course when admins go into a course, then unset it. if ($COURSE->id != SITEID && !isset($SESSION->cal_courses_shown[$COURSE->id]) && has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM))) { $courseset = true; $SESSION->cal_courses_shown[$COURSE->id] = $COURSE; } // calendar, display hebrew dates $strhebrewcalendardate = ''; // Remark next line to disable Hebrew dates $CFG->hebrewdates = true; if (!empty($CFG->hebrewdates)) { $strhebrewcalendardate = '<div style="text-align:center;">' . mb_convert_encoding(jdtojewish(gregoriantojd(date('n'), date('j'), date('Y')), true, CAL_JEWISH_ADD_GERESHAYIM + CAL_JEWISH_ADD_ALAFIM + CAL_JEWISH_ADD_ALAFIM_GERESH), "UTF-8", "ISO-8859-8") . '</div>'; } // Be VERY careful with the format for default courses arguments! // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions. calendar_set_filters($courses, $group, $user, $filtercourse, $groupeventsfrom, false); if ($courseshown == SITEID) { // For the front page $this->content->text .= calendar_overlib_html(); $this->content->text .= $strhebrewcalendardate; $this->content->text .= calendar_top_controls('frontpage', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y)); $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y); // No filters for now } else { // For any other course $this->content->text .= calendar_overlib_html(); $this->content->text .= $strhebrewcalendardate; $this->content->text .= calendar_top_controls('course', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y)); $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y); $this->content->text .= '<h3 class="eventskey">' . get_string('eventskey', 'calendar') . '</h3>'; $this->content->text .= '<div class="filters">' . calendar_filter_controls('course', '', $COURSE) . '</div>'; } // MDL-9059, unset this so that it doesn't stay in session if (!empty($courseset)) { unset($SESSION->cal_courses_shown[$COURSE->id]); } return $this->content; }
<?php $jday = unixtojd(); echo jdtojewish($jday, true);
<?php echo frenchtojd(-1, -1, -1), "\n"; echo frenchtojd(0, 0, 0), "\n"; echo frenchtojd(1, 1, 1), "\n"; echo frenchtojd(14, 31, 15), "\n"; echo easter_days(1999), "\n"; echo easter_days(1492), "\n"; echo easter_days(1913), "\n"; $num = cal_days_in_month(CAL_GREGORIAN, 8, 2003); echo "There are {$num} days in August 2003\n"; $num = cal_days_in_month(CAL_GREGORIAN, 2, 2003); echo "There are {$num} days in February 2003\n"; $num = cal_days_in_month(CAL_GREGORIAN, 2, 2004); echo "There are {$num} days in February 2004\n"; $num = cal_days_in_month(CAL_GREGORIAN, 12, 2034); echo "There are {$num} days in December 2034\n"; echo cal_to_jd(CAL_GREGORIAN, 8, 26, 74), "\n"; echo cal_to_jd(CAL_JULIAN, 8, 26, 74), "\n"; echo cal_to_jd(CAL_JEWISH, 8, 26, 74), "\n"; echo cal_to_jd(CAL_FRENCH, 8, 26, 74), "\n"; echo bin2hex(jdtojewish(gregoriantojd(10, 28, 2002))), "\n"; echo bin2hex(jdtojewish(gregoriantojd(10, 28, 2002), true)) . "\n"; echo bin2hex(jdtojewish(gregoriantojd(10, 28, 2002), true, CAL_JEWISH_ADD_ALAFIM_GERESH)) . "\n"; echo bin2hex(jdtojewish(gregoriantojd(10, 28, 2002), true, CAL_JEWISH_ADD_ALAFIM)) . "\n"; echo bin2hex(jdtojewish(gregoriantojd(10, 28, 2002), true, CAL_JEWISH_ADD_ALAFIM_GERESH + CAL_JEWISH_ADD_ALAFIM)) . "\n"; echo bin2hex(jdtojewish(gregoriantojd(10, 28, 2002), true, CAL_JEWISH_ADD_GERESHAYIM)) . "\n"; echo bin2hex(jdtojewish(gregoriantojd(10, 8, 2002), true, CAL_JEWISH_ADD_GERESHAYIM)) . "\n"; echo bin2hex(jdtojewish(gregoriantojd(10, 8, 2002), true, CAL_JEWISH_ADD_GERESHAYIM + CAL_JEWISH_ADD_ALAFIM_GERESH)) . "\n"; echo bin2hex(jdtojewish(gregoriantojd(10, 8, 2002), true, CAL_JEWISH_ADD_GERESHAYIM + CAL_JEWISH_ADD_ALAFIM)) . "\n"; echo bin2hex(jdtojewish(gregoriantojd(10, 8, 2002), true, CAL_JEWISH_ADD_GERESHAYIM + CAL_JEWISH_ADD_ALAFIM + CAL_JEWISH_ADD_ALAFIM_GERESH)) . "\n";
function hanukkahStart($year = null) { $reference = ($year == '2021' || $year == '2032' ? '11/1/' : '12/1/') . ($year !== null ? $year : date('Y')); list($month, $day, $year) = explode("/", jdtojewish(unixtojd(strtotime($reference)))); return jdtounix(jewishtojd(3, 25, $year)); }
<?php $a = array(38245310, 324542846, 324542847, 9223372036854743639); foreach ($a as $x) { var_dump(jdtojewish($x)); }
<?php $jday = unixtojd(); echo jdtojewish($jday);
<?php $today_in_julian_day = gregoriantojd(8, 16, 2011); // $mese, $giorno, $anno $today_in_jewish_cal = jdtojewish($today_in_julian_day); // restituisce una stringa del formato 'mese/giorno/anno' echo jdmonthname($today_in_julian_day, 4) . "\n"; $today_in_french_cal = JDToFrench($today_in_julian_day); $month_in_french_cal = jdmonthname($today_in_julian_day, CAL_FRENCH); var_dump($today_in_french_cal); var_dump($month_in_french_cal); $today_in_julian_day = cal_to_jd(CAL_GREGORIAN, 00, 16, 2011); // con CAL_GREGORIAN costante statica e gli altri parametri corrispondenti alla sintassi di data all'americana con, in ordine, $mese, $giorno, $anno. var_dump($today_in_julian_day);
//SEGMENT 1.0 $arSeg1 = array("Ianuarius", "Februarius", "Martius", "Aprilis", "Maius", "Iunius", "Iulius", "Augustus", "October", "Messidor", "November", "December"); //SEGMENT 2.0 $arSeg2 = array("Ianuariis", "Februariis", "Martiis", "Aprilibus", "Maiis", "Iuniis", "Iuliis", "Augustis", "Septembribus", "Octobribus", "Novembribus", "Decembribus"); //SEGMENT 3.0 $arSeg3 = array("Ianuarias", "Februarias", "Martias", "Apriles", "Maias", "Iunias", "Iulias", "Augustas", "Septembres", "Octobres", "Novembres", "Decembres"); /* if ((date('L'))==1){ return $arSeg3[(date('n')-1]; } else { if (rand(1,2) == 1) { return $arSeg2[(date('n'))-1]; } else { return $arSeg1[(date('n'))-1]; } } */ } function GetLatinDate($timeseed) { return decrom(date('yyyy')) . ' of year ' . LatinMonthNames($timeseed) . ' in day ' . decrom(date('t')); } //$arDateFrench = gregorian2FrenchDateArray(date('d',$tme), date('m',$tme), date('Y',$tme)) ; $gregorianMonth = date(n, $tme); $gregorianDay = date(j, $tme); $gregorianYear = date(Y, $tme); $arDateFrench = cal_from_jd(gregoriantojd($gregorianMonth, $gregorianDay, $gregorianYear), CAL_FRENCH); $jdDate = gregoriantojd($gregorianMonth, $gregorianDay, $gregorianYear); $hebrewMonthName = jdmonthname($jdDate, 4); $hebrewDate = jdtojewish($jdDate); list($hebrewMonth, $hebrewDay, $hebrewYear) = split('/', $hebrewDate);
private function is_jd_kodesh($jd) { $wd = ($jd + 1) % 7; if ($wd == 6) { return true; } // Shabbes $d = explode('/', jdtojewish($jd)); $d = intval($d[0]) . '/' . intval($d[1]); $chul = $this->is_chul ? 'chul' : 'eretz'; if (in_array($d, self::$kodesh_dates[$chul])) { return true; } return false; }