| [ Index ] |
krapohl.info |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * $Id: function.pc_week_range.php,v 1.1 2004/02/11 17:31:22 larsneo Exp $ 4 * 5 * PostCalendar::PostNuke Events Calendar Module 6 * Copyright (C) 2002 The PostCalendar Team 7 * http://postcalendar.tv 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * 23 * To read the license please read the docs/license.txt or visit 24 * http://www.gnu.org/copyleft/gpl.html 25 * 26 */ 27 function smarty_function_pc_week_range($args) 28 { 29 // $args['date'] date to use for range building 30 // $args['sep'] seperate the dates by this string 31 // $args['format'] format all dates like this 32 // $args['format1'] format date 1 like this 33 // $args['format2'] format date 1 like this 34 setlocale(LC_TIME, _PC_LOCALE); 35 if(!isset($args['date'])) { 36 $args['date'] = postcalendar_getDate(); 37 } 38 39 $y = substr($args['date'],0,4); 40 $m = substr($args['date'],4,2); 41 $d = substr($args['date'],6,2); 42 43 if(!isset($args['sep'])) { 44 $args['sep'] = ' - '; 45 } 46 if(!isset($args['format'])) { 47 if(!isset($args['format1'])) { 48 $args['format1'] = _SETTING_DATE_FORMAT; 49 } 50 if(!isset($args['format2'])) { 51 $args['format2'] = _SETTING_DATE_FORMAT; 52 } 53 } else { 54 $args['format1'] = $args['format']; 55 $args['format2'] = $args['format']; 56 } 57 58 // get the week date range for the supplied $date 59 $dow = date('w',mktime(0,0,0,$m,$d,$y)); 60 if(_SETTING_FIRST_DAY_WEEK == 0) { 61 $firstDay = strftime($args['format1'],mktime(0,0,0,$m,($d-$dow),$y)); 62 $lastDay = strftime($args['format2'],mktime(0,0,0,$m,($d+(6-$dow)),$y)); 63 } elseif(_SETTING_FIRST_DAY_WEEK == 1) { 64 if($dow == 0) $sub = 6; 65 else $sub = $dow-1; 66 $firstDay = strftime($args['format1'],mktime(0,0,0,$m,($d-$sub),$y)); 67 $lastDay = strftime($args['format2'],mktime(0,0,0,$m,($d+(6-$sub)),$y)); 68 } elseif(_SETTING_FIRST_DAY_WEEK == 6) { 69 if($dow == 6) $sub = 0; 70 else $sub = $dow+1; 71 $firstDay = strftime($args['format1'],mktime(0,0,0,$m,($d-$sub),$y)); 72 $lastDay = strftime($args['format2'],mktime(0,0,0,$m,($d+(6-$sub)),$y)); 73 } 74 // return the formated range 75 echo $firstDay.$args['sep'].$lastDay; 76 } 77 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Feb 16 22:40:07 2005 | Cross-referenced by PHPXref 0.6 |