/*////////////////////////////////////////////////////////////////////////////// // Script Name: 0i_time //////////////////////////////////////////////////////////////////////////////// Include script for handling all time functions for the server. Lokey's functions: int GetPosixTimestamp(); string GetCurrentDateTime(); */////////////////////////////////////////////////////////////////////////////// #include "inc_sqlite_time" // RETURNS a Timestamp in seconds since 1970-01-01. int GetCurrentTimeInSeconds(); // RETURNS a formated date, good for timestamping logs and text. string GetCurrentDateTime(); // Sends a server shutdown message 1800 seconds i.e 30 minutes before. // nDuration is in seconds. i.e. one hours is 3600 defaults to 24 hours (86400). // Should be put into the servers OnHeartBeat. void CheckServerShutdownMessage(int nDuration = 86400); int GetCurrentTimeInSeconds() { string stmt = "SELECT strftime('%s','now');"; sqlquery sqlQuery = SqlPrepareQueryObject(GetModule(), stmt); SqlStep(sqlQuery); return SqlGetInt(sqlQuery, 0); } string GetCurrentDateTime() { string stmt = "SELECT datetime('now', 'localtime')"; sqlquery sqlQuery = SqlPrepareQueryObject(GetModule(), stmt); SqlStep(sqlQuery); return SqlGetString(sqlQuery, 0); }