mess822x 1.23
mess822x
Loading...
Searching...
No Matches
mess822_date.c
Go to the documentation of this file.
1#include "mess822.h"
2#include "stralloc.h"
3
4static char *montab[12] = {
5"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
6};
7
8int mess822_date(stralloc *out,mess822_time *when)
9{
10 long i;
11
12 if (!stralloc_copys(out,"")) return 0;
13
14 if (!when->known) return 1;
15
16 if (!stralloc_catint(out,when->ct.date.day)) return 0;
17 if (!stralloc_cats(out," ")) return 0;
18
19 i = when->ct.date.month - 1;
20 if (i < 0) i = 0;
21 if (i > 11) i = 11;
22 if (!stralloc_cats(out,montab[i])) return 0;
23 if (!stralloc_cats(out," ")) return 0;
24
25 if (!stralloc_catlong(out,when->ct.date.year)) return 0;
26 if (!stralloc_cats(out," ")) return 0;
27
28 if (!stralloc_catint0(out,when->ct.hour,2)) return 0;
29 if (!stralloc_cats(out,":")) return 0;
30 if (!stralloc_catint0(out,when->ct.minute,2)) return 0;
31 if (!stralloc_cats(out,":")) return 0;
32 if (!stralloc_catint0(out,when->ct.second,2)) return 0;
33
34 if (when->known == 1) {
35 if (!stralloc_cats(out," -0000")) return 0;
36 }
37 else {
38 i = when->ct.offset;
39 if (i < 0) {
40 if (!stralloc_cats(out," -")) return 0;
41 i = -i;
42 }
43 else {
44 if (!stralloc_cats(out," +")) return 0;
45 }
46 if (!stralloc_catint0(out,(int) (i / 60),2)) return 0;
47 if (!stralloc_catint0(out,(int) (i % 60),2)) return 0;
48 }
49
50 return 1;
51}
stralloc out
Definition: b64decode.c:12
int mess822_date(stralloc *out, mess822_time *when)
Definition: mess822_date.c:8
int day
Definition: caldate.h:7
long year
Definition: caldate.h:5
int month
Definition: caldate.h:6
int hour
Definition: caltime.h:9
struct caldate date
Definition: caltime.h:8
int minute
Definition: caltime.h:10
int second
Definition: caltime.h:11
long offset
Definition: caltime.h:12
int known
Definition: mess822.h:9
struct caltime ct
Definition: mess822.h:8