Fixes previous commit: dc3f9d299b40
This commit is contained in:
parent
2dfe66d72f
commit
4cd4b82553
1 changed files with 15 additions and 19 deletions
|
@ -3,18 +3,20 @@
|
|||
|
||||
int uflg, nflg, iflg, tflg;
|
||||
|
||||
static
|
||||
void
|
||||
numstr(char *cp, int n)
|
||||
{
|
||||
cp[0] = (n/10)%10 + '0';
|
||||
cp[1] = n%10 + '0';
|
||||
}
|
||||
|
||||
char*
|
||||
isodate(Tm *t)
|
||||
{
|
||||
static char c[10+14+1]; /* leave room to append isotime */
|
||||
|
||||
ct_numb(c, t->year / 100 + 119);
|
||||
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;
|
||||
static char c[25]; /* leave room to append isotime */
|
||||
snprint(c, 11, "%04d-%02d-%02d",
|
||||
t->year +1900, t->mon + 1, t->mday);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -24,13 +26,9 @@ isotime(Tm *t)
|
|||
int tz;
|
||||
char *c, *d;
|
||||
d = isodate(t);
|
||||
c = d + 10; /* append to isodate */
|
||||
c[0] = 'T';
|
||||
ct_numb(c+1, t->hour+100);
|
||||
c[3] = ':';
|
||||
ct_numb(c+4, t->min+100);
|
||||
c[6] = ':';
|
||||
ct_numb(c+7, t->sec+100);
|
||||
c = d+10;
|
||||
snprint(c, 10, "T%02d:%02d:%02d",
|
||||
t->hour, t->min, t->sec); /* append to isodate */
|
||||
tz = t->tzoff / 60;
|
||||
if(t->tzoff) {
|
||||
/* localtime */
|
||||
|
@ -40,9 +38,7 @@ isotime(Tm *t)
|
|||
c[9] = '-';
|
||||
tz = -tz;
|
||||
}
|
||||
ct_numb(c+10, tz / 60 + 100);
|
||||
ct_numb(c+12, tz % 60 + 100);
|
||||
c[14] = 0;
|
||||
snprint(c+10, 5, "%02d%02d", tz / 60, tz % 60);
|
||||
} else {
|
||||
c[9] = 'Z';
|
||||
c[10] = 0;
|
||||
|
|
Loading…
Reference in a new issue