Пример #1
1
function DaysBetweenDates($dformat, $endDate, $beginDate)
{
    $DateParts1 = explode($dformat, $beginDate);
    echo print_r($DateParts1);
    $DateParts2 = explode($dformat, $endDate);
    $StartDate = gregoriantojd($DateParts1[1], $DateParts1[2], $DateParts1[0]);
    echo print_r($StartDate) . "+";
    $EndDate = gregoriantojd($DateParts2[1], $DateParts2[2], $DateParts2[0]);
    echo print_r($EndDate);
    return $EndDate - $StartDate;
}
/**
 * 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;
}
Пример #3
0
/**
 * Takes the payment data gotten from process_pdt_function.php's function
 * checks the transaction details and gives a code based on several things:
 * [receiver_email] => the seller's email
 * [payment_gross] => the amount paid
 * [mc_currency] => the type of currency (USD)
 * [item_name] => the item name (Chinese Hack Code, English Hack Code)
 * @param $data     the array returned from the pdt function
 * @param $mysql    the mysql connection
 * @return          the code or invalid transaction ID message
 */
function id_to_code($data, $mysql)
{
    //check payment reciever's emails
    if ($data[receiver_email] !== "*****@*****.**" && $data[receiver_email] !== "*****@*****.**") {
        return "Looks like you paid the wrong person...";
    }
    //check currency type
    if ($data[mc_currency] !== "USD") {
        return "We like USD. Pay in USD.";
    }
    //set timezone to pdt
    date_default_timezone_set('America/Vancouver');
    //today's date
    $month = jdmonthname(gregoriantojd(date(m), 13, 1998), 0);
    $this_date = jdmonthname($jd, 0) . " " . date(Y) . " PDT";
    //date of purchase
    $payment_date = $data[payment_date];
    $payment_date1 = substr($payment_date, -9);
    $payment_date2 = substr($payment_date, 9, 3);
    /*check time of purchase
    	if ( strcmp($this_date, $payment_date2 . $payment_date1) !== 0)
    	{
    		return "You're a little late on redeeming...";
    	}
    	*/
    //check kind of item
    if ($data[item_name] == "somethin") {
        $db = mysql_select_db("somethin", $mysql);
    } else {
        if ($data[item_name] == "somethin2") {
            $db = mysql_select_db("somethin2", $mysql);
        } else {
            return "We're not sure what you bought...";
        }
    }
    //check amount paid
    if ($data[payment_gross] == 20.0) {
        $table = "20";
    } else {
        if ($data[payment_gross] == 7.0) {
            $table = "7";
        } else {
            if ($data[payment_gross] == 2.0) {
                $table = "2";
            } else {
                return "You paid an incorrect amount...";
            }
        }
    }
    //look around table for code that has matching transaction ID
    $result = mysql_query("SELECT * FROM `{$table}` WHERE `id` LIKE '{$data['txn_id']}' LIMIT 1");
    //if there is none found, make a new entry
    if (mysql_num_rows($result) == 0) {
        mysql_query("UPDATE `{$table}` SET id='{$data['txn_id']}',date='{$data['payment_date']}',ip='{$ip}' WHERE `id` LIKE '' LIMIT 1");
        $result = mysql_query("SELECT * FROM `{$table}` WHERE `id` LIKE '{$data['txn_id']}' LIMIT 1");
    }
    //get the row that the transaction ID is found on and return the cod value
    $row = mysql_fetch_array($result);
    return $row['cod'];
}
 public function postAdd()
 {
     $mulai = Input::get('start');
     $selesai = Input::get('finish');
     //pecah tanggal mulai
     $pecah_mulai = explode('/', $mulai);
     $hari_mulai = $pecah_mulai[1];
     $bulan_mulai = $pecah_mulai[0];
     $tahun_mulai = $pecah_mulai[2];
     //pecah tanggal selesai
     $pecah_selesai = explode('/', $selesai);
     $hari_selesai = $pecah_selesai[1];
     $bulan_selesai = $pecah_selesai[0];
     $tahun_selesai = $pecah_selesai[2];
     $cuti_mulai = gregoriantojd($bulan_mulai, $hari_mulai, $tahun_mulai);
     $cuti_selesai = gregoriantojd($bulan_selesai, $hari_selesai, $tahun_selesai);
     $selisi = $cuti_selesai - $cuti_mulai + 1;
     $libur = 0;
     for ($x = 1; $x <= $selisi; $x++) {
         $hitung_waktu = mktime(0, 0, 0, $bulan_mulai, $hari_mulai + $x, $tahun_mulai);
         if (date('w', $hitung_waktu) == 0 || date('w', $hitung_waktu) == 6) {
             $libur++;
         }
     }
     $jumlah_curi = $selisi - $libur;
     $cuti = Request::all();
     $cuti['period'] = $jumlah_curi;
     $query = Leave::create($cuti);
     $query == true ? $message = 'Berhasil tambah data' : ($message = 'Gagal tambah data');
     return redirect('leave')->with('message', $message);
 }
Пример #5
0
 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);
 }
Пример #6
0
function daysBetweenDate($from, $till)
{
    /*
     *This function will calculate the difference between two given dates.
     *
     *Please input time by ISO 8601 standards (yyyy-mm-dd).
     *i.e: daysBetweenDate('2009-01-01', '2010-01-01');
     *This will return 365.
     *
     *Author: brian [at] slaapkop [dot] net
     *May 5th 2010
    */
    if ($till < $from) {
        trigger_error("The date till is before the date from", E_USER_NOTICE);
    }
    //Explode date since gregoriantojd() requires mm, dd, yyyy input;
    $from = explode('-', $from);
    $till = explode('-', $till);
    //Calculate date to Julian Day Count with freshly created array $from.
    $from = gregoriantojd($from[1], $from[2], $from[0]) . "<br />";
    //Calculate date to Julian Day Count with freshly created array $till.
    $till = gregoriantojd($till[1], $till[2], $till[0]) . "<br />";
    //Substract the days $till (largest number) from $from (smallest number) to get the amount of days
    $days = $till - $from;
    //Return the number of days.
    return $days;
    //Isn't it sad how my comments use more lines than the actual code?
}
Пример #7
0
function compararFechas($primera, $segunda) {
    $valoresPrimera = explode("/", $primera);
    $valoresSegunda = explode("/", $segunda);

    $diaPrimera = $valoresPrimera[0];
    $mesPrimera = $valoresPrimera[1];
    $anyoPrimera = $valoresPrimera[2];

    $diaSegunda = $valoresSegunda[0];
    $mesSegunda = $valoresSegunda[1];
    $anyoSegunda = $valoresSegunda[2];

    $diasPrimeraJuliano = gregoriantojd($mesPrimera, $diaPrimera, $anyoPrimera);
    $diasSegundaJuliano = gregoriantojd($mesSegunda, $diaSegunda, $anyoSegunda);

    if (!checkdate($mesPrimera, $diaPrimera, $anyoPrimera)) {
        // "La fecha ".$primera." no es v&aacute;lida";
        return 0;
    } elseif (!checkdate($mesSegunda, $diaSegunda, $anyoSegunda)) {
        // "La fecha ".$segunda." no es v&aacute;lida";
        return 0;
    } else {
        return $diasPrimeraJuliano - $diasSegundaJuliano;
    }
}
Пример #8
0
function dateDiff($dformat, $endDate, $beginDate)
{
    $date_parts1 = explode($dformat, $beginDate);
    $date_parts2 = explode($dformat, $endDate);
    $start_date = gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
    $end_date = gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
    return $end_date - $start_date;
}
Пример #9
0
 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)));
 }
Пример #10
0
 function getDate($date, $now)
 {
     date_default_timezone_set('Asia/Taipei');
     $date1 = date_parse($date);
     $date2 = explode("-", $now);
     $start = gregoriantojd($date1['month'], $date1['day'], $date1['year']);
     $end = gregoriantojd($date2[0], $date2[1], $date2[2]);
     return $end - $start == 0 ? "Today" : $end - $start . " days ago";
 }
Пример #11
0
 function daysDifference($beginDate, $endDate)
 {
     //explode the date by "-" and storing to array
     $date_parts1 = explode("-", $beginDate);
     $date_parts2 = explode("-", $endDate);
     //gregoriantojd() Converts a Gregorian date to Julian Day Count
     $start_date = gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
     $end_date = gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
     return $end_date - $start_date;
 }
Пример #12
0
 public static function dateDiff($dformat, $endDate, $beginDate)
 {
     # Calculates difference between two dates
     # Input date format m, d, Y
     $date_parts1 = explode($dformat, $beginDate);
     $date_parts2 = explode($dformat, $endDate);
     $start_date = gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
     $end_date = gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
     return $end_date - $start_date;
 }
Пример #13
0
 /**
  * Get Julian Day Number.
  * 
  * @param null|DateTime $DateTime Date (optional)
  * @return int
  */
 public static function getJDN(DateTime $DateTime = null)
 {
     if (is_null($DateTime)) {
         $DateTime = new DateTime('now');
     }
     $year = $DateTime->format('Y');
     $month = $DateTime->format('n');
     $day = $DateTime->format('j');
     $JDN = gregoriantojd($month, $day, $year);
     return (int) $JDN;
 }
Пример #14
0
 public static function dateDiff($startDate, $endDate)
 {
     // Parse dates for conversion
     $startArry = date_parse($startDate);
     $endArry = date_parse($endDate);
     // Convert dates to Julian Days
     $start_date = gregoriantojd($startArry["month"], $startArry["day"], $startArry["year"]) - 1;
     $end_date = gregoriantojd($endArry["month"], $endArry["day"], $endArry["year"]);
     // Return difference
     return round($end_date - $start_date, 0);
 }
Пример #15
0
function dateDiff($startDate, $endDate)
{
    // Parse dates for conversion
    $startArry = date_parse($startDate);
    $endArry = date_parse($endDate);
    // Convert dates to Julian Days
    $start_date = gregoriantojd($startArry['month'], $startArry['day'], $startArry['year']);
    $end_date = gregoriantojd($endArry['month'], $endArry['day'], $endArry['year']);
    // Return difference
    return round($end_date - $start_date, 0);
}
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;
    }
}
Пример #17
0
 public function interestcalculation($fdate, $ldate, $trnsdate, $bal, $loaninterest, $installmentid)
 {
     $len = count($trnsdate);
     for ($i = 0; $i < $len; $i++) {
         $be[] = explode('-', $trnsdate[$i]);
         //exploding
         $gr[] = gregoriantojd($be[$i][1], $be[$i][2], $be[$i][0]);
         //gregorian format
     }
     // echo "len".$len;
     $fdateexp = explode('-', $fdate);
     $fdatevalue = gregoriantojd($fdateexp[1], $fdateexp[2], $fdateexp[0]);
     //gregorian format
     $ldateexp = explode('-', $ldate);
     $ldatevalue = gregoriantojd($ldateexp[1], $ldateexp[2], $ldateexp[0]);
     //gregorian format
     // //find difference between transaction date
     $interest = 0;
     $balance = 0;
     if ($len == 0) {
         if ($installmentid[0] != 1) {
             $diff = $gr[0] - $fdatevalue;
             $interest += $diff * $bal[0] * $loaninterest / 100 * 1 / 365;
             $diff = $ldatevalue - $gr[0];
             $interest += $diff * $bal[0] * $loaninterest / 100 * 1 / 365;
             $balance += round($bal[0] + $interest, 2);
         } else {
             $diff = $ldatevalue - $gr[0];
             $interest += $diff * $bal[0] * $loaninterest / 100 * 1 / 365;
             $balance += round($bal[0] + $interest, 2);
         }
     } else {
         for ($k = 0; $k < $len; $k++) {
             if ($k == 0) {
                 if ($installmentid[$k] != 1) {
                     $diff = $gr[$k] - $fdatevalue;
                     $interest += $diff * $bal[$k] * $loaninterest / 100 * 1 / 365;
                 }
             }
             if ($k != $len and $k != 0) {
                 $diffdate = $gr[$k] - $gr[$k - 1];
                 $interest += $diffdate * $bal[$k] * $loaninterest / 100 * 1 / 365;
             }
         }
         $diff = $ldatevalue - $gr[$len - 1];
         $interest += $diff * $bal[$len - 1] * $loaninterest / 100 * 1 / 365;
         $balance += round($bal[$len - 1] + $interest, 2);
     }
     $result = array(round($interest, 2), $balance);
     return $result;
 }
Пример #18
0
    function querycrit($dbname,$dbname2,$sdate,$edate,$brgy,$misc){   
	  
	  $sdate_orig = trim($sdate);
	  $edate_orig = trim($edate);


	  list($smonth,$sday,$syr) = explode('/',$sdate);
	  list($emonth,$eday,$eyr) = explode('/',$edate);


	  $smonth = (strlen($smonth)==1)?(str_pad($smonth,2,'0',STR_PAD_LEFT)):$smonth;
	  $emonth = (strlen($emonth)==1)?(str_pad($emonth,2,'0',STR_PAD_LEFT)):$emonth;
	  
	  $sdate = $syr.'-'.$smonth.'-'.$sday;
	  $edate = $eyr.'-'.$emonth.'-'.$eday;	  
	  
	  	  
	  $start_date=gregoriantojd($smonth, $sday, $syr);   
	  $end_date=gregoriantojd($emonth, $eday, $eyr);
	  $diff = $end_date - $start_date; 



      if(empty($sdate) || empty($edate)):
        echo "Please supply a date.";
      elseif($frage>$toage):
        echo "Start age should be lower than end age.";	  
      elseif($diff < 0):
	echo 'End month should be on or after the start month';
      elseif(empty($brgy)):
	echo 'Please select one or more barangays.';
      else:

      echo "<br><table border=\"1\">";
        $_SESSION[sdate] = $sdate.' 00:00:00';
        $_SESSION[edate] = $edate.' 23:59:59';
        $_SESSION[brgy] = $brgy;		
        $_SESSION[edate2] = $edate;
	$_SESSION[sdate2] = $sdate;
	$_SESSION[sdate_orig] = $sdate_orig;
	$_SESSION[edate_orig] = $edate_orig;
	
	$_SESSION[fp_method] = (isset($misc))?$misc:0; //assign fp method to a session if it exists from the form, otherwise place 0

	$this->stat_table($q,$_SESSION[ques]);
      
      endif;
      
      echo "</table>";
    }
Пример #19
0
 public function gawa_ng_kalendaryo($year)
 {
     $numberOfDays = 390;
     $newdayofweek = 1;
     $weekNumber = 1;
     $days = "+0 days";
     // check table for the last date on the the table
     $query = "SELECT juliandate FROM fiscalcalendar ORDER BY juliandate desc Limit 1";
     $result = fetch_record($query);
     if ($result['juliandate'] == 0) {
         $juliandate = gregoriantojd(01, 01, date('Y', strtotime($year)));
     } else {
         $juliandate = $result['juliandate'] + 1;
     }
     // $juliandate = gregoriantojd(01,01,date('Y',strtotime($days)));
     echo "<table border='5px'><thead><td>Julian Date</td><td>Gregorian Date</td><td>end of week</td><td>end of month</td><td>week#</td></thead><tbody>";
     for ($i = 0; $i <= $numberOfDays; $i++) {
         // check for end of week
         $days = JDToGregorian($juliandate);
         if (date('N', strtotime($days)) == 7) {
             $endOfWeek = 'Y';
         } else {
             $endOfWeek = 'N';
         }
         // end of year
         if (date("m", strtotime($days)) == 12 && date("j", strtotime($days)) == date("t", strtotime($days))) {
             $endofyear = 'Y';
         } else {
             $endofyear = 'N';
         }
         // end of month
         if (date("j", strtotime($days)) == date("t", strtotime($days))) {
             $endofmonth = 'Y';
         } else {
             $endofmonth = 'N';
         }
         if (date("j", strtotime($days)) == 1) {
             $weekNumber = 1;
             $newdayofweek = date('N', strtotime($days));
         } else {
             if ($newdayofweek == date('N', strtotime($days))) {
                 $weekNumber += 1;
             }
         }
         echo "<tr>" . $juliandate . '</td><td>' . JDToGregorian($juliandate) . '</td><td>' . $endOfWeek . '</td><td>' . $endofmonth . '</td><td>' . $weekNumber . '</td></tr>';
         $query = "INSERT INTO fiscalcalendar (juliandate,fdate, fmonth, fday, fyear, endOfWeek, endofmonth,  dayOfWeek, weekNumber) VALUES('" . $juliandate . "','" . date("y-m-d", strtotime($days)) . "'," . date("m", strtotime($days)) . "," . date('j', strtotime($days)) . "," . date('Y', strtotime($days)) . ",'" . $endOfWeek . "','" . $endofmonth . "','" . date('N', strtotime($days)) . "'," . $weekNumber . ")";
         $result = run_mysql_query($query);
         $juliandate += 1;
     }
 }
Пример #20
0
function daysDifference($endDate, $beginDate)
{
    /*
    returned verschil in  dagen
    date format string “YYYY-MM-DD”,
    */
    //explode the date by "-" and storing to array
    $date_parts1 = explode("-", $beginDate);
    $date_parts2 = explode("-", $endDate);
    //gregoriantojd() Converts a Gregorian date to Julian Day Count
    $start_date = gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
    $end_date = gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
    return $end_date - $start_date;
}
Пример #21
0
 static function years($date)
 {
     ###http://www.php.net/date :: txmn41@yahoo.com
     list($year, $mon, $day) = explode("-", $date);
     $today = getdate(time());
     // find the difference in the years of the two dates
     $yeardiff = $today['year'] - $year;
     // if the current date occurs before the birthday, subtract one
     $birth_jd = gregoriantojd($mon, $day, $today['year']);
     $today_jd = gregoriantojd($today['mon'], $today['mday'], $today['year']);
     if ($today_jd < $birth_jd) {
         $yeardiff--;
     }
     return $yeardiff;
 }
Пример #22
0
 function diff_date($startDate, $endDate = null, $type = 'mois')
 {
     $endDate = $endDate ? $endDate : date('Y-m-d');
     // Parse dates for conversion
     $startArry = date_parse($startDate);
     $endArry = date_parse($endDate);
     // Convert dates to Julian Days
     $start_date = gregoriantojd($startArry["month"], $startArry["day"], $startArry["year"]);
     $end_date = gregoriantojd($endArry["month"], $endArry["day"], $endArry["year"]);
     if ($type == 'annees') {
         $annees = ($end_date - $start_date) / 365;
         if ($annees < 1) {
             $mois = round(round($end_date - $start_date, 0) / 30);
             if ($mois >= 1) {
                 return $mois . ' mois';
             } else {
                 return 'moins d\'un mois';
             }
         } else {
             $wordingAnnees = $annees > 1 ? 'ans' : 'an';
             $retour = floor($annees) . ' ' . $wordingAnnees;
             $arrondi = floor($annees);
             if ($arrondi < $annees) {
                 $jours = ($annees - $arrondi) * 365;
                 $mois = round($jours / 30, 0);
                 $retour .= ' et ' . $mois . ' mois';
             }
             return $retour;
         }
     } elseif ($type == 'mois') {
         $mois = round(round($end_date - $start_date, 0) / 30);
         if ($mois > 0) {
             return $mois . ' mois';
         } else {
             $jours = $end_date - $start_date;
             $wording = $jours > 1 ? 'jours' : 'jour';
             return $jours > 0 ? $jours . ' ' . $wording : false;
         }
     } elseif ($type == 'semaines') {
         $semaines = floor(($end_date - $start_date) / 7);
         $wordingSemaine = $semaines > 1 ? 'semaines' : 'semaine';
         return $semaines . ' ' . $wordingSemaine;
     } elseif ($type == 'jours') {
         $jours = $end_date - $start_date;
         $wording = $jours > 1 ? 'jours' : 'jour';
         return $jours > 0 ? $jours . ' ' . $wording : false;
     }
 }
Пример #23
0
function compareDate($i_sFirstDate, $i_sSecondDate)
{
    //Break the Date strings into seperate components
    $arrFirstDate = explode("-", $i_sFirstDate);
    $arrSecondDate = explode("-", $i_sSecondDate);
    $intFirstYear = $arrFirstDate[0];
    $intFirstMonth = $arrFirstDate[2];
    $intFirstDay = $arrFirstDate[1];
    $intSecondYear = $arrSecondDate[0];
    $intSecondMonth = $arrSecondDate[2];
    $intSecondDay = $arrSecondDate[1];
    // Calculate the diference of the two dates and return the number of days.
    $intDate1 = gregoriantojd($intFirstDay, $intFirstMonth, $intFirstYear);
    $intDate2 = gregoriantojd($intSecondDay, $intSecondMonth, $intSecondYear);
    return $intDate1 - $intDate2;
}
Пример #24
0
 public static function getDate($id, $allow_blank = true)
 {
     $m = Request::get($id . "_m");
     $d = Request::get($id . "_d");
     $y = Request::get($id . "_y");
     if ($m > 0 && $d > 0) {
         if ($y == 0) {
             $y = date("Y");
         }
         return gregoriantojd($m, $d, $y);
     } elseif (!$allow_blank) {
         return gregoriantojd(date("m"), date("d"), date("Y"));
     } else {
         return 0;
     }
 }
Пример #25
0
function get_times($userIDarray)
{
    global $conn;
    $user_ids = $userIDarray;
    $array = [];
    for ($i = 0; $i < 24; $i++) {
        $array2 = array(false, false, false, false, false, false, false);
        array_push($array, $array2);
    }
    for ($i = 0; $i < count($user_ids); $i++) {
        $tempID = $user_ids[$i];
        $sql = "SELECT * FROM events WHERE userID='{$tempID}'";
        $result = $conn->query($sql);
        while ($row = $result->fetch_assoc()) {
            $val = date_parse($row["startTime"]);
            $val2 = date_parse($row["endTime"]);
            $week = date_parse(date("Y/m/d h:i:sa", strtotime("+1 week")));
            $jd1 = gregoriantojd($val['month'], $val['day'], $val['year']);
            $jd2 = gregoriantojd($week['month'], $week['day'], $week['year']);
            if ($week['year'] == $val['year']) {
                $day = 7 - ($jd2 - $jd1);
                if ($day < 7 && $day > -1) {
                    $diff = $val2["hour"] - $val["hour"];
                    for ($j = 0; $j < $diff; $j++) {
                        $hour = $val['hour'] + $j;
                        $array[$hour][$day] = true;
                    }
                }
            }
        }
    }
    //$conn->close();
    for ($i = 0; $i < 24; $i++) {
        for ($j = 0; $j < 7; $j++) {
            if (!$array[$i][$j]) {
                echo "<button onclick='settime(" . $i . "," . $j . "); return false;' class='yes'>Y</button>";
            } else {
                echo "<button class='no' disabled>N</button>";
            }
        }
        echo " " . $i;
        echo "<br>";
    }
}
function weekday($daynum, $mon, $yr)
{
    $jd = gregoriantojd($mon, $daynum, $yr);
    switch (JDDayOfWeek($jd, 0)) {
        case 0:
            return "<font color=red>Sonntag</font>";
        case 1:
            return "Montag";
        case 2:
            return "Dienstag";
        case 3:
            return "Mittwoch";
        case 4:
            return "Donnerstag";
        case 5:
            return "Freitag";
        case 6:
            return "Samstag";
    }
}
Пример #27
0
function wkdaynum($daynum, $mon, $yr)
{
    $jd = gregoriantojd($mon, $daynum, $yr);
    switch (JDDayOfWeek($jd, 0)) {
        case 0:
            return 6;
        case 1:
            return 0;
        case 2:
            return 1;
        case 3:
            return 2;
        case 4:
            return 3;
        case 5:
            return 4;
        case 6:
            return 5;
    }
}
Пример #28
0
 public function postUpdateDate()
 {
     if (ClientUser::getInstance()->isAdmin()) {
         $id = Request::post('id');
         $key = Request::post('key');
         $column = Request::post('column');
         $table = Request::post('table');
         $m = Request::post("date_m");
         $d = Request::post("date_d");
         $y = Request::post("date_y");
         if ($m > 0 && $d > 0) {
             if ($y == 0) {
                 $y = date("Y");
             }
             $value = gregoriantojd($m, $d, $y);
         } else {
             $value = 0;
         }
         Database::getInstance()->update($table, array($column => $value), array($key => $id));
         Output::json(Output::SUCCESS);
     } else {
         Output::json(Output::ACCESS_DENIED);
     }
 }
Пример #29
0
function gregorian2FrenchDateArray($m, $d, $y)
{
    $julian_date = gregoriantojd($m, $d, $y);
    $french = jdtofrench($julian_date);
    if ($french == "0/0/0") {
        return "";
    }
    $arD = split("/", $french);
    // get the month name
    $monthname = FrenchMonthNames($arD[0]);
    /* convert the year number to roman digits (as most historians do and documents of the time did */
    $stryear = decrom($arD[2]);
    return array($monthname, $arD[1], $stryear);
}
Пример #30
0
    }
    $tgl_surat_tugas = date("Y-m-d", strtotime($row->tgl_surat_tugas));
    $tgl2 = date('Y-m-d');
    //tgl sekarang
    $tgl1 = date("Y-m-d", strtotime($tgl_surat_tugas));
    //tgl di db
    $pecah1 = explode("-", $tgl1);
    $date1 = $pecah1[2];
    $month1 = $pecah1[1];
    $year1 = $pecah1[0];
    $pecah2 = explode("-", $tgl2);
    $date2 = $pecah2[2];
    $month2 = $pecah2[1];
    $year2 = $pecah2[0];
    $jd1 = gregoriantojd($month1, $date1, $year1);
    $jd2 = gregoriantojd($month2, $date2, $year2);
    $total_hari = $jd2 - $jd1;
    $selisih = $total_hari;
    if ($selisih <= 0) {
        $selisih = 0;
    }
    ?>
        <tr class="gradeX">
          <td height="40"><?php 
    echo $no;
    ?>
</td>
          <td><?php 
    echo $row->id_surat_tugas;
    ?>
</td>