summaryrefslogtreecommitdiff
path: root/src/lib9/ctime.c
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2012-01-30 15:38:19 +0100
committerOndřej Surý <ondrej@sury.org>2012-01-30 15:38:19 +0100
commit4cecda6c347bd6902b960c6a35a967add7070b0d (patch)
treea462e224ff41ec9f3eb1a0b6e815806f9e8804ad /src/lib9/ctime.c
parent6c7ca6e4d4e26e4c8cbe0d183966011b3b088a0a (diff)
downloadgolang-4cecda6c347bd6902b960c6a35a967add7070b0d.tar.gz
Imported Upstream version 2012.01.27upstream-weekly/2012.01.27
Diffstat (limited to 'src/lib9/ctime.c')
-rw-r--r--src/lib9/ctime.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/lib9/ctime.c b/src/lib9/ctime.c
new file mode 100644
index 000000000..1bc29fbf9
--- /dev/null
+++ b/src/lib9/ctime.c
@@ -0,0 +1,28 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#define NOPLAN9DEFINES
+#include <u.h>
+#include <libc.h>
+
+char*
+p9ctime(long t)
+{
+ static char buf[100];
+ time_t tt;
+ struct tm *tm;
+
+ tt = t;
+ tm = localtime(&tt);
+ snprint(buf, sizeof buf, "%3.3s %3.3s %02d %02d:%02d:%02d %3.3s %d\n",
+ "SunMonTueWedThuFriSat"+(tm->tm_wday*3),
+ "JanFebMarAprMayJunJulAugSepOctNovDec"+(tm->tm_mon*3),
+ tm->tm_mday,
+ tm->tm_hour,
+ tm->tm_min,
+ tm->tm_sec,
+ "XXX", // tm_zone is unavailable on windows, and no one cares
+ tm->tm_year + 1900);
+ return buf;
+}