File Coverage

blib/lib/Dotiac/DTL/Tag/now.pm
Criterion Covered Total %
statement 50 55 90.9
branch 3 6 50.0
condition 2 6 33.3
subroutine 11 13 84.6
pod 10 10 100.0
total 76 90 84.4


line stmt bran cond sub pod time code
1             #now.pm
2             #Last Change: 2009-01-19
3             #Copyright (c) 2009 Marc-Seabstian "Maluku" Lucksch
4             #Version 0.8
5             ####################
6             #This file is part of the Dotiac::DTL project.
7             #http://search.cpan.org/perldoc?Dotiac::DTL
8             #
9             #now.pm is published under the terms of the MIT license, which basically
10             #means "Do with it whatever you want". For more information, see the
11             #license.txt file that should be enclosed with libsofu distributions. A copy of
12             #the license is (at the time of writing) also available at
13             #http://www.opensource.org/licenses/mit-license.php .
14             ###############################################################################
15            
16             package Dotiac::DTL::Tag::now;
17 11     11   67 use base qw/Dotiac::DTL::Tag/;
  11         20  
  11         929  
18 11     11   63 use strict;
  11         26  
  11         330  
19 11     11   64 use warnings;
  11         22  
  11         8714  
20            
21             our $VERSION = 0.8;
22            
23             sub new {
24 1     1 1 3 my $class=shift;
25 1         4 my $self={p=>shift()};
26 1         4 bless $self,$class;
27 1         6 $self->{format}=(Dotiac::DTL::get_variables(shift()))[0];
28 1         5 return $self;
29             }
30             sub print {
31 1     1 1 2 my $self=shift;
32 1         4 print $self->{p};
33 1   33     7 print scalar Dotiac::DTL::Filter::date(Dotiac::DTL::Value->safe(time),Dotiac::DTL::devar_raw($self->{format}||$Dotiac::DTL::DATETIME_FORMAT,@_))->string();
34 1         10 $self->{n}->print(@_);
35             }
36             sub string {
37 1     1 1 3 my $self=shift;
38 1   33     6 return $self->{p}.Dotiac::DTL::Filter::date(Dotiac::DTL::Value->safe(time),Dotiac::DTL::devar_raw($self->{format}||$Dotiac::DTL::DATETIME_FORMAT,@_))->string().$self->{n}->string(@_);
39             }
40             sub perl {
41 1     1 1 3 my $self=shift;
42 1         2 my $fh=shift;
43 1         2 my $id=shift;
44 1         18 $self->SUPER::perl($fh,$id,@_);
45 1 50       5 if ($self->{format}) {
46 1         3 print $fh "my ";
47 1         7 print $fh (Data::Dumper->Dump([$self->{format}],["\$format$id"]));
48             }
49 1         45 return $self->{n}->perl($fh,$id+1,@_);
50             }
51             sub perlprint {
52 1     1 1 3 my $self=shift;
53 1         2 my $fh=shift;
54 1         3 my $id=shift;
55 1         2 my $level=shift;
56 1         15 $self->SUPER::perlprint($fh,$id,$level,@_);
57 1 50       8 print $fh "\t" x $level,"print scalar Dotiac::DTL::Filter::date(Dotiac::DTL::Value->safe(time),".($self->{format}?"Dotiac::DTL::devar_raw(\$format$id,\$vars,\$escape,\@_)":"\$Dotiac::DTL::DATETIME_FORMAT").")->string();\n";
58 1         5 return $self->{n}->perlprint($fh,$id+1,$level,@_);
59             }
60             sub perlstring {
61 1     1 1 2 my $self=shift;
62 1         2 my $fh=shift;
63 1         3 my $id=shift;
64 1         2 my $level=shift;
65 1         9 $self->SUPER::perlstring($fh,$id,$level,@_);
66 1 50       21 print $fh "\t" x $level,"\$r.=Dotiac::DTL::Filter::date(Dotiac::DTL::Value->safe(time),".($self->{format}?"Dotiac::DTL::devar_raw(\$format$id,\$vars,\$escape,\@_)":"\$Dotiac::DTL::DATETIME_FORMAT").")->string();\n";
67 1         6 return $self->{n}->perlstring($fh,$id+1,$level,@_);
68             }
69             sub perlcount {
70 0     0 1 0 my $self=shift;
71 0         0 my $id=shift;
72 0         0 return $self->{n}->perlcount($id+1);
73             }
74             sub perleval {
75 1     1 1 2 my $self=shift;
76 1         2 my $fh=shift;
77 1         2 my $id=shift;
78 1         17 return $self->{n}->perleval($fh,$id+1,@_);
79             }
80             sub perlinit {
81 1     1 1 2 my $self=shift;
82 1         2 my $fh=shift;
83 1         2 my $id=shift;
84 1         6 return $self->{n}->perlinit($fh,$id+1,@_);
85             }
86             sub eval {
87 0     0 1   my $self=shift;
88 0           $self->{n}->eval(@_);
89             }
90             1;
91            
92             __END__