summaryrefslogtreecommitdiff
path: root/sys/src/cmd/date.c
diff options
context:
space:
mode:
authorgoogle <google@daverabbitz.ath.cx>2012-09-02 01:06:38 +1200
committergoogle <google@daverabbitz.ath.cx>2012-09-02 01:06:38 +1200
commit4cd4b8255378a0c2f28da7a9cf1ab0925c88f5a1 (patch)
tree44703bd578b016be05596148f53787d87bdbfae2 /sys/src/cmd/date.c
parent2dfe66d72f23e9e4cf24cd3634ebe786c68440e3 (diff)
Fixes previous commit: dc3f9d299b40
Diffstat (limited to 'sys/src/cmd/date.c')
-rw-r--r--sys/src/cmd/date.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/sys/src/cmd/date.c b/sys/src/cmd/date.c
index 5b14fe22e..b9c1a5dca 100644
--- a/sys/src/cmd/date.c
+++ b/sys/src/cmd/date.c
@@ -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;