开发者

How can I switch timezones in Perl's Template::Plugin::Date?

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 ar开发者_高级运维e 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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜