File: myctime.c

package info (click to toggle)
qmail 1.01-5
  • links: PTS
  • area: non-free
  • in suites: hamm
  • size: 2,188 kB
  • ctags: 1,711
  • sloc: ansic: 13,993; makefile: 1,914; perl: 448; sh: 377
file content (37 lines) | stat: -rw-r--r-- 872 bytes parent folder | download | duplicates (11)
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
#include "datetime.h"
#include "fmt.h"
#include "myctime.h"

static char *daytab[7] = {
"Sun","Mon","Tue","Wed","Thu","Fri","Sat"
};
static char *montab[12] = {
"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
};

static char result[30];

char *myctime(t)
datetime_sec t;
{
 struct datetime dt;
 unsigned int len;
 datetime_tai(&dt,t);
 len = 0;
 len += fmt_str(result + len,daytab[dt.wday]);
 result[len++] = ' ';
 len += fmt_str(result + len,montab[dt.mon]);
 result[len++] = ' ';
 len += fmt_uint0(result + len,dt.mday,2);
 result[len++] = ' ';
 len += fmt_uint0(result + len,dt.hour,2);
 result[len++] = ':';
 len += fmt_uint0(result + len,dt.min,2);
 result[len++] = ':';
 len += fmt_uint0(result + len,dt.sec,2);
 result[len++] = ' ';
 len += fmt_uint(result + len,1900 + dt.year);
 result[len++] = '\n';
 result[len++] = 0;
 return result;
}