]> git.lizzy.rs Git - plan9front.git/commitdiff
Fixes previous commit: dc3f9d299b40
authorgoogle <google@daverabbitz.ath.cx>
Sat, 1 Sep 2012 13:06:38 +0000 (01:06 +1200)
committergoogle <google@daverabbitz.ath.cx>
Sat, 1 Sep 2012 13:06:38 +0000 (01:06 +1200)
sys/src/cmd/date.c

index 5b14fe22e8ccef0bef992e87b717ade79304ed32..b9c1a5dca12d4eb504d7334a970030f97c5e8ce3 100644 (file)
@@ -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;