-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcaltime_fmt.c
More file actions
45 lines (36 loc) · 803 Bytes
/
caltime_fmt.c
File metadata and controls
45 lines (36 loc) · 803 Bytes
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
#include "caldate.h"
#include "caltime.h"
unsigned int caltime_fmt(s,ct)
char *s;
struct caltime *ct;
{
unsigned int result;
long x;
result = caldate_fmt(s,&ct->date);
if (s) {
s += result;
x = ct->hour;
s[0] = ' ';
s[2] = '0' + (x % 10); x /= 10;
s[1] = '0' + (x % 10);
s += 3;
x = ct->minute;
s[0] = ':';
s[2] = '0' + (x % 10); x /= 10;
s[1] = '0' + (x % 10);
s += 3;
x = ct->second;
s[0] = ':';
s[2] = '0' + (x % 10); x /= 10;
s[1] = '0' + (x % 10);
s += 3;
s[0] = ' ';
x = ct->offset;
if (x < 0) { s[1] = '-'; x = -x; } else s[1] = '+';
s[5] = '0' + (x % 10); x /= 10;
s[4] = '0' + (x % 6); x /= 6;
s[3] = '0' + (x % 10); x /= 10;
s[2] = '0' + (x % 10);
}
return result + 15;
}