/* * Copyright (c) 1994, 1995, 1996 Gunther Schadow. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* NAME * * mtime -- report the last modification time of a file * * SYNOPSIS * * mtime file [ strftime-format ] */ #include #include #include #include int main(int argc, char *argv[]) { struct stat statbuf; char strbuf[1024]; char *file = argv[1]; char *format; switch(argc) { case 2: format = "%D"; break; case 3: format = argv[2]; break; default: fprintf(stderr, "usage: %s file [ strftime-format ]\n", argv[0]); exit(1); } if(stat(file, &statbuf) == -1) { perror(file); exit(1); } strftime(strbuf, 1024, format, localtime(&statbuf.st_mtime)); puts(strbuf); return 0; }