# -------------------------------------------------------------------------------------
# flo::HTTP::Date
# -------------------------------------------------------------------------------------
#
#       Author : Jean-Michel Hiver (jhiver@cisedi.com).
#    Copyright : (c) MKDoc Holdings Ltd, 2001
# 
#      Unauthorized modification, use, reuse, distribution or redistribution
#      of this module is stricly forbidden.
#
#    Description :
#
#      Returns an HTTP date given an input in non-leap seconds since the epoch
#      such as time()
#
# -------------------------------------------------------------------------------------
package flo::HTTP::Date;
use strict;


sub http_date
{
    my $localtime = shift || time;
    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime ($localtime);
    my @weekday = qw /Sun Mon Tue Wed Thu Fri Sat/;
    my @month   = qw /Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/;
    $wday = $weekday[$wday];
    $mon  = $month[$mon];
    $year += 1900;
    $mday = '0' . $mday if (length $mday == 1);
    $hour = '0' . $hour if (length $hour == 1);
    $min  = '0' . $min  if (length $min == 1);
    $sec  = '0' . $sec  if (length $sec == 1);
    
    return "$wday, $mday $mon $year $hour:$min:$sec GMT";
}


1;
