Author Topic: nwnx_cool Timestamp Scripting  (Read 394 times)

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
nwnx_cool Timestamp Scripting
« on: June 04, 2013, 04:21:32 pm »


                
So, I've used the custom function in nwnx_cool (found in the "cool_include" script) named  Time();

It returns the actual timestamp, which is in the format of a unix timestampe (from what I've gathered...

So the time was listed as an integer as such...

1370355542

As far as I can tell the 42 = seconds in (0-99) form...
The 55 I assume is minutes as when the 42 reaches 00 55 would jump to 56...

However, I've read somewhere that:

In UNIX timestamp format time is a number of seconds since Jan 1, 1970.

Which seems to make perfect sense....

What I'm asking for here specifically though is code to decipher month/day/year / hours / minutes / seconds in 24 hour time. e.g. (0-23 hours) 

Can anyone whip up some custom functions to return the time (as requested above) ?

(I"m sure I could do it in a few days (or weeks), but my brain, meh, it's not working like it use too!)  ':?'

Anyway, thanks for your help/feedback in advance...
               
               

               
            

Legacy_leo_x

  • Sr. Member
  • ****
  • Posts: 403
  • Karma: +0/-0
nwnx_cool Timestamp Scripting
« Reply #1 on: June 04, 2013, 04:39:46 pm »


                This isn't what you asked for, but if you're using NWNX and the database plugin already... it might be simpler to just use one of your databases DATE functions. e,g http://dev.mysql.com...on_current-date

Like with mysql:

#include "whatever_the_nwnx_database_include_is"
void main() {
   SQLExecDirect("SELECT UTC_TIMESTAMP()");
   if (SQLFetch() == SQL_SUCCESS) {
       SpeakString(SQLGetData(1));
   }
}

I forget how to format code on this site.
               
               

               


                     Modifié par pope_leo, 04 juin 2013 - 03:41 .
                     
                  


            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
nwnx_cool Timestamp Scripting
« Reply #2 on: June 04, 2013, 05:15:34 pm »


               (BTW, I'm not using linux at all, I'm using Windows =)

Wow Leo!  You mean I can use actual SQL commands in nwn scripting?

Erm, how would I go about doing this? (sorry for being such a nOOb! =)

I mean could you shoot me a quick tutorial on how to use, like
SELECT TIME_TO_SEC('22:23:00');

[code]
[/code][/b] #include "whatever_the_nwnx_database_include_is"
 void main()
{

 SQLExecDirect("SELECT UTC_TIMESTAMP()"); 

 if (SQLFetch() == SQL_SUCCESS)
 {
  SpeakString(SQLGetData(1));
 }

}


               
               

               


                     Modifié par _Guile, 04 juin 2013 - 04:31 .