Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

RE: [SMARTY] date offset
Hi Travis,

stuff like this really belongs into the business logic, not into the display
logic. The _way_ a date/time is shown is controlled by the display logic,
but not the _value_ of the date/time itself.

Cheers and a Happy New Year to you,

David


> -----Original Message-----
> From: Travis Low [mailto:travis@dawnstar.com]
> Sent: Saturday, January 01, 2005 7:29 AM
> To: smarty-general@lists.php.net
> Subject: [SMARTY] date offset
>
> Happy new year, everyone.
>
> I have a customer in Australia who uses a server in California.  I'd like
> to
> give them a configurable offset value (plus or minus hours) that could be
> used
> to change the time they're seeing.  I know I could muck with the time from
> within the application itself, but ultimately, I think it would be better
> if
> the end-user could set the value, so that (for example) users in different
> timezones can adjust the times to suit their locale.  Here is a hack of
> modifier.date_format.php that seems to work:
>
> function smarty_modifier_date_format($string, $format="%b %e, %Y",
> $offset=0,
> $default_date=null)
> {
>          echo "<h1>$offset</h1>";
>      if($string != '') {
>          return strftime($format, smarty_make_timestamp($string) +
> ($offset*3600));
>      } elseif (isset($default_date) && $default_date != '') {
>          return strftime($format, smarty_make_timestamp($default_date) +
> ($offset*3600));
>      } else {
>          return;
>      }
> }
>
> Unfortunately, I couldn't get it to work without swapping $offset and
> $default_date, and I fear that may break existing code.  Does anyone have
> any
> ideas, and could something like the above be included in the next Smarty
> release?
>
> cheers,
>
> Travis
>
> --
> Travis Low
> <mailto:travis@dawnstar.com>
> <http://www.dawnstar.com>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Report this thread to moderator Post Follow-up to this message
Old Post
David Zülke
01-01-05 01:56 PM


Re: [SMARTY] date offset
Hi David,

I completely disagree.  This is a display function.

Think of it this way: the fact that something happened at 6:00 pm in some ot
her
time zone is meaningless to me.  It doesn't tell me when it REALLY happened,
 in
the time zone that I am familiar with.  I need to adjust the date so it has
meaning for me.  The REAL time is unaffected -- it is simply being interpret
ed.

Similarly, I would have no problem with a temperature conversion routine in 
the
template.  If the temperature is stored in degrees Centigrade, then converti
ng
it to Fahrenheit does not change the meaning of the data in any way -- inste
ad,
it makes the data accessible to me.

It's really no different from interpreting the number 2 as Dienstag in one
locale, and Tuesday in another.

Grüße,

Travis


David Zülke wrote:
> Hi Travis,
>
> stuff like this really belongs into the business logic, not into the displ
ay
> logic. The _way_ a date/time is shown is controlled by the display logic,
> but not the _value_ of the date/time itself.
>
> Cheers and a Happy New Year to you,
>
> David
>
>
> 
>
>

--
Travis Low
<mailto:travis@dawnstar.com>
<http://www.dawnstar.com>

Report this thread to moderator Post Follow-up to this message
Old Post
Travis Low
01-01-05 08:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Smarty Templates archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:40 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.