public function get() { $this->load->library("jdf"); $from = jmktime(0, 0, 0, $this->input->post("month_from"), $this->input->post("day_from"), $this->input->post("year_from")); $to = jmktime(0, 0, 0, $this->input->post("month_to"), $this->input->post("day_to"), $this->input->post("year_to")); $this->showGoals($from, $to); }
/** * use <b>jmktime()</b> instead jmaketime() * @deprecated since 5.0.0 */ function jmaketime($hour = 0, $minute = 0, $second = 0, $month = 0, $day = 0, $year = 0, $is_dst = -1) { return jmktime($hour, $minute, $second, $month, $day, $year, $is_dst); }
function makeTime($date, $time = "00:00") { $dateArray = explode("/", $date); $year = $dateArray[0]; $month = $dateArray[1]; $day = $dateArray[2]; $timeArray = explode(":", $time); $hour = intval($timeArray[0]); $minute = intval($timeArray[1]); return jmktime($hour, $minute, 0, $month, $day, $year); }
function osc_draw_jdate_pull_down_menu($name, $value = null, $default_today = true, $show_days = true, $use_month_names = true, $year_range_start = 0, $year_range_end = 1) { $year = jdate('Y', '', '', '', 'en'); if (!is_bool($default_today)) { $default_today = true; } if (!is_bool($show_days)) { $show_days = true; } if (!is_bool($use_month_names)) { $use_month_names = true; } if (!is_numeric($year_range_start)) { $year_range_start = 0; } if (!is_numeric($year_range_end)) { $year_range_end = 1; } if (!is_array($value)) { $value = array(); } if (!isset($value['year']) || !is_numeric($value['year']) || $value['year'] < $year - $year_range_start || $value['year'] > $year + $year_range_end) { if ($default_today === true) { $value['year'] = $year; } else { $value['year'] = $year - $year_range_start; } } if (!isset($value['month']) || !is_numeric($value['month']) || $value['month'] < 1 || $value['month'] > 12) { if ($default_today === true) { $value['month'] = jdate('n', '', '', '', 'en'); } else { $value['month'] = 1; } } if (!isset($value['date']) || !is_numeric($value['date']) || $value['date'] < 1 || $value['date'] > 31) { if ($default_today === true) { $value['date'] = jdate('j', '', '', '', 'en'); } else { $value['date'] = 1; } } $days_select_string = ''; if ($show_days === true) { $days_in_month = $default_today === true ? jdate('t', '', '', '', 'en') : 31; $days_array = array(); for ($i = 1; $i <= $days_in_month; $i++) { $days_array[] = array('id' => $i, 'text' => sprintf("%02d", $i)); } $days_select_string = osc_draw_pull_down_menu($name . '_days', $days_array, $value['date']); } $months_array = array(); for ($i = 1; $i <= 12; $i++) { $months_array[] = array('id' => $i, 'text' => $use_month_names === true ? jdate('F', jmktime(0, 0, 0, $i, 1, 1393), '', '', 'en') : $i); } $months_select_string = osc_draw_pull_down_menu($name . '_months', $months_array, $value['month']); $years_array = array(); for ($i = $year - $year_range_start; $i <= $year + $year_range_end; $i++) { $years_array[] = array('id' => $i, 'text' => $i); } $years_select_string = osc_draw_pull_down_menu($name . '_years', $years_array, $value['year']); return $days_select_string . $months_select_string . $years_select_string; }
/** * own widget function */ function ztjalali_calendar_widget($shortname = TRUE, $echo = TRUE, $thisyear = 0, $thismonth = 0) { global $wpdb, $posts, $wp; global $jdate_month_name, $ztjalali_option; if (isset($wp->query_vars['m'])) { $m_year = (int) substr($wp->query_vars['m'], 0, 4); $m_month = (int) substr($wp->query_vars['m'], 4, 2); if ($m_year < 1700) { list($m_year, $m_month, $tmp_day) = jalali_to_gregorian($m_year, $m_month, 15); } } elseif (isset($wp->query_vars['m'])) { $thisyear = (int) substr($wp->query_vars['m'], 0, 4); } if (empty($thisyear)) { if (isset($wp->query_vars['year'])) { $thisyear = (int) $wp->query_vars['year']; } elseif (isset($m_year)) { $thisyear = $m_year; } else { $thisyear = date('Y', time()); } } if (empty($thismonth)) { if (isset($wp->query_vars['monthnum'])) { $thismonth = (int) $wp->query_vars['monthnum']; } elseif (isset($m_month)) { $thismonth = $m_month; } else { $thismonth = date('m', time()); } } //doing: support $_GET['w'] // if (isset($_GET['w'])) // $w = '' . (int)($_GET['w']); // if (!empty($w)) { //// We need to get the month from MySQL // $thisyear = '' . (int)(substr($m, 0, 4)); // $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's // $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')"); // } /* doing : cache */ $cache = array(); $key = md5($thismonth . $thisyear); if ($cache = wp_cache_get('ztjalali_calendar', 'calendar')) { if (is_array($cache) && isset($cache[$key])) { if ($echo) { /** This filter is documented in wp-includes/general-template.php */ echo apply_filters('ztjalali_calendar', $cache[$key]); return; } else { /** This filter is documented in wp-includes/general-template.php */ return apply_filters('ztjalali_calendar', $cache[$key]); } } } if (!is_array($cache)) { $cache = array(); } // Quick check. If we have no posts at all, abort! if (!$posts) { $gotsome = $wpdb->get_var("SELECT 1 as test FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1"); if (!$gotsome) { $cache[$key] = ''; wp_cache_set('ztjalali_calendar', $cache, 'calendar'); return; } } if ($thisyear > 1700) { list($thisyear, $thismonth, $thisday) = gregorian_to_jalali($thisyear, $thismonth, 1); } $unixmonth = jmktime(0, 0, 0, $thismonth, 1, $thisyear); $jthisyear = $thisyear; $jthismonth = $thismonth; list($thisyear, $thismonth, $jthisday) = jalali_to_gregorian($jthisyear, $jthismonth, 1); $last_day = jdate('t', $unixmonth, FALSE, FALSE); // Get the next and previous month and year with at least one post $startdate = date("Y:m:d", jmktime(0, 0, 0, $jthismonth, 1, $jthisyear)); $enddate = date("Y:m:d", jmktime(23, 59, 59, $jthismonth, $last_day, $jthisyear)); $previous = $wpdb->get_row("SELECT DAYOFMONTH(post_date) AS `dayofmonth`,MONTH(post_date) AS month, YEAR(post_date) AS year\n\t\tFROM {$wpdb->posts}\n\t\tWHERE post_date < '{$startdate}'\n\t\tAND post_type = 'post' AND post_status = 'publish'\n\t\t\tORDER BY post_date DESC\n\t\t\tLIMIT 1"); $next = $wpdb->get_row("SELECT DAYOFMONTH(post_date) AS `dayofmonth`,MONTH(post_date) AS month, YEAR(post_date) AS year\n\t\tFROM {$wpdb->posts}\n\t\tWHERE post_date > '{$enddate} 23:59:59'\n\t\tAND post_type = 'post' AND post_status = 'publish'\n\t\t\tORDER BY post_date ASC\n\t\t\tLIMIT 1"); /* translators: Calendar caption: 1: month name, 2: 4-digit year */ $calendar_caption = _x('%1$s %2$s', 'calendar caption'); $calendar_output = '<table id="wp-calendar" class="widget_calendar"> <caption>' . sprintf($calendar_caption, $jdate_month_name[(int) $jthismonth], jdate('Y', $unixmonth)) . '</caption> <thead> <tr>'; $myweek = $myshortweek = array(); $week_begins = (int) get_option('start_of_week'); for ($wdcount = 0; $wdcount <= 6; $wdcount++) { $myweek[] = ztjalali_get_week_name(($wdcount + $week_begins) % 7); $myshortweek[] = ztjalali_get_short_week_name(($wdcount + $week_begins) % 7); } foreach ($myweek as $k => $wd) { $day_name = true == $shortname ? $myshortweek[$k] : $wd; $wd = esc_attr($wd); $calendar_output .= "\n\t\t<th scope=\"col\" title=\"{$wd}\">{$day_name}</th>"; } $calendar_output .= ' </tr> </thead> <tfoot> <tr>'; if ($previous) { $jprevious = gregorian_to_jalali($previous->year, $previous->month, $previous->dayofmonth); if ($ztjalali_option['change_url_date_to_jalali']) { $calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="' . get_month_link($jprevious[0], $jprevious[1]) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s', 'ztjalali'), $jdate_month_name[$jprevious[1]], jdate('Y', mktime(0, 0, 0, $previous->month, 1, $previous->year)))) . '">« ' . $jdate_month_name[$jprevious[1]] . '</a></td>'; } else { $calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s', 'ztjalali'), $jdate_month_name[$jprevious[1]], jdate('Y', mktime(0, 0, 0, $previous->month, 1, $previous->year)))) . '">« ' . $jdate_month_name[$jprevious[1]] . '</a></td>'; } } else { $calendar_output .= "\n\t\t" . '<td colspan="3" id="prev" class="pad"> </td>'; } $calendar_output .= "\n\t\t" . '<td class="pad"> </td>'; if ($next) { $jnext = gregorian_to_jalali($next->year, $next->month, $next->dayofmonth); if ($ztjalali_option['change_url_date_to_jalali']) { $calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="' . get_month_link($jnext[0], $jnext[1]) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s', 'ztjalali'), $jdate_month_name[$jnext[1]], jdate('Y', mktime(0, 0, 0, $next->month, 1, $next->year)))) . '">' . $jdate_month_name[$jnext[1]] . ' »</a></td>'; } else { $calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s', 'ztjalali'), $jdate_month_name[$jnext[1]], jdate('Y', mktime(0, 0, 0, $next->month, 1, $next->year)))) . '">' . $jdate_month_name[$jnext[1]] . ' »</a></td>'; } } else { $calendar_output .= "\n\t\t" . '<td colspan="3" id="next" class="pad"> </td>'; } $calendar_output .= ' </tr> </tfoot> <tbody> <tr>'; // Get days with posts $dayswithposts = $wpdb->get_results("SELECT DISTINCT post_date\n\t\tFROM {$wpdb->posts} WHERE post_date >= '{$startdate} 00:00:00'\n\t\tAND post_type = 'post' AND post_status = 'publish'\n\t\tAND post_date <= '{$enddate} 23:59:59'", ARRAY_N); if ($dayswithposts) { foreach ((array) $dayswithposts as $daywith) { $jdaywithpost[] = jdate('j', strtotime($daywith[0]), FALSE, FALSE); } } else { $jdaywithpost = array(); } if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false) { $ak_title_separator = "\n"; } else { $ak_title_separator = ', '; } $ak_titles_for_day = array(); $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, post_date as dom " . "FROM {$wpdb->posts} " . "WHERE post_date >= '{$startdate} 00:00:00' " . "AND post_date <= '{$enddate} 23:59:59' " . "AND post_type = 'post' AND post_status = 'publish'"); if ($ak_post_titles) { foreach ((array) $ak_post_titles as $ak_post_title) { /** This filter is documented in wp-includes/post-template.php */ $post_title = esc_attr(apply_filters('the_title', $ak_post_title->post_title, $ak_post_title->ID)); $jdom = $jdaywithpost[] = jdate('j', strtotime($ak_post_title->dom), FALSE, FALSE); if (empty($ak_titles_for_day['day_' . $jdom])) { $ak_titles_for_day['day_' . $jdom] = ''; } if (empty($ak_titles_for_day["{$jdom}"])) { // first one $ak_titles_for_day["{$jdom}"] = $post_title; } else { $ak_titles_for_day["{$jdom}"] .= $ak_title_separator . $post_title; } } } // See how much we should pad in the beginning $pad = calendar_week_mod(jdate('w', $unixmonth, false, false) - $week_begins); $pad--; if ($pad < 0) { $pad = 6; } if (0 != $pad) { $calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr($pad) . '" class="pad"> </td>'; } $jdaysinmonth = (int) jdate('t', $unixmonth, FALSE, FALSE); for ($jday = 1; $jday <= $jdaysinmonth; ++$jday) { if (isset($newrow) && $newrow) { $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t"; } $newrow = false; if ($jday == jdate('j', time(), FALSE, FALSE) && $jthismonth == jdate('m', time(), FALSE, FALSE) && $jthisyear == jdate('Y', time(), FALSE, FALSE)) { $calendar_output .= '<td id="today">'; } else { $calendar_output .= '<td>'; } if (in_array($jday, $jdaywithpost)) { // any posts today? $day = jalali_to_gregorian($jthisyear, $jthismonth, $jday); if ($ztjalali_option['change_url_date_to_jalali']) { $calendar_output .= '<a href="' . get_day_link($jthisyear, $jthismonth, $jday) . '" title="' . esc_attr($ak_titles_for_day[$jday]) . "\">{$jday}</a>"; } else { $calendar_output .= '<a href="' . get_day_link($day[0], $day[1], $day[2]) . '" title="' . esc_attr($ak_titles_for_day[$jday]) . "\">{$jday}</a>"; } } else { $calendar_output .= $jday; } $calendar_output .= '</td>'; jdate('w', jmktime(0, 0, 0, $jthismonth, $jday, $jthisyear), FALSE, FALSE); if (6 == calendar_week_mod(date('w', jmktime(0, 0, 0, $jthismonth, $jday, $jthisyear)) - $week_begins)) { $newrow = true; } } $pad = 7 - calendar_week_mod(date('w', jmktime(0, 0, 0, $jthismonth, $jday, $jthisyear)) - $week_begins); if ($pad != 0 && $pad != 7) { $calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr($pad) . '"> </td>'; } $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>"; $cache[$key] = $calendar_output; wp_cache_set('ztjalali_calendar', $cache, 'calendar'); if ($ztjalali_option['change_jdate_number_to_persian']) { $calendar_output = ztjalali_persian_num($calendar_output); } if ($echo) { /** * Filter the HTML calendar output. * * @since 3.0.0 * * @param string $calendar_output HTML output of the calendar. */ echo apply_filters('ztjalali_calendar', $calendar_output); } else { /** This filter is documented in wp-includes/general-template.php */ return apply_filters('ztjalali_calendar', $calendar_output); } }
public function makeTime() { $this->load->library("jdf"); echo "<meta charset='utf-8'>"; echo jdate("Y/m/d H:i:s", makeTime("1394/5/18", "11:00")) . "<br>"; echo jdate("Y/m/d H:i:s", jmktime(6, 15, 34, 11, 22, 1389)) . "<br>"; echo jdate("Y/m/d H:i:s", jmktime(11, 0, 0, 5, 18, 1394)) . "<br>"; }