Exemple #1
0
/**
 * Generates html option tags with month values
 * @param integer $selected selected value
 * @return void
 */
function select_option_month($selected)
{
    for ($i = 1; $i < 13; $i++) {
        $im = date('m', mktime(0, 0, 0, $i, 1, 1));
        $is = getMonthAbrv(date('m', mktime(0, 0, 0, $i, 1, 1)));
        if ($im == $selected) {
            echo '            <option value="' . $im . '" selected="selected">' . $is . "</option>\n";
        } else {
            echo '            <option value="' . $im . '">' . $is . "</option>\n";
        }
    }
}
Exemple #2
0
/**
 * Returns the localized representation of the date/time.
 *
 * @param string date_format The format for the date, like the input for the PHP date() function.
 * @param int stamp the timestamp to convert
 * @return string a full date representation
 */
function date_intl($date_format, $stamp)
{
    $ret = str_replace(array('D', 'F', 'l', 'M'), array('$1', '$2', '$3', '$4'), $date_format);
    // to reduce the date calls we retrieve m and w in the same call
    $ret = date('w#m#' . $ret, $stamp);
    // extract day and month in order to replace later by intl day and month
    $aParts = explode('#', $ret);
    $ret = str_replace(array('$1', '$4', '$2', '$3'), array(getDayAbrv($aParts[0]), getMonthAbrv($aParts[1]), getMonthName($aParts[1]), getDayName($aParts[0])), $aParts[2]);
    return $ret;
}
/**
 * Parses a user date string into an rfc 3501 date string
 * Handles space, slash, backslash, dot and comma as separators (and dash of course ;=)
 * @global array imap_asearch_months
 * @param string user date
 * @return array a preg_match-style array:
 *  - [0] = fully formatted rfc 3501 date string (<day number>-<US month TLA>-<4 digit year>)
 *  - [1] = day
 *  - [2] = month
 *  - [3] = year
 */
function sqimap_asearch_parse_date($what)
{
    global $imap_asearch_months;
    $what = trim($what);
    $what = preg_replace('/[ \\/\\.,]+/', '-', $what);
    if ($what) {
        preg_match('/^([0-9]+)-+([^\\-]+)-+([0-9]+)$/', $what, $what_parts);
        if (count($what_parts) == 4) {
            $what_month = strtolower(asearch_unhtmlentities($what_parts[2]));
            /*                if (!in_array($what_month, $imap_asearch_months)) {*/
            foreach ($imap_asearch_months as $month_number => $month_code) {
                if ($what_month == $month_number || $what_month == $month_code || $what_month == strtolower(asearch_unhtmlentities(getMonthName($month_number))) || $what_month == strtolower(asearch_unhtmlentities(getMonthAbrv($month_number)))) {
                    $what_parts[2] = $month_number;
                    $what_parts[0] = $what_parts[1] . '-' . $month_code . '-' . $what_parts[3];
                    break;
                }
            }
            /*                }*/
        }
    } else {
        $what_parts = array();
    }
    return $what_parts;
}