mess822x 1.23
mess822x
Loading...
Searching...
No Matches
caldate_fmt.c
Go to the documentation of this file.
1#include "caldate.h"
2
3unsigned int caldate_fmt(char *s,struct caldate *cd)
4{
5 long x;
6 int i = 0;
7
8 x = cd->year; if (x < 0) x = -x; do { ++i; x /= 10; } while(x);
9
10 if (s) {
11 x = cd->year;
12 if (x < 0) { x = -x; *s++ = '-'; }
13 s += i; do { *--s = '0' + (x % 10); x /= 10; } while(x); s += i;
14
15 x = cd->month;
16 s[0] = '-'; s[2] = '0' + (x % 10); x /= 10; s[1] = '0' + (x % 10);
17
18 x = cd->day;
19 s[3] = '-'; s[5] = '0' + (x % 10); x /= 10; s[4] = '0' + (x % 10);
20 }
21
22 return (cd->year < 0) + i + 6;
23}
unsigned int caldate_fmt(char *s, struct caldate *cd)
Definition: caldate_fmt.c:3
Definition: caldate.h:4
int day
Definition: caldate.h:7
long year
Definition: caldate.h:5
int month
Definition: caldate.h:6