libtime++: Date and time calculation

◆ main()

main ( )

Definition at line 29 of file timeutil.c.

References timeutil_Ttime::day, timeutil_Ttime::hour, timeutil_Ttime::min, timeutil_Ttime::month, timeutil_Ttime::msec, timeutil_Ttime::sec, timeutil_add(), timeutil_clear(), timeutil_date(), timeutil_finish(), timeutil_is_leap(), timeutil_print(), timeutil_Ttime::usec, and timeutil_Ttime::year.

30 {
31  timeutil_Ttime time1, time2;
32  char *cptr;
33 
34  timeutil_clear(&time1);
35  timeutil_clear(&time2);
36 
37  time1.year=97;
38  time1.month=4;
39  time1.day=29;
40  time1.hour=12;
41  time1.min=10;
42  time1.sec=9;
43  time1.msec=200;
44  time1.usec=300;
45  printf("time: %s\n", timeutil_print(time1));
46  timeutil_finish(&time1);
47  printf("time: %s\n", timeutil_print(time1));
48 
49  timeutil_date(&time1, 35L);
50  printf("time: %s\n", timeutil_print(time1));
51 
52  printf("leapyear: 1996: %d 1997: %d 2000: %d 1900: %d\n",
53  timeutil_is_leap(1996),
54  timeutil_is_leap(1997),
55  timeutil_is_leap(2000),
56  timeutil_is_leap(1900));
57 
58  timeutil_clear(&time1);
59  printf("time: %s\n", timeutil_print(time1));
60 
61  timeutil_add(&time2, time1, time2);
62  printf("time: %s\n", timeutil_print(time2));
63 
64  timeutil_clear(&time2);
65  time2.hour=12;
66  timeutil_add(&time2, time1, time2);
67  printf("time: %s\n", timeutil_print(time2));
68 
69  timeutil_clear(&time2);
70  time2.hour=34;
71  timeutil_add(&time2, time1, time2);
72  printf("time: %s\n", timeutil_print(time2));
73 
74  timeutil_clear(&time2);
75  time2.hour=1;
76  time2.min=2;
77  time2.sec=3;
78  time2.msec=4;
79  time2.usec=5;
80  timeutil_add(&time2, time1, time2);
81  printf("time: %s\n", timeutil_print(time2));
82 
83  timeutil_clear(&time2);
84  time2.hour=24;
85  time2.min=60;
86  time2.sec=60;
87  time2.msec=1000;
88  time2.usec=1000;
89  timeutil_add(&time2, time1, time2);
90  printf("time: %s\n", timeutil_print(time2));
91 
92  timeutil_clear(&time2);
93  time2.hour=24;
94  time2.min=241;
95  time2.sec=60;
96  time2.msec=1000;
97  time2.usec=1000;
98  timeutil_add(&time2, time1, time2);
99  printf("time: %s\n", timeutil_print(time2));
100 
101  time1.day=29;
102  time1.month=2;
103  time1.year=1997;
104  printf("time: %s\n", timeutil_print(time1));
105 
106  time1.day=29;
107  time1.month=2;
108  time1.year=1996;
109  printf("time: %s\n", timeutil_print(time1));
110 
111  time1.day=30;
112  time1.month=2;
113  time1.year=1996;
114  printf("time: %s\n", timeutil_print(time1));
115 
116  cptr=timeutil_print(time1);
117  cptr[27]='\0';
118  printf("nicetime: %s\n", cptr+4);
119 }
long int month
Definition: timeutil.h:58
void timeutil_date(timeutil_Ttime *td, long int doy)
Definition: timeutil.c:161
long int msec
Definition: timeutil.h:59
int timeutil_is_leap(long int year)
Definition: timeutil.c:137
long int sec
Definition: timeutil.h:59
char * timeutil_print(timeutil_Ttime td)
Definition: timeutil.c:78
void timeutil_finish(timeutil_Ttime *td)
Definition: timeutil.c:95
long int hour
Definition: timeutil.h:59
long int day
Definition: timeutil.h:58
long int usec
Definition: timeutil.h:59
long int min
Definition: timeutil.h:59
void timeutil_clear(timeutil_Ttime *td)
Definition: timeutil.c:62
void timeutil_add(timeutil_Ttime *sum, timeutil_Ttime td1, timeutil_Ttime td2)
Definition: timeutil.c:236
long int year
Definition: timeutil.h:58
Here is the call graph for this function: