Index: /trunk/src/kmk/Makefile.am
===================================================================
--- /trunk/src/kmk/Makefile.am	(revision 1120)
+++ /trunk/src/kmk/Makefile.am	(revision 1121)
@@ -112,4 +112,5 @@
 	-DCONFIG_WITH_NANOTS \
 	-DCONFIG_WITH_SET_CONDITIONALS \
+	-DCONFIG_WITH_DATE \
 	-DCONFIG_PRETTY_COMMAND_PRINTING \
 	\
Index: /trunk/src/kmk/Makefile.kmk
===================================================================
--- /trunk/src/kmk/Makefile.kmk	(revision 1120)
+++ /trunk/src/kmk/Makefile.kmk	(revision 1121)
@@ -114,4 +114,5 @@
 	CONFIG_WITH_NANOTS \
 	CONFIG_WITH_SET_CONDITIONALS \
+	CONFIG_WITH_DATE \
 	CONFIG_PRETTY_COMMAND_PRINTING \
 	\
Index: /trunk/src/kmk/function.c
===================================================================
--- /trunk/src/kmk/function.c	(revision 1120)
+++ /trunk/src/kmk/function.c	(revision 1121)
@@ -2673,4 +2673,43 @@
 #endif
 
+#ifdef CONFIG_WITH_DATE
+static char *
+func_date (char *o, char **argv, const char *funcname)
+{
+  char *buf;
+  size_t buf_size;
+  time_t tval;
+  const char *format = !strcmp (funcname, "date-utc")
+                     ? "%Y-%m-%dT%H:%M:%SZ" 
+                     : "%Y-%m-%dT%H:%M:%S";
+  if (argv[0]) 
+    {
+      buf = argv[0];
+      while (isspace ((unsigned char)*buf))
+        buf++;
+      if (*buf)
+        format = buf;
+    }
+
+  if (argv[1])
+    {
+      /* FIXME */
+      fatal (NILF, _("The reverse strftime aspect of the $(date*) functions isn't implemented yet.\n"));
+    }
+  else
+    time(&tval);
+
+  buf_size = 64;
+  buf = xmalloc (buf_size);
+  while (strftime (buf, buf_size, format, 
+                   !strcmp (funcname, "date-utc") 
+                   ? gmtime (&tval) : localtime (&tval)) == 0)
+    buf = xrealloc (buf, buf_size <<= 1);
+  o = variable_buffer_output (o, buf, strlen (buf));
+  free (buf);
+  return o;
+}
+#endif
+
 
 #ifdef CONFIG_WITH_STACK
@@ -3153,4 +3192,8 @@
   { STRING_SIZE_TUPLE("comp-cmds"),     3,  3,  1,  func_comp_vars},
 #endif
+#ifdef CONFIG_WITH_DATE
+  { STRING_SIZE_TUPLE("date"),          0,  1,  1,  func_date},
+  { STRING_SIZE_TUPLE("date-utc"),      0,  1,  1,  func_date},
+#endif
 #ifdef CONFIG_WITH_STACK
   { STRING_SIZE_TUPLE("stack-push"),    2,  2,  1,  func_stack_push},
Index: /trunk/src/kmk/variable.c
===================================================================
--- /trunk/src/kmk/variable.c	(revision 1120)
+++ /trunk/src/kmk/variable.c	(revision 1121)
@@ -1027,15 +1027,16 @@
 
   /* Define KMK_FEATURES to indicate various working KMK features. */
-# if defined(CONFIG_WITH_RSORT) \
-  && defined(CONFIG_WITH_ABSPATHEX) \
-  && defined(CONFIG_WITH_TOUPPER_TOLOWER) \
-  && defined(CONFIG_WITH_VALUE_LENGTH) && defined(CONFIG_WITH_COMPARE) \
-  && defined(CONFIG_WITH_STACK) \
-  && defined(CONFIG_WITH_MATH) \
-  && defined(CONFIG_WITH_XARGS) \
-  && defined(CONFIG_WITH_EXPLICIT_MULTITARGET) \
-  && defined(CONFIG_WITH_PREPEND_ASSIGNMENT) \
-  && defined(CONFIG_WITH_SET_CONDITIONALS) \
-  && defined(KMK_HELPERS)
+# if defined (CONFIG_WITH_RSORT) \
+  && defined (CONFIG_WITH_ABSPATHEX) \
+  && defined (CONFIG_WITH_TOUPPER_TOLOWER) \
+  && defined (CONFIG_WITH_VALUE_LENGTH) && defined (CONFIG_WITH_COMPARE) \
+  && defined (CONFIG_WITH_STACK) \
+  && defined (CONFIG_WITH_MATH) \
+  && defined (CONFIG_WITH_XARGS) \
+  && defined (CONFIG_WITH_EXPLICIT_MULTITARGET) \
+  && defined (CONFIG_WITH_PREPEND_ASSIGNMENT) \
+  && defined (CONFIG_WITH_SET_CONDITIONALS) \
+  && defined (CONFIG_WITH_DATE) \
+  && defined (KMK_HELPERS)
   (void) define_variable ("KMK_FEATURES", 12,
                           "append-dash-n abspath"
@@ -1050,4 +1051,5 @@
                           " prepend-assignment"
                           " set-conditionals"
+                          " date"
                           " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one "
                           , o_default, 0);
@@ -1085,4 +1087,7 @@
   strcat (buf, " set-conditionals");
 #  endif
+#  if defined (CONFIG_WITH_DATE)
+  strcat (buf, " date");
+#  endif
 #  if defined (KMK_HELPERS)
   strcat (buf, " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one");
