- Drop magic_quote_gpc (DB API takes care of it itself). -MC
- Drop cache algorithm (was complex for no gain). -MC
- Enhancements wrt COOKIE. -MC
+ - More homogenous date formating (use %x / %X everywhere). -MC
* Contacts :
- Brand new PDF of the contact list (using FPDF). -MC
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-function smarty_modifier_date_format($string, $format="%d %b %Y", $default_date=null)
+function smarty_modifier_date_format($string, $format = '%x', $default_date=null)
{
- require_once('Date.php');
- if($string != '') {
- $date = new Date($string);
- return $date->format($format);
- } elseif (!empty($default_date)) {
- $date = new Date($default_date);
- return $date->format($format);
+ if (empty($format) && empty($default_date)) return;
+ $f = empty($format) ? $default_date : $format;
+ $f = str_replace('%X', '%T', str_replace('%x', '%d %B %Y', $f));
+
+ if ( ($t = strtotime($string)) != -1 ) {
+ return strftime($f , $t);
} else {
- return;
+ require_once('Date.php');
+ $date = new Date($string);
+ return $date->format($f);
}
}
{$user.forlife}
{/if}
</td>
- <td>{$user.expire|date_format:"%d %b %Y"}</td>
+ <td>{$user.expire|date_format}</td>
<td>
<a href="{"fiche.php"|url}?user={$user.forlife}" class='popup2'>fiche</a>
<a href="utilisateurs.php?login={$user.forlife}">edit</a>
</tr>
{foreach item=nl from=$nl_list}
<tr class="{cycle values="pair,impair"}">
- <td>{$nl.date|date_format:"%Y-%m-%d"}</td>
+ <td>{$nl.date|date_format}</td>
<td>
<a href="{"admin/newsletter_edit.php"|url}?nid={$nl.id}">{$nl.titre|default:"[no title]"}</a>
</td>
<td>
<input type="radio" name='best' {if $a.best}checked="checked"{/if} value='{$a.alias}' onclick="this.form.submit()" />
{if $a.for_life}<strong>{$a.alias}</strong>{else}{$a.alias}{/if}
- {if $a.expire}<span class='erreur'>(expire le {$a.expire|date_format:"%d %b %Y"})</span>{/if}
+ {if $a.expire}<span class='erreur'>(expire le {$a.expire|date_format})</span>{/if}
</td>
{if $a.for_life}
<td>garanti à vie*</td>
{foreach from=$emails item=mail}
{if $email->panne && $email->panne neq "0000-00-00"}
<p class="erreur">
-Panne pour l'email "{$mail->email}" le {$mail->panne|date_format:"%d %b %Y"}
+Panne pour l'email "{$mail->email}" le {$mail->panne|date_format}
</p>
{/if}
{/foreach}
{/if}
</td>
<td style="width:25%">
- {$promo[row].date|date_format:"%d %b. %Y"}
+ {$promo[row].date|date_format}
</td>
</tr>
{/section}
{foreach from=$aliases item=a}
<input type='radio' {if $a.best}checked="checked"{/if} name='best' value='{$a.alias}' onclick='this.form.submit()' />
{if $a.a_vie}(*){/if} <strong>{$a.alias}</strong>@{#globals.mail.domain#} et @{#globals.mail.domain2#}
- {if $a.expire}<span class='erreur'>(expire le {$a.expire|date_format:"%d %b %Y"})</span>{/if}
+ {if $a.expire}<span class='erreur'>(expire le {$a.expire|date_format})</span>{/if}
<br />
{/foreach}
</div>
{foreach from=$alias item=a}
<li>
<strong>{$a.alias}@{#globals.mail.domain#}</strong>
- {if $a.expire}<span class='erreur'>(expire le {$a.expire|date_format:"%d %b %Y"})</span>{/if}
+ {if $a.expire}<span class='erreur'>(expire le {$a.expire|date_format})</span>{/if}
</li>
{/foreach}
</ul>
{else}
de toutes les promotions
{/if}
-et sera affiché sur la page d'accueil jusqu'au {$peremption|date_format:"%e %b %Y"}
+et sera affiché sur la page d'accueil jusqu'au {$peremption|date_format}
</p>
{if $validation_message}
</div>
<div class='maj'>
Fiche mise à jour<br />
- le {$x.date|date_format:"%d %b. %Y"}
+ le {$x.date|date_format}
</div>
<div class="contact">
<div class='email'>
{if $x.dcd}
- Décédé{if $x.sexe}e{/if} le {$x.deces|date_format:"%d %B %Y"}
+ Décédé{if $x.sexe}e{/if} le {$x.deces|date_format}
{elseif !$x.inscrit}
Le compte de cette personne n'est pas actif (personne non inscrite ou exclue).
{else}
</tr>
<tr class="impair">
<td class="titre">Péremption</td>
- <td>{$valid->peremption|date_format:"%d %B %Y"}</td>
+ <td>{$valid->peremption|date_format}</td>
</tr>
<tr class="impair">
<td class="titre">Promos</td>
{if !$c.inscrit || $c.dcd}<div class='grayed'>{/if}
-<div class="contact" {if $c.inscrit}{min_auth level='cookie'}title="fiche mise à jour le {$c.date|date_format:"%d %b %Y"}"{/min_auth}{/if}>
+<div class="contact" {if $c.inscrit}{min_auth level='cookie'}title="fiche mise à jour le {$c.date|date_format}"{/min_auth}{/if}>
<div class="nom">
{if $c.sexe}•{/if}
{min_auth level="cookie"}
{/if}
(X {$c.promo}{if $c.app0text}, {applis_fmt type=$c.app0type text=$c.app0text url=$c.app0url}
{/if}{if $c.app1text}, {applis_fmt type=$c.app1type text=$c.app1text url=$c.app1url}{/if})
- {if $c.dcd}décédé{if $c.sexe}e{/if} le {$c.deces|date_format:"%d %b. %Y"}{/if}
+ {if $c.dcd}décédé{if $c.sexe}e{/if} le {$c.deces|date_format}{/if}
{min_auth level="cookie"}
{if !$c.dcd && !$c.wasinscrit}
<a href="{"marketing/public.php"|url}?num={$c.matricule}" class='popup'>clique ici si tu connais son adresse email !</a>
<td>{$m.sender}</td>
<td>{$m.subj|default:"[pas de sujet]"}</td>
<td class='right'>{$m.size}o</td>
- <td class='right'>{$m.stamp|date_format:"%H:%M:%S<br />%d %b %Y"}</td>
+ <td class='right'>{$m.stamp|date_format:"%X<br />%x"}</td>
<td class='action'>
<a href='?liste={$smarty.request.liste}&mid={$m.id}'>voir</a>
<a href='?liste={$smarty.request.liste}&mid={$m.id}&mok=1'>accepter</a><br />
</tr>
<tr>
<td class='titre'>date</td>
- <td>{$mail.stamp|date_format:"%H:%M:%S le %d %b %Y"}</td>
+ <td>{$mail.stamp|date_format:"%X le %x"}</td>
</tr>
</table>
</tr>
{foreach from=$events item=myevent}
<tr class="{cycle values="impair,pair"}">
- <td style="font-size:90%;">{$myevent.stamp|date_format:"%Y-%m-%d %H:%M:%S"}</td>
+ <td style="font-size:90%;">{$myevent.stamp|date_format:"%x %X"}</td>
<td><strong>{$myevent.text}</strong></td>
<td>{$myevent.data}</td>
</tr>
</tr>
{foreach from=$sessions item=mysess}
<tr class="{cycle values="impair,pair"}">
- <td>{$mysess.start|date_format:"%Y-%m-%d %H:%M:%S"}</td>
+ <td>{$mysess.start|date_format:"%x %X"}</td>
<td><strong>{$mysess.username}</strong> <span class="smaller">({$mysess.lauth})</span></td>
<td>
{foreach from=$mysess.events item=myevent}{$myevent}<br />{/foreach}
<div class="smaller">
Ta connexion précédente date du
- <strong>{$smarty.session.lastlogin|date_format:"%x, %T"}</strong>
+ <strong>{$smarty.session.lastlogin|date_format:"%x, %X"}</strong>
depuis la machine <strong>{$smarty.session.host}</strong>
</div>
{if $fiche_incitation}
<p>La dernière mise à jour de ta
<a href="{"fiche.php"|url}?user={$smarty.session.forlife}" class="popup2">fiche</a>
- date du {$fiche_incitation|date_format:"%x"}.
+ date du {$fiche_incitation|date_format}.
Il est possible qu'elle ne soit pas à jour.
Si tu souhaites la modifier, <a href="profil.php">clique ici !</a>
</p>
</tr>
{foreach from=$recents item=it}
<tr class="{cycle values="pair,impair"}">
- <td>{$it.date_envoi|date_format:"%e %b %y"}</td>
+ <td>{$it.date_envoi|date_format}</td>
<td>{$it.sender|lower|truncate:8:""}</td>
<td>
<a href="mailto:{$it.email}" title="{$it.email}">{$it.nom} {$it.prenom}</a>
(x<a href="promo.php?promo={$it.promo}">{$it.promo}</a>)
</td>
- <td>{$it.date_succes|date_format:"%e %b %y"}</td>
+ <td>{$it.date_succes|date_format}</td>
</tr>
{/foreach}
</table>
</tr>
{foreach from=$notsub item=it}
<tr class="{cycle values="pair,impair"}">
- <td>{$it.date_envoi|date_format:"%e %b %y"}</td>
+ <td>{$it.date_envoi|date_format}</td>
<td>{$it.sender|lower|truncate:8:""}</td>
<td>
<a href="mailto:{$it.email}" title="{$it.email}">{$it.nom} {$it.prenom}</a>
</tr>
{foreach item=in from=$ins}
<tr class="{cycle values="impair,pair"}">
- <td class="center">{$in.date_ins|date_format:"%d/%m/%Y - %H:%M"}</td>
+ <td class="center">{$in.date_ins|date_format:"%x %X"}</td>
<td class="center">
<a href="promo.php?promo={$in.promo}">{$in.promo}</a>
</td>
</h1>
<p>
-<strong>Mot de passe enregistré le {$smarty.now|date_format:"%x"}</strong>
+<strong>Mot de passe enregistré le {$smarty.now|date_format}</strong>
</p>
<p>
<strong>Attention!</strong> Il est crypté irréversiblement,
</tr>
{foreach item=nl from=$nl_list}
<tr class="{cycle values="impair,pair"}">
- <td>{$nl.date|date_format:"%d %b %Y"}</td>
+ <td>{$nl.date|date_format}</td>
<td>
<a href="{"newsletter/show.php"|url}?nid={$nl.id}">{$nl.titre}</a>
</td>
***************************************************************************}
<h1>
- Lettre de Polytechnique.org du {$nl->_date|date_format:"%d %B %Y"}
+ Lettre de Polytechnique.org du {$nl->_date|date_format}
</h1>
<p>
</td>
<td class="skimilieu">
<strong>{$skin.name}</strong>
- ajoutée le {$skin.date|date_format:"%x"}<br />
+ ajoutée le {$skin.date|date_format}<br />
{$skin.comment}
<br /><br />
Créée par <strong>{$skin.auteur}</strong>
</tr>
<tr class="pair">
<td class="titre">début</td>
- <td>{$cp.debut|date_format:"%d/%m/%Y, %Hh%M"}</td>
+ <td>{$cp.debut|date_format:"%x %X"}</td>
</tr>
<tr class="pair">
<td class="titre">durée</td>
<tr class="{cycle values="pair,impair"}">
<td>
<span class="smaller">
- {$cp.debut|date_format:"%d/%m/%Y"}
+ {$cp.debut|date_format}
</span>
</td>
<td>
{if $myval.sum}
<td>
{if $myval.type=="timestamp"}
- <span class="smaller">{$myarr.$mykey|date_format:"%Y-%m-%d %H:%M:%S"}</span>
+ <span class="smaller">{$myarr.$mykey|date_format:"%x %X"}</span>
{elseif $myval.type=="set" and $myval.trans}
{$myval.trans[$myval.value]}
{elseif $myval.type=="ext"}
{elseif $myval.type=="ext"}
{extval table=$table field=$mykey name="$prefix$mykey" vtable=$myval.vtable vjoinid=$myval.vjoinid vfield=$myval.vfield selected=$myval.value}
{elseif $myval.type=="timestamp"}
- <input type="text" name="{$prefix}{$mykey}" value="{$myval.value|date_format:"%Y-%m-%d %H:%M:%S"}" />
+ <input type="text" name="{$prefix}{$mykey}" value="{$myval.value|date_format:"%x %X"}" />
{elseif $myval.type=="password"}
<input type="password" name="{$prefix}{$mykey}" size="40" />
{else}
<h1>Récupération de mot de passe</h1>
<p>
-<strong>Mot de passe enregistré le {$smarty.now|date_format:"%x"}</strong>
+<strong>Mot de passe enregistré le {$smarty.now|date_format}</strong>
</p>
<p>
Cette procédure n'est pas sécurisée. Ton mot de passe est certes crypté, mais le
<tr>
<td>Date (DD/MM/YYYY)</td>
<td><input type="text" name="op_date" size="40"
- value="{$op_date|date_format:"%d/%m/%Y"}" /></td>
+ value="{$op_date|date_format}" /></td>
</tr>
<tr>
<td>Description libre</td>
{foreach item=op from=$ops}
<tr class="{cycle values="pair,impair"}">
<td>{$op.id}</td>
- <td>{$op.date|date_format:"%d/%m/%Y"}</td>
+ <td>{$op.date|date_format}</td>
<td>{$op.label}</td>
<td class="right">{$op.debit}</td>
<td class="right">{$op.credit}</td>
</tr>
{foreach item=op from=$ops}
<tr class="{cycle values="impair,pair"}">
- <td>{$op.date|date_format:"%d/%m/%Y"}</td>
+ <td>{$op.date|date_format}</td>
<td>{$op.label}</td>
<td class="right">{$op.debit}</td>
<td class="right">{$op.credit}</td>