Support Forum Softcomplex logo
About Us  | Services  | Download  | Order  | Support  | |
| Search | Today's Posts | Stats | Board Rules | Not logged in [ Login | Register ]
go to bottom
Last active: Never

Printable Version | Subscribe | Add to Favourites   Post new thread
Author: Subject: noon and midnight time display fix
factorypower
Junior Member

Posts: 2
Registered: 11/24/2007
Location: Central PA, USA
Member Is Offline
posted on 11/24/2007 at 06:04 AM Reply With Quote
noon and midnight time display fix


Hello,

I am new to this board and PHP Event Calendar (and php for that matter) but I have a fix for the noon and midnight issue... it took me a while but here goes...

In the calendar.php page the following code needs to be replaced (it is located at 2 different spots once in the "function show_event()" and once in the "function show_month_event()" starting on line 685 in my file):

if($this->a_template['time_format'])
$time = $v->time_start['h']>11?($v->time_start['h']-12).':'.$v->time_start['m']." pm":$v->time_start['h'].':'.$v->time_start['m']." am").' -'.($v->time_end['h']>11?($v->time_end['h']-12).':'.$v->time_end['m']." pm":$v->time_end['h'].':'.$v->time_end['m']." am");
else $time = $v->time_start['h'].':'.$v->time_start['m'].' - '.$v->time_end['h'].':'.$v->time_end['m'];
}


with this new code:

if($this->a_template['time_format']){
if(($v->time_start['h'])>12){
$time = ($v->time_start['h']-12).':'.($v->time_start['m']).' pm';
} elseif (($v->time_start['h'])==12) {
$time = ($v->time_start['h']).':'.($v->time_start['m']).' pm';
} else {
$time = $v->time_start['h'].':'.$v->time_start['m']." am";
}
if(($v->time_end['h'])>12){
$time = ($time).' - '.($v->time_end['h']-12).':'.($v->time_end['m']).' pm';
} elseif (($v->time_end['h'])==12) {
$time = ($time).' - '.($v->time_end['h']).':'.($v->time_end['m'])." pm";
} else {
$time = ($time).' - '.$v->time_end['h'].':'.$v->time_end['m']." am";
}
} else {
$time = $v->time_start['h'].':'.$v->time_start['m'].' - '.$v->time_end['h'].':'.$v->time_end['m'];
}
}

I am certain there is some "cleaning up" of my php code that could occur but this is working very well for me... hope it helps out some others...

~ factorypower
View User's Profile View All Posts By User U2U Member
factorypower
Junior Member

Posts: 2
Registered: 11/24/2007
Location: Central PA, USA
Member Is Offline
posted on 11/24/2007 at 03:14 PM Reply With Quote

It was late when I posted last night (actually this morning) and I realized that the code I posted above only fixed the noon issue not the midnight... so a little tweak and the addition of one more elseif statement and here IS the correct code to take care of both midnight and noon display issues...


if($this->a_template['time_format']){
if(($v->time_start['h'])>12){
$time = ($v->time_start['h']-12).':'.($v->time_start['m']).' pm';
} elseif (($v->time_start['h'])==12) {
$time = ($v->time_start['h']).':'.($v->time_start['m']).' pm';
} elseif (($v->time_start['h'])==0) {
$time = '12:'.($v->time_start['m']).' am';
} else {
$time = $v->time_start['h'].':'.$v->time_start['m']." am";
}
if(($v->time_end['h'])>12){
$time = ($time).' - '.($v->time_end['h']-12).':'.($v->time_end['m']).' pm';
} elseif (($v->time_end['h'])==12) {
$time = ($time).' - '.($v->time_end['h']).':'.($v->time_end['m'])." pm";
} elseif (($v->time_end['h'])==0) {
$time = '12:'.($v->time_end['m']).' am';
} else {
$time = ($time).' - '.$v->time_end['h'].':'.$v->time_end['m']." am";
}
} else {
$time = $v->time_start['h'].':'.$v->time_start['m'].' - '.$v->time_end['h'].':'.$v->time_end['m'];
}
}


Once again I hope this helps other users out there!

~ factorypower
View User's Profile View All Posts By User U2U Member
jjoyce25
Member

Posts: 13
Registered: 7/3/2008
Member Is Offline
posted on 8/4/2008 at 09:38 PM Reply With Quote
update?


It has been almost a year since the previous post for the noon/midnight fix was made so perhaps a new update has been made...but I just wanted to let others know that I added this code only once in the function show_event() location and couldn't find function show_month_event() in calendar.php. It seems to work. If someone has also had this work and wants to chime in about the other missing location, please feel free. Thanks factorypower for your fix.
View User's Profile View All Posts By User U2U Member
Post new thread

Related Links:
Product Page
Product Demonstrations Live Demos
Free/Trial Script Download Free Download
Product Documentation Documentation
Documentation page
Change Log
Support Forum Support Forum
Order Now ORDER NOW!
Add to Cart
View Cart
 

Go To Top


Powered by XMB 1.9.1 Nexus
Developed By Aventure Media & The XMB Group © 2002-2004