コード例 #1
0
ファイル: adodb.inc.php プロジェクト: dasatti/dashboard
 /**
  *
  * @param v  	is the character timestamp in YYYY-MM-DD hh:mm:ss format
  * @param fmt 	is the format to apply to it, using date()
  *
  * @return a timestamp formated as user desires
  */
 function UserTimeStamp($v, $fmt = 'Y-m-d H:i:s', $gmt = false)
 {
     if (!isset($v)) {
         return $this->emptyTimeStamp;
     }
     # strlen(14) allows YYYYMMDDHHMMSS format
     if (is_numeric($v) && strlen($v) < 14) {
         return $gmt ? adodb_gmdate($fmt, $v) : adodb_date($fmt, $v);
     }
     $tt = $this->UnixTimeStamp($v);
     // $tt == -1 if pre TIMESTAMP_FIRST_YEAR
     if (($tt === false || $tt == -1) && $v != false) {
         return $v;
     }
     if ($tt == 0) {
         return $this->emptyTimeStamp;
     }
     return $gmt ? adodb_gmdate($fmt, $tt) : adodb_date($fmt, $tt);
 }
コード例 #2
0
 function mkActiveGMDate($param, $acttime = false)
 {
     if (!$acttime) {
         $acttime = time();
     }
     if (function_exists("adodb_gmdate")) {
         return adodb_gmdate($param, $acttime);
     } else {
         return gmdate($param, $acttime);
     }
 }
コード例 #3
0
ファイル: calendar.php プロジェクト: andxbes/firstwpSite1
/**
 * Calendar view.
 *
 * @global object $wpdb
 * @global type $m
 * @global type $wp_locale
 * @global type $actors
 * @param type $params
 * @param type $initial
 * @param type $echo
 * @return type
 */
function wpcf_fields_date_get_calendar($params, $initial = true, $echo = true)
{
    global $wpdb, $m, $wp_locale, $actors;
    // wpcf Set our own date
    $monthnum = adodb_date('n', $params['field_value']);
    $year = adodb_date('Y', $params['field_value']);
    $wpcf_date = adodb_date('j', $params['field_value']);
    $cache = array();
    $key = md5($params['field']['slug'] . $wpcf_date);
    if ($cache = wp_cache_get('get_calendar', 'calendar')) {
        if (is_array($cache) && isset($cache[$key])) {
            if ($echo) {
                echo apply_filters('get_calendar', $cache[$key]);
                return;
            } else {
                return apply_filters('get_calendar', $cache[$key]);
            }
        }
    }
    if (!is_array($cache)) {
        $cache = array();
    }
    if (isset($_GET['w'])) {
        $w = '' . intval($_GET['w']);
    }
    // week_begins = 0 stands for Sunday
    $week_begins = intval(get_option('start_of_week'));
    // Let's figure out when we are
    if (!empty($monthnum) && !empty($year)) {
        $thismonth = '' . zeroise(intval($monthnum), 2);
        $thisyear = '' . intval($year);
    } elseif (!empty($w)) {
        // We need to get the month from MySQL
        $thisyear = '' . intval(substr($m, 0, 4));
        $d = ($w - 1) * 7 + 6;
        //it seems MySQL's weeks disagree with PHP's
        $thismonth = $wpdb->get_var($wpdb->prepare("SELECT DATE_FORMAT((DATE_ADD(%s, INTERVAL %d DAY) ), '%%m')", sprintf('%d0101', $thisyear), $d));
    } elseif (!empty($m)) {
        $thisyear = '' . intval(substr($m, 0, 4));
        if (strlen($m) < 6) {
            $thismonth = '01';
        } else {
            $thismonth = '' . zeroise(intval(substr($m, 4, 2)), 2);
        }
    } else {
        $thisyear = adodb_gmdate('Y', current_time('timestamp'));
        $thismonth = adodb_gmdate('m', current_time('timestamp'));
    }
    $unixmonth = adodb_mktime(0, 0, 0, $thismonth, 1, $thisyear);
    $last_day = adodb_date('t', $unixmonth);
    $class = !empty($params['class']) ? ' class="' . $params['class'] . '"' : '';
    /* 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-' . md5(serialize(func_get_args())) . '" summary="' . esc_attr__('Calendar') . '"' . $class . '>
	<caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), adodb_date('Y', $unixmonth)) . '</caption>
	<thead>
	<tr>';
    $myweek = array();
    for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
        $myweek[] = $wp_locale->get_weekday(($wdcount + $week_begins) % 7);
    }
    foreach ($myweek as $wd) {
        $day_name = true == $initial ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
        $wd = esc_attr($wd);
        $calendar_output .= "\n\t\t<th scope=\"col\" title=\"{$wd}\">{$day_name}</th>";
    }
    $calendar_output .= '
	</tr>
	</thead>

	<tfoot>
	<tr>';
    $calendar_output .= '
	</tr>
	</tfoot>

	<tbody>
	<tr>';
    // See how much we should pad in the beginning
    $pad = calendar_week_mod(adodb_date('w', $unixmonth) - $week_begins);
    if (0 != $pad) {
        $calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr($pad) . '" class="pad">&nbsp;</td>';
    }
    $daysinmonth = intval(adodb_date('t', $unixmonth));
    for ($day = 1; $day <= $daysinmonth; ++$day) {
        if (isset($newrow) && $newrow) {
            $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
        }
        $newrow = false;
        if ($day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp'))) {
            $calendar_output .= '<td id="today">';
        } else {
            $calendar_output .= '<td>';
        }
        // wpcf
        if ($wpcf_date == $day) {
            $calendar_output .= '<a href="javascript:void(0);">' . $day . '</a>';
        } else {
            $calendar_output .= $day;
        }
        $calendar_output .= '</td>';
        if (6 == calendar_week_mod(adodb_date('w', adodb_mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins)) {
            $newrow = true;
        }
    }
    $pad = 7 - calendar_week_mod(adodb_date('w', adodb_mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins);
    if ($pad != 0 && $pad != 7) {
        $calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr($pad) . '">&nbsp;</td>';
    }
    $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
    $cache[$key] = $calendar_output;
    wp_cache_set('get_calendar', $cache, 'calendar');
    if ($echo) {
        echo apply_filters('get_calendar', $calendar_output);
    } else {
        return apply_filters('get_calendar', $calendar_output);
    }
}
コード例 #4
0
/**
 * Date select form for Group edit screen.
 *
 * @global type $wp_locale
 * @param type $function
 * @param type $value
 * @param type $name
 * @return string
 *
 */
function wpcf_conditional_add_date_controls($function, $value, $name)
{
    global $wp_locale;
    if ($function == 'date') {
        $date_parts = explode(',', $value);
        $time_adj = adodb_mktime(0, 0, 0, $date_parts[1], $date_parts[0], $date_parts[2]);
    } else {
        $time_adj = current_time('timestamp');
    }
    $jj = adodb_gmdate('d', $time_adj);
    $mm = adodb_gmdate('m', $time_adj);
    $aa = adodb_gmdate('Y', $time_adj);
    $output = '<div class="wpcf-custom-field-date">' . "\n";
    $month = "<select name=\"" . $name . '[month]' . "\" >\n";
    for ($i = 1; $i < 13; $i = $i + 1) {
        $monthnum = zeroise($i, 2);
        $month .= "\t\t\t" . '<option value="' . $monthnum . '"';
        if ($i == $mm) {
            $month .= ' selected="selected"';
        }
        $month .= '>' . $monthnum . '-' . $wp_locale->get_month_abbrev($wp_locale->get_month($i)) . "</option>\n";
    }
    $month .= '</select>';
    $day = '<input name="' . $name . '[date]" type="text" value="' . $jj . '" size="2" maxlength="2" autocomplete="off" />';
    $year = '<input name="' . $name . '[year]" type="text" value="' . $aa . '" size="4" maxlength="4" autocomplete="off" />';
    $output .= sprintf(__('%1$s%2$s, %3$s'), $month, $day, $year);
    $output .= '<div class="wpcf_custom_field_invalid_date wpcf-form-error"><p>' . __('Please enter a valid date here', 'wpcf') . '</p></div>' . "\n";
    $output .= "</div>\n";
    return $output;
}
コード例 #5
0
/**
 * Alias for adodb_gmdate()
 */
function carl_gmdate($format, $timestamp = false)
{
    return adodb_gmdate($format, $timestamp);
}