[Devel] r170 - trunk

svn at agendadulibre.org svn at agendadulibre.org
Mar 2 Mai 19:28:28 CEST 2006


Author: thomas
Date: Tue May  2 19:28:26 2006
New Revision: 170

Modified:
   trunk/funcs.inc.php

Log:

 * funcs.inc.php:

  - Amélioration de l'affichage des dates de début et de fin. Le
  jour n'est affichée qu'une seule fois si le début et la fin d'un
  évènement sont le même jour.

  Patch proposé par David Mentré.



Modified: trunk/funcs.inc.php
==============================================================================
--- trunk/funcs.inc.php	(original)
+++ trunk/funcs.inc.php	Tue May  2 19:28:26 2006
@@ -138,6 +138,16 @@
   return strftime ("%A %d %B %Y %Hh%M", $timestamp);
 }
 
+function onlyday_timestamp2humanreadable($timestamp)
+{
+  return strftime ("%A %d %B %Y", $timestamp);
+}
+
+function onlyhour_timestamp2humanreadable($timestamp)
+{
+  return strftime ("%Hh%M", $timestamp);
+}
+
 function date_month2string($month)
 {
   return strftime("%B", mktime(0,0,0,$month,1));
@@ -438,17 +448,25 @@
                        $moderation = FALSE)
 {
   $title       = stripslashes($title);
-  $start       = date_timestamp2humanreadable($start);
-  $end         = date_timestamp2humanreadable($end);
   $region      = stripslashes(region_find($db, $region));
   $city        = stripslashes($city);
   $description = stripslashes($description);
   $url         = stripslashes($url);
   $contact     = scramble_email(stripslashes($contact));
 
+  $start_day = onlyday_timestamp2humanreadable($start);
+  if ($start_day == onlyday_timestamp2humanreadable($end)) {
+    $date = "<p>Le " .  $start_day . ", de " 
+      . onlyhour_timestamp2humanreadable($start) . " à "
+      . onlyhour_timestamp2humanreadable($end) . ".</p>\n";
+  } else {
+    $date = "<p>Du " . date_timestamp2humanreadable($start)
+      . " au " . date_timestamp2humanreadable($end) . ".</p>\n";
+  }
+
   $result  = "<h2><i>" . $city . "</i> : " . $title . "</h2>\n\n";
   $result .= "<h3>Date et lieu</h3>\n";
-  $result .= "<p>Du " . $start . " au " . $end . "</p>\n";
+  $result .= $date;
   $result .= "<p>À <i><a href=\"http://fr.wikipedia.org/wiki/" . $city . "\">" . $city . "</a></i>, <a href=\"http://fr.wikipedia.org/wiki/" . $region . "\">" . $region . "</a></p>\n\n";
   $result .= "<h3>Description</h3>\n";
   $result .= $description . "\n\n";


Plus d'informations sur la liste de diffusion Devel