Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSContest tool: Add UTC timezone indicators to date and time display #71

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
// Autoload Twig and IntlExtension
require_once __DIR__ . '/vendor/autoload.php'; // Adjust this path as per your directory structure

use Twig\Loader\FilesystemLoader;
use Twig\Environment;
use Twig\Extra\Intl\IntlExtension;

// Set up Twig environment
$loader = new FilesystemLoader(__DIR__ . '/src/templates'); // Adjust this path to your templates directory
$twig = new Environment($loader);
$twig->addExtension(new IntlExtension());

// Example date to render
$date = new \DateTime('now', new \DateTimeZone('UTC'));

// Render template
echo $twig->render('templates/contests_view.html.twig', ['date' => $date]);
22 changes: 22 additions & 0 deletions src/libs/twig-intl-extra/IntlExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
// Autoload Twig
require_once __DIR__ . '/vendor/twig/twig/lib/Twig/Autoloader.php'; // Adjust this path to where Twig is installed
Twig_Autoloader::register();

// Autoload IntlExtension
require_once __DIR__ . '/src/libs/twig-intl-extra/IntlExtension.php'; // Adjust this path as per your directory structure

use Twig\Loader\FilesystemLoader;
use Twig\Environment;
use Twig\Extra\Intl\IntlExtension;

// Set up Twig
$loader = new FilesystemLoader(__DIR__ . '/src/templates'); // Adjust this path to your templates directory
$twig = new Environment($loader);
$twig->addExtension(new IntlExtension());

// Example date to render
$date = new \DateTime('now', new \DateTimeZone('UTC'));

// Render template
echo $twig->render('your_template.html.twig', ['date' => $date]);
4 changes: 2 additions & 2 deletions templates/contests_view.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
{% if contest.privacy == 3 %}{{ msg('privacy-private') }}{% endif %}
</dd>
<dt>{{ msg('dates') }}</dt>
<dd>{{ msg('start-date-label') }} {{ contest.start_date }}</dd>
<dd>{{ msg('end-date-label') }} {{ contest.end_date }}</dd>
<dd>{{ msg('start-date-label') }} {{ contest.start_date|format_datetime('medium', 'medium', null, 'en_US', 'UTC') }}</dd>
<dd>{{ msg('end-date-label') }} {{ contest.end_date|format_datetime('medium', 'medium', null, 'en_US', 'UTC') }}</dd>
<dt>{{ msg('administrators') }}</dt>
<dd>
<ul class="list-inline">
Expand Down
Loading