diff --git a/libc/Makefile b/libc/Makefile
index d0e86596..f1cd1b44 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -27,7 +27,6 @@ bsearch.o \
calloc.o \
clearerr.o \
c++.o \
-ctime.o \
ctype.o \
dir.o \
div.o \
@@ -122,6 +121,8 @@ strtok_r.o \
strxfrm.o \
time/asctime.o \
time/asctime_r.o \
+time/ctime.o \
+time/ctime_r.o \
timespec.o \
time/strftime.o \
ungetc.o \
diff --git a/libc/ctime.cpp b/libc/time/ctime.cpp
similarity index 78%
rename from libc/ctime.cpp
rename to libc/time/ctime.cpp
index 321cf1ad..31e86515 100644
--- a/libc/ctime.cpp
+++ b/libc/time/ctime.cpp
@@ -1,6 +1,6 @@
/*******************************************************************************
- Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
+ Copyright(C) Jonas 'Sortie' Termansen 2013.
This file is part of the Sortix C Library.
@@ -17,14 +17,15 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- ctime.cpp
- Transform date and time.
+ time/ctime.cpp
+ Convert a time value to a date and time string.
*******************************************************************************/
#include
-extern "C" char* ctime(const time_t* /*timep*/)
+// TODO: Gah, remove this as well when asctime is removed.
+extern "C" char* ctime(const time_t* clock)
{
- return (char*) "ctime(3) is not implemented";
+ return asctime(localtime(clock));
}
diff --git a/libc/time/ctime_r.cpp b/libc/time/ctime_r.cpp
new file mode 100644
index 00000000..adab97e3
--- /dev/null
+++ b/libc/time/ctime_r.cpp
@@ -0,0 +1,31 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2013.
+
+ This file is part of the Sortix C Library.
+
+ The Sortix C Library is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ The Sortix C Library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with the Sortix C Library. If not, see .
+
+ time/ctime_r.cpp
+ Convert a time value to a date and time string.
+
+*******************************************************************************/
+
+#include
+
+// TODO: Gah, remove this as well when asctime_r is removed.
+extern "C" char* ctime_r(const time_t* clock, char* buf)
+{
+ return asctime_r(localtime(clock), buf);
+}