/[dolibarr]/dolibarr/htdocs/includes/magpierss/rss_utils.inc
ViewVC logotype

Diff of /dolibarr/htdocs/includes/magpierss/rss_utils.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by erics, Tue Jul 22 15:00:48 2003 UTC revision 1.2 by eldy, Fri Sep 2 21:03:34 2005 UTC
# Line 3  Line 3 
3   * Project:     MagpieRSS: a simple RSS integration tool   * Project:     MagpieRSS: a simple RSS integration tool
4   * File:        rss_utils.inc, utility methods for working with RSS   * File:        rss_utils.inc, utility methods for working with RSS
5   * Author:      Kellan Elliott-McCrea <kellan@protest.net>   * Author:      Kellan Elliott-McCrea <kellan@protest.net>
6   * Version:             0.51   * Version:     0.51
7   * License:             GPL   * License:     GPL
8   *   *
9   * The lastest version of MagpieRSS can be obtained from:   * The lastest version of MagpieRSS can be obtained from:
10   * http://magpierss.sourceforge.net   * http://magpierss.sourceforge.net
# Line 19  Line 19 
19      Function: parse_w3cdtf      Function: parse_w3cdtf
20      Purpose:  parse a W3CDTF date into unix epoch      Purpose:  parse a W3CDTF date into unix epoch
21    
22          NOTE: http://www.w3.org/TR/NOTE-datetime      NOTE: http://www.w3.org/TR/NOTE-datetime
23  \*======================================================================*/  \*======================================================================*/
24    
25  function parse_w3cdtf ( $date_str ) {  function parse_w3cdtf ( $date_str ) {
26                
27          # regex to match wc3dtf      # regex to match wc3dtf
28          $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";      $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
29                
30          if ( preg_match( $pat, $date_str, $match ) ) {      if ( preg_match( $pat, $date_str, $match ) ) {
31                  list( $year, $month, $day, $hours, $minutes, $seconds) =          list( $year, $month, $day, $hours, $minutes, $seconds) =
32                          array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]);              array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]);
33                            
34                  # calc epoch for current date assuming GMT          # calc epoch for current date assuming GMT
35                  $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year);          $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year);
36                            
37                  $offset = 0;          $offset = 0;
38                  if ( $match[10] == 'Z' ) {          if ( $match[10] == 'Z' ) {
39                          # zulu time, aka GMT              # zulu time, aka GMT
40                  }          }
41                  else {          else {
42                          list( $tz_mod, $tz_hour, $tz_min ) =              list( $tz_mod, $tz_hour, $tz_min ) =
43                                  array( $match[8], $match[9], $match[10]);                  array( $match[8], $match[9], $match[10]);
44                                        
45                          # zero out the variables              # zero out the variables
46                          if ( ! $tz_hour ) { $tz_hour = 0; }              if ( ! $tz_hour ) { $tz_hour = 0; }
47                          if ( ! $tz_min ) { $tz_min = 0; }              if ( ! $tz_min ) { $tz_min = 0; }
48                            
49                          $offset_secs = (($tz_hour*60)+$tz_min)*60;              $offset_secs = (($tz_hour*60)+$tz_min)*60;
50                                        
51                          # is timezone ahead of GMT?  then subtract offset              # is timezone ahead of GMT?  then subtract offset
52                          #              #
53                          if ( $tz_mod == '+' ) {              if ( $tz_mod == '+' ) {
54                                  $offset_secs = $offset_secs * -1;                  $offset_secs = $offset_secs * -1;
55                          }              }
56                                        
57                          $offset = $offset_secs;              $offset = $offset_secs;
58                  }          }
59                  $epoch = $epoch + $offset;          $epoch = $epoch + $offset;
60                  return $epoch;          return $epoch;
61          }      }
62          else {      else {
63                  return -1;          return -1;
64          }      }
65  }  }
66    
67  ?>  ?>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26