-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime.c
62 lines (54 loc) · 1.46 KB
/
time.c
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
53
54
55
56
57
58
59
60
61
62
/* (c) Yves Lafon <yves@raubacapeu.net> */
/* */
/* $Id: time.c,v 1.2 2007/07/03 14:02:58 ylafon Exp $ */
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
#include "time.h"
#ifdef SUNOS
double difftime(time1, time2)
time_t time1,time2;
{
return((double)time1-time2);
}
#endif
void GmtTime(timestring)
char *timestring;
{
char f1[16],f2[16],f3[16],f4[16],f5[16];
time_t tim;
struct tm *time_tm;
tim=time((time_t *)NULL);
time_tm=gmtime(&tim);
sscanf(asctime(time_tm),"%s %s %s %s %s",f1,f2,f3,f4,f5);
if (strlen(f3) == 1)
sprintf(timestring,"%s, 0%s %s %s %s GMT",f1,f3,f2,f5,f4);
else
sprintf(timestring,"%s, %s %s %s %s GMT",f1,f3,f2,f5,f4);
}
void LocalTime(timestring)
char *timestring;
{
char f1[16],f2[16],f3[16],f4[16],f5[16];
time_t tim;
struct tm *time_tm;
tim=time((time_t *)NULL);
time_tm=localtime(&tim);
sscanf(asctime(time_tm),"%s %s %s %s %s",f1,f2,f3,f4,f5);
if (strlen(f3) == 1)
sprintf(timestring,"%s, 0%s %s %s %s",f1,f3,f2,f5,f4);
else
sprintf(timestring,"%s, %s %s %s %s",f1,f3,f2,f5,f4);
}
void ShortTime(timestring)
char *timestring;
{
char f2[16],f3[16],f4[16];
time_t tim;
struct tm *time_tm;
tim=time((time_t *)NULL);
time_tm=localtime(&tim);
sscanf(asctime(time_tm),"%*s %s %s %s",f2,f3,f4);
sprintf(timestring,"%s %s %s",f3,f2,f4);
}