Aller au contenu

Photo

nwnx_cool Timestamp Scripting


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
_Guile

_Guile
  • Members
  • 685 messages
 
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...

#2
leo_x

leo_x
  • Members
  • 223 messages
 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 .


#3
_Guile

_Guile
  • Members
  • 685 messages
(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));
 }

}
[b]

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