Files
Anphillia_PRC8/_module/nss/0i_time.nss
Jaysyn904 df58b1a133 2025/07/20 Update
Added PEPS AI.
Full compile.
2025-07-20 00:16:36 -04:00

35 lines
1.3 KiB
Plaintext

/*//////////////////////////////////////////////////////////////////////////////
// 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);
}