convtime.c revision 1
1N/A * Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers. 1N/A * All rights reserved. 1N/A * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 1N/A * Copyright (c) 1988, 1993 1N/A * The Regents of the University of California. All rights reserved. 1N/A * By using this file, you agree to the terms and conditions set 1N/A * forth in the LICENSE file which can be found at the top level of 1N/A * the sendmail distribution. 1N/A#
pragma ident "%Z%%M% %I% %E% SMI" 1N/A** CONVTIME -- convert time 1N/A** Takes a time as an ascii string with a trailing character 1N/A** d -- days (default) 1N/A** For example, "3d12h" is three and a half days. 1N/A** p -- pointer to ascii time. 1N/A** units -- default units if none specified. 1N/A t = t *
10 + (c -
'0');
1N/A case 'w':
/* weeks */ 1N/A case 'd':
/* days */ 1N/A case 'h':
/* hours */ 1N/A case 'm':
/* minutes */ 1N/A case 's':
/* seconds */ 1N/A** PINTVL -- produce printable version of a time interval 1N/A** intvl -- the interval to be converted 1N/A** brief -- if true, print this in an extremely compact form 1N/A** (basically used for logging). 1N/A** A pointer to a string version of intvl suitable for 1N/A** printing or framing. 1N/A** The string returned is in a static buffer. 1N/A return "zero seconds";
1N/A /* decode the interval into weeks, days, hours, minutes, seconds */ 1N/A /* now turn it into a sexy form */ 1N/A /* use the verbose form */