sxtwl_cpp/swig/sxtwl.i
2024-04-14 20:02:01 +08:00

121 lines
3.0 KiB
OpenEdge ABL

%module sxtwl
%{
#include "const.h"
#include "sxtwl.h"
%}
%include "stdint.i"
%include "std_vector.i"
%include "std_string.i"
namespace std{
%template(JDList) vector<double>;
%template(JQList) vector<sxtwl::JieQiInfo>;
}
%constant int J2000=2451545;
// %catches(LunarException) Lunar::getLunarMonthNum(int By, uint8_t month, bool isRun = false);
// %catches(LunarException) Lunar::getDayBySolar(int year, uint8_t month, uint8_t day);
// %catches(LunarException) Lunar::getDayByLunar(int year, uint8_t month, uint8_t day, bool isRun = false);
struct Time
{
Time();
Time(int year, int month, int day, double hour, double min, double sec);
int Y, M, D;
double h, m, s;
//=========================================================
//time
int getYear();
void setYear(int year);
void setMonth(int month) ;
int getMonth() ;
int getDay() ;
void setDay(int day);
double getHour();
void setHour(double hour);
double getMin() ;
void setMour(double min);
double getSec();
void setSec(double sec);
//=========================================================
};
struct GZ
{
GZ(){};
GZ(uint8_t tg, uint8_t dz) : tg(tg), dz(dz)
{
}
uint8_t tg;
uint8_t dz;
};
class Day
{
public:
static Day *fromSolar(int _year, uint8_t _month, int _day);
static Day *fromLunar(int year, uint8_t month, int day, bool isRun = false);
private:
Day(int d0);
public:
Day *after(int day);
Day *before(int day);
//
int getLunarDay();
//
uint8_t getLunarMonth();
// chineseNewYearBoundary
int getLunarYear(bool chineseNewYearBoundary = true);
// chineseNewYearBoundary
GZ getYearGZ(bool chineseNewYearBoundary = false);
GZ getMonthGZ();
GZ getDayGZ();
GZ getHourGZ(uint8_t hour, bool isZaoWanZiShi = true);
bool isLunarLeap();
int getSolarYear();
uint8_t getSolarMonth();
int getSolarDay() ;
uint8_t getWeek();
//
uint8_t getWeekIndex();
//
bool hasJieQi();
//
uint8_t getJieQi() ;
double getJieQiJD();
//
uint8_t getConstellation();
};
namespace sxtwl
{
struct JieQiInfo
{
double jd; //
uint8_t jqIndex; //
};
Day *fromSolar(int year, uint8_t month, int day);
Day *fromLunar(int year, uint8_t month, int day, bool isRun = false);
//
std::vector<double> siZhu2Year(GZ year, GZ yue, GZ ri, GZ shi, int fromYear, int toYear);
//
GZ getShiGz(uint8_t dayTg, uint8_t hour, bool isZaoWanZiShi = true);
//(0)
uint8_t getRunMonth(int By);
//
uint8_t getLunarMonthNum(int By, uint8_t month, bool isRun = false);
//
Time JD2DD(double jd);
//
double toJD(Time& time);
std::vector<JieQiInfo> getJieQiByYear(int year);
};