Index: EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.c
===================================================================
--- EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.c	(revision 427)
+++ EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.c	(revision 433)
@@ -789,4 +789,30 @@
 }
 
+int usrcmd_date(int argc, char **argv)
+{
+	int ret;
+	struct timespec tp;
+	char buf[30];
+
+	ret = shell_clock_gettime(CLOCK_REALTIME, &tp);
+	if (ret != 0) {
+		ntstdio_printf(&ntstdio, "clock_gettime error %d", ret);
+		return 0;
+	}
+
+	memset(buf, 0, sizeof(buf));
+	if (ctime_r(&tp.tv_sec, buf) == NULL) {
+		ntstdio_printf(&ntstdio, "ctime_r error");
+		return 0;
+	}
+
+	/* 改行コードの削除 */
+	ret = ntlibc_strlen(buf);
+	buf[ret - 1] = '\0';
+
+	ntstdio_printf(&ntstdio, "%s .%09ld\n", buf, tp.tv_nsec);
+	return 0;
+}
+
 int usrcmd_info(int argc, char **argv)
 {
Index: EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.h
===================================================================
--- EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.h	(revision 427)
+++ EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.h	(revision 433)
@@ -50,4 +50,5 @@
 int usrcmd_mkdir(int argc, char **argv);
 int usrcmd_hexdump(int argc, char **argv);
+int usrcmd_date(int argc, char **argv);
 
 int usrcmd_help(int argc, char **argv);
Index: EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.c
===================================================================
--- EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.c	(revision 427)
+++ EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.c	(revision 433)
@@ -186,5 +186,5 @@
 		 */
 		value = (flag & FLAG_SIZE_LONG_INT) ? va_arg(arp, long)
-			: (flag & FLAG_SIZE_HALF_INT) ? ((d == 'D') ? (long)va_arg(arp, short) : (long)va_arg(arp, unsigned short))
+			: (flag & FLAG_SIZE_HALF_INT) ? ((d == 'D') ? (long)((short)va_arg(arp, int)) : (long)((unsigned short)va_arg(arp, unsigned int)))
 				: ((d == 'D') ? (long)va_arg(arp, int) : (long)va_arg(arp, unsigned int));
 		if ((d == 'D') && (value & 0x80000000)) {
@@ -224,6 +224,4 @@
 	handle->xi = xi;
 	handle->xo = xo;
-	handle->outptr = 0;
-	handle->len = 0;
 	handle->pos = 0;
 	handle->option = option;
@@ -232,12 +230,4 @@
 static void _putc(ntstdio_t *handle, char c)
 {
-	if (handle->outptr) {
-		if ((handle->pos + 1) >= handle->len)
-			return;
-		handle->outptr[handle->pos] = (unsigned char)c;
-		handle->pos++;
-		return;
-	}
-
 	if (handle->xo) {
 		handle->xo(handle, (unsigned char)c);
@@ -291,14 +281,32 @@
 }
 
+struct put_buf_t {
+	char *outptr;
+	int len;
+};
+
+static void put_buf(struct ntstdio_t *handle, unsigned char c)
+{
+	struct put_buf_t *put_buf = (struct put_buf_t *)handle->exinf;
+	if ((handle->pos + 1) >= put_buf->len)
+		return;
+	put_buf->outptr[handle->pos] = (char)c;
+	handle->pos++;
+}
+
 int ntstdio_snprintf(char *buf, int len, const char *fmt, ...)
 {
 	int result;
 	ntstdio_t handle;
+	struct put_buf_t exinf;
 	va_list arp;
 	/* Switch destination for memory */
+	handle.xo = put_buf;
 	handle.option = 0;
-	handle.outptr = buf;
-	handle.len = len;
 	handle.pos = 0;
+	handle.exinf = &exinf;
+	exinf.outptr = buf;
+	exinf.len = len;
+
 	va_start(arp, fmt);
 	result = xvprintf(&handle, fmt, arp);
@@ -306,5 +314,5 @@
 
 	/* Terminate output string with a \0 */
-	handle.outptr[handle.pos] = '\0';
+	buf[handle.pos] = '\0';
 	return result;
 }
Index: EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.h
===================================================================
--- EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.h	(revision 427)
+++ EcnlProtoTool/trunk/ntshell/ntshell/util/ntstdio.h	(revision 433)
@@ -67,4 +67,5 @@
 #define NTSTDIO_OPTION_LF_CR        (1 << 3)
 
+struct ntstdio_t;
 typedef unsigned char (*NTSTDIO_XI)(struct ntstdio_t *handle);
 typedef void (*NTSTDIO_XO)(struct ntstdio_t *handle, unsigned char c);
@@ -73,8 +74,7 @@
 	NTSTDIO_XI xi;
 	NTSTDIO_XO xo;
-	char *outptr;
-	int len;
 	int pos;
 	unsigned int option;
+	void *exinf;
 } ntstdio_t;
 
