OSDN Git Service

minor fix of date motor function.
authorvisor <visor@users.sourceforge.jp>
Sun, 24 Oct 2010 14:07:48 +0000 (23:07 +0900)
committervisor <visor@users.sourceforge.jp>
Sun, 24 Oct 2010 14:07:48 +0000 (23:07 +0900)
modules/motor-function.cc

index f418124..3086282 100644 (file)
@@ -168,19 +168,21 @@ void  mf_date (const std::vector<ustring>& args, MlEnv* mlenv) {
     ustring  format;
 //    boost::ptr_vector<MNodePtr>  par;
     int  i;
+    MNode*  v;
 
     if (args.size () > 0) {
-       tm = to_int (mlenv->getVar (args[0]));
-       for (i = 1; i < args.size (); i ++) {
-           if (i > 1)
-               format.append (uColon);
-           format.append (args[i]);
+       v = mlenv->getVar (args[0]);
+       if (! isNil (v)) {
+           tm = to_int (v);
+           for (i = 1; i < args.size (); i ++) {
+               if (i > 1)
+                   format.append (uColon);
+               format.append (args[i]);
+           }
+           if (format.length () == 0)
+               format = uTimeFormat;
+           mlenv->env->output->out_toHTML (formatDateString (format, tm));
        }
-       if (format.length () == 0)
-           format = uTimeFormat;
-//     datetime_list (par, tm);
-//     mlenv->env->output->out_toHTML (formatDateString (format, par));
-       mlenv->env->output->out_toHTML (formatDateString (format, tm));
     }
 }