From 0675c05fe7bc5e8787714c73d50c86113676d6bb Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Thu, 4 Mar 2021 22:51:09 +0200 Subject: [PATCH] Update Time.cpp --- module/PocoLib/Time.cpp | 68 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/module/PocoLib/Time.cpp b/module/PocoLib/Time.cpp index 5dc57e23..9ec306b9 100644 --- a/module/PocoLib/Time.cpp +++ b/module/PocoLib/Time.cpp @@ -1,6 +1,9 @@ // ------------------------------------------------------------------------------------------------ #include "PocoLib/Time.hpp" +// ------------------------------------------------------------------------------------------------ +#include + // ------------------------------------------------------------------------------------------------ namespace SqMod { @@ -18,6 +21,45 @@ SQMOD_DECL_TYPENAME(SqTimezone, _SC("SqTimezone")) // ================================================================================================ void Register_POCO_Time(HSQUIRRELVM vm, Table & ns) { + // -------------------------------------------------------------------------------------------- + ns.Bind(_SC("DateTime"), + Class< DateTime >(vm, SqDateTime::Str) + // Constructors + .Ctor() + .Ctor< const Timestamp & >() + .Ctor< int, int, int, int, int, int, int, int >() + // Meta-methods + .SquirrelFunc(_SC("_typename"), &SqDateTime::Fn) + // Properties + .Prop(_SC("Year"), &DateTime::year) + .Prop(_SC("Month"), &DateTime::month) + .Prop(_SC("Week"), &DateTime::week) + .Prop(_SC("Day"), &DateTime::day) + .Prop(_SC("DayOfWeek"), &DateTime::dayOfWeek) + .Prop(_SC("DayOfYear"), &DateTime::dayOfYear) + .Prop(_SC("Hour"), &DateTime::hour) + .Prop(_SC("HourAMPM"), &DateTime::hourAMPM) + .Prop(_SC("IsAM"), &DateTime::isAM) + .Prop(_SC("IsPM"), &DateTime::isPM) + .Prop(_SC("Minute"), &DateTime::minute) + .Prop(_SC("Second"), &DateTime::second) + .Prop(_SC("Millisecond"), &DateTime::millisecond) + .Prop(_SC("Microsecond"), &DateTime::microsecond) + .Prop(_SC("JulianDay"), &DateTime::julianDay) + .Prop(_SC("TimeStamp"), &DateTime::timestamp) + .Prop(_SC("UtcTime"), &DateTime::utcTime) + // Member Methods + .Func(_SC("Assign"), &DateTime::assign) + .Func(_SC("Swap"), &DateTime::swap) + .Func(_SC("GetWeek"), &DateTime::week) + .Func(_SC("MakeUTC"), &DateTime::makeUTC) + .Func(_SC("MakeLocal"), &DateTime::makeLocal) + // Static method + .StaticFunc(_SC("IsLeapYear"), &DateTime::isLeapYear) + .StaticFunc(_SC("DaysOfMonth"), &DateTime::daysOfMonth) + .StaticFunc(_SC("IsValid"), &DateTime::isValid) + ); + // -------------------------------------------------------------------------------------------- ns.Bind(_SC("Timespan"), Class< Timespan >(vm, SqTimespan::Str) @@ -55,6 +97,32 @@ void Register_POCO_Time(HSQUIRRELVM vm, Table & ns) .SetStaticValue(_SC("HOURS"), static_cast< SQInteger >(Timespan::HOURS)) .SetStaticValue(_SC("DAYS"), static_cast< SQInteger >(Timespan::DAYS)) ); + + // -------------------------------------------------------------------------------------------- + ConstTable(vm).Enum(_SC("SqMonth"), Enumeration(vm) + .Const(_SC("January"), static_cast< SQInteger >(Poco::DateTime::JANUARY)) + .Const(_SC("February"), static_cast< SQInteger >(Poco::DateTime::FEBRUARY)) + .Const(_SC("March"), static_cast< SQInteger >(Poco::DateTime::MARCH)) + .Const(_SC("April"), static_cast< SQInteger >(Poco::DateTime::APRIL)) + .Const(_SC("May"), static_cast< SQInteger >(Poco::DateTime::MAY)) + .Const(_SC("June"), static_cast< SQInteger >(Poco::DateTime::JUNE)) + .Const(_SC("July"), static_cast< SQInteger >(Poco::DateTime::JULY)) + .Const(_SC("August"), static_cast< SQInteger >(Poco::DateTime::AUGUST)) + .Const(_SC("September"), static_cast< SQInteger >(Poco::DateTime::SEPTEMBER)) + .Const(_SC("October"), static_cast< SQInteger >(Poco::DateTime::OCTOBER)) + .Const(_SC("November"), static_cast< SQInteger >(Poco::DateTime::NOVEMBER)) + .Const(_SC("December"), static_cast< SQInteger >(Poco::DateTime::DECEMBER)) + ); + // -------------------------------------------------------------------------------------------- + ConstTable(vm).Enum(_SC("SqDayOfWeek"), Enumeration(vm) + .Const(_SC("Sunday"), static_cast< SQInteger >(Poco::DateTime::SUNDAY)) + .Const(_SC("Monday"), static_cast< SQInteger >(Poco::DateTime::MONDAY)) + .Const(_SC("Tuesday"), static_cast< SQInteger >(Poco::DateTime::TUESDAY)) + .Const(_SC("Wednesday"), static_cast< SQInteger >(Poco::DateTime::WEDNESDAY)) + .Const(_SC("Thursday"), static_cast< SQInteger >(Poco::DateTime::THURSDAY)) + .Const(_SC("Friday"), static_cast< SQInteger >(Poco::DateTime::FRIDAY)) + .Const(_SC("Saturday"), static_cast< SQInteger >(Poco::DateTime::SATURDAY)) + ); } } // Namespace:: SqMod