[go: up one dir, main page]

Menu

[r303]: / libpetey / time_calc.cc  Maximize  Restore  History

Download this file

53 lines (36 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "stdlib.h"
#include "stdio.h"
#include "time_class.h"
#define MAXLL 200
using namespace std;
using namespace libpetey;
int main() {
char line[MAXLL];
time_class t1;
time_class t2;
char *tstr;
char *tstr1, *tstr2;
char tstr3[50];
char day[7][10]={"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday"};
// t2=" 1999/01/31-03";
printf("Enter the first date:\n");
fgets(line, MAXLL, stdin);
t1=line;
printf("Enter the second date:\n");
fgets(line, MAXLL, stdin);
t2=line;
tstr1=(char *) t1;
tstr2=(char *) t2;
//printf("Fields for %s: %d %f\n", tstr2, t2.year(), t2.doy());
//printf("Day: %d\n", t2.day());
//printf("Month: %d\n", t2.month());
printf("Days between %s and %s = %f\n", tstr1, tstr2, t2.diff(t1));
printf("%s was a %s\n", tstr1, day[t1.dow()-1]);
printf("%s was a %s\n", tstr2, day[t2.dow()-1]);
tstr=(char *) (t2-t1);
printf("%s\n", tstr);
delete [] tstr;
delete [] tstr1;
delete [] tstr2;
}