[mythtv] Patch for time & date format in mythweb2

Magnus Hoglund mho at du.se
Wed Aug 20 22:17:55 EDT 2003


Hi,

I've done some patching in mythweb2 to enable configuration of the time and
date format. In Sweden we consistently use 24-hour format and are not used to
the 12-hour AM/PM format. The attached patch makes time_format a configuration
variable and makes it possible for the user to choose prefered format. I've
also patched mythweb to use the already existing configuration variable 
longdate_format wherever date/time is displayed. I hope you'll find the patch
useful and applies it!

Regards, Magnus

-- 
-------------------+----------------------------+----------------------------
Magnus Hoglund     : Mail: mho at du.se            : If we knew what it was we
IT-department      : URL: http://www.du.se/~mho : were doing, it would not
Dalarna University : Tel: +46 23-778120         : be called research, would
SE-781 88 Borlange : Fax: +46 23-778050         : it?      - Albert Einstein
-------------------+----------------------------+----------------------------

-------------- next part --------------
Index: mythweb2/config/conf.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb2/config/conf.php,v
retrieving revision 1.6
diff -u -r1.6 conf.php
--- mythweb2/config/conf.php	20 Aug 2003 15:04:49 -0000	1.6
+++ mythweb2/config/conf.php	20 Aug 2003 19:03:11 -0000
@@ -29,8 +29,12 @@
 // Email address to which php and database errors are mailed to
     define('Error_Email', 'php_errors@'.server_domain);
 
-// Date and time format used in menustrip
-    define('longdate_format', "D, M d, g:i A");
+// Time format
+    define('time_format', "g:i A");  // 12-hour
+//    define('time_format', "G:i");  // 24-hour
+
+// Date and time format used in various places
+    define('longdate_format', "D, M d, " . time_format);
 
 
 // Locan and web paths to the pixmap image cache
Index: mythweb2/includes/channels.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb2/includes/channels.php,v
retrieving revision 1.2
diff -u -r1.2 channels.php
--- mythweb2/includes/channels.php	31 Jul 2003 02:38:52 -0000	1.2
+++ mythweb2/includes/channels.php	20 Aug 2003 19:03:11 -0000
@@ -100,7 +100,7 @@
 			if ($program->endtime > $program_ends + timeslot_size) {
 				$program_ends += timeslot_size;
 			}
-			#$program->title .= date("g:i", $program_starts)." - ".date("g:i", $program_ends)."<BR>";
+			#$program->title .= date(time_format, $program_starts)." - ".date(time_format, $program_ends)."<BR>";
 		// Calculate the number of time slots this program gets
 			$timeslots_used = round(($program_ends - $program_starts) / timeslot_size);
 		// We might need to add another timeslot
@@ -126,4 +126,4 @@
 	}
 }
 
-?>
\ No newline at end of file
+?>
Index: mythweb2/themes/Default/channel_detail.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb2/themes/Default/channel_detail.php,v
retrieving revision 1.2
diff -u -r1.2 channel_detail.php
--- mythweb2/themes/Default/channel_detail.php	7 Aug 2003 04:28:24 -0000	1.2
+++ mythweb2/themes/Default/channel_detail.php	20 Aug 2003 19:03:11 -0000
@@ -78,7 +78,7 @@
 		foreach ($this_channel->programs as $show) {
 	// Print the content
 	?><tr class="<?php echo $show->class ?>">
-	<td nowrap align="center"><a href="program_listing.php?time=<?php echo $show->starttime ?>"><?php echo date('g:i A', $show->starttime)?> - <?php echo date('g:i A', $show->endtime)?></a></td>
+	<td nowrap align="center"><a href="program_listing.php?time=<?php echo $show->starttime ?>"><?php echo date(time_format, $show->starttime)?> - <?php echo date(time_format, $show->endtime)?></a></td>
 	<td class="<?php echo $show->class ?>"><?php
 		echo '<a href="program_detail.php?chanid='.$show->chanid.'&starttime='.$show->starttime.'">'
 			 .$show->title.'</a>';
Index: mythweb2/themes/Default/program_detail.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb2/themes/Default/program_detail.php,v
retrieving revision 1.5
diff -u -r1.5 program_detail.php
--- mythweb2/themes/Default/program_detail.php	7 Aug 2003 04:28:24 -0000	1.5
+++ mythweb2/themes/Default/program_detail.php	20 Aug 2003 19:03:11 -0000
@@ -51,7 +51,7 @@
 			<td width="24px">&nbsp;</td>
 			<td><span class="huge"><?=$this_program->title?></span><BR>
 				<span class="small">
-				<?=date('g:i A', $this_program->starttime)?> to <?=date('g:i A', $this_program->endtime)?> (<?=(int)($this_program->length/60)?> minutes)<BR>
+				<?=date(time_format, $this_program->starttime)?> to <?=date(time_format, $this_program->endtime)?> (<?=(int)($this_program->length/60)?> minutes)<BR>
 				<?
 				if ($this_program->previouslyshown)
 					echo '(Rerun) ';
@@ -148,4 +148,4 @@
 
 }
 
-?>
\ No newline at end of file
+?>
Index: mythweb2/themes/Default/program_listing.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb2/themes/Default/program_listing.php,v
retrieving revision 1.6
diff -u -r1.6 program_listing.php
--- mythweb2/themes/Default/program_listing.php	20 Aug 2003 05:13:33 -0000	1.6
+++ mythweb2/themes/Default/program_listing.php	20 Aug 2003 19:03:12 -0000
@@ -17,13 +17,13 @@
 	*/
 	function print_header($start_time, $end_time) {
 	// Print the main page header
-		parent::print_header('MythWeb - Program Listing:  '.date('F j, Y, g:i A', $start_time));
+		parent::print_header('MythWeb - Program Listing:  '.date(longdate_format, $start_time));
 	// Print the header info specific to the program listing
 ?>
 <p>
 <table align="center" width="90%" cellspacing="2" cellpadding="2">
 <tr>
-	<td width="50%" align="center">Currently Browsing:  <?=date('F j, Y, g:i A', $start_time)?></td>
+	<td width="50%" align="center">Currently Browsing:  <?=date(longdate_format, $start_time)?></td>
 	<td class="command command_border_l command_border_t command_border_b command_border_r" align="center">
 		<form class="form" action="program_listing.php" method="get">
 		<table width="100%" border="0" cellspacing="0" cellpadding="2">
@@ -127,7 +127,7 @@
 ?><tr>
 	<td class="menu" width="4%" align="right"><a href="program_listing.php?time=<?=$start_time - (timeslot_size * num_time_slots)?>#anchor<?=$timeslot_anchor?>" name="anchor<?=$timeslot_anchor?>"><img src="images/left.gif" border="0" alt="left"></a></td>
 <?		foreach ($timeslots as $time) { ?>
-	<td class="menu" width="<?=(int)(96 / num_time_slots)?>%" align="center"><?=date('g:i', $time)?></td>
+	<td class="menu" width="<?=(int)(96 / num_time_slots)?>%" align="center"><?=date(time_format, $time)?></td>
 <?		} ?>
 	<td class="menu" width="2%"><a href="program_listing.php?time=<?=$start_time + (timeslot_size * num_time_slots)?>#anchor<?=$timeslot_anchor?>"><img src="images/right.gif" border="0" alt="right"></a></td>
 </tr><?
@@ -194,7 +194,7 @@
 	<td><table class=\"menu small\" cellpadding=\"2\" cellspacing=\"0\">
 		<tr>
 			<td align=\"right\">Airtime:</td>
-			<td>".date('g:i A', $program->starttime).' to '.date('g:i A', $program->endtime)."</td>
+			<td>".date(time_format, $program->starttime).' to '.date(time_format, $program->endtime)."</td>
 		</tr><tr>
 			<td align=\"right\">Program:</td>
 			<td>$program->title</td>
@@ -240,7 +240,7 @@
 // then, we just display the info
 ?>
 	<td class="small <?php echo $program->class ?>" colspan="<?php echo $timeslots_used?>" valign="top"><?
-		$mouseover = 'onmouseover="window.status=\''.date('g:ia', $program->starttime).' - '.date('g:ia', $program->endtime).' -- '
+		$mouseover = 'onmouseover="window.status=\''.date(time_format, $program->starttime).' - '.date(time_format, $program->endtime).' -- '
 					 .str_replace(array("'", '"'),array("\\'", '&quot;'), $program->title)
 					 .($program->subtitle ? ':  '.str_replace(array("'", '"'),array("\\'", '&quot;'), $program->subtitle)
 					 					  : '')
Index: mythweb2/themes/Default/recorded_programs.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb2/themes/Default/recorded_programs.php,v
retrieving revision 1.12
diff -u -r1.12 recorded_programs.php
--- mythweb2/themes/Default/recorded_programs.php	20 Aug 2003 15:04:49 -0000	1.12
+++ mythweb2/themes/Default/recorded_programs.php	20 Aug 2003 19:03:12 -0000
@@ -95,7 +95,7 @@
 	<td><?php echo $show->subtitle?></td>
 	<td><?php echo $show->description?></td>
 	<td><?php echo $show->channame?></td>
-	<td nowrap><?php echo date('D, M j,Y (g:i A)', $show->starttime)?></td>
+	<td nowrap><?php echo date(longdate_format, $show->starttime)?></td>
 	<td nowrap><?php echo nice_length($show->length)?></td>
 	<td nowrap><?php echo nice_filesize($show->filesize)?></td>
 <?php	if ($show->endtime > time()) { ?>
@@ -119,4 +119,4 @@
 
 }
 
-?>
\ No newline at end of file
+?>
Index: mythweb2/themes/Default/scheduled_recordings.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb2/themes/Default/scheduled_recordings.php,v
retrieving revision 1.6
diff -u -r1.6 scheduled_recordings.php
--- mythweb2/themes/Default/scheduled_recordings.php	7 Aug 2003 04:28:24 -0000	1.6
+++ mythweb2/themes/Default/scheduled_recordings.php	20 Aug 2003 19:03:12 -0000
@@ -59,7 +59,7 @@
 	<td><table class=\"menu small\" cellpadding=\"2\" cellspacing=\"0\">
 		<tr>
 			<td align=\"right\">Airtime:</td>
-			<td>".date('D, M j, g:i A', $show->starttime).' to '.date('g:i A', $show->endtime)."</td>
+			<td>".date(longdate_format, $show->starttime).' to '.date(time_format, $show->endtime)."</td>
 		</tr><tr>
 			<td align=\"right\">Program:</td>
 			<td>$show->title</td>
@@ -114,7 +114,7 @@
 			 .'</a>';
 		?></td>
 	<td><?=$show->channel->name?></td>
-	<td nowrap><?=date('D, M j (g:i A)', $show->starttime)?></td>
+	<td nowrap><?=date(longdate_format, $show->starttime)?></td>
 	<td nowrap><?=nice_length($show->length)?></td>
 <?	if ($command) { ?>
 	<td width="5%" class="command command_border_l command_border_t command_border_b command_border_r" align="center"><?=$command?></td>
@@ -133,4 +133,4 @@
 
 }
 
-?>
\ No newline at end of file
+?>
Index: mythweb2/themes/Default/search.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb2/themes/Default/search.php,v
retrieving revision 1.4
diff -u -r1.4 search.php
--- mythweb2/themes/Default/search.php	7 Aug 2003 04:28:24 -0000	1.4
+++ mythweb2/themes/Default/search.php	20 Aug 2003 19:03:12 -0000
@@ -80,7 +80,7 @@
 	<td><?php echo $show->subtitle?></td>
 	<td><?php echo $show->description?></td>
 	<td><?php echo $show->channel->name?></td>
-	<td nowrap><?php echo date('D, M j (g:i A)', $show->starttime)?></td>
+	<td nowrap><?php echo date(longdate_format, $show->starttime)?></td>
 	<td nowrap><?php echo nice_length($show->length)?></td>
 </tr><?php
 			$row++;


More information about the mythtv-dev mailing list