LTP GCOV extension - code coverage report
Current view: directory - ext/standard - datetime.c
Test: PHP Code Coverage
Date: 2007-04-10 Instrumented lines: 25
Code covered: 0.0 % Executed lines: 0
Legend: not executed executed

       1                 : /* 
       2                 :    +----------------------------------------------------------------------+
       3                 :    | PHP Version 5                                                        |
       4                 :    +----------------------------------------------------------------------+
       5                 :    | Copyright (c) 1997-2007 The PHP Group                                |
       6                 :    +----------------------------------------------------------------------+
       7                 :    | This source file is subject to version 3.01 of the PHP license,      |
       8                 :    | that is bundled with this package in the file LICENSE, and is        |
       9                 :    | available through the world-wide-web at the following url:           |
      10                 :    | http://www.php.net/license/3_01.txt                                  |
      11                 :    | If you did not receive a copy of the PHP license and are unable to   |
      12                 :    | obtain it through the world-wide-web, please send a note to          |
      13                 :    | license@php.net so we can mail you a copy immediately.               |
      14                 :    +----------------------------------------------------------------------+
      15                 :    | Authors: Andi Gutmans <andi@zend.com>                                |
      16                 :    |          Zeev Suraski <zeev@zend.com>                                |
      17                 :    |          Rasmus Lerdorf <rasmus@php.net>                             |
      18                 :    +----------------------------------------------------------------------+
      19                 :  */
      20                 : 
      21                 : /* $Id: datetime.c,v 1.134.2.2.2.3 2007/01/01 09:36:08 sebastian Exp $ */
      22                 : 
      23                 : #include "php.h"
      24                 : #include "zend_operators.h"
      25                 : #include "datetime.h"
      26                 : #include "php_globals.h"
      27                 : 
      28                 : #include <time.h>
      29                 : #ifdef HAVE_SYS_TIME_H
      30                 : # include <sys/time.h>
      31                 : #endif
      32                 : #include <stdio.h>
      33                 : 
      34                 : char *mon_full_names[] = {
      35                 :         "January", "February", "March", "April",
      36                 :         "May", "June", "July", "August",
      37                 :         "September", "October", "November", "December"
      38                 : };
      39                 : 
      40                 : char *mon_short_names[] = {
      41                 :         "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
      42                 : };
      43                 : 
      44                 : char *day_full_names[] = {
      45                 :         "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
      46                 : };
      47                 : 
      48                 : char *day_short_names[] = {
      49                 :         "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
      50                 : };
      51                 : 
      52                 : /* {{{ php_std_date
      53                 :    Return date string in standard format for http headers */
      54                 : PHPAPI char *php_std_date(time_t t TSRMLS_DC)
      55               0 : {
      56                 :         struct tm *tm1, tmbuf;
      57                 :         char *str;
      58                 : 
      59               0 :         tm1 = php_gmtime_r(&t, &tmbuf);
      60               0 :         str = emalloc(81);
      61               0 :         if (PG(y2k_compliance)) {
      62               0 :                 snprintf(str, 80, "%s, %02d %s %04d %02d:%02d:%02d GMT",
      63                 :                                 day_short_names[tm1->tm_wday],
      64                 :                                 tm1->tm_mday,
      65                 :                                 mon_short_names[tm1->tm_mon],
      66                 :                                 tm1->tm_year + 1900,
      67                 :                                 tm1->tm_hour, tm1->tm_min, tm1->tm_sec);
      68                 :         } else {
      69               0 :                 snprintf(str, 80, "%s, %02d-%s-%02d %02d:%02d:%02d GMT",
      70                 :                                 day_full_names[tm1->tm_wday],
      71                 :                                 tm1->tm_mday,
      72                 :                                 mon_short_names[tm1->tm_mon],
      73                 :                                 ((tm1->tm_year) % 100),
      74                 :                                 tm1->tm_hour, tm1->tm_min, tm1->tm_sec);
      75                 :         }
      76                 :         
      77               0 :         str[79] = 0;
      78               0 :         return (str);
      79                 : }
      80                 : /* }}} */
      81                 : 
      82                 : 
      83                 : #if HAVE_STRPTIME
      84                 : #ifndef HAVE_STRPTIME_DECL_FAILS
      85                 : char *strptime(const char *s, const char *format, struct tm *tm);
      86                 : #endif
      87                 : 
      88                 : /* {{{ proto string strptime(string timestamp, string format)
      89                 :    Parse a time/date generated with strftime() */
      90                 : PHP_FUNCTION(strptime)
      91               0 : {
      92                 :         char      *ts;
      93                 :         int        ts_length;
      94                 :         char      *format;
      95                 :         int        format_length;
      96                 :         struct tm  parsed_time;
      97                 :         char      *unparsed_part;
      98                 : 
      99               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", 
     100                 :                 &ts, &ts_length, &format, &format_length) == FAILURE) {
     101               0 :                 return;
     102                 :         }
     103                 : 
     104               0 :         memset(&parsed_time, 0, sizeof(parsed_time));
     105                 : 
     106               0 :         unparsed_part = strptime(ts, format, &parsed_time);
     107               0 :         if (unparsed_part == NULL) {
     108               0 :                 RETURN_FALSE;
     109                 :         }
     110                 : 
     111               0 :         array_init(return_value);
     112               0 :         add_assoc_long(return_value, "tm_sec",   parsed_time.tm_sec);
     113               0 :         add_assoc_long(return_value, "tm_min",   parsed_time.tm_min);
     114               0 :         add_assoc_long(return_value, "tm_hour",  parsed_time.tm_hour);
     115               0 :         add_assoc_long(return_value, "tm_mday",  parsed_time.tm_mday);
     116               0 :         add_assoc_long(return_value, "tm_mon",   parsed_time.tm_mon);
     117               0 :         add_assoc_long(return_value, "tm_year",  parsed_time.tm_year);
     118               0 :         add_assoc_long(return_value, "tm_wday",  parsed_time.tm_wday);
     119               0 :         add_assoc_long(return_value, "tm_yday",  parsed_time.tm_yday);
     120               0 :         add_assoc_string(return_value, "unparsed", unparsed_part, 1);
     121                 : }
     122                 : /* }}} */
     123                 : #endif
     124                 : 
     125                 : /*
     126                 :  * Local variables:
     127                 :  * tab-width: 4
     128                 :  * c-basic-offset: 4
     129                 :  * End:
     130                 :  * vim600: sw=4 ts=4 fdm=marker
     131                 :  * vim<600: sw=4 ts=4
     132                 :  */

Generated by: LTP GCOV extension version 1.5