Game Development Community

Time function?

by Martin Schultz · in Torque Game Engine Advanced · 07/09/2006 (6:26 am) · 0 replies

I haven't found any getTime() functions or something like this to receive in script the current time and date. I found in my TGE sources a getLocalTime() and don't know anymore if it was a resource I once put in my TGE code or if it was already in the stock code.

I thought it would be wonderful to have such a function also in stock TSE. What do you think? The function I found in main.cc looks like this:

// get date and time --drew
ConsoleFunction( getLocalTime, const char *, 1, 1, "Return the current local time as: month day year hour min sec.\n\n" "Local time is platform defined.")
{
   Platform::LocalTime lt;
    Platform::getLocalTime(lt);

   char *retBuffer = Con::getReturnBuffer(128);
    dSprintf(retBuffer, 128, "%d %d %d %02d %02d %02d",
        lt.month + 1,
        lt.monthday,
        lt.year + 1900,
        lt.hour,
        lt.min,
        lt.sec);

   return retBuffer;
}

Martin