package Gruntmaster::Page::Ct;

use 5.014000;
use strict;
use warnings;
use Gruntmaster::Page::Base ct => 'Contests';
our @ISA = qw/Gruntmaster::Page::Base/;
our $VERSION = '0.001';

sub _generate{
	my ($self, $htc, $lang, $env) = @_;
	debug $env => "language is '$lang'";

	my (@running, @pending, @finished);
	for (contests) {
		my $ct = { id => $_,
				   name => contest_name,
				   start => strftime ('%c', localtime contest_start),
				   end => strftime ('%c', localtime contest_end),
				   owner => contest_owner };

		my $time = time;
		push @pending, $ct if time < contest_start;
		push @running, $ct if time >= contest_start && time < contest_end;
		push @finished, $ct if time > contest_end;
	}

	$htc->param(running => \@running) if @running;
	$htc->param(pending => \@pending) if @pending;
	$htc->param(finished => \@finished) if @finished;
}

1
