views:

75

answers:

2

I have a calendar on my website, generated in Perl using Template::Toolkit and Template::Plugin::Date.

It highlights the current day. I achieve this by iterating through all the dates (as I print the calendar) and comparing against the current date. Something like this:

[% IF cur_date == date.format(format = '%Y-%m-%d') %]
...
[% END %]

It all works well until someone in Australia looks at it. (They are in a different timezone to me and my server in the UK).

What's the best way to get Template::Plugin::Date to use a different time zone? It accepts a 'locale' parameter, but AFAIK this is only used for formatting.

A: 

It doesn't look like you can do it via that plugin.

A rough idea (without seeing code) would be to set a variable that marks the current date for that user while your script loops through the dates (depending on how you pull the dates). That variable would be checked in the template and set a CSS class or ID for that date to highlight it.

Woody2143
+1  A: 

For anything more than very simple dates, you should be using DateTime and/or Template::Plugin::DateTime.

stu42j
perfect. thanks!
aidan