PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/date/lib - interval.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 29 29 100.0 %
Date: 2014-04-18 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 5                                                        |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1997-2013 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: Derick Rethans <derick@derickrethans.nl>                    |
      16             :    +----------------------------------------------------------------------+
      17             :  */
      18             : 
      19             : /* $Id$ */
      20             : 
      21             : #include "timelib.h"
      22             : #include <math.h>
      23             : 
      24      173475 : timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
      25             : {
      26             :         timelib_rel_time *rt;
      27             :         timelib_time *swp;
      28      173475 :         timelib_sll dst_h_corr = 0, dst_m_corr = 0;
      29             :         timelib_time one_backup, two_backup;
      30             : 
      31      173475 :         rt = timelib_rel_time_ctor();
      32      173475 :         rt->invert = 0;
      33      173475 :         if (one->sse > two->sse) {
      34        7415 :                 swp = two;
      35        7415 :                 two = one;
      36        7415 :                 one = swp;
      37        7415 :                 rt->invert = 1;
      38             :         }
      39             : 
      40             :         /* Calculate correction for DST change over, but only if the TZ type is ID
      41             :          * and it's the same */
      42      692916 :         if (one->zone_type == 3 && two->zone_type == 3
      43      346332 :                 && (strcmp(one->tz_info->name, two->tz_info->name) == 0)
      44      173109 :                 && (one->z != two->z))
      45             :         {
      46         112 :                 dst_h_corr = (two->z - one->z) / 3600;
      47         112 :                 dst_m_corr = ((two->z - one->z) % 3600) / 60;
      48             :         }
      49             : 
      50             :         /* Save old TZ info */
      51      173475 :         memcpy(&one_backup, one, sizeof(one_backup));
      52      173475 :         memcpy(&two_backup, two, sizeof(two_backup));
      53             : 
      54      173475 :     timelib_apply_localtime(one, 0);
      55      173475 :     timelib_apply_localtime(two, 0);
      56             : 
      57      173475 :         rt->y = two->y - one->y;
      58      173475 :         rt->m = two->m - one->m;
      59      173475 :         rt->d = two->d - one->d;
      60      173475 :         rt->h = two->h - one->h + dst_h_corr;
      61      173475 :         rt->i = two->i - one->i + dst_m_corr;
      62      173475 :         rt->s = two->s - one->s;
      63      173475 :         rt->days = abs(floor((one->sse - two->sse - (dst_h_corr * 3600) - (dst_m_corr * 60)) / 86400));
      64             : 
      65      173475 :         timelib_do_rel_normalize(rt->invert ? one : two, rt);
      66             : 
      67             :         /* Restore old TZ info */
      68      173475 :         memcpy(one, &one_backup, sizeof(one_backup));
      69      173475 :         memcpy(two, &two_backup, sizeof(two_backup));
      70             : 
      71      173475 :         return rt;
      72             : }

Generated by: LCOV version 1.10

Generated at Fri, 18 Apr 2014 07:01:26 +0000 (2 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.