]> the.earth.li Git - htag.git/blob - plugins/09date
Import Upstream version 0.0.23
[htag.git] / plugins / 09date
1 #!/usr/bin/perl -w
2
3 # Copyright (C) 2000-2003 Simon Huggins
4 # date just calls date.  You may pass in a strftime compatible formatting
5 # string.
6
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the Free
9 # Software Foundation; either version 2 of the License, or (at your option)
10 # any later version.
11 #
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 # for more details.
16 #
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc., 59
19 # Temple Place, Suite 330, Boston, MA 02111-1307  USA
20
21 # Outputs date to tmpdir/D
22 # Therefore replaces @D... in sigs via merge.
23
24 use integer;
25 use strict;
26 use POSIX qw(strftime);
27
28 my @found = scansigfile("D");
29 return if not @found;
30
31 # srand( time() ^ ($$ + ($$ << 15) )); # Since 5.004 not required
32
33 open(OUT, ">$cfg{'tmpdir'}/D") or htagdie "$0: Could not open $cfg{'tmpdir'}/D: $!\n";
34 reg_deletion("$cfg{'tmpdir'}/D");
35 foreach my $f (@found) {
36         my @f = @{$f};
37         my $date = strftime($cfg{'date_format'} ? $cfg{'date_format'} : "%a %b %e %H:%M:%S %Y", localtime);
38         if ($f[1] eq "*") {
39                 print OUT $date,"\n";
40         } elsif (length $date <= $f[1]) {
41                 print OUT chunksizealign($date, $f[1], $f[2]),"\n";
42         } else {
43                 my $diemsg = "Can't fit your chosen date format (";
44                 if (defined $cfg{'date_format'}) {
45                         $diemsg .= $cfg{'date_format'};
46                 } else { 
47                         $diemsg .= "%a %b %e %H:%M:%S %Y";
48                 }
49                 $diemsg .= ") in <= $f[1].\nPerhaps your space isn't big enough.\nAlternatively modify this script to give less information.\n";
50                 htagdie $diemsg;
51         }
52 }
53 close(OUT);
54 return;