File Coverage

blib/lib/App/PS1/Plugin/Date.pm
Criterion Covered Total %
statement 9 17 52.9
branch 0 2 0.0
condition 0 3 0.0
subroutine 3 4 75.0
pod 1 1 100.0
total 13 27 48.1


line stmt bran cond sub pod time code
1             package App::PS1::Plugin::Date;
2              
3             # Created on: 2011-06-21 09:48:24
4             # Create by: Ivan Wills
5             # $Id$
6             # $Revision$, $HeadURL$, $Date$
7             # $Revision$, $Source$, $Date$
8              
9 1     1   1483 use strict;
  1         3  
  1         37  
10 1     1   7 use warnings;
  1         3  
  1         37  
11 1     1   7 use English qw/ -no_match_vars /;
  1         2  
  1         12  
12              
13             our $VERSION = 0.08;
14              
15             sub date {
16 0     0 1   my ($self, $options) = @_;
17              
18 0           my ($sec,$min,$hour,$mday,$mon,$year) = localtime(time);
19 0           $year += 1900;
20 0           $mon++;
21 0           my $date = sprintf "%04d-%02d-%02d", $year, $mon, $mday;
22 0 0 0       if ( $self->cols && $self->cols > 60 ) {
23 0           $date .= sprintf " %02d:%02d:%02d", $hour, $min, $sec;
24             }
25              
26 0           return $self->surround( length $date, $self->colour('date') . $date );
27             }
28              
29             1;
30              
31             __END__
32              
33             =head1 NAME
34              
35             App::PS1::Plugin::Date - Adds the current date to prompt
36              
37             =head1 VERSION
38              
39             This documentation refers to App::PS1::Plugin::Date version 0.08.
40              
41             =head1 SYNOPSIS
42              
43             use App::PS1::Plugin::Date;
44              
45             # Brief but working code example(s) here showing the most common usage(s)
46             # This section will be as far as many users bother reading, so make it as
47             # educational and exemplary as possible.
48              
49              
50             =head1 DESCRIPTION
51              
52             =head1 SUBROUTINES/METHODS
53              
54             =head3 C<date ()>
55              
56             The current date and time
57              
58             =head1 DIAGNOSTICS
59              
60             =head1 CONFIGURATION AND ENVIRONMENT
61              
62             =head1 DEPENDENCIES
63              
64             =head1 INCOMPATIBILITIES
65              
66             =head1 BUGS AND LIMITATIONS
67              
68             There are no known bugs in this module.
69              
70             Please report problems to Ivan Wills (ivan.wills@gmail.com).
71              
72             Patches are welcome.
73              
74             =head1 AUTHOR
75              
76             Ivan Wills - (ivan.wills@gmail.com)
77              
78             =head1 LICENSE AND COPYRIGHT
79              
80             Copyright (c) 2011 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW, Australia 2077)
81             All rights reserved.
82              
83             This module is free software; you can redistribute it and/or modify it under
84             the same terms as Perl itself. See L<perlartistic>. This program is
85             distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
86             without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
87             PARTICULAR PURPOSE.
88              
89             =cut