1 # Copyright 2002-2007 Interchange Development Group and others
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version. See the LICENSE file for details.
8 # $Id: db_date.tag,v 1.4 2007-03-30 23:40:56 pajamian Exp $
10 # [db-date table format]
12 # This tag returns the last-modified time of a database table,
13 # 'products' by default. Accepts a POSIX strftime value for
14 # date format; uses '%A %d %b %Y' by default.
16 UserTag db-date Order table format
17 UserTag db-date PosNumber 2
18 UserTag db-date Version $Revision: 1.4 $
19 UserTag db-date Routine <<EOF
21 my ($db, $format) = @_;
24 # use defaults if necessary
25 $db = 'products' unless $db;
26 $format = '%A %d %b %Y' unless $format;
28 # build database file name
29 $dbfile = $Vend::Cfg->{ProductDir} . '/'
30 . $Vend::Cfg->{Database}{$db}{'file'};
32 # get last modified time
33 $mtime = (stat ($dbfile))[9];
35 if (defined ($mtime)) {
36 return POSIX::strftime($format, localtime($mtime));
38 logError ("Couldn't stat $dbfile: $!\n");