/* * u2ltime * * $Id: u2ltime.c,v 1.3 2002/07/16 21:40:38 johan Exp $ * * u2ltime converts "UNIX time" (seconds since 00:00 1 Jan. 1970 UTC) to * the "local" system time. If integer arguments are supplied, their * equivalent local times are supplied. If run without arguments, it * displays the current times. * * u2ltime was orignally written in anticipation of the billionth * UNIX second. * * u2ltime has been compiled and tested on: * SunOS 5.[78] * NetBSD 1.[45] * * (C) 2001-2002 Johan van Zanten * johan@giantfoo.org * http://www.giantfoo.org/~johan * 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. * The GPL can be found at http://www.fsf.org/copyleft/gpl.html * Unlimited License to use this program is granted to anyone who * wants it. */ #include #include #include printtime(long seconds) { long *tp; tp = &seconds; /* printf("%10i == %s", seconds, ctime(tp)); */ printf("%s", ctime(tp)); } main(int argc, char *argv[]){ int i; long secs; struct timeval tv; struct timezone dtz; if (argc < 2) { gettimeofday(&tv, &dtz); printtime(tv.tv_sec); exit(0); } for ( i = 1 ; i < argc ; ++i ) { secs = atol(argv[i]); printtime(secs); } exit(0); }