Esempio n. 1
0
 public function info($datetime = null)
 {
     if (DevValue::isNull($datetime)) {
         return $this->_data;
     }
     $timestamp = $this->timestamp($datetime);
     $today = array();
     $count = 0;
     $today = getdate($timestamp);
     $timestamp2 = mktime(0, 0, 0, $today['mon'], 1, $today['year']);
     $first = getdate($timestamp2);
     $sd = $today['mday'];
     $tsd = 28;
     $numdays = cal_days_in_month(CAL_GREGORIAN, $today['mon'], $today['year']);
     $sm = isset($sm) && is_numeric($sm) ? $sm : '';
     $sy = isset($sy) && is_numeric($sy) ? $sy : '';
     if ($sm <= 12 && $sm >= 0 && $sy != '') {
         $jday = juliantojd($sm, $sd, $sy);
         $timestamp = jdtounix($jday);
         $today = getdate($timestamp);
         $numdays = cal_days_in_month(CAL_GREGORIAN, $today['mon'], $today['year']);
         $timestamp2 = mktime(0, 0, 0, $today['mon'], 1, $today['year']);
         $first = getdate($timestamp2);
     }
     $last_month = $today['mon'] - 1;
     if ($last_month < 1) {
         $last_month = 11;
         $last_year = $today['year'] - 1;
     } else {
         $last_year = $today['year'];
     }
     $next_month = $today['mon'] + 1;
     if ($next_month >= 12) {
         $next_month = 1;
         $next_year = $today['year'] + 1;
     } else {
         $next_year = $today['year'];
     }
     $date = array();
     $date['day'] = (int) $sd;
     $date['firstweekday'] = $first['wday'];
     $date['year'] = (int) $today['year'];
     $date['lastyear'] = (int) $last_year;
     $date['nextyear'] = (int) $next_year;
     $date['month'] = (int) $today['mon'];
     $date['lastmonth'] = (int) $last_month;
     $date['nextmonth'] = (int) $next_month;
     $date['daysinmonth'] = (int) $numdays;
     $date['second'] = (int) $today['seconds'];
     $date['minute'] = (int) $today['minutes'];
     $date['hour'] = (int) $today['hours'];
     $date['timestamp'] = $today[0];
     $date['timezone'] = '';
     $date['offset'] = '';
     // $this->assign($date);
     //Phew! that was a lot of work!
     return $date;
 }
Esempio n. 2
0
function dev_get_date_info($sm = '', $sy = '', $timestamp = '')
{
    $today;
    $count;
    $undefined;
    if ($timestamp == '') {
        $timestamp = mktime();
    }
    $today = getdate($timestamp);
    $timestamp2 = mktime(0, 0, 0, $today['mon'], 1, $today['year']);
    $first = getdate($timestamp2);
    $sd = $today['mday'];
    $tsd = 28;
    $numdays = cal_days_in_month(CAL_GREGORIAN, $today['mon'], $today['year']);
    $sm = isset($sm) && is_numeric($sm) ? $sm : '';
    $sy = isset($sy) && is_numeric($sy) ? $sy : '';
    if ($sm <= 12 && $sm >= 0 && $sy != '') {
        $jday = juliantojd($sm, $sd, $sy);
        $timestamp = jdtounix($jday);
        $today = getdate($timestamp);
        $numdays = cal_days_in_month(CAL_GREGORIAN, $today['mon'], $today['year']);
        $timestamp2 = mktime(0, 0, 0, $today['mon'], 1, $today['year']);
        $first = getdate($timestamp2);
    }
    $last_month = $today['mon'] - 1;
    if ($last_month < 1) {
        $last_month = 11;
        $last_year = $today['year'] - 1;
    } else {
        $last_year = $today['year'];
    }
    $next_month = $today['mon'] + 1;
    if ($next_month >= 12) {
        $next_month = 1;
        $next_year = $today['year'] + 1;
    } else {
        $next_year = $today['year'];
    }
    $date = array();
    $date['day'] = $sd;
    $date['firstweekday'] = $first['wday'];
    $date['year'] = $today['year'];
    $date['lastyear'] = $last_year;
    $date['nextyear'] = $next_year;
    $date['month'] = $today['mon'];
    $date['lastmonth'] = $last_month;
    $date['nextmonth'] = $next_month;
    $date['daysinmonth'] = $numdays;
    return $date;
}
Esempio n. 3
0
<?php

echo juliantojd(0, 0, 0) . "\n";
echo juliantojd(1, 1, 1582) . "\n";
echo juliantojd(10, 5, 1582) . "\n";
echo juliantojd(1, 1, 1970) . "\n";
echo juliantojd(1, 1, 2999) . "\n";
Esempio n. 4
0
    $lha = false;
}
// luas areal
$luas = 0;
$str = "select luasareaproduktif from " . $dbname . ".setup_blok \n                where kodeorg like '" . $kdAfd . "%'";
$res = mysql_query($str);
while ($bar = mysql_fetch_object($res)) {
    $luas += $bar->luasareaproduktif;
}
//          echo $luas;
$tgl1_ = tanggalsystem($tgl1_);
$tgl1 = substr($tgl1_, 0, 4) . '-' . substr($tgl1_, 4, 2) . '-' . substr($tgl1_, 6, 2);
$tgl2_ = tanggalsystem($tgl2_);
$tgl2 = substr($tgl2_, 0, 4) . '-' . substr($tgl2_, 4, 2) . '-' . substr($tgl2_, 6, 2);
$tglqwe1 = juliantojd(substr($tgl1_, 4, 2), substr($tgl1_, 6, 2), substr($tgl1_, 0, 4));
$tglqwe2 = juliantojd(substr($tgl2_, 4, 2), substr($tgl2_, 6, 2), substr($tgl2_, 0, 4));
$jumlahhari = 1 + $tglqwe2 - $tglqwe1;
if ($proses == 'preview' or $proses == 'excel' or $proses == 'pdf') {
    if ($kdOrg == '') {
        echo "Error: Organization/estate required.";
        exit;
    }
    if ($tgl1_ == '') {
        echo "Error: date required.";
        exit;
    }
}
$str = "select kodekegiatan,namakegiatan,namakegiatan1 from " . $dbname . ".setup_kegiatan";
$res = mysql_query($str);
while ($bar = mysql_fetch_object($res)) {
    if ($_SESSION['language'] == 'EN') {
Esempio n. 5
0
function displaycalendar()
{
    // THIS FUNCTION CANNOT GO BACK MORE THAN TWO MONTH
    $dayfetched = date(d);
    $monthfetched = date(m);
    $yearfetched = date(Y);
    // The "< number" determines the days you want to display in past
    for ($i = 0; $i < 7; $i++) {
        if ($dayfetched - $i > 0) {
            echo "<a href='?d=" . ($dayfetched - $i) . "&m=" . $monthfetched . "&y=" . $yearfetched . "'>" . ($dayfetched - $i) . " " . jdmonthname(juliantojd($monthfetched, $dayfetched - $i, $yearfetched), 2) . "</a> • ";
        } else {
            $previousmonth = $monthfetched - 1;
            if ($previousmonth > 0) {
                $query_date = $yearfetched . "-" . $previousmonth . "01";
                $numberofdaysinpreviousmonth = date('t', strtotime($query_date));
                echo "<a href='?d=" . ($numberofdaysinpreviousmonth + ($dayfetched - $i)) . "&m=" . $previousmonth . "&y=" . $yearfetched . "'>" . ($numberofdaysinpreviousmonth + ($dayfetched - $i)) . " " . jdmonthname(juliantojd($previousmonth, $numberofdaysinpreviousmonth + ($dayfetched - $i), $yearfetched), 2) . "</a> •";
            } else {
                echo "Previous year...";
            }
        }
    }
}
Esempio n. 6
0
 /**
  * {@inheritdoc}
  */
 public static function toInternal($date)
 {
     $greg = new DateTime($date);
     return Calends::toInternalFromUnix(bcadd(bcmul(bcsub(juliantojd($greg->format('m'), $greg->format('d'), $greg->format('Y')), 2440587), 86400), bcmod($greg->getTimestamp(), 86400)));
 }
Esempio n. 7
0
function check_value_type($value, $type)
{
    //dates for use
    $date = date("Y-m-d");
    $day = date("d");
    $month = date("m");
    $year = date("Y");
    //funcitons vars
    $error_type = "";
    $preg_symbols = "-_@.,!:;#\$%&'*\\/+=?^`{\\|}()~ÁÉÍÓÚáéíóuñÑ";
    $preg_symbols_html = $preg_symbols . "<>\\\\\"'";
    $preg_file_symbols = "-_.()";
    switch ($type) {
        case 'options':
            trigger_error("This function can't check options type", E_USER_WARNING);
            $error_type = " This vale can't be checked";
            break;
        case 'email':
            $regex = "/[_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*(\\.[a-zA-Z]{2,3})\$/";
            if (!preg_match($regex, $value)) {
                $error_type = " Email invalido";
            }
            break;
        case 'boolean':
            $regex = "/^[01]\$/";
            if (!preg_match($regex, $value)) {
                $error_type = "{$error_header_msg} solo puede valer 0 o 1";
            } else {
                $error_msg = "";
            }
            break;
        case 'date':
            if (preg_match("/(?P<year>[0-9]{4})[\\/-](?P<month>[0-9]{2})[\\/-](?P<day>[0-9]{2})/", $value, $matches)) {
                if (!checkdate($matches['month'], $matches['day'], $matches['year'])) {
                    $error_type = " valores de fecha in validos";
                }
            } else {
                $error_type = " formato de fecha invalida";
            }
            break;
        case 'date-past':
            if (preg_match("/(?P<year>[0-9]{4})[\\/-](?P<month>[0-9]{2})[\\/-](?P<day>[0-9]{2})/", $value, $matches)) {
                if (checkdate($matches['month'], $matches['day'], $matches['year'])) {
                    $actual_date_number = juliantojd($month, $day, $year);
                    $value_date_number = juliantojd($matches['month'], $matches['day'], $matches['year']);
                    if ($value_date_number >= $actual_date_number) {
                        $error_type = " de fecha no puede ser mayor al dia de hoy: {$date}";
                    }
                } else {
                    $error_type = " valores de fecha in validos";
                }
            } else {
                $error_type = " formato de fecha invalida";
            }
            break;
        case 'date-future':
            if (preg_match("/(?P<year>[0-9]{4})[\\/-](?P<month>[0-9]{2})[\\/-](?P<day>[0-9]{2})/", $value, $matches)) {
                if (checkdate($matches['month'], $matches['day'], $matches['year'])) {
                    $actual_date_number = juliantojd($month, $day, $year);
                    $value_date_number = juliantojd($matches['month'], $matches['day'], $matches['year']);
                    if ($value_date_number < $actual_date_number) {
                        $error_type = " de fecha debe ser mayor al dia de hoy: {$date}";
                    }
                } else {
                    $error_type = " valores de fecha in validos";
                }
            } else {
                $error_type = " formato de fecha invalida";
            }
            break;
        case 'datetime':
            // TODO
            break;
        case 'time':
            // TODO
            break;
        case 'letters':
            $regex = "/^[a-zA-Z\\s]*\$/";
            if (!preg_match($regex, $value)) {
                $error_type = " deber ser solo letras de la a-z y A-Z sin symbolos";
            }
            break;
        case 'letters-symbols':
            $regex = "/^[a-zA-Z0-9\\s{$preg_symbols}]*\$/";
            if (!preg_match($regex, $value)) {
                $error_type = " deber ser solo letras de la a-z y A-Z y symbolos: {$preg_symbols}";
            }
            break;
        case 'password':
            $regex = "/^[a-zA-Z0-9\\s{$preg_symbols}]*\$/";
            if (!preg_match($regex, $value)) {
                $error_type = " deber ser solo letras de la a-z y A-Z y symbolos: {$preg_symbols}";
            }
            break;
        case 'decimals':
            $regex = "/^[0-9.]*\$/";
            if (!(preg_match($regex, $value) && is_numeric($value))) {
                $error_type .= " deber ser solo numeros y decimales positivos";
            }
            break;
        case 'decimals-unsigned':
            $regex = "/^[\\-0-9.]*\$/";
            if (!(preg_match($regex, $value) && is_numeric($value))) {
                $error_type = " debe contener solo numeros y decimales";
            }
            break;
        case 'numbers':
            $regex = "/^[0-9]*\$/";
            if (!(preg_match($regex, $value) && is_numeric($value))) {
                $error_type .= " deber ser solo numeros positivos";
            }
            break;
        case 'numbers-unsigned':
            $regex = "/^[\\-0-9]*\$/";
            if (!(preg_match($regex, $value) && is_numeric($value))) {
                $error_type = " debe contener solo numeros";
            }
            break;
        case 'numbers-symbols':
            $regex = "/^[\\-0-9\\s{$preg_symbols}]*\$/";
            if (!preg_match($regex, $value)) {
                $error_type = " debe contener solo numeros y symbolos: {$preg_symbols}";
            }
            break;
        case 'mixed':
            $regex = "/^[\\-a-zA-Z0-9\\s]*\$/";
            if (!preg_match($regex, $value)) {
                $error_type = " deber ser solo letras de la a-z y A-Z y numeros";
            }
            break;
        case 'mixed-symbols':
            $regex = "/^[a-zA-Z0-9\\s{$preg_symbols}]*\$/";
            if (!preg_match($regex, $value)) {
                $error_type = " deber ser solo letras de la a-z y A-Z, numeros y symbolos: {$preg_symbols}";
            }
            break;
        case 'html':
            $regex = "/^[a-zA-Z0-9\\s{$preg_symbols_html}]*\$/";
            if (!preg_match($regex, $value)) {
                $error_type = " deber ser solo letras de la a-z y A-Z, numeros y symbolos: {$preg_symbols_html}";
            }
            break;
        case 'file-upload':
            $regex = "/^[a-zA-Z0-9\\s{$preg_file_symbols}]*\$/";
            if (!preg_match($regex, $value)) {
                $error_type = " solo pude contener letras y los siguientes simbolos: {$preg_symbols}";
            }
            break;
        default:
            $error_type = "Not defined VALIDATION on Type '{$type}' from field '{$label}' ";
            break;
    }
    return $error_type;
}
Esempio n. 8
0
 function xlsDate($month, $day, $year)
 {
     return juliantojd($month, $day, $year) - XLS_DATE + 1;
 }
Esempio n. 9
0
 function xlsDate($m, $d, $y)
 {
     /**
      * check for date errors
      */
     if ($y == 0 || $y < -4713 || $m <= 0 || $m > 12 || $d <= 0 || $d > 31) {
         return 0;
     }
     if ($y == -4713) {
         if ($m == 1 && $d == 1) {
             return 0;
         }
     }
     // end of error check
     if (function_exists('juliantojd')) {
         return juliantojd($m, $d, $y) - XLS_DATE;
     } else {
         /**
          * function take from origianal PHP sources
          */
         $month = 0;
         $year = 0;
         if ($y < 0) {
             $year = $y + 4801;
         } else {
             $year = $y + 4800;
         }
         if ($m > 2) {
             $month = $m - 3;
         } else {
             $month = $m + 9;
             $year--;
         }
         return $year * DAYS_PER_4_YEARS / 4 + ($month * DAYS_PER_5_MONTHS + 2) / 5 + $d - JULIAN_SDN_OFFSET - XLS_DATE - 1;
     }
 }