diff options
| author | Lester Caine <lester@lsces.co.uk> | 2005-08-28 08:27:09 +0000 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2005-08-28 08:27:09 +0000 |
| commit | 85b19ddbc63f73b7af502ecd58d68153b03516e3 (patch) | |
| tree | ea79f59f6fe266944031e0d0e15a4ebd8e06c93f | |
| parent | cb4f4fb508a71a0e488530bdf6e9e5e52048d624 (diff) | |
| download | calendar-85b19ddbc63f73b7af502ecd58d68153b03516e3.tar.gz calendar-85b19ddbc63f73b7af502ecd58d68153b03516e3.tar.bz2 calendar-85b19ddbc63f73b7af502ecd58d68153b03516e3.zip | |
Fix time offseting for time zone/daylight saving when using UTC/Local switch
This SHOULD now work with and TZ offset we want to apply, but is only set up for the user options at present
| -rw-r--r-- | Calendar.php | 22 | ||||
| -rw-r--r-- | index.php | 5 | ||||
| -rw-r--r-- | templates/calendar.tpl | 14 | ||||
| -rw-r--r-- | templates/calendar_box.tpl | 4 | ||||
| -rw-r--r-- | templates/calendar_nav_inc.tpl | 2 |
5 files changed, 22 insertions, 25 deletions
diff --git a/Calendar.php b/Calendar.php index 2d3e4cf..867b2c8 100644 --- a/Calendar.php +++ b/Calendar.php @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_calendar/Calendar.php,v 1.19 2005/08/26 01:22:01 lsces Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_calendar/Calendar.php,v 1.20 2005/08/28 08:27:09 lsces Exp $ * @package calendar */ @@ -21,7 +21,7 @@ class Calendar extends LibertyContent { function Calendar() { LibertyContent::LibertyContent(); global $gBitSystem; - $this->mDate = new BitDate(); + $this->mDate = new BitDate(0); } /** @@ -29,7 +29,6 @@ class Calendar extends LibertyContent { * return array of items **/ function getList( $pListHash ) { - global $gBitSystem, $gBitUser; $ret = array(); if( $this->prepGetList( $pListHash ) ) { include_once( LIBERTY_PKG_PATH.'LibertyContent.php' ); @@ -39,8 +38,8 @@ class Calendar extends LibertyContent { foreach( $res['data'] as $item ) { // shift all time data by user timezone offset - $item['created'] = $item['created'] - $gBitSystem->get_display_offset(); - $item['last_modified'] = $item['last_modified'] - $gBitSystem->get_display_offset(); + $item['created'] = $item['created'] + $this->mDate->get_display_offset(); + $item['last_modified'] = $item['last_modified'] + $this->mDate->get_display_offset(); $dstart = $this->mDate->mktime( 0, 0, 0, $this->mDate->date( "m", $item[$pListHash['calendar_sort_mode']] ), $this->mDate->date( "d", $item[$pListHash['calendar_sort_mode']] ), $this->mDate->date( "Y", $item[$pListHash['calendar_sort_mode']] ) ); $ret[$dstart][] = $item; } @@ -52,7 +51,6 @@ class Calendar extends LibertyContent { * calculate the start and stop time for the current display page **/ function doRangeCalculations( $pDateHash ) { - global $gBitSystem, $gBitUser; $focus = $this->mDate->getdate( $pDateHash['focus_date'] ); if( $pDateHash['view_mode'] == 'month' ) { @@ -74,8 +72,8 @@ class Calendar extends LibertyContent { } // this is where we adjust the start and stop times to user local time settings -// $view_start = $view_start + $gBitSystem->get_display_offset(); -// $view_end = $view_end + $gBitSystem->get_display_offset(); +// $view_start = $view_start + $this->mDate->get_display_offset(); +// $view_end = $view_end + $this->mDate->get_display_offset(); $start_year = $this->mDate->date( 'Y', $view_start ); // vd( 'start: '.$this->mDate->strftime( '%d %m %Y, %T', $view_start ) ); // vd( 'end: '. $this->mDate->strftime( '%d %m %Y, %T', $view_end ) ); @@ -125,14 +123,15 @@ class Calendar extends LibertyContent { // calculare what the visible day view range is $day_start = isset( $gBitUser->mUserPrefs['day_start'] ) ? $gBitUser->mUserPrefs['day_start'] : $gBitSystem->getPreference( 'day_start', 0 ); $day_end = isset( $gBitUser->mUserPrefs['day_end'] ) ? $gBitUser->mUserPrefs['day_end'] : $gBitSystem->getPreference( 'day_end', 0 ); - $start_time = $this->mDate->mktime( 0, 0, 0, $focus['mon'], $focus['mday'] - 1, $focus['year'] ) + ( 60 * 60 * $day_start ); - $stop_time = $this->mDate->mktime( 0, 0, 0, $focus['mon'], $focus['mday'], $focus['year'] ) - ( 60 * 60 * ( 24 - $day_end ) ); + $start_time = $this->mDate->mktime( 0, 0, 0, $focus['mon'], $focus['mday'], $focus['year'] ) + ( 60 * 60 * $day_start ); + $stop_time = $this->mDate->mktime( 0, 0, 0, $focus['mon'], $focus['mday'] + 1, $focus['year'] ) - ( 60 * 60 * ( 24 - $day_end ) ); $hours_count = ( $stop_time - $start_time ) / ( 60 * 60 ); // allow for custom time intervals $hour_fraction = !empty( $gBitUser->mUserPrefs['hour_fraction'] ) ? $gBitUser->mUserPrefs['hour_fraction'] : $gBitSystem->getPreference( 'hour_fraction', 1 ); $row_count = $hours_count * $hour_fraction; - $hour = $this->mDate->strftime( '%H', $start_time ) - 1; + $start_time_info = $this->mDate->getdate( $start_time ); + $hour = $start_time_info['hours'] - 1; $mins = 0; for( $i = 0; $i < $row_count; $i++ ) { if( !( $i % $hour_fraction ) ) { @@ -143,7 +142,6 @@ class Calendar extends LibertyContent { $ret[$i]['time'] = $this->mDate->mktime( $hour, $mins, 0, $focus['mon'], $focus['mday'], $focus['year'] ); $mins += 60 / $hour_fraction; } - // calendar data is added below } return $ret; @@ -1,6 +1,6 @@ <?php -// $Header: /cvsroot/bitweaver/_bit_calendar/index.php,v 1.30 2005/08/26 01:22:01 lsces Exp $ +// $Header: /cvsroot/bitweaver/_bit_calendar/index.php,v 1.31 2005/08/28 08:27:09 lsces Exp $ // Copyright( c ) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. // All Rights Reserved. See copyright.txt for details and a complete list of authors. @@ -35,7 +35,7 @@ $gCalendar = new Calendar(); if( !empty( $_REQUEST["todate"] ) ) { // clean up todate. who knows where this has come from if ( is_numeric( $_REQUEST['todate'] ) ) { - $_SESSION['calendar']['focus_date'] = $_REQUEST['todate'] + $gCalendar->mDate->get_display_offset(); + $_SESSION['calendar']['focus_date'] = $_REQUEST['todate']; } else { $_SESSION['calendar']['focus_date'] = $_REQUEST['todate'] = $gCalendar->mDate->mktime( 0, 0, 0, $gCalendar->mDate->date2( 'm', $_REQUEST['todate'] ), $gCalendar->mDate->date2( 'd', $_REQUEST['todate'] ), $gCalendar->mDate->date2( 'Y', $_REQUEST['todate'] ) ) + $gBitSystem->get_display_offset(); } @@ -96,7 +96,6 @@ foreach( $calMonth as $w => $week ) { $i++; } } - if( !empty( $dayEvents ) ) { $calMonth[$w][$d]['items'] = array_values( $dayEvents ); } diff --git a/templates/calendar.tpl b/templates/calendar.tpl index f932e23..31283bb 100644 --- a/templates/calendar.tpl +++ b/templates/calendar.tpl @@ -1,4 +1,4 @@ -{* $Header: /cvsroot/bitweaver/_bit_calendar/templates/calendar.tpl,v 1.25 2005/08/25 06:58:48 squareing Exp $ *} +{* $Header: /cvsroot/bitweaver/_bit_calendar/templates/calendar.tpl,v 1.26 2005/08/28 08:27:06 lsces Exp $ *} {strip} {if !$gBitSystem->isFeatureActive( 'feature_helppopup' )} @@ -19,7 +19,7 @@ {include file="bitpackage:calendar/calendar_nav_inc.tpl"} <table class="data caltable {$smarty.session.calendar.view_mode}"> - <caption>{tr}Selection: {$navigation.focus_date|bit_long_date}{/tr}</caption> + <caption>{tr}Selection: {$navigation.focus_date|cal_date_format:"%A %d of %B, %Y %Z"}{/tr}</caption> {if $smarty.session.calendar.view_mode eq 'day'} <tr> <th style="width:5%;">{tr}Time{/tr}</th> @@ -27,12 +27,12 @@ </tr> {foreach item=t from=$calDay} <tr class="{cycle values="odd,even"}"> - <td style="text-align:right; vertical-align:top; padding-right:15px;">{$t.time|date_format:"%H:%M"}</td> + <td style="text-align:right; vertical-align:top; padding-right:15px;">{$t.time|cal_date_format:"%H:%M"}</td> <td> {foreach from=$t.items item=item} {assign var=over value=$item.over} <div class="cal cal{$item.content_type_guid}"> - {$item.last_modified|date_format:"%H:%M"}: + {$item.last_modified|cal_date_format:"%H:%M"}: <a href="{$smarty.const.BIT_ROOT_URL}index.php?content_id={$item.content_id}" {popup fullhtml="1" sticky="1" timeout="2500" text=$over|escape:"javascript"|escape:"html"}> {$item.title|default:"..."} </a> @@ -54,7 +54,7 @@ <th><a href="{$smarty.const.CALENDAR_PKG_URL}index.php?view_mode=week&todate={$week.6.day}">{$week_num}</a></th> {foreach from=$week item=day} {if $smarty.session.calendar.view_mode eq "month"} - {if $day.day|date_format:"%m" eq $navigation.focus_month} + {if $day.day|cal_date_format:"%m" eq $navigation.focus_month} {cycle values="odd,even" print=false advance=false} {else} {cycle values="notmonth" print=false advance=false} @@ -64,9 +64,9 @@ {/if} <td class="calday {if $day.day eq $navigation.server_focus_date}current{/if} {cycle}" style="vertical-align:top;"> - {if $day.day|date_format:"%m" eq $navigation.focus_month or $smarty.session.calendar.view_mode eq "week"} + {if $day.day|cal_date_format:"%m" eq $navigation.focus_month or $smarty.session.calendar.view_mode eq "week"} <div class="calnumber"> - <a href="{$smarty.const.CALENDAR_PKG_URL}index.php?view_mode=day&todate={$day.day}&{$url_string}">{$day.day|date_format:"%d"}</a> + <a href="{$smarty.const.CALENDAR_PKG_URL}index.php?view_mode=day&todate={$day.day}&{$url_string}">{$day.day|cal_date_format:"%d"}</a> </div> {* - Cell Content - *} diff --git a/templates/calendar_box.tpl b/templates/calendar_box.tpl index 72215e6..81206f6 100644 --- a/templates/calendar_box.tpl +++ b/templates/calendar_box.tpl @@ -4,9 +4,9 @@ {tr}Content Type{/tr}: {$cellHash.content_description} <small> <br /> - {tr}First created by {displayname login=$cellHash.creator_user real_name=$cellHash.creator_real_name}<br /> on {$cellHash.created|date_format:"%Y-%m-%d - %H:%M"}{/tr} + {tr}First created by {displayname login=$cellHash.creator_user real_name=$cellHash.creator_real_name}<br /> on {$cellHash.created|cal_date_format:"%Y-%m-%d - %H:%M %Z"}{/tr} <br /> - {tr}Last modified by {displayname login=$cellHash.modifier_user real_name=$cellHash.modifier_real_name}<br /> on {$cellHash.last_modified|date_format:"%Y-%m-%d - %H:%M"}{/tr} + {tr}Last modified by {displayname login=$cellHash.modifier_user real_name=$cellHash.modifier_real_name}<br /> on {$cellHash.last_modified|cal_date_format:"%Y-%m-%d - %H:%M %Z"}{/tr} </small> </div> </div> diff --git a/templates/calendar_nav_inc.tpl b/templates/calendar_nav_inc.tpl index 0b661be..77e0909 100644 --- a/templates/calendar_nav_inc.tpl +++ b/templates/calendar_nav_inc.tpl @@ -3,7 +3,7 @@ <tr> <td> <form action="{$gBitLoc.CALENDAR_PKG_URL}index.php" method="get" id="f"> - <input type="hidden" id="todate" name="todate" value="{$focus_date|date_format:"%B %e, %Y %H:%M"}" /> + <input type="hidden" id="todate" name="todate" value="{$focus_date|cal_date_format:"%B %e, %Y %H:%M %Z"}" /> <span title="{tr}Date Selector{/tr}" id="datrigger">{$focus_date|bit_long_date}</span> <- {tr}click to navigate{/tr} </form> |
