1 /* Implement timing-related runtime actions for CHILL.
2 Copyright (C) 1992,1993 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* As a special exception, if you link this library with other files,
23 some of which are compiled with GCC, to produce an executable,
24 this library does not by itself cause the resulting executable
25 to be covered by the GNU General Public License.
26 This exception does not however invalidate any other reasons why
27 the executable file might be covered by the GNU General Public License. */
32 EXCEPTION (rangefail
);
34 #define SECOND_VALID 1
35 #define MINUTE_VALID 2
38 #define MONTH_VALID 16
41 extern void __cause_ex1 (char *ex
, char *file
, int lineno
);
43 #define CAUSE_RANGEFAIL __cause_ex1 ("rangefail", filename, lineno)
49 * mask - mask of valid values
64 * perform the ABSTIME builtin call
69 _abstime (mask
, year
, month
, day
, hour
, minute
, second
,
71 int mask
, year
, month
, day
, hour
, minute
, second
;
76 time_t result
, current_time
;
78 /* first of all get current time */
79 if ((current_time
= time (0)) == (time_t)-1)
80 /* FIXME: what excpetion ?? */
83 /* if we just have to determine the current time, we are ready.
84 This is shown by mask == 0. */
86 return (unsigned long)current_time
;
88 /* convert current time to struct tm */
89 time_str
= localtime (¤t_time
);
91 if (mask
& YEAR_VALID
)
95 time_str
->tm_year
= year
- 1900;
98 if (mask
& MONTH_VALID
)
100 if (month
< 1 || month
> 12)
102 time_str
->tm_mon
= month
- 1;
105 if (mask
& DAY_VALID
)
107 if (day
< 1 || day
> 31)
109 time_str
->tm_mday
= day
;
112 if (mask
& HOUR_VALID
)
114 if (hour
< 0 || hour
> 23)
116 time_str
->tm_hour
= hour
;
119 if (mask
& MINUTE_VALID
)
121 if (minute
< 0 || minute
> 59)
123 time_str
->tm_min
= minute
;
126 if (mask
& SECOND_VALID
)
128 if (second
< 0 || second
> 59)
130 time_str
->tm_sec
= second
;
134 time_str
->tm_isdst
= -1;
135 if ((result
= mktime (time_str
)) == (time_t)-1)
138 return (unsigned long)result
;