1 /*---------------------------------------------------------------------------- 2 -- 3 -- Module: TimDate 4 -- 5 -- Project: Tools - General C objects. 6 -- System: Tim - Time and date manipulation. 7 -- Subsystem: <> 8 -- Function block: <> 9 -- 10 -- Description: 11 -- Interface file for module TimDate. 12 -- 13 -- Filename: TimDate.h 14 -- 15 -- Authors: Roger Larsson, Ulrika Bornetun 16 -- Creation date: 1990-11-30 17 -- 18 -- 19 -- (C) Copyright Ulrika Bornetun, Roger Larsson (1995) 20 -- All rights reserved 21 -- 22 -- Permission to use, copy, modify, and distribute this software and its 23 -- documentation for any purpose and without fee is hereby granted, 24 -- provided that the above copyright notice appear in all copies. Ulrika 25 -- Bornetun and Roger Larsson make no representations about the usability 26 -- of this software for any purpose. It is provided "as is" without express 27 -- or implied warranty. 28 ----------------------------------------------------------------------------*/ 29 30 /* SCCS module identifier. */ 31 /* SCCSID = @(#) Module: TimDate.h, Version: 1.1, Date: 95/02/18 14:32:32 */ 32 33 34 /* Only include this module once. */ 35 #ifndef define_TimDate_h 36 # define define_TimDate_h 37 38 39 /*---------------------------------------------------------------------------- 40 -- Include files 41 ----------------------------------------------------------------------------*/ 42 43 #include <time.h> 44 45 46 /*---------------------------------------------------------------------------- 47 -- Macro definitions 48 ----------------------------------------------------------------------------*/ 49 50 #define TIM_NOW -1 51 52 53 /*---------------------------------------------------------------------------- 54 -- Type declarations 55 ----------------------------------------------------------------------------*/ 56 57 typedef time_t TIM_TIME_REF; 58 59 typedef enum { 60 TIM_OK, 61 TIM_ERROR, 62 TIM_YES, 63 TIM_NO 64 } TIM_STATUS_TYPE; 65 66 typedef enum { 67 TIM_KEEP, 68 TIM_NOON, 69 TIM_MIDNIGHT 70 } TIM_DAY_TYPE; 71 72 typedef enum { 73 TIM_START_MONTH, 74 TIM_END_MONTH 75 } TIM_MONTH_TYPE; 76 77 typedef struct { 78 int weeks; 79 int days; 80 int hours; 81 int minutes; 82 int seconds; 83 } TIM_DELTA_TYPE; 84 85 86 /*---------------------------------------------------------------------------- 87 -- Global definitions 88 ----------------------------------------------------------------------------*/ 89 90 91 /*---------------------------------------------------------------------------- 92 -- Function prototypes 93 ----------------------------------------------------------------------------*/ 94 95 void 96 TimAddDays( TIM_TIME_REF *time, int days ); 97 98 void 99 TimAddHours( TIM_TIME_REF *time, int hours ); 100 101 void 102 TimAddMinutes( TIM_TIME_REF *time, int minutes ); 103 104 void 105 TimAddMonths( TIM_TIME_REF *time, int months ); 106 107 void 108 TimAddSeconds( TIM_TIME_REF *time, int seconds ); 109 110 TIM_TIME_REF 111 TimAddTime( TIM_TIME_REF time, 112 TIM_TIME_REF to_time ); 113 114 void 115 TimAddYears( TIM_TIME_REF *time, int years ); 116 117 int 118 TimDaysInMonth( TIM_TIME_REF time ); 119 120 int 121 TimDaysInYear( TIM_TIME_REF time ); 122 123 TIM_STATUS_TYPE 124 TimDelta( TIM_TIME_REF time1, 125 TIM_TIME_REF time2, 126 TIM_DELTA_TYPE *delta ); 127 128 void 129 TimFormatDate( TIM_TIME_REF time, 130 char *buffer, 131 int buffer_size ); 132 133 void 134 TimFormatIsoDate( TIM_TIME_REF time, 135 char *buffer, 136 int buffer_size ); 137 138 void 139 TimFormatFullDate( TIM_TIME_REF time, 140 char *buffer, 141 int buffer_size ); 142 143 void 144 TimFormatFullIsoDate( TIM_TIME_REF time, 145 char *buffer, 146 int buffer_size ); 147 148 void 149 TimFormatTime( TIM_TIME_REF time, 150 char *buffer, 151 int buffer_size ); 152 153 void 154 TimFormatIsoTime( TIM_TIME_REF time, 155 char *buffer, 156 int buffer_size ); 157 158 void 159 TimFormatStrTime( TIM_TIME_REF time, 160 char *format, 161 char *buffer, 162 int buffer_size ); 163 164 int 165 TimHour( TIM_TIME_REF time ); 166 167 int 168 TimIndexOfDay( TIM_TIME_REF time ); 169 170 int 171 TimIndexOfDayInIsoWeek( TIM_TIME_REF time ); 172 173 int 174 TimIndexOfDayInWeek( TIM_TIME_REF time ); 175 176 int 177 TimIndexOfDayInYear( TIM_TIME_REF time ); 178 179 int 180 TimIndexOfFirstDayInWeek(); 181 182 int 183 TimIndexOfMonth( TIM_TIME_REF time ); 184 185 int 186 TimIndexOfIsoWeek( TIM_TIME_REF time ); 187 188 int 189 TimIndexOfWeek( TIM_TIME_REF time ); 190 191 int 192 TimIndexOfYear( TIM_TIME_REF time ); 193 194 TIM_STATUS_TYPE 195 TimInitializeFormat( char *date_format_str, 196 char *time_format_str ); 197 198 TIM_STATUS_TYPE 199 TimIsLeapYear( TIM_TIME_REF time ); 200 201 TIM_STATUS_TYPE 202 TimIsSameDate( TIM_TIME_REF time1, 203 TIM_TIME_REF time2 ); 204 205 TIM_TIME_REF 206 TimLocalTime( TIM_TIME_REF time ); 207 208 TIM_TIME_REF 209 TimMakeTime( int year, 210 int month, 211 int day, 212 int hour, 213 int minute, 214 int second ); 215 216 TIM_STATUS_TYPE 217 TimMakeDateFromString( TIM_TIME_REF *time, 218 char *string ); 219 220 TIM_STATUS_TYPE 221 TimMakeDateFromIsoString( TIM_TIME_REF *time, 222 char *string ); 223 224 TIM_STATUS_TYPE 225 TimMakeTimeFromString( TIM_TIME_REF *time, 226 char *string ); 227 228 TIM_STATUS_TYPE 229 TimMakeTimeFromIsoString( TIM_TIME_REF *time, 230 char *string ); 231 232 TIM_TIME_REF 233 TimMakeTimeNow(); 234 235 TIM_STATUS_TYPE 236 TimMakeTimeFromWeek( int year, 237 int week_number, 238 TIM_TIME_REF *time ); 239 240 int 241 TimMinute( TIM_TIME_REF time ); 242 243 void 244 TimNextDay( TIM_TIME_REF *time, 245 TIM_DAY_TYPE time_of_day ); 246 247 void 248 TimNextMonth( TIM_TIME_REF *time, 249 TIM_MONTH_TYPE day_in_month ); 250 251 void 252 TimPreviousDay( TIM_TIME_REF *time, 253 TIM_DAY_TYPE time_of_day ); 254 255 void 256 TimPreviousMonth( TIM_TIME_REF *time, 257 TIM_MONTH_TYPE day_in_month ); 258 259 int 260 TimSecond( TIM_TIME_REF time ); 261 262 void 263 TimSetUnixWeekNo( Boolean use_unix_week_no ); 264 265 TIM_STATUS_TYPE 266 TimTimeInSecondsRange( TIM_TIME_REF master, 267 TIM_TIME_REF check, 268 int seconds_range ); 269 270 char 271 *TimWhatDateFormat(); 272 273 char 274 *TimWhatTimeFormat(); 275 276 #endif 277