diff options
author | andi <andi@splitbrain.org> | 2005-02-25 13:37:42 +0100 |
---|---|---|
committer | andi <andi@splitbrain.org> | 2005-02-25 13:37:42 +0100 |
commit | 9d3035d13c5d37b8a3fab7fb8aa2152fef5b60f7 (patch) | |
tree | 22ff78b447d7c7a33bbe2754fc7d5bf31eb408ba /inc/magpie/rss_utils.inc | |
parent | 9cc5a0da20d076fb71e86844ced88adcb5e8de87 (diff) | |
download | rpg-9d3035d13c5d37b8a3fab7fb8aa2152fef5b60f7.tar.gz rpg-9d3035d13c5d37b8a3fab7fb8aa2152fef5b60f7.tar.bz2 |
magpie update to 0.71.1 (#163)
darcs-hash:20050225123742-9977f-009c7a4a54c66611db36e714d488597de14b4a6d.gz
Diffstat (limited to 'inc/magpie/rss_utils.inc')
-rw-r--r-- | inc/magpie/rss_utils.inc | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/inc/magpie/rss_utils.inc b/inc/magpie/rss_utils.inc index 655db8a19..2a29e72a9 100644 --- a/inc/magpie/rss_utils.inc +++ b/inc/magpie/rss_utils.inc @@ -3,8 +3,8 @@ * Project: MagpieRSS: a simple RSS integration tool * File: rss_utils.inc, utility methods for working with RSS * Author: Kellan Elliott-McCrea <kellan@protest.net> - * Version: 0.51 - * License: GPL + * Version: 0.51 + * License: GPL * * The lastest version of MagpieRSS can be obtained from: * http://magpierss.sourceforge.net @@ -19,49 +19,49 @@ Function: parse_w3cdtf Purpose: parse a W3CDTF date into unix epoch - NOTE: http://www.w3.org/TR/NOTE-datetime + NOTE: http://www.w3.org/TR/NOTE-datetime \*======================================================================*/ function parse_w3cdtf ( $date_str ) { - - # regex to match wc3dtf - $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/"; - - if ( preg_match( $pat, $date_str, $match ) ) { - list( $year, $month, $day, $hours, $minutes, $seconds) = - array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]); - - # calc epoch for current date assuming GMT - $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year); - - $offset = 0; - if ( $match[10] == 'Z' ) { - # zulu time, aka GMT - } - else { - list( $tz_mod, $tz_hour, $tz_min ) = - array( $match[8], $match[9], $match[10]); - - # zero out the variables - if ( ! $tz_hour ) { $tz_hour = 0; } - if ( ! $tz_min ) { $tz_min = 0; } - - $offset_secs = (($tz_hour*60)+$tz_min)*60; - - # is timezone ahead of GMT? then subtract offset - # - if ( $tz_mod == '+' ) { - $offset_secs = $offset_secs * -1; - } - - $offset = $offset_secs; - } - $epoch = $epoch + $offset; - return $epoch; - } - else { - return -1; - } + + # regex to match wc3dtf + $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/"; + + if ( preg_match( $pat, $date_str, $match ) ) { + list( $year, $month, $day, $hours, $minutes, $seconds) = + array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]); + + # calc epoch for current date assuming GMT + $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year); + + $offset = 0; + if ( $match[10] == 'Z' ) { + # zulu time, aka GMT + } + else { + list( $tz_mod, $tz_hour, $tz_min ) = + array( $match[8], $match[9], $match[10]); + + # zero out the variables + if ( ! $tz_hour ) { $tz_hour = 0; } + if ( ! $tz_min ) { $tz_min = 0; } + + $offset_secs = (($tz_hour*60)+$tz_min)*60; + + # is timezone ahead of GMT? then subtract offset + # + if ( $tz_mod == '+' ) { + $offset_secs = $offset_secs * -1; + } + + $offset = $offset_secs; + } + $epoch = $epoch + $offset; + return $epoch; + } + else { + return -1; + } } ?> |