1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-19 16:47:14 +02:00

Furher implementation and improvement of the Chrono types and also exposed them to the module API.

Tighten the safety of exported functions to avoid exceptions leaking outside the host plugin.
This commit is contained in:
Sandu Liviu Catalin
2016-06-04 22:33:34 +03:00
parent 36c49cd09c
commit 2aa7e8b7c2
10 changed files with 367 additions and 16 deletions

@ -1,7 +1,8 @@
// ------------------------------------------------------------------------------------------------
#include "Library/Chrono/Date.hpp"
#include "Library/Chrono/Date.hpp"
#include "Library/Chrono/Time.hpp"
#include "Library/Chrono/Datetime.hpp"
#include "Library/Chrono/Timestamp.hpp"
#include "Base/Shared.hpp"
// ------------------------------------------------------------------------------------------------
@ -355,6 +356,20 @@ Date Date::AndDays(Int32 days)
return d;
}
// ------------------------------------------------------------------------------------------------
Timestamp Date::GetTimestamp() const
{
// Calculate the current day of the year
Int32 days = Chrono::DayOfYear(m_Year, m_Month, m_Day);
// Calculate all days till the current year
for (Int32 year = 0; year < m_Year; --year)
{
days += Chrono::DaysInYear(year);
}
// Return the resulted timestamp
return Timestamp(static_cast< Int64 >(days * 86400000000LL));
}
// ================================================================================================
void Register_ChronoDate(HSQUIRRELVM vm, Table & /*cns*/)
{
@ -385,6 +400,7 @@ void Register_ChronoDate(HSQUIRRELVM vm, Table & /*cns*/)
.Prop(_SC("LeapYear"), &Date::IsThisLeapYear)
.Prop(_SC("YearDays"), &Date::GetYearDays)
.Prop(_SC("MonthDays"), &Date::GetMonthDays)
.Prop(_SC("Timestamp"), &Date::GetTimestamp)
// Member Methods
.Func(_SC("AddYears"), &Date::AddYears)
.Func(_SC("AddMonths"), &Date::AddMonths)