⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timestr.c

📁 Apache V2.0.15 Alpha For Linuxhttpd-2_0_15-alpha.tar.Z
💻 C
字号:
/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. * * 3. The end-user documentation included with the redistribution, *    if any, must include the following acknowledgment: *       "This product includes software developed by the *        Apache Software Foundation (http://www.apache.org/)." *    Alternately, this acknowledgment may appear in the software itself, *    if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must *    not be used to endorse or promote products derived from this *    software without prior written permission. For written *    permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", *    nor may "Apache" appear in their name, without prior written *    permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation.  For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */#include "win32/atime.h"#include "apr_portable.h"APR_DECLARE_DATA const char apr_month_snames[12][4] ={    "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};APR_DECLARE_DATA const char apr_day_snames[7][4] ={    "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};APR_DECLARE(apr_status_t) apr_rfc822_date(char *date_str, apr_time_t t){    apr_exploded_time_t xt;    const char *s;    int real_year;    apr_explode_gmt(&xt, t);    /* example: "Sat, 08 Jan 2000 18:31:41 GMT" */    /*           12345678901234567890123456789  */    s = &apr_day_snames[xt.tm_wday][0];    *date_str++ = *s++;    *date_str++ = *s++;    *date_str++ = *s++;    *date_str++ = ',';    *date_str++ = ' ';    *date_str++ = xt.tm_mday / 10 + '0';    *date_str++ = xt.tm_mday % 10 + '0';    *date_str++ = ' ';    s = &apr_month_snames[xt.tm_mon][0];    *date_str++ = *s++;    *date_str++ = *s++;    *date_str++ = *s++;    *date_str++ = ' ';    real_year = 1900 + xt.tm_year;    /* This routine isn't y10k ready. */    *date_str++ = real_year / 1000 + '0';    *date_str++ = real_year % 1000 / 100 + '0';    *date_str++ = real_year % 100 / 10 + '0';    *date_str++ = real_year % 10 + '0';    *date_str++ = ' ';    *date_str++ = xt.tm_hour / 10 + '0';    *date_str++ = xt.tm_hour % 10 + '0';    *date_str++ = ':';    *date_str++ = xt.tm_min / 10 + '0';    *date_str++ = xt.tm_min % 10 + '0';    *date_str++ = ':';    *date_str++ = xt.tm_sec / 10 + '0';    *date_str++ = xt.tm_sec % 10 + '0';    *date_str++ = ' ';    *date_str++ = 'G';    *date_str++ = 'M';    *date_str++ = 'T';    *date_str++ = 0;    return APR_SUCCESS;}APR_DECLARE(apr_status_t) apr_ctime(char *date_str, apr_time_t t){    apr_exploded_time_t xt;    const char *s;    int real_year;    /* example: "Wed Jun 30 21:49:08 1993" */    /*           123456789012345678901234  */    apr_explode_localtime(&xt, t);    s = &apr_day_snames[xt.tm_wday][0];    *date_str++ = *s++;    *date_str++ = *s++;    *date_str++ = *s++;    *date_str++ = ' ';    s = &apr_month_snames[xt.tm_mon][0];    *date_str++ = *s++;    *date_str++ = *s++;    *date_str++ = *s++;    *date_str++ = ' ';    *date_str++ = xt.tm_mday / 10 + '0';    *date_str++ = xt.tm_mday % 10 + '0';    *date_str++ = ' ';    *date_str++ = xt.tm_hour / 10 + '0';    *date_str++ = xt.tm_hour % 10 + '0';    *date_str++ = ':';    *date_str++ = xt.tm_min / 10 + '0';    *date_str++ = xt.tm_min % 10 + '0';    *date_str++ = ':';    *date_str++ = xt.tm_sec / 10 + '0';    *date_str++ = xt.tm_sec % 10 + '0';    *date_str++ = ' ';    real_year = 1900 + xt.tm_year;    *date_str++ = real_year / 1000 + '0';    *date_str++ = real_year % 1000 / 100 + '0';    *date_str++ = real_year % 100 / 10 + '0';    *date_str++ = real_year % 10 + '0';    *date_str++ = 0;    return APR_SUCCESS;}APR_DECLARE(apr_status_t) apr_strftime(char *s, apr_size_t *retsize,                                       apr_size_t max, const char *format,                                       apr_exploded_time_t *xt){    struct tm tm;    memset(&tm, 0, sizeof tm);    tm.tm_sec  = xt->tm_sec;    tm.tm_min  = xt->tm_min;    tm.tm_hour = xt->tm_hour;    tm.tm_mday = xt->tm_mday;    tm.tm_mon  = xt->tm_mon;    tm.tm_year = xt->tm_year;    tm.tm_wday = xt->tm_wday;    tm.tm_yday = xt->tm_yday;    tm.tm_isdst = xt->tm_isdst;    (*retsize) = strftime(s, max, format, &tm);    return APR_SUCCESS;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -