예제 #1
0
function getEntry($id)
{
    $path = ENTRIES_DIRECTORY . '/' . $id . '.php';
    $dom = new DOMDocument();
    $dom->loadHTML('<?xml version="1.0" encoding="UTF-8"?>' . file_get_contents($path));
    $xpath = new DOMXPath($dom);
    $entry = new stdClass();
    $entry->id = $id;
    $entry->path = $path;
    foreach ($xpath->query('//*[@class]') as $element) {
        $attributeName = $element->attributes->getNamedItem('class')->value;
        if ($element->childNodes->length > 1) {
            $childs = array();
            foreach ($element->childNodes as $childNode) {
                if (strlen(trim($childNode->textContent))) {
                    $childs[] = trim($childNode->textContent);
                }
            }
            $entry->{$attributeName} = $childs;
        } else {
            if (strlen($element->textContent)) {
                $entry->{$attributeName} = trim($element->textContent);
            }
        }
    }
    include_once 'jdf.php';
    $parts = explode('/', $entry->date);
    $entry->timestamp = jmaketime(0, 0, 0, $parts[1], $parts[2], $parts[0]);
    $entry->url = 'index.php?page=entries/' . $entry->id;
    return $entry;
}
예제 #2
0
파일: Date.php 프로젝트: redknight/frot
function inputTimeToGregorian($usertime)
{
    list($jfdate, $ftime) = preg_split('/ /', $usertime);
    list($fhour, $fminut, $fsec) = preg_split('/:/', $ftime);
    // convert persian numbers to english if exist
    $hour = Convertnumber2english($fhour);
    $minut = Convertnumber2english($fminut);
    $sec = Convertnumber2english($fsec);
    list($jfyear, $jfmonth, $jfday) = preg_split('/-/', $jfdate);
    // convert persian numbers to english if exist
    $jyear = Convertnumber2english($jfyear);
    $jmonth = Convertnumber2english($jfmonth);
    $jday = Convertnumber2english($jfday);
    if (_JDF_USE_HEGIRADATE) {
        $maket = jmaketime($hour - _JDF_TZhours, $minut - _JDF_TZminute, $sec, $jmonth, $jday, $jyear);
    } else {
        $maket = mktime($hour, $minut, $sec, $jmonth, $jday, $jyear);
    }
    $usertime = date("Y-m-d H:i:s", $maket);
    return $usertime;
}
예제 #3
0
function jdate($type, $maket = 'now')
{
    global $icmsConfig;
    icms_loadLanguageFile('core', 'calendar');
    $result = '';
    if ($maket == 'now') {
        $year = date('Y');
        $month = date('m');
        $day = date('d');
        list($jyear, $jmonth, $jday) = gregorian_to_jalali($year, $month, $day);
        $maket = jmaketime(date('h'), date('i'), date('s'), $jmonth, $jday, $jyear);
    } else {
        $date = date('Y-m-d', $maket);
        list($year, $month, $day) = preg_split('/-/', $date);
        list($jyear, $jmonth, $jday) = gregorian_to_jalali($year, $month, $day);
    }
    $need = $maket;
    $year = date('Y', $need);
    $month = date('m', $need);
    $day = date('d', $need);
    $i = 0;
    while ($i < strlen($type)) {
        $subtype = substr($type, $i, 1);
        switch ($subtype) {
            case 'A':
                $result1 = date('a', $need);
                if ($result1 == 'pm') {
                    $result .= _CAL_PM_LONG;
                } else {
                    $result .= _CAL_AM_LONG;
                }
                break;
            case 'a':
                $result1 = date('a', $need);
                if ($result1 == 'pm') {
                    $result .= _CAL_PM;
                } else {
                    $result .= _CAL_AM;
                }
                break;
            case 'd':
                list($jyear, $jmonth, $jday) = gregorian_to_jalali($year, $month, $day);
                if ($jday < 10) {
                    $result1 = '0' . $jday;
                } else {
                    $result1 = $jday;
                }
                $result .= $result1;
                break;
            case 'D':
                $result1 = date('D', $need);
                if ($result1 == 'Sat') {
                    $result1 = _CAL_SAT;
                } else {
                    if ($result1 == 'Sun') {
                        $result1 = _CAL_SUN;
                    } else {
                        if ($result1 == 'Mon') {
                            $result1 = _CAL_MON;
                        } else {
                            if ($result1 == 'Tue') {
                                $result1 = _CAL_TUE;
                            } else {
                                if ($result1 == 'Wed') {
                                    $result1 = _CAL_WED;
                                } else {
                                    if ($result1 == 'Thu') {
                                        $result1 = _CAL_THU;
                                    } else {
                                        if ($result1 == 'Fri') {
                                            $result1 = _CAL_FRI;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                $result .= $result1;
                break;
            case 'F':
                list($jyear, $jmonth, $jday) = gregorian_to_jalali($year, $month, $day);
                $result .= Icms_getMonthNameById($jmonth);
                break;
            case 'g':
                $result .= date('g', $need);
                break;
            case 'G':
                $result .= date('G', $need);
                break;
            case 'h':
                $result .= date('h', $need);
                break;
            case 'H':
                $result .= date('H', $need);
                break;
            case 'i':
                $result .= date('i', $need);
                break;
            case 'j':
                list($jyear, $jmonth, $jday) = gregorian_to_jalali($year, $month, $day);
                $result .= $jday;
                break;
            case 'l':
                $result1 = date('l', $need);
                if ($result1 == 'Saturday') {
                    $result1 = _CAL_SATURDAY;
                } else {
                    if ($result1 == 'Sunday') {
                        $result1 = _CAL_SUNDAY;
                    } else {
                        if ($result1 == 'Monday') {
                            $result1 = _CAL_MONDAY;
                        } else {
                            if ($result1 == 'Tuesday') {
                                $result1 = _CAL_TUESDAY;
                            } else {
                                if ($result1 == 'Wednesday') {
                                    $result1 = _CAL_WEDNESDAY;
                                } else {
                                    if ($result1 == 'Thursday') {
                                        $result1 = _CAL_THURSDAY;
                                    } else {
                                        if ($result1 == 'Friday') {
                                            $result1 = _CAL_FRIDAY;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                $result .= $result1;
                break;
            case 'm':
                list($jyear, $jmonth, $jday) = gregorian_to_jalali($year, $month, $day);
                if ($jmonth < 10) {
                    $result1 = '0' . $jmonth;
                } else {
                    $result1 = $jmonth;
                }
                $result .= $result1;
                break;
            case 'M':
                list($jyear, $jmonth, $jday) = gregorian_to_jalali($year, $month, $day);
                $result .= Icms_getMonthNameById($jmonth);
                break;
            case 'n':
                list($jyear, $jmonth, $jday) = gregorian_to_jalali($year, $month, $day);
                $result .= $jmonth;
                break;
            case 's':
                $result .= date('s', $need);
                break;
            case 'S':
                $result .= _CAL_SUFFIX;
                break;
            case 't':
                $result .= lastday($month, $day, $year);
                break;
            case 'w':
                $result .= date('w', $need);
                break;
            case 'y':
                list($jyear, $jmonth, $jday) = gregorian_to_jalali($year, $month, $day);
                $result .= substr($jyear, 2, 4);
                break;
            case 'Y':
                list($jyear, $jmonth, $jday) = gregorian_to_jalali($year, $month, $day);
                $result .= $jyear;
                break;
            default:
                $result .= $subtype;
        }
        $i++;
    }
    return $result;
}
예제 #4
0
 function date_fa($date)
 {
     list($year, $month, $day) = preg_split('/-/', $date);
     list($jyear, $jmonth, $jday) = cmfcDateTime::gregorianToJalali($year, $month, $day);
     $date = jmaketime(0, 0, 0, $jmonth, $jday, $jyear);
     $date = jdate("d M Y", $date);
     return $date;
 }