mirror of https://github.com/OpenTTD/OpenTTD
(svn r23619) -Add: ScriptDate::GetSystemTime, to get the seconds since 1 Jan 1970 of the real system (GameScript only)
parent
55de5d336c
commit
c7c1deaf41
|
@ -26,6 +26,7 @@ void SQGSDate_Register(Squirrel *engine)
|
||||||
SQGSDate.DefSQStaticMethod(engine, &ScriptDate::GetMonth, "GetMonth", 2, ".i");
|
SQGSDate.DefSQStaticMethod(engine, &ScriptDate::GetMonth, "GetMonth", 2, ".i");
|
||||||
SQGSDate.DefSQStaticMethod(engine, &ScriptDate::GetDayOfMonth, "GetDayOfMonth", 2, ".i");
|
SQGSDate.DefSQStaticMethod(engine, &ScriptDate::GetDayOfMonth, "GetDayOfMonth", 2, ".i");
|
||||||
SQGSDate.DefSQStaticMethod(engine, &ScriptDate::GetDate, "GetDate", 4, ".iii");
|
SQGSDate.DefSQStaticMethod(engine, &ScriptDate::GetDate, "GetDate", 4, ".iii");
|
||||||
|
SQGSDate.DefSQStaticMethod(engine, &ScriptDate::GetSystemTime, "GetSystemTime", 1, ".");
|
||||||
|
|
||||||
SQGSDate.PostRegister(engine);
|
SQGSDate.PostRegister(engine);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
/** @file script_date.cpp Implementation of ScriptDate. */
|
/** @file script_date.cpp Implementation of ScriptDate. */
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
#include "../../stdafx.h"
|
#include "../../stdafx.h"
|
||||||
#include "script_date.hpp"
|
#include "script_date.hpp"
|
||||||
#include "../../date_func.h"
|
#include "../../date_func.h"
|
||||||
|
@ -53,3 +54,10 @@
|
||||||
|
|
||||||
return ::ConvertYMDToDate(year, month - 1, day_of_month);
|
return ::ConvertYMDToDate(year, month - 1, day_of_month);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ int32 ScriptDate::GetSystemTime()
|
||||||
|
{
|
||||||
|
time_t t;
|
||||||
|
time(&t);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
|
@ -65,6 +65,14 @@ public:
|
||||||
* @return The date.
|
* @return The date.
|
||||||
*/
|
*/
|
||||||
static int32 GetDate(int32 year, int32 month, int32 day_of_month);
|
static int32 GetDate(int32 year, int32 month, int32 day_of_month);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the time of the host system.
|
||||||
|
* @return The amount of seconds passed since 1 Jan 1970.
|
||||||
|
* @api -ai
|
||||||
|
* @note This uses the clock of the host system, which can skew or be set back. Use with caution.
|
||||||
|
*/
|
||||||
|
static int32 GetSystemTime();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SCRIPT_DATE_HPP */
|
#endif /* SCRIPT_DATE_HPP */
|
||||||
|
|
Loading…
Reference in New Issue