Fixes previous commit: dc3f9d299b40

This commit is contained in:
google 2012-09-02 01:06:38 +12:00
parent 2dfe66d72f
commit 4cd4b82553

View file

@ -3,18 +3,20 @@
int uflg, nflg, iflg, tflg; int uflg, nflg, iflg, tflg;
static
void
numstr(char *cp, int n)
{
cp[0] = (n/10)%10 + '0';
cp[1] = n%10 + '0';
}
char* char*
isodate(Tm *t) isodate(Tm *t)
{ {
static char c[10+14+1]; /* leave room to append isotime */ static char c[25]; /* leave room to append isotime */
snprint(c, 11, "%04d-%02d-%02d",
ct_numb(c, t->year / 100 + 119); t->year +1900, t->mon + 1, t->mday);
ct_numb(c+2, t->year % 100 + 100);
c[4] = '-';
ct_numb(c+5, t->mon + 101);
c[7] = '-';
ct_numb(c+8, t->mday + 100);
c[10] = 0;
return c; return c;
} }
@ -24,13 +26,9 @@ isotime(Tm *t)
int tz; int tz;
char *c, *d; char *c, *d;
d = isodate(t); d = isodate(t);
c = d + 10; /* append to isodate */ c = d+10;
c[0] = 'T'; snprint(c, 10, "T%02d:%02d:%02d",
ct_numb(c+1, t->hour+100); t->hour, t->min, t->sec); /* append to isodate */
c[3] = ':';
ct_numb(c+4, t->min+100);
c[6] = ':';
ct_numb(c+7, t->sec+100);
tz = t->tzoff / 60; tz = t->tzoff / 60;
if(t->tzoff) { if(t->tzoff) {
/* localtime */ /* localtime */
@ -40,9 +38,7 @@ isotime(Tm *t)
c[9] = '-'; c[9] = '-';
tz = -tz; tz = -tz;
} }
ct_numb(c+10, tz / 60 + 100); snprint(c+10, 5, "%02d%02d", tz / 60, tz % 60);
ct_numb(c+12, tz % 60 + 100);
c[14] = 0;
} else { } else {
c[9] = 'Z'; c[9] = 'Z';
c[10] = 0; c[10] = 0;