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

Formatting date #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions lib/Dancer/Plugin/DirectoryView.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use Dancer::Plugin;
use DirHandle;
use File::ShareDir;
use File::Spec::Functions qw(catfile);
use HTTP::Date;
use Date::Format;
use URI::Escape;

our $VERSION = '0.02';
Expand Down Expand Up @@ -111,6 +111,9 @@ sub _serve_files {
# Views directory
my $views_dir = abs_path(setting('views'));

# Timeformat for directory-listing
my $timeformat = $options{timeformat} || '%a, %d %b %Y %H:%M:%S %Z';

# Strip off unwanted leading/trailing slashes
$root_dir =~ s!/$!!;
$path =~ s!^/!!;
Expand Down Expand Up @@ -211,7 +214,7 @@ sub _serve_files {
name => $name,
size => $is_dir ? '' : _format_size($stat[7]),
mime_type => $mime_type,
mtime => HTTP::Date::time2str($stat[9]),
mtime => time2str($timeformat, $stat[9]),
class => $classes{$mime_type} || 'file-unknown'
});
}
Expand Down