How can I switch time zones in Perl Template :: Plugin :: Date?

I have a calendar on my site created in Perl using Template :: Toolkit and Template :: Plugin :: Date .

He highlights the current day. I achieve this by repeating all the dates (when I print the calendar) and comparing them with the current date. Something like that:

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

Everything works well until someone in Australia looks at him. (They are in a different time zone for me and my server in the UK).

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

+3
source share
2 answers

For something more than very simple dates, you should use DateTime and / or Template :: Plugin :: DateTime .

+1
source

It doesn't seem like you can do this through this plugin.

The rough idea (without looking at the code) is to set a variable that marks the current date for this user, while your script goes through the dates (depending on how you pull the dates). This variable will be checked in the template and a CSS class or identifier will be set for this date to highlight it.

0
source

Source: https://habr.com/ru/post/1737403/


All Articles