1 /* @(#)gettnum.c	1.9 09/07/08 Copyright 1984-2002, 2004-2009 J. Schilling */
2 #include <schily/mconfig.h>
3 #ifndef lint
4 static	UConst char sccsid[] =
5 	"@(#)gettnum.c	1.9 09/07/08 Copyright 1984-2002, 2004-2009 J. Schilling";
6 #endif
7 /*
8  *	Generic time conversion routines rewritten from
9  *	'dd' like number conversion in 'sdd'.
10  *
11  *	Copyright (c) 1984-2002, 2004-2009 J. Schilling
12  */
13 /*
14  * The contents of this file are subject to the terms of the
15  * Common Development and Distribution License, Version 1.0 only
16  * (the "License").  You may not use this file except in compliance
17  * with the License.
18  *
19  * See the file CDDL.Schily.txt in this distribution for details.
20  * A copy of the CDDL is also available via the Internet at
21  * http://www.opensource.org/licenses/cddl1.txt
22  *
23  * When distributing Covered Code, include this CDDL HEADER in each
24  * file and include the License file CDDL.Schily.txt from this distribution.
25  */
26 
27 #include <schily/standard.h>
28 #include <schily/utypes.h>
29 #include <schily/time.h>
30 #include <schily/schily.h>
31 
32 #define	MINSECS		(60)
33 #define	HOURSECS	(60  * MINSECS)
34 #define	DAYSECS		(24  * HOURSECS)
35 #define	WEEKSECS	(7   * DAYSECS)
36 #define	YEARSECS	(365 * DAYSECS)		/* A non leap year */
37 
38 
39 EXPORT	int	gettnum		__PR((char *arg, time_t *valp));
40 EXPORT	int	getlltnum	__PR((char *arg, Llong *lvalp));
41 
42 LOCAL gnmult_t	nums[] = {
43 	{ 'y', YEARSECS, },
44 	{ 'w', WEEKSECS, },
45 	{ 'd', DAYSECS, },
46 	{ 'h', HOURSECS, },
47 	{ 'm', MINSECS, },
48 	{ 's', 1, },
49 	{ '\0', 0, },
50 };
51 
52 EXPORT int
gettnum(arg,valp)53 gettnum(arg, valp)
54 	char	*arg;
55 	time_t	*valp;
56 {
57 	return (getxtnum(arg, valp, nums));
58 }
59 
60 EXPORT int
getlltnum(arg,lvalp)61 getlltnum(arg, lvalp)
62 	char	*arg;
63 	Llong	*lvalp;
64 {
65 	return (getllxtnum(arg, lvalp, nums));
66 }
67