libtime++: Date and time calculation

◆ main()

int main ( )

Definition at line 136 of file ctlibtime.c.

References arout(), cmptest(), divmultest(), time_Ts::doy, head(), time_Ts::hour, time_Ts::micsec, time_Ts::milsec, time_Ts::minute, time_Ts::second, subaddtest(), subhead(), time_clear(), time_copy(), time_finish(), time_fullyear(), time_getdate(), time_isleapyear(), time_libversion(), time_norm(), time_setdoy(), time_sprint(), and time_Ts::year.

137 {
138  time_Ts date1, date2;
139  timeint day, month, year;
140 
141  date1.year=97;
142  date1.doy=150;
143  date1.hour=12;
144  date1.minute=10;
145  date1.second=9;
146  date1.milsec=123;
147  date1.micsec=456;
148 
149  head("time_libversion");
150  printf("libversion: %f\n",time_libversion());
151 
152  head("time_isleapyear");
153  printf("leap 2000 %d\n",time_isleapyear(2000));
154  printf("leap 1996 %d\n",time_isleapyear(1996));
155  printf("leap 1997 %d\n",time_isleapyear(1997));
156  printf("leap 92 %d\n",time_isleapyear( 92));
157  printf("leap 0 %d\n",time_isleapyear( 0));
158  printf("leap 1900 %d\n",time_isleapyear(1900));
159 
160  head("time_fullyear");
161  year=0;
162  time_fullyear(&year);
163  printf("year 0: %d\n",year);
164  year=15;
165  time_fullyear(&year);
166  printf("year 15: %d\n",year);
167  year=97;
168  time_fullyear(&year);
169  printf("year 97: %d\n",year);
170  year=70;
171  time_fullyear(&year);
172  printf("year 70: %d\n",year);
173  year=100;
174  time_fullyear(&year);
175  printf("year 100: %d\n",year);
176  year=69;
177  time_fullyear(&year);
178  printf("year 69: %d\n",year);
179  year=99 ;
180  time_fullyear(&year);
181  printf("year 99: %d\n",year);
182  year=1831;
183  time_fullyear(&year);
184  printf("year 1831: %d\n",year);
185  year=2061;
186  time_fullyear(&year);
187  printf("year 2061: %d\n",year);
188  time_fullyear(&date1.year);
189  printf("full year: %s\n", time_sprint(date1));
190  date1.year=50;
191  time_fullyear(&date1.year);
192  printf("full year 50: %s\n", time_sprint(date1));
193 
194  head("time_sprint (time_getdate is implicit)");
195  date1.year=97;
196  date1.doy=150;
197  date1.hour=12;
198  date1.minute=10;
199  date1.second=9;
200  date1.milsec=123;
201  date1.micsec=456;
202  arout(date1);
203  printf("date: %s\n", time_sprint(date1));
204  date1.year=96;
205  printf("other year: %s\n", time_sprint(date1));
206  date1.doy=366;
207  printf("last doy (set by doy): %s\n", time_sprint(date1));
208  date1.year=0;
209  date1.doy=12345;
210  printf("relative time value: %s\n", time_sprint(date1));
211 
212  head("time_setdoy");
213  date1.year=97;
214  date1.doy=150;
215  date1.hour=12;
216  date1.minute=10;
217  date1.second=9;
218  date1.milsec=123;
219  date1.micsec=456;
220  time_setdoy(1, 1, &date1);
221  printf("jan first: %s\n", time_sprint(date1));
222  time_setdoy(31, 12, &date1);
223  printf("dec last: %s\n", time_sprint(date1));
224 
225  head("time_clear");
226  time_clear(&date1);
227  arout(date1);
228  printf("after clear: %s\n", time_sprint(date1));
229 
230  head("time_norm");
231  date1.year=96;
232  date1.doy=1;
233  date1.hour=24;
234  date1.minute=60;
235  date1.second=60;
236  date1.milsec=1000;
237  date1.micsec=1000;
238  arout(date1);
239  time_norm(&date1);
240  arout(date1);
241  printf("after norm: %s\n", time_sprint(date1));
242  date1.year=96;
243  date1.doy=1;
244  date1.hour=0;
245  date1.minute=0;
246  date1.second=0;
247  date1.milsec=0;
248  date1.micsec=-1;
249  arout(date1);
250  time_norm(&date1);
251  arout(date1);
252  printf("after norm: %s\n", time_sprint(date1));
253  date1.year=0;
254  date1.doy=5003;
255  date1.hour=24;
256  date1.minute=60;
257  date1.second=60;
258  date1.milsec=1000;
259  date1.micsec=1000;
260  arout(date1);
261  time_norm(&date1);
262  arout(date1);
263  printf("after norm: %s\n", time_sprint(date1));
264  date1.year=0;
265  date1.doy=123;
266  date1.hour=0;
267  date1.minute=0;
268  date1.second=0;
269  date1.milsec=0;
270  date1.micsec=-1;
271  arout(date1);
272  time_norm(&date1);
273  arout(date1);
274  printf("after norm: %s\n", time_sprint(date1));
275 
276  head("time_getdate after time_clear");
277  time_clear(&date1);
278  arout(date1);
279  time_getdate(&day, &month, date1);
280  printf("date after time_clear %d %d\n",day,month);
281 
282  head("time_add and time_sub");
283  date1.year=1997;
284  date1.doy=150;
285  date1.hour=12;
286  date1.minute=34;
287  date1.second=56;
288  date1.milsec=123;
289  date1.micsec=456;
290 
291  subhead("absolute & absolute");
292  time_copy(date1, &date2);
293  date2.year=1999;
294  subaddtest(date1, date2);
295  subaddtest(date2, date1);
296  time_copy(date1, &date2);
297  date2.hour=11;
298  date2.minute=33;
299  date2.second=55;
300  date2.milsec=122;
301  date2.micsec=455;
302  subaddtest(date2, date1);
303  date2.micsec=127;
304  subaddtest(date2, date1);
305 
306  subhead("absolute & relative");
307  time_clear(&date2);
308  date2.doy=12;
309  date2.hour=40;
310  date2.minute=40;
311  date2.second=20;
312  date2.milsec=20;
313  date2.micsec=20;
314  subaddtest(date2, date1);
315  subaddtest(date1, date2);
316 
317  subhead("relative & relative");
318  date1.year=0;
319  date1.doy=1;
320  date1.hour=11;
321  date1.minute=12;
322  date1.second=13;
323  date1.milsec=14;
324  date1.micsec=15;
325  subaddtest(date2, date1);
326  subaddtest(date1, date2);
327 
328  head("time_copy");
329  date1.year=1997;
330  date1.doy=150;
331  date1.hour=12;
332  date1.minute=34;
333  date1.second=56;
334  date1.milsec=123;
335  date1.micsec=456;
336  time_clear(&date2);
337  printf("date1: %s\n", time_sprint(date1));
338  printf("date2 after clear: %s\n", time_sprint(date2));
339  time_copy(date1, &date2);
340  printf("date2 after copy: %s\n", time_sprint(date2));
341 
342  head("time_finish");
343  date1.year=57;
344  date1.doy=450;
345  date1.hour=12;
346  date1.minute=0;
347  date1.second=4781;
348  date1.milsec=0;
349  date1.micsec=45456;
350  arout(date1);
351  time_finish(&date1);
352  arout(date1);
353 
354  head("time_compare");
355  date1.year=1997;
356  date1.doy=150;
357  date1.hour=12;
358  date1.minute=34;
359  date1.second=56;
360  date1.milsec=123;
361  date1.micsec=456;
362  time_copy(date1, &date2);
363  cmptest(date1, date2);
364  date1.doy=146;
365  cmptest(date1, date2);
366  date1.year=0;
367  date1.doy=5667;
368  time_copy(date1, &date2);
369  date2.minute=12;
370  date2.second=45;
371  cmptest(date1, date2);
372 
373  head("time_mul and time_div and time_nfit");
374  date1.year=0;
375  date1.doy=0;
376  date1.hour=0;
377  date1.minute=0;
378  date1.second=1;
379  date1.milsec=2;
380  date1.micsec=3;
381  time_copy(date1, &date2);
382  date1.second=0;
383  date1.milsec=1;
384  date1.micsec=500;
385  divmultest(date1, 5, date2);
386  divmultest(date1, 8567, date2);
387  divmultest(date1, 2658567, date2);
388 } /* main */
integer time_isleapyear(timeint year)
integer milsec
Definition: libtime.h:127
char * time_sprint(time_Ts Date)
Definition: ctime_sprint.c:39
integer minute
Definition: libtime.h:125
integer hour
Definition: libtime.h:124
void head(char *routine)
Definition: ctlibtime.c:54
void divmultest(time_Ts date1, long int n, time_Ts date2)
Definition: ctlibtime.c:91
integer doy
Definition: libtime.h:123
void subhead(char *routine)
Definition: ctlibtime.c:60
void time_getdate(timeint *day, timeint *month, time_Ts Date)
Definition: ctime_getdate.c:36
void subaddtest(time_Ts date1, time_Ts date2)
Definition: ctlibtime.c:36
double time_libversion()
void time_setdoy(timeint day, timeint month, time_Ts *Pdate)
Definition: ctime_setdoy.c:36
void time_clear(time_Ts *Pdate)
Definition: ctime_clear.c:33
void time_copy(time_Ts Date1, time_Ts *Pdate2)
Definition: ctime_copy.c:33
void time_norm(time_Ts *Pdate)
Definition: ctime_norm.c:33
void time_fullyear(timeint *year)
integer second
Definition: libtime.h:126
void arout(time_Ts Date)
Definition: ctlibtime.c:66
integer year
Definition: libtime.h:122
integer timeint
Definition: libtime.h:77
void time_finish(time_Ts *Pdate)
Definition: ctime_finish.c:33
integer micsec
Definition: libtime.h:128
void cmptest(time_Ts date1, time_Ts date2)
Definition: ctlibtime.c:77
Here is the call graph for this function: