初始提交
This commit is contained in:
commit
ad0a0f52b3
17
.gitignore
vendored
Normal file
17
.gitignore
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
|
||||
*.vs
|
||||
*Debug
|
||||
*build
|
74
.travis.yml
Normal file
74
.travis.yml
Normal file
@ -0,0 +1,74 @@
|
||||
matrix:
|
||||
include:
|
||||
#IOS
|
||||
- os: osx
|
||||
language: cpp
|
||||
env: BUILD_TARGET=Ios
|
||||
sudo: true
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/ios.cmake
|
||||
-DIOS_PLATFORM=OS
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
- cmake --build .
|
||||
|
||||
#Android
|
||||
- os: linux
|
||||
language: cpp
|
||||
env: BUILD_TARGET=Android
|
||||
sudo: true
|
||||
script:
|
||||
- wget https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip
|
||||
- unzip -q ./android-ndk-r14b-linux-x86_64.zip
|
||||
- export ANDROID_NDK_ROOT=`pwd`/android-ndk-r14b
|
||||
- export ANDROID_NDK=`pwd`/android-ndk-r14b
|
||||
- wget https://cmake.org/files/v3.12/cmake-3.12.0-Linux-x86_64.tar.gz
|
||||
- tar -xf ./cmake-3.12.0-Linux-x86_64.tar.gz
|
||||
- export PATH=`pwd`/cmake-3.12.0-Linux-x86_64/bin:$PATH
|
||||
- echo $ANDROID_NDK
|
||||
- which cmake
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/android.cmake
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
-DANDROID_ABI=armeabi-v7a
|
||||
-DANDROID_STL=gnustl_static
|
||||
-DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9
|
||||
-DCMAKE_MAKE_PROGRAM=$ANDROID_NDK/prebuilt/linux-x86_64/bin/make
|
||||
-DANDROID_NATIVE_API_LEVEL=21
|
||||
-DSXTWL_BUILD_EXAMPLES=1
|
||||
-G "Unix Makefiles"
|
||||
- cmake --build .
|
||||
|
||||
# linux
|
||||
- os: linux
|
||||
language: cpp
|
||||
env: BUILD_TARGET=Linux
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake .. -DSXTWL_BUILD_EXAMPLES=1
|
||||
- cmake --build .
|
||||
- ./example/example
|
||||
|
||||
#mac
|
||||
- os: osx
|
||||
language: cpp
|
||||
env: BUILD_TARGET=Mac
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake .. -DSXTWL_BUILD_EXAMPLES=1
|
||||
- cmake --build .
|
||||
- ./example/example
|
||||
|
||||
|
||||
|
||||
|
195
CMakeLists.txt
Normal file
195
CMakeLists.txt
Normal file
@ -0,0 +1,195 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
project(sxtwl_cpp)
|
||||
|
||||
IF(MSVC)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
|
||||
add_compile_options(/wd26495) # 初始化警告
|
||||
add_compile_options(/wd6011) #可能为null指针警告
|
||||
add_compile_options(/wd4244) #隐式转换可能丢失数据警告
|
||||
add_compile_options(/wd4101) #未引用的局部变量警告
|
||||
add_compile_options(/wd4267) #隐式转换可能丢失数据警告 size_t -> int
|
||||
add_compile_options(/wd4018) #有符号与无符号的比较
|
||||
ENDIF()
|
||||
|
||||
#编译库的例子
|
||||
add_subdirectory(src)
|
||||
|
||||
#编译例子
|
||||
if(SXTWL_BUILD_EXAMPLES)
|
||||
add_subdirectory(example)
|
||||
endif(SXTWL_BUILD_EXAMPLES)
|
||||
|
||||
#python的接口导出
|
||||
# if(SXTWL_WRAPPER_PYTHON)
|
||||
# find_package(SWIG REQUIRED)
|
||||
# include(${SWIG_USE_FILE})
|
||||
|
||||
# find_package(PythonLibs)
|
||||
# include_directories(${PYTHON_INCLUDE_DIR} "./src")
|
||||
# set(CMAKE_SWIG_FLAGS)
|
||||
# set_property(SOURCE swig/sxtwl.i PROPERTY CPLUSPLUS ON)
|
||||
|
||||
# SWIG_ADD_MODULE(sxtwl_python python swig/sxtwl.i)
|
||||
# #SWIG_ADD_LIBRARY(sxtwl_python MODULE LANGUAGE python SOURCES swig/sxtwl.i)
|
||||
# SWIG_LINK_LIBRARIES(sxtwl_python ${PYTHON_LIBRARY} sxtwl)
|
||||
# endif(SXTWL_WRAPPER_PYTHON)
|
||||
|
||||
#java的接口导出(适作于android, 在externalNativeBuild 下的cmake加上 arguments "-DSXTWL_WRAPPER_JAVA=1")
|
||||
if(SXTWL_WRAPPER_JAVA)
|
||||
# find_package(SWIG REQUIRED)
|
||||
|
||||
|
||||
IF(ANDROID)
|
||||
message(STATUS "Android Jni")
|
||||
ELSE(ANDROID)
|
||||
find_package(JNI)
|
||||
if(${JNI_FOUND})
|
||||
message(STATUS "Jni Found")
|
||||
else(${JNI_FOUND})
|
||||
message(FATAL_ERROR "not found Jni")
|
||||
endif()
|
||||
endif(ANDROID)
|
||||
|
||||
include_directories(${JNI_INCLUDE_DIRS} "./src")
|
||||
# #增加包名
|
||||
# IF(ANDROID)
|
||||
# #参考:https://github.com/sureshjoshi/android-ndk-swig-example/blob/master/AS3/app/CMakeLists.txt
|
||||
# set(JAVA_GEN_PACKAGE "com.seantone.sxtwl")
|
||||
# string(REPLACE "." "/" JAVA_GEN_SUBDIR ${JAVA_GEN_PACKAGE})
|
||||
# set(JAVA_GEN_DIR ${Project_SOURCE_DIR}/src/main/java/${JAVA_GEN_SUBDIR})
|
||||
|
||||
# # -s选项为strip,不strip生成的库文件会很大
|
||||
# set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
|
||||
|
||||
# set(CMAKE_SWIG_FLAGS -c++ -package ${JAVA_GEN_PACKAGE})
|
||||
# if(CONSOLE)
|
||||
# else(CONSOLE)
|
||||
# set(CMAKE_SWIG_OUTDIR ${JAVA_GEN_DIR})
|
||||
# set(SWIG_OUTFILE_DIR ${Project_SOURCE_DIR}/src/main/sxtwl_jni_cpp/sxtwlJAVA_wrap.cxx)
|
||||
# endif(CONSOLE)
|
||||
# ELSE(ANDROID)
|
||||
# set(CMAKE_SWIG_FLAGS -c++ -package com.huoyaojing.sxtwl)
|
||||
# ENDIF(ANDROID)
|
||||
|
||||
# set_property(SOURCE swig/sxtwl.i PROPERTY CPLUSPLUS ON)
|
||||
# SWIG_ADD_MODULE(sxtwl_java java com.seantone.sxtwl)
|
||||
# #SWIG_ADD_LIBRARY(sxtwl_java MODULE LANGUAGE java SOURCES swig/sxtwl.i)
|
||||
# SWIG_LINK_LIBRARIES(sxtwl_java ${JNI_LIBRARIES} sxtwl)
|
||||
|
||||
add_library(sxtwl_java SHARED "./export/java/sxtwl_wrap.cxx")
|
||||
target_link_libraries(sxtwl_java sxtwl ${JNI_LIBRARIES})
|
||||
|
||||
|
||||
endif(SXTWL_WRAPPER_JAVA)
|
||||
|
||||
#lua接口的导出
|
||||
if(SXTWL_WRAPPER_LUA)
|
||||
# find_package(SWIG REQUIRED)
|
||||
# include(${SWIG_USE_FILE})
|
||||
|
||||
find_package(Lua)
|
||||
if(${LUA_FOUND})
|
||||
message(STATUS "lua Found")
|
||||
else(${LUA_FOUND})
|
||||
message(FATAL_ERROR "not found lua")
|
||||
endif()
|
||||
|
||||
include_directories(${LUA_INCLUDE_DIR} "./src")
|
||||
|
||||
|
||||
add_library(sxtwl_lua SHARED "./export/lua/sxtwl_wrap.cxx")
|
||||
target_link_libraries(sxtwl_lua sxtwl ${LUA_LIBRARIES})
|
||||
|
||||
# set_property(SOURCE swig/sxtwl.i PROPERTY CPLUSPLUS ON)
|
||||
# set(CMAKE_SWIG_FLAGS)
|
||||
|
||||
# SWIG_ADD_MODULE(sxtwl_lua lua swig/sxtwl.i)
|
||||
# #SWIG_ADD_LIBRARY(sxtwl_lua MODULE LANGUAGE lua SOURCES swig/sxtwl.i)
|
||||
# SWIG_LINK_LIBRARIES(sxtwl_lua ${LUA_LIBRARIES} sxtwl)
|
||||
endif(SXTWL_WRAPPER_LUA)
|
||||
|
||||
|
||||
#C#接口导出
|
||||
if(SXTWL_WRAPPER_CSHARP)
|
||||
# find_package(SWIG REQUIRED)
|
||||
# include(${SWIG_USE_FILE})
|
||||
|
||||
include_directories( "./src")
|
||||
|
||||
add_library(sxtwl_csharp SHARED "./export/C#/sxtwl_wrap.cxx")
|
||||
target_link_libraries(sxtwl_csharp sxtwl)
|
||||
|
||||
|
||||
# set_property(SOURCE swig/sxtwl.i PROPERTY CPLUSPLUS ON)
|
||||
# set(CMAKE_SWIG_FLAGS)
|
||||
|
||||
# SWIG_ADD_MODULE(sxtwl_csharp csharp swig/sxtwl.i)
|
||||
# #SWIG_ADD_LIBRARY(sxtwl_csharp MODULE LANGUAGE csharp SOURCES swig/sxtwl.i)
|
||||
# SWIG_LINK_LIBRARIES(sxtwl_csharp sxtwl)
|
||||
endif(SXTWL_WRAPPER_CSHARP)
|
||||
|
||||
|
||||
#php接口导出(仅支持php5和php7)
|
||||
if(SXTWL_WRAPPER_PHP5)
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/FindPHP.cmake)
|
||||
|
||||
include_directories(${PHP_INCLUDE_DIRS} ${PHP_EXTENSIONS_INCLUDE_DIR} "./src")
|
||||
|
||||
|
||||
add_library(sxtwl_php5 SHARED "./export/php5/sxtwl_wrap.cxx")
|
||||
target_link_libraries(sxtwl_php5 sxtwl)
|
||||
|
||||
|
||||
|
||||
# find_package(SWIG REQUIRED)
|
||||
# include(${SWIG_USE_FILE})
|
||||
# set_property(SOURCE swig/sxtwl.i PROPERTY CPLUSPLUS ON)
|
||||
# set(CMAKE_SWIG_FLAGS)
|
||||
|
||||
# if(${PHP_VERSION_MAJOR} MATCHES 7)
|
||||
# SWIG_ADD_MODULE(sxtwl_php php7 swig/sxtwl.i)
|
||||
# else(${PHP_VERSION_MAJOR} MATCHES 7)
|
||||
# SWIG_ADD_MODULE(sxtwl_php php swig/sxtwl.i)
|
||||
# endif(${PHP_VERSION_MAJOR} MATCHES 7)
|
||||
# SWIG_LINK_LIBRARIES(sxtwl_php sxtwl )
|
||||
|
||||
endif(SXTWL_WRAPPER_PHP5)
|
||||
|
||||
|
||||
if(SXTWL_WRAPPER_PHP7)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/FindPHP.cmake)
|
||||
|
||||
include_directories(${PHP_INCLUDE_DIRS} ${PHP_EXTENSIONS_INCLUDE_DIR} "./src")
|
||||
|
||||
|
||||
add_library(sxtwl_php7 SHARED "./export/php5/sxtwl_wrap.cxx")
|
||||
target_link_libraries(sxtwl_php7 sxtwl)
|
||||
|
||||
|
||||
|
||||
# find_package(SWIG REQUIRED)
|
||||
# include(${SWIG_USE_FILE})
|
||||
# set_property(SOURCE swig/sxtwl.i PROPERTY CPLUSPLUS ON)
|
||||
# set(CMAKE_SWIG_FLAGS)
|
||||
|
||||
# if(${PHP_VERSION_MAJOR} MATCHES 7)
|
||||
# SWIG_ADD_MODULE(sxtwl_php php7 swig/sxtwl.i)
|
||||
# else(${PHP_VERSION_MAJOR} MATCHES 7)
|
||||
# SWIG_ADD_MODULE(sxtwl_php php swig/sxtwl.i)
|
||||
# endif(${PHP_VERSION_MAJOR} MATCHES 7)
|
||||
# SWIG_LINK_LIBRARIES(sxtwl_php sxtwl )
|
||||
|
||||
endif(SXTWL_WRAPPER_PHP7)
|
||||
|
||||
# for golang
|
||||
if(SXTWL_WRAPPER_GO)
|
||||
include_directories("./src")
|
||||
add_library(sxtwl_go STATIC "./export/golang/sxtwl_wrap.cxx")
|
||||
target_link_libraries(sxtwl_go sxtwl)
|
||||
endif(SXTWL_WRAPPER_GO)
|
||||
|
||||
# for c
|
||||
if(SXTWL_WRAPPER_C)
|
||||
add_subdirectory(c)
|
||||
endif(SXTWL_WRAPPER_C)
|
29
LICENSE
Normal file
29
LICENSE
Normal file
@ -0,0 +1,29 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2017-2022, 元谷
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25
README.md
Normal file
25
README.md
Normal file
@ -0,0 +1,25 @@
|
||||
## 介绍
|
||||
|
||||
sxtwl_cpp是作者`yuangu`参考[寿星天文历](http://www.nongli.net/sxwnl/)并使用C++实现日历库。
|
||||
|
||||
以下链接是原作者`yuangu`项目链接,我这里仅做备份。
|
||||
|
||||
[GitHub](https://github.com/yuangu/sxtwl_cpp) / [Gitee(码云)](https://gitee.com/yuangu/sxtwl)。
|
||||
|
||||
## 特性
|
||||
|
||||
* 易于使用:使用cmake管理工程
|
||||
* 多平台支持
|
||||
* 查询范围广
|
||||
* 免除附带表数据
|
||||
|
||||
## 用途
|
||||
|
||||
* 做为航海历使用。(注:虽然叫做农历,其实和农业生产一点关系都没有。但和航海有关)
|
||||
* 命理研究
|
||||
* 考古工作
|
||||
* 与农历相关的数据提供
|
||||
* 天文研究
|
||||
|
||||
|
||||
|
25
appveyor.yml
Normal file
25
appveyor.yml
Normal file
@ -0,0 +1,25 @@
|
||||
version: 1.0.{build}
|
||||
skip_tags: true
|
||||
skip_branch_with_pr: true
|
||||
image:
|
||||
- Visual Studio 2015
|
||||
- Visual Studio 2017
|
||||
- Ubuntu
|
||||
- macOS
|
||||
|
||||
platform: Any CPU
|
||||
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
|
||||
before_build:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake .. -DSXTWL_BUILD_EXAMPLES=1 -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=C:/projects/sxtwl-cpp/build/out -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=C:/projects/sxtwl-cpp/build/out
|
||||
|
||||
build_script:
|
||||
- cmake --build .
|
||||
|
||||
# after_build:
|
||||
# - C:/projects/sxtwl-cpp/build/out/example.exe
|
27
c/CMakeLists.txt
Normal file
27
c/CMakeLists.txt
Normal file
@ -0,0 +1,27 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
project(sxtwl_c)
|
||||
|
||||
include_directories("../src")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
|
||||
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
|
||||
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
|
||||
ENDIF()
|
||||
|
||||
file(GLOB SRC_FILES *.cpp *.c )
|
||||
|
||||
IF (EMSCRIPTEN)
|
||||
add_executable(sxtwl_c ${SRC_FILES})
|
||||
target_link_libraries(sxtwl_c
|
||||
sxtwl)
|
||||
ELSE(EMSCRIPTEN)
|
||||
add_library(sxtwl_c STATIC ${SRC_FILES})
|
||||
target_link_libraries(sxtwl_c
|
||||
sxtwl)
|
||||
ENDIF(EMSCRIPTEN)
|
||||
|
||||
|
241
c/sxtwl_c.cpp
Normal file
241
c/sxtwl_c.cpp
Normal file
@ -0,0 +1,241 @@
|
||||
#include "sxtwl_export.h"
|
||||
|
||||
#include "sxtwl.h"
|
||||
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
sxtwl_Day *sxtwl_after(sxtwl_Day *day, sxtwl_Day *ret, int day_num)
|
||||
{
|
||||
ret->ptr = (Day *)((Day *)day->ptr)->after(day_num);
|
||||
return ret;
|
||||
}
|
||||
|
||||
sxtwl_Day *sxtwl_before(sxtwl_Day *day, sxtwl_Day *ret, int day_num)
|
||||
{
|
||||
ret->ptr = (Day *)((Day *)day->ptr)->before(day_num);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int sxtwl_getLunarMonth(sxtwl_Day *day)
|
||||
{
|
||||
return ((Day *)day->ptr)->getLunarMonth();
|
||||
}
|
||||
|
||||
int sxtwl_getLunarDay(sxtwl_Day *day)
|
||||
{
|
||||
return ((Day *)day->ptr)->getLunarDay();
|
||||
}
|
||||
|
||||
int sxtwl_getLunarYear(sxtwl_Day *day, bool chineseNewYearBoundary)
|
||||
{
|
||||
return ((Day *)day->ptr)->getLunarYear(chineseNewYearBoundary);
|
||||
}
|
||||
|
||||
void *sxtwl_getYearGZ(void *GZPtr, sxtwl_Day *day, bool chineseNewYearBoundary)
|
||||
{
|
||||
auto ret = (GZ *)GZPtr;
|
||||
*ret = ((Day *)day->ptr)->getYearGZ(chineseNewYearBoundary);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *sxtwl_getMonthGZ(void *GZPtr, sxtwl_Day *day)
|
||||
{
|
||||
auto ret = (GZ *)GZPtr;
|
||||
*ret = ((Day *)day->ptr)->getMonthGZ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *sxtwl_getDayGZ(void *GZPtr, sxtwl_Day *day)
|
||||
{
|
||||
auto ret = (GZ *)GZPtr;
|
||||
*ret = ((Day *)day->ptr)->getDayGZ();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *sxtwl_getHourGZ(void *GZPtr, sxtwl_Day *day, uint8_t hour, bool isZaoWanZiShi)
|
||||
{
|
||||
auto ret = (GZ *)GZPtr;
|
||||
*ret = ((Day *)day->ptr)->getHourGZ(hour, isZaoWanZiShi);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool sxtwl_isLunarLeap(sxtwl_Day *day)
|
||||
{
|
||||
return ((Day *)day->ptr)->isLunarLeap();
|
||||
}
|
||||
|
||||
int sxtwl_getSolarYear(sxtwl_Day *day)
|
||||
{
|
||||
return ((Day *)day->ptr)->getSolarYear();
|
||||
}
|
||||
|
||||
uint8_t sxtwl_getSolarMonth(sxtwl_Day *day)
|
||||
{
|
||||
return ((Day *)day->ptr)->getSolarMonth();
|
||||
}
|
||||
|
||||
int sxtwl_getSolarDay(sxtwl_Day *day)
|
||||
{
|
||||
return ((Day *)day->ptr)->getSolarDay();
|
||||
}
|
||||
|
||||
uint8_t sxtwl_getWeek(sxtwl_Day *day)
|
||||
{
|
||||
return ((Day *)day->ptr)->getWeek();
|
||||
}
|
||||
|
||||
// 处于该月的第几周
|
||||
uint8_t sxtwl_getWeekIndex(sxtwl_Day *day)
|
||||
{
|
||||
return ((Day *)day->ptr)->getWeekIndex();
|
||||
}
|
||||
|
||||
// 是否有节气
|
||||
bool sxtwl_hasJieQi(sxtwl_Day *day)
|
||||
{
|
||||
return ((Day *)day->ptr)->hasJieQi();
|
||||
}
|
||||
|
||||
// 获取节气
|
||||
uint8_t sxtwl_getJieQi(sxtwl_Day *day)
|
||||
{
|
||||
return ((Day *)day->ptr)->getJieQi();
|
||||
}
|
||||
|
||||
double sxtwl_getJieQiJD(sxtwl_Day *day)
|
||||
{
|
||||
return ((Day *)day->ptr)->getJieQiJD();
|
||||
}
|
||||
|
||||
// 获取星座
|
||||
uint8_t sxtwl_getConstellation(sxtwl_Day *day)
|
||||
{
|
||||
return ((Day *)day->ptr)->getConstellation();
|
||||
}
|
||||
|
||||
sxtwl_Day *sxtwl_newDay()
|
||||
{
|
||||
sxtwl_Day *day = new sxtwl_Day();
|
||||
day->ptr = NULL;
|
||||
return day;
|
||||
}
|
||||
|
||||
void sxtwl_freeDay(sxtwl_Day *day)
|
||||
{
|
||||
if (day->ptr != NULL)
|
||||
{
|
||||
delete ((Day *)day->ptr);
|
||||
}
|
||||
delete day;
|
||||
}
|
||||
|
||||
void *sxtwl_getShiGz(void *GZPtr, uint8_t dayTg, uint8_t hour, bool isZaoWanZiShi)
|
||||
{
|
||||
auto ret = (GZ *)GZPtr;
|
||||
*ret = sxtwl::getShiGz(dayTg, hour, isZaoWanZiShi);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t sxtwl_getRunMonth(int By)
|
||||
{
|
||||
return sxtwl::getRunMonth(By);
|
||||
}
|
||||
|
||||
uint8_t sxtwl_getLunarMonthNum(int By, uint8_t month, bool isRun)
|
||||
{
|
||||
return sxtwl::getLunarMonthNum(By, month, isRun);
|
||||
}
|
||||
|
||||
sxtwl_Time sxtwl_JD2DD(double jd)
|
||||
{
|
||||
Time t = sxtwl::JD2DD(jd);
|
||||
sxtwl_Time time;
|
||||
time.year = t.Y;
|
||||
time.month = t.M;
|
||||
time.day = t.D;
|
||||
|
||||
time.hour = t.h;
|
||||
time.min = t.m;
|
||||
time.sec = t.s;
|
||||
return time;
|
||||
}
|
||||
|
||||
double sxtwl_toJD(sxtwl_Time *time)
|
||||
{
|
||||
Time t(time->year, time->month, time->day, time->hour, time->min, time->sec);
|
||||
return sxtwl::toJD(t);
|
||||
}
|
||||
|
||||
sxtwl_Day *sxtwl_fromSolar(sxtwl_Day *ret, int year, uint8_t month, int day)
|
||||
{
|
||||
ret->ptr = (void *)sxtwl::fromSolar(year, month, day);
|
||||
return ret;
|
||||
}
|
||||
|
||||
sxtwl_Day *sxtwl_fromLunar(sxtwl_Day *ret, int year, uint8_t month, int day, bool isRun)
|
||||
{
|
||||
ret->ptr = (void *)sxtwl::fromLunar(year, month, day, isRun);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *sxtwl_siZhu2Year(void *JdListPtr, void *yearGZ, void *yueGZ, void *riGZ, void *shiGZ, int fromYear, int toYear)
|
||||
{
|
||||
auto ret = (std::vector<double> *)JdListPtr;
|
||||
*ret = sxtwl::siZhu2Year(*((GZ *)yearGZ), *((GZ *)yueGZ), *((GZ *)riGZ), *((GZ *)shiGZ), fromYear, toYear);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *JdList_new()
|
||||
{
|
||||
auto ret = new std::vector<double>();
|
||||
return ret;
|
||||
}
|
||||
void JdList_free(void *ptr)
|
||||
{
|
||||
auto ret = (std::vector<double> *)ptr;
|
||||
delete ret;
|
||||
}
|
||||
int JdList_getNum(void *ptr)
|
||||
{
|
||||
auto ret = (std::vector<double> *)ptr;
|
||||
return ret->size();
|
||||
}
|
||||
|
||||
double JdList_indexOf(void *ptr, int index)
|
||||
{
|
||||
auto ret = (std::vector<double> *)ptr;
|
||||
return ret->at(index);
|
||||
}
|
||||
|
||||
void *GZ_new(int tg, int dz)
|
||||
{
|
||||
return new GZ(tg, dz);
|
||||
}
|
||||
void GZ_free(void *ptr)
|
||||
{
|
||||
auto ret = (GZ *)ptr;
|
||||
delete ret;
|
||||
}
|
||||
int GZ_getTg(void *ptr)
|
||||
{
|
||||
auto ret = (GZ *)ptr;
|
||||
return ret->tg;
|
||||
}
|
||||
void GZ_setTg(void *ptr, int tg)
|
||||
{
|
||||
auto ret = (GZ *)ptr;
|
||||
ret->tg = tg;
|
||||
}
|
||||
int GZ_getDz(void *ptr)
|
||||
{
|
||||
auto ret = (GZ *)ptr;
|
||||
return ret->dz;
|
||||
}
|
||||
void GZ_setDz(void *ptr, int dz)
|
||||
{
|
||||
auto ret = (GZ *)ptr;
|
||||
ret->dz = dz;
|
||||
}
|
||||
EXTERN_C_END
|
109
c/sxtwl_c.h
Normal file
109
c/sxtwl_c.h
Normal file
@ -0,0 +1,109 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#if _WIN32
|
||||
#define FFI_PLUGIN_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
#define FFI_PLUGIN_EXPORT EMSCRIPTEN_KEEPALIVE
|
||||
#else
|
||||
#define FFI_PLUGIN_EXPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN_C_BEGIN \
|
||||
extern "C" \
|
||||
{
|
||||
#else
|
||||
#define EXTERN_C_BEGIN
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN_C_END }
|
||||
#else
|
||||
#define EXTERN_C_END
|
||||
#endif
|
||||
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
typedef struct sxtwl_Time
|
||||
{
|
||||
int year, month, day;
|
||||
double hour, min, sec;
|
||||
} sxtwl_Time;
|
||||
|
||||
typedef struct sxtwl_Day
|
||||
{
|
||||
void *ptr;
|
||||
} sxtwl_Day;
|
||||
|
||||
// 内存管理
|
||||
FFI_PLUGIN_EXPORT sxtwl_Day *sxtwl_newDay();
|
||||
FFI_PLUGIN_EXPORT void sxtwl_freeDay(sxtwl_Day *day);
|
||||
|
||||
// 注意返回的sxtwl_Day指针,需要使用sxtwl_freeDay释放
|
||||
FFI_PLUGIN_EXPORT sxtwl_Day *sxtwl_after(sxtwl_Day *day, sxtwl_Day *ret, int day_num);
|
||||
FFI_PLUGIN_EXPORT sxtwl_Day *sxtwl_before(sxtwl_Day *day, sxtwl_Day *ret, int day_num);
|
||||
|
||||
FFI_PLUGIN_EXPORT int sxtwl_getLunarMonth(sxtwl_Day *day);
|
||||
FFI_PLUGIN_EXPORT int sxtwl_getLunarDay(sxtwl_Day *day);
|
||||
FFI_PLUGIN_EXPORT int sxtwl_getLunarYear(sxtwl_Day *day, bool chineseNewYearBoundary);
|
||||
|
||||
FFI_PLUGIN_EXPORT void *sxtwl_getYearGZ(void *GZPtr, sxtwl_Day *day, bool chineseNewYearBoundary);
|
||||
FFI_PLUGIN_EXPORT void *sxtwl_getMonthGZ(void *GZPtr, sxtwl_Day *day);
|
||||
FFI_PLUGIN_EXPORT void *sxtwl_getDayGZ(void *GZPtr, sxtwl_Day *day);
|
||||
// 注意非早晚子时的时候,day要算第二天
|
||||
FFI_PLUGIN_EXPORT void *sxtwl_getHourGZ(void *GZPtr, sxtwl_Day *day, uint8_t hour, bool isZaoWanZiShi);
|
||||
FFI_PLUGIN_EXPORT bool sxtwl_isLunarLeap(sxtwl_Day *day);
|
||||
|
||||
FFI_PLUGIN_EXPORT int sxtwl_getSolarYear(sxtwl_Day *day);
|
||||
FFI_PLUGIN_EXPORT uint8_t sxtwl_getSolarMonth(sxtwl_Day *day);
|
||||
FFI_PLUGIN_EXPORT int sxtwl_getSolarDay(sxtwl_Day *day);
|
||||
FFI_PLUGIN_EXPORT uint8_t sxtwl_getWeek(sxtwl_Day *day);
|
||||
// 处于该月的第几周
|
||||
FFI_PLUGIN_EXPORT uint8_t sxtwl_getWeekIndex(sxtwl_Day *day);
|
||||
// 是否有节气
|
||||
FFI_PLUGIN_EXPORT bool sxtwl_hasJieQi(sxtwl_Day *day);
|
||||
// 获取节气
|
||||
FFI_PLUGIN_EXPORT uint8_t sxtwl_getJieQi(sxtwl_Day *day);
|
||||
FFI_PLUGIN_EXPORT double sxtwl_getJieQiJD(sxtwl_Day *day);
|
||||
// 获取星座
|
||||
FFI_PLUGIN_EXPORT uint8_t sxtwl_getConstellation(sxtwl_Day *day);
|
||||
|
||||
FFI_PLUGIN_EXPORT sxtwl_Day *sxtwl_fromSolar(sxtwl_Day *ret, int year, uint8_t month, int day);
|
||||
|
||||
FFI_PLUGIN_EXPORT sxtwl_Day *sxtwl_fromLunar(sxtwl_Day *ret, int year, uint8_t month, int day, bool isRun);
|
||||
|
||||
// 通过四柱获取年月日, 返回的是儒略日列表
|
||||
FFI_PLUGIN_EXPORT void *sxtwl_siZhu2Year(void *JdListPtr, void *yearGZ, void *yueGZ, void *riGZ, void *shiGZ, int fromYear, int toYear);
|
||||
////获取时辰上的那个天干
|
||||
FFI_PLUGIN_EXPORT void *sxtwl_getShiGz(void *gzPtr, uint8_t dayTg, uint8_t hour, bool isZaoWanZiShi);
|
||||
|
||||
// 获取一年中的润月(不存,则返回0)
|
||||
FFI_PLUGIN_EXPORT uint8_t sxtwl_getRunMonth(int By);
|
||||
// 获取一月中的阴日数量
|
||||
FFI_PLUGIN_EXPORT uint8_t sxtwl_getLunarMonthNum(int By, uint8_t month, bool isRun);
|
||||
// 儒略日数转公历
|
||||
FFI_PLUGIN_EXPORT sxtwl_Time sxtwl_JD2DD(double jd);
|
||||
// 公历转儒略日
|
||||
FFI_PLUGIN_EXPORT double sxtwl_toJD(sxtwl_Time *time);
|
||||
|
||||
// 反推的jd列表使用
|
||||
FFI_PLUGIN_EXPORT void *JdList_new();
|
||||
FFI_PLUGIN_EXPORT void JdList_free(void *ptr);
|
||||
FFI_PLUGIN_EXPORT int JdList_getNum(void *ptr);
|
||||
FFI_PLUGIN_EXPORT double JdList_indexOf(void *ptr, int index);
|
||||
|
||||
FFI_PLUGIN_EXPORT void *GZ_new(int tg, int dz);
|
||||
FFI_PLUGIN_EXPORT void GZ_free(void *ptr);
|
||||
FFI_PLUGIN_EXPORT int GZ_getTg(void *ptr);
|
||||
FFI_PLUGIN_EXPORT void GZ_setTg(void *ptr, int tg);
|
||||
FFI_PLUGIN_EXPORT int GZ_getDz(void *ptr);
|
||||
FFI_PLUGIN_EXPORT void GZ_setDz(void *ptr, int dz);
|
||||
|
||||
EXTERN_C_END
|
199
cmake/FindPHP.cmake
Normal file
199
cmake/FindPHP.cmake
Normal file
@ -0,0 +1,199 @@
|
||||
# - Find PHP
|
||||
# This module finds if PHP is installed and determines where the include files
|
||||
# and libraries are.
|
||||
#
|
||||
# Note, unlike the FindPHP4 module, this module uses the php-config script to
|
||||
# determine information about the installed PHP configuration. For Linux
|
||||
# distributions, this script is normally installed as part of some php-dev or
|
||||
# php-devel package. See http://php.net/manual/en/install.pecl.php-config.php
|
||||
# for php-config documentation.
|
||||
#
|
||||
# This code sets the following variables:
|
||||
# PHP_CONFIG_DIR = directory containing PHP configuration files
|
||||
# PHP_CONFIG_EXECUTABLE = full path to the php-config binary
|
||||
# PHP_EXECUTABLE = full path to the php binary
|
||||
# PHP_EXTENSIONS_DIR = directory containing PHP extensions
|
||||
# PHP_EXTENSIONS_INCLUDE_DIR = directory containing PHP extension headers
|
||||
# PHP_INCLUDE_DIRS = include directives for PHP development
|
||||
# PHP_LIBS = libraries necessary
|
||||
# PHP_VERSION_NUMBER = PHP version number in PHP's "vernum" format eg 50303
|
||||
# PHP_VERSION_MAJOR = PHP major version number eg 5
|
||||
# PHP_VERSION_MINOR = PHP minor version number eg 3
|
||||
# PHP_VERSION_PATCH = PHP patch version number eg 3
|
||||
# PHP_VERSION_STRING = PHP version string eg 5.3.3-1ubuntu9.3
|
||||
# PHP_API = PHP version api string eg 20131226
|
||||
# PHP_FOUND = set to TRUE if all of the above has been found.
|
||||
#
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2016 Jerry Jacobs
|
||||
# Copyright 2011-2012 Paul Colby
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file LICENSE.md for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
set(FINDPHP_DEBUG No)
|
||||
|
||||
find_program(PHP_CONFIG_EXECUTABLE NAMES php-config7 php-config5 php-config4 php-config)
|
||||
|
||||
if (PHP_CONFIG_EXECUTABLE)
|
||||
# PHP_CONFIG_DIR
|
||||
execute_process(
|
||||
COMMAND
|
||||
${PHP_CONFIG_EXECUTABLE} --configure-options
|
||||
#COMMAND sed -ne "s/^.*--with-config-file-scan-dir=\\([^ ]*\\).*/\\1/p"
|
||||
OUTPUT_VARIABLE PHP_CONFIG_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
# PHP_EXECUTABLE
|
||||
execute_process(
|
||||
COMMAND
|
||||
${PHP_CONFIG_EXECUTABLE} --php-binary
|
||||
OUTPUT_VARIABLE PHP_EXECUTABLE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
# PHP_EXTENSIONS_DIR
|
||||
execute_process(
|
||||
COMMAND
|
||||
${PHP_CONFIG_EXECUTABLE} --extension-dir
|
||||
OUTPUT_VARIABLE PHP_EXTENSIONS_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
# PHP_EXTENSIONS_INCLUDE_DIR
|
||||
execute_process(COMMAND
|
||||
${PHP_CONFIG_EXECUTABLE} --include-dir
|
||||
OUTPUT_VARIABLE PHP_EXTENSIONS_INCLUDE_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# PHP_INCLUDE_DIRS
|
||||
execute_process(COMMAND
|
||||
${PHP_CONFIG_EXECUTABLE} --includes
|
||||
OUTPUT_VARIABLE _PHP_INCLUDE_DIRS
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Create CMake list from compiler include paths string
|
||||
string(REPLACE "-I" ";" PHP_INCLUDE_DIRS ${_PHP_INCLUDE_DIRS})
|
||||
|
||||
# PHP_LIBS
|
||||
execute_process(COMMAND
|
||||
${PHP_CONFIG_EXECUTABLE} --libs
|
||||
OUTPUT_VARIABLE PHP_LIBS
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
|
||||
# PHP_VERSION_NUMBER
|
||||
execute_process(COMMAND
|
||||
${PHP_CONFIG_EXECUTABLE} --vernum
|
||||
OUTPUT_VARIABLE PHP_VERSION_NUMBER
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# PHP_VERSION_MAJOR
|
||||
# TODO sed should be replaced by CMake function(s)
|
||||
execute_process(
|
||||
COMMAND
|
||||
${PHP_CONFIG_EXECUTABLE} --vernum
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
COMMAND sed -ne "s/....$//p"
|
||||
OUTPUT_VARIABLE PHP_VERSION_MAJOR
|
||||
)
|
||||
|
||||
# PHP_VERSION_MINOR
|
||||
# TODO sed should be replaced by CMake function(s)
|
||||
execute_process(
|
||||
COMMAND
|
||||
${PHP_CONFIG_EXECUTABLE} --vernum
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
COMMAND sed -ne "s/..$//p"
|
||||
COMMAND sed -ne "s/^.0\\?//p"
|
||||
OUTPUT_VARIABLE PHP_VERSION_MINOR
|
||||
)
|
||||
|
||||
# PHP_VERSION_PATCH
|
||||
# TODO sed should be replaced by CMake function(s)
|
||||
execute_process(
|
||||
COMMAND
|
||||
${PHP_CONFIG_EXECUTABLE} --vernum
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
# COMMAND sed -ne "s/^...0\\t\?//p"
|
||||
OUTPUT_VARIABLE PHP_VERSION_PATCH
|
||||
)
|
||||
|
||||
# PHP_VERSION_STRING
|
||||
execute_process(
|
||||
COMMAND
|
||||
${PHP_CONFIG_EXECUTABLE} --version
|
||||
OUTPUT_VARIABLE PHP_VERSION_STRING
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
# PHP_API
|
||||
execute_process(
|
||||
COMMAND
|
||||
${PHP_CONFIG_EXECUTABLE} php-config --phpapi
|
||||
OUTPUT_VARIABLE PHP_API
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endif(PHP_CONFIG_EXECUTABLE)
|
||||
|
||||
mark_as_advanced(
|
||||
PHP_CONFIG_DIR
|
||||
PHP_CONFIG_EXECUTABLE
|
||||
PHP_EXECUTABLE
|
||||
PHP_EXTENSIONS_DIR
|
||||
PHP_EXTENSIONS_INCLUDE_DIR
|
||||
PHP_INCLUDE_DIRS
|
||||
PHP_LIBS
|
||||
PHP_VERSION_MAJOR
|
||||
PHP_VERSION_MINOR
|
||||
PHP_VERSION_PATCH
|
||||
PHP_VERSION_STRING
|
||||
PHP_API
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
|
||||
php
|
||||
DEFAULT_MSG
|
||||
PHP_VERSION_STRING
|
||||
PHP_CONFIG_DIR
|
||||
PHP_CONFIG_EXECUTABLE
|
||||
PHP_EXECUTABLE
|
||||
PHP_EXTENSIONS_DIR
|
||||
PHP_EXTENSIONS_INCLUDE_DIR
|
||||
PHP_INCLUDE_DIRS
|
||||
PHP_LIBS
|
||||
PHP_VERSION_NUMBER
|
||||
PHP_VERSION_NUMBER
|
||||
PHP_VERSION_MAJOR
|
||||
PHP_VERSION_MINOR
|
||||
PHP_VERSION_PATCH
|
||||
PHP_VERSION_STRING
|
||||
)
|
||||
|
||||
# Some handy dev output. Is there a way to enable these in some debug mode?
|
||||
if (${FINDPHP_DEBUG})
|
||||
message("PHP_FOUND = ${PHP_FOUND}")
|
||||
message("PHP_CONFIG_DIR = ${PHP_CONFIG_DIR}")
|
||||
message("PHP_CONFIG_EXECUTABLE = ${PHP_CONFIG_EXECUTABLE}")
|
||||
message("PHP_EXECUTABLE = ${PHP_EXECUTABLE}")
|
||||
message("PHP_EXTENSIONS_DIR = ${PHP_EXTENSIONS_DIR}")
|
||||
message("PHP_EXTENSIONS_INCLUDE_DIR = ${PHP_EXTENSIONS_INCLUDE_DIR}")
|
||||
message("PHP_INCLUDE_DIRS = ${PHP_INCLUDE_DIRS}")
|
||||
message("PHP_LIBS = ${PHP_LIBS}")
|
||||
message("PHP_VERSION_NUMBER = ${PHP_VERSION_NUMBER}")
|
||||
message("PHP_VERSION_MAJOR = ${PHP_VERSION_MAJOR}")
|
||||
message("PHP_VERSION_MINOR = ${PHP_VERSION_MINOR}")
|
||||
message("PHP_VERSION_PATCH = ${PHP_VERSION_PATCH}")
|
||||
message("PHP_VERSION_STRING = ${PHP_VERSION_STRING}")
|
||||
message("PHP_API = ${PHP_API}")
|
||||
endif()
|
1715
cmake/android.cmake
Normal file
1715
cmake/android.cmake
Normal file
File diff suppressed because it is too large
Load Diff
436
cmake/ios.cmake
Normal file
436
cmake/ios.cmake
Normal file
@ -0,0 +1,436 @@
|
||||
# This file is part of the ios-cmake project. It was retrieved from
|
||||
# https://github.com/cristeab/ios-cmake.git, which is a fork of
|
||||
# https://code.google.com/p/ios-cmake/. Which in turn is based off of
|
||||
# the Platform/Darwin.cmake and Platform/UnixPaths.cmake files which
|
||||
# are included with CMake 2.8.4
|
||||
#
|
||||
# The ios-cmake project is licensed under the new BSD license.
|
||||
#
|
||||
# Copyright (c) 2014, Bogdan Cristea and LTE Engineering Software,
|
||||
# Kitware, Inc., Insight Software Consortium. All rights reserved.
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# This file is based off of the Platform/Darwin.cmake and
|
||||
# Platform/UnixPaths.cmake files which are included with CMake 2.8.4
|
||||
# It has been altered for iOS development.
|
||||
#
|
||||
# Updated by Alex Stewart (alexs.mac@gmail.com)
|
||||
#
|
||||
# *****************************************************************************
|
||||
# Now maintained by Alexander Widerberg (widerbergaren [at] gmail.com)
|
||||
# under the BSD-3-Clause license
|
||||
# https://github.com/leetal/ios-cmake
|
||||
# *****************************************************************************
|
||||
#
|
||||
# INFORMATION / HELP
|
||||
#
|
||||
# The following variables control the behaviour of this toolchain:
|
||||
#
|
||||
# IOS_PLATFORM: OS (default) or SIMULATOR or SIMULATOR64 or TVOS or SIMULATOR_TVOS
|
||||
# OS = Build for iPhoneOS.
|
||||
# SIMULATOR = Build for x86 i386 iPhone Simulator.
|
||||
# SIMULATOR64 = Build for x86_64 iPhone Simulator.
|
||||
# TVOS = Build for AppleTVOS.
|
||||
# SIMULATOR_TVOS = Build for x86_64 AppleTV Simulator.
|
||||
# CMAKE_OSX_SYSROOT: Path to the iOS SDK to use. By default this is
|
||||
# automatically determined from IOS_PLATFORM and xcodebuild, but
|
||||
# can also be manually specified (although this should not be required).
|
||||
# CMAKE_IOS_DEVELOPER_ROOT: Path to the Developer directory for the iOS platform
|
||||
# being compiled for. By default this is automatically determined from
|
||||
# CMAKE_OSX_SYSROOT, but can also be manually specified (although this should
|
||||
# not be required).
|
||||
# ENABLE_BITCODE: (1|0) Enables or disables bitcode support. Default 1 (true)
|
||||
# ENABLE_ARC: (1|0) Enables or disables ARC support. Default 1 (true, ARC enabled by default)
|
||||
# ENABLE_VISIBILITY: (1|0) Enables or disables symbol visibility support. Default 0 (false, visibility hidden by default)
|
||||
# IOS_ARCH: (armv7 armv7s arm64 i386 x86_64) If specified, will override the default architectures for the given IOS_PLATFORM
|
||||
# OS = armv7 armv7s arm64
|
||||
# SIMULATOR = i386
|
||||
# SIMULATOR64 = x86_64
|
||||
# TVOS = arm64
|
||||
# SIMULATOR_TVOS = x86_64
|
||||
#
|
||||
# This toolchain defines the following variables for use externally:
|
||||
#
|
||||
# XCODE_VERSION: Version number (not including Build version) of Xcode detected.
|
||||
# IOS_SDK_VERSION: Version of iOS SDK being used.
|
||||
# CMAKE_OSX_ARCHITECTURES: Architectures being compiled for (generated from
|
||||
# IOS_PLATFORM).
|
||||
#
|
||||
# This toolchain defines the following macros for use externally:
|
||||
#
|
||||
# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE XCODE_VARIANT)
|
||||
# A convenience macro for setting xcode specific properties on targets.
|
||||
# Available variants are: All, Release, RelWithDebInfo, Debug, MinSizeRel
|
||||
# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1" "all").
|
||||
#
|
||||
# find_host_package (PROGRAM ARGS)
|
||||
# A macro used to find executable programs on the host system, not within the
|
||||
# iOS environment. Thanks to the android-cmake project for providing the
|
||||
# command.
|
||||
|
||||
# Fix for PThread library not in path
|
||||
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
|
||||
set(CMAKE_HAVE_THREADS_LIBRARY 1)
|
||||
set(CMAKE_USE_WIN32_THREADS_INIT 0)
|
||||
set(CMAKE_USE_PTHREADS_INIT 1)
|
||||
|
||||
# Get the Xcode version being used.
|
||||
execute_process(COMMAND xcodebuild -version
|
||||
OUTPUT_VARIABLE XCODE_VERSION
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REGEX MATCH "Xcode [0-9\\.]+" XCODE_VERSION "${XCODE_VERSION}")
|
||||
string(REGEX REPLACE "Xcode ([0-9\\.]+)" "\\1" XCODE_VERSION "${XCODE_VERSION}")
|
||||
message(STATUS "Building with Xcode version: ${XCODE_VERSION}")
|
||||
# Default to building for iPhoneOS if not specified otherwise, and we cannot
|
||||
# determine the platform from the CMAKE_OSX_ARCHITECTURES variable. The use
|
||||
# of CMAKE_OSX_ARCHITECTURES is such that try_compile() projects can correctly
|
||||
# determine the value of IOS_PLATFORM from the root project, as
|
||||
# CMAKE_OSX_ARCHITECTURES is propagated to them by CMake.
|
||||
if (NOT DEFINED IOS_PLATFORM)
|
||||
if (CMAKE_OSX_ARCHITECTURES)
|
||||
if (CMAKE_OSX_ARCHITECTURES MATCHES ".*arm.*")
|
||||
set(IOS_PLATFORM "OS")
|
||||
elseif (CMAKE_OSX_ARCHITECTURES MATCHES "i386")
|
||||
set(IOS_PLATFORM "SIMULATOR")
|
||||
elseif (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
|
||||
set(IOS_PLATFORM "SIMULATOR64")
|
||||
endif()
|
||||
endif()
|
||||
if (NOT IOS_PLATFORM)
|
||||
set(IOS_PLATFORM "OS")
|
||||
endif()
|
||||
endif()
|
||||
set(IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING
|
||||
"Type of iOS platform for which to build.")
|
||||
# Determine the platform name and architectures for use in xcodebuild commands
|
||||
# from the specified IOS_PLATFORM name.
|
||||
if (IOS_PLATFORM STREQUAL "OS")
|
||||
set(XCODE_IOS_PLATFORM iphoneos)
|
||||
if(NOT IOS_ARCH)
|
||||
set(IOS_ARCH armv7 armv7s arm64)
|
||||
endif()
|
||||
elseif (IOS_PLATFORM STREQUAL "SIMULATOR")
|
||||
set(XCODE_IOS_PLATFORM iphonesimulator)
|
||||
if(NOT IOS_ARCH)
|
||||
set(IOS_ARCH i386)
|
||||
endif()
|
||||
elseif(IOS_PLATFORM STREQUAL "SIMULATOR64")
|
||||
set(XCODE_IOS_PLATFORM iphonesimulator)
|
||||
if(NOT IOS_ARCH)
|
||||
set(IOS_ARCH x86_64)
|
||||
endif()
|
||||
elseif (IOS_PLATFORM STREQUAL "TVOS")
|
||||
set(XCODE_IOS_PLATFORM appletvos)
|
||||
if(NOT IOS_ARCH)
|
||||
set(IOS_ARCH arm64)
|
||||
endif()
|
||||
elseif (IOS_PLATFORM STREQUAL "SIMULATOR_TVOS")
|
||||
set(XCODE_IOS_PLATFORM appletvsimulator)
|
||||
if(NOT IOS_ARCH)
|
||||
set(IOS_ARCH x86_64)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid IOS_PLATFORM: ${IOS_PLATFORM}")
|
||||
endif()
|
||||
message(STATUS "Configuring iOS build for platform: ${IOS_PLATFORM}, "
|
||||
"architecture(s): ${IOS_ARCH}")
|
||||
# If user did not specify the SDK root to use, then query xcodebuild for it.
|
||||
if (NOT CMAKE_OSX_SYSROOT)
|
||||
execute_process(COMMAND xcodebuild -version -sdk ${XCODE_IOS_PLATFORM} Path
|
||||
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT} for platform: ${IOS_PLATFORM}")
|
||||
endif()
|
||||
if (NOT EXISTS ${CMAKE_OSX_SYSROOT})
|
||||
message(SEND_ERROR "Please make sure that Xcode is installed and that the toolchain"
|
||||
"is pointing to the correct path. Please run:"
|
||||
"sudo xcode-select -s /Applications/Xcode.app/Contents/Developer"
|
||||
"and see if that fixes the problem for you.")
|
||||
message(FATAL_ERROR "Invalid CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT} "
|
||||
"does not exist.")
|
||||
endif()
|
||||
# Specify minimum version of deployment target.
|
||||
if (NOT DEFINED IOS_DEPLOYMENT_TARGET)
|
||||
# Unless specified, SDK version 8.0 is used by default as minimum target version.
|
||||
set(IOS_DEPLOYMENT_TARGET "8.0"
|
||||
CACHE STRING "Minimum iOS version to build for." )
|
||||
message(STATUS "Using the default min-version since IOS_DEPLOYMENT_TARGET not provided!")
|
||||
endif()
|
||||
# Use bitcode or not
|
||||
if (NOT DEFINED ENABLE_BITCODE AND NOT IOS_ARCH MATCHES "((^|, )(i386|x86_64))+")
|
||||
# Unless specified, enable bitcode support by default
|
||||
set(ENABLE_BITCODE TRUE CACHE BOOL "Whether or not to enable bitcode")
|
||||
message(STATUS "Enabling bitcode support by default. ENABLE_BITCODE not provided!")
|
||||
endif()
|
||||
if (NOT DEFINED ENABLE_BITCODE)
|
||||
message(STATUS "Disabling bitcode support by default on simulators. ENABLE_BITCODE not provided for override!")
|
||||
endif()
|
||||
# Use ARC or not
|
||||
if (NOT DEFINED ENABLE_ARC)
|
||||
# Unless specified, enable ARC support by default
|
||||
set(ENABLE_ARC TRUE CACHE BOOL "Whether or not to enable ARC")
|
||||
message(STATUS "Enabling ARC support by default. ENABLE_ARC not provided!")
|
||||
endif()
|
||||
# Use hidden visibility or not
|
||||
if (NOT DEFINED ENABLE_VISIBILITY)
|
||||
# Unless specified, disable symbols visibility by default
|
||||
set(ENABLE_VISIBILITY FALSE CACHE BOOL "Whether or not to hide symbols (-fvisibility=hidden)")
|
||||
message(STATUS "Hiding symbols visibility by default. ENABLE_VISIBILITY not provided!")
|
||||
endif()
|
||||
# Get the SDK version information.
|
||||
execute_process(COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version SDKVersion
|
||||
OUTPUT_VARIABLE IOS_SDK_VERSION
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
# Find the Developer root for the specific iOS platform being compiled for
|
||||
# from CMAKE_OSX_SYSROOT. Should be ../../ from SDK specified in
|
||||
# CMAKE_OSX_SYSROOT. There does not appear to be a direct way to obtain
|
||||
# this information from xcrun or xcodebuild.
|
||||
if (NOT CMAKE_IOS_DEVELOPER_ROOT)
|
||||
get_filename_component(IOS_PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT} PATH)
|
||||
get_filename_component(CMAKE_IOS_DEVELOPER_ROOT ${IOS_PLATFORM_SDK_DIR} PATH)
|
||||
endif()
|
||||
if (NOT EXISTS ${CMAKE_IOS_DEVELOPER_ROOT})
|
||||
message(FATAL_ERROR "Invalid CMAKE_IOS_DEVELOPER_ROOT: "
|
||||
"${CMAKE_IOS_DEVELOPER_ROOT} does not exist.")
|
||||
endif()
|
||||
# Find the C & C++ compilers for the specified SDK.
|
||||
if (NOT CMAKE_C_COMPILER)
|
||||
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang
|
||||
OUTPUT_VARIABLE CMAKE_C_COMPILER
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "Using C compiler: ${CMAKE_C_COMPILER}")
|
||||
endif()
|
||||
if (NOT CMAKE_CXX_COMPILER)
|
||||
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang++
|
||||
OUTPUT_VARIABLE CMAKE_CXX_COMPILER
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "Using CXX compiler: ${CMAKE_CXX_COMPILER}")
|
||||
endif()
|
||||
# Find (Apple's) libtool.
|
||||
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find libtool
|
||||
OUTPUT_VARIABLE IOS_LIBTOOL
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "Using libtool: ${IOS_LIBTOOL}")
|
||||
# Configure libtool to be used instead of ar + ranlib to build static libraries.
|
||||
# This is required on Xcode 7+, but should also work on previous versions of
|
||||
# Xcode.
|
||||
set(CMAKE_C_CREATE_STATIC_LIBRARY
|
||||
"${IOS_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
|
||||
set(CMAKE_CXX_CREATE_STATIC_LIBRARY
|
||||
"${IOS_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
|
||||
# Get the version of Darwin (OS X) of the host.
|
||||
execute_process(COMMAND uname -r
|
||||
OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
# Standard settings.
|
||||
set(CMAKE_SYSTEM_NAME Darwin CACHE INTERNAL "")
|
||||
set(CMAKE_SYSTEM_VERSION ${IOS_SDK_VERSION} CACHE INTERNAL "")
|
||||
set(UNIX TRUE CACHE BOOL "")
|
||||
set(APPLE TRUE CACHE BOOL "")
|
||||
set(IOS TRUE CACHE BOOL "")
|
||||
set(CMAKE_AR ar CACHE FILEPATH "" FORCE)
|
||||
set(CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE)
|
||||
# Force unset of OS X-specific deployment target (otherwise autopopulated),
|
||||
# required as of cmake 2.8.10.
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING
|
||||
"Must be empty for iOS builds." FORCE)
|
||||
# Set the architectures for which to build.
|
||||
set(CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS")
|
||||
# Change the type of target generated for try_compile() so it'll work when cross-compiling
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
# Skip the platform compiler checks for cross compiling.
|
||||
set(CMAKE_CXX_COMPILER_FORCED TRUE)
|
||||
set(CMAKE_CXX_COMPILER_WORKS TRUE)
|
||||
set(CMAKE_C_COMPILER_FORCED TRUE)
|
||||
set(CMAKE_C_COMPILER_WORKS TRUE)
|
||||
# All iOS/Darwin specific settings - some may be redundant.
|
||||
set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
|
||||
set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
|
||||
set(CMAKE_SHARED_MODULE_PREFIX "lib")
|
||||
set(CMAKE_SHARED_MODULE_SUFFIX ".so")
|
||||
set(CMAKE_C_COMPILER_ABI ELF)
|
||||
set(CMAKE_CXX_COMPILER_ABI ELF)
|
||||
set(CMAKE_C_HAS_ISYSROOT 1)
|
||||
set(CMAKE_CXX_HAS_ISYSROOT 1)
|
||||
set(CMAKE_MODULE_EXISTS 1)
|
||||
set(CMAKE_DL_LIBS "")
|
||||
set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
|
||||
set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
|
||||
set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
|
||||
set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
|
||||
|
||||
if(IOS_ARCH MATCHES "((^|, )(arm64|x86_64))+")
|
||||
set(CMAKE_C_SIZEOF_DATA_PTR 8)
|
||||
set(CMAKE_CXX_SIZEOF_DATA_PTR 8)
|
||||
message(STATUS "Using a data_ptr size of 8")
|
||||
else()
|
||||
set(CMAKE_C_SIZEOF_DATA_PTR 4)
|
||||
set(CMAKE_CXX_SIZEOF_DATA_PTR 4)
|
||||
message(STATUS "Using a data_ptr size of 4")
|
||||
endif()
|
||||
|
||||
message(STATUS "Building for minimum iOS version: ${IOS_DEPLOYMENT_TARGET}"
|
||||
" (SDK version: ${IOS_SDK_VERSION})")
|
||||
# Note that only Xcode 7+ supports the newer more specific:
|
||||
# -m${XCODE_IOS_PLATFORM}-version-min flags, older versions of Xcode use:
|
||||
# -m(ios/ios-simulator)-version-min instead.
|
||||
if (IOS_PLATFORM STREQUAL "OS")
|
||||
if (XCODE_VERSION VERSION_LESS 7.0)
|
||||
set(XCODE_IOS_PLATFORM_VERSION_FLAGS
|
||||
"-mios-version-min=${IOS_DEPLOYMENT_TARGET}")
|
||||
else()
|
||||
# Xcode 7.0+ uses flags we can build directly from XCODE_IOS_PLATFORM.
|
||||
set(XCODE_IOS_PLATFORM_VERSION_FLAGS
|
||||
"-m${XCODE_IOS_PLATFORM}-version-min=${IOS_DEPLOYMENT_TARGET}")
|
||||
endif()
|
||||
elseif (IOS_PLATFORM STREQUAL "TVOS")
|
||||
set(XCODE_IOS_PLATFORM_VERSION_FLAGS
|
||||
"-mtvos-version-min=${IOS_DEPLOYMENT_TARGET}")
|
||||
elseif (IOS_PLATFORM STREQUAL "SIMULATOR_TVOS")
|
||||
set(XCODE_IOS_PLATFORM_VERSION_FLAGS
|
||||
"-mtvos-simulator-version-min=${IOS_DEPLOYMENT_TARGET}")
|
||||
else()
|
||||
# SIMULATOR or SIMULATOR64 both use -mios-simulator-version-min.
|
||||
set(XCODE_IOS_PLATFORM_VERSION_FLAGS
|
||||
"-mios-simulator-version-min=${IOS_DEPLOYMENT_TARGET}")
|
||||
endif()
|
||||
message(STATUS "Version flags set to: ${XCODE_IOS_PLATFORM_VERSION_FLAGS}")
|
||||
|
||||
if (ENABLE_BITCODE)
|
||||
set(BITCODE "-fembed-bitcode")
|
||||
set(HEADER_PAD "")
|
||||
message(STATUS "Enabling bitcode support.")
|
||||
else()
|
||||
set(BITCODE "")
|
||||
set(HEADER_PAD "-headerpad_max_install_names")
|
||||
message(STATUS "Disabling bitcode support.")
|
||||
endif()
|
||||
|
||||
if (ENABLE_ARC)
|
||||
set(FOBJC_ARC "-fobjc-arc")
|
||||
message(STATUS "Enabling ARC support.")
|
||||
else()
|
||||
set(FOBJC_ARC "-fno-objc-arc")
|
||||
message(STATUS "Disabling ARC support.")
|
||||
endif()
|
||||
|
||||
if (NOT ENABLE_VISIBILITY)
|
||||
set(VISIBILITY "-fvisibility=hidden")
|
||||
message(STATUS "Hiding symbols (-fvisibility=hidden).")
|
||||
else()
|
||||
set(VISIBILITY "")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS
|
||||
"${XCODE_IOS_PLATFORM_VERSION_FLAGS} ${BITCODE} -fobjc-abi-version=2 ${FOBJC_ARC} ${C_FLAGS}")
|
||||
# Hidden visibilty is required for C++ on iOS.
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${XCODE_IOS_PLATFORM_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} -fvisibility-inlines-hidden -fobjc-abi-version=2 ${FOBJC_ARC} ${CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG -Os -ffast-math ${BITCODE} ${CXX_FLAGS_MINSIZEREL}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG -O2 -g -ffast-math ${BITCODE} ${CXX_FLAGS_RELWITHDEBINFO}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG -O3 -ffast-math ${BITCODE} ${CXX_FLAGS_RELEASE}")
|
||||
set(CMAKE_C_LINK_FLAGS "${XCODE_IOS_PLATFORM_VERSION_FLAGS} -Wl,-search_paths_first ${C_LINK_FLAGS}")
|
||||
set(CMAKE_CXX_LINK_FLAGS "${XCODE_IOS_PLATFORM_VERSION_FLAGS} -Wl,-search_paths_first ${CXX_LINK_FLAGS}")
|
||||
|
||||
# In order to ensure that the updated compiler flags are used in try_compile()
|
||||
# tests, we have to forcibly set them in the CMake cache, not merely set them
|
||||
# in the local scope.
|
||||
list(APPEND VARS_TO_FORCE_IN_CACHE
|
||||
CMAKE_C_FLAGS
|
||||
CMAKE_CXX_FLAGS
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_C_LINK_FLAGS
|
||||
CMAKE_CXX_LINK_FLAGS)
|
||||
foreach(VAR_TO_FORCE ${VARS_TO_FORCE_IN_CACHE})
|
||||
set(${VAR_TO_FORCE} "${${VAR_TO_FORCE}}" CACHE STRING "" FORCE)
|
||||
endforeach()
|
||||
|
||||
set(CMAKE_PLATFORM_HAS_INSTALLNAME 1)
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "-rpath @executable_path/Frameworks -rpath @loader_path/Frameworks")
|
||||
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib ${HEADER_PAD}")
|
||||
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle ${HEADER_PAD}")
|
||||
set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
|
||||
set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
|
||||
|
||||
# Hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old
|
||||
# build tree (where install_name_tool was hardcoded) and where
|
||||
# CMAKE_INSTALL_NAME_TOOL isn't in the cache and still cmake didn't fail in
|
||||
# CMakeFindBinUtils.cmake (because it isn't rerun) hardcode
|
||||
# CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did
|
||||
# before, Alex.
|
||||
if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
||||
find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
|
||||
endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
||||
|
||||
# Set the find root to the iOS developer roots and to user defined paths.
|
||||
set(CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_OSX_SYSROOT}
|
||||
${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root" FORCE)
|
||||
# Default to searching for frameworks first.
|
||||
set(CMAKE_FIND_FRAMEWORK FIRST)
|
||||
# Set up the default search directories for frameworks.
|
||||
set(CMAKE_SYSTEM_FRAMEWORK_PATH
|
||||
${CMAKE_OSX_SYSROOT}/System/Library/Frameworks
|
||||
${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks
|
||||
${CMAKE_OSX_SYSROOT}/Developer/Library/Frameworks)
|
||||
# Only search the specified iOS SDK, not the remainder of the host filesystem.
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
# This little macro lets you set any XCode specific property.
|
||||
macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE XCODE_RELVERSION)
|
||||
set(XCODE_RELVERSION_I "${XCODE_RELVERSION}")
|
||||
if (XCODE_RELVERSION_I STREQUAL "All")
|
||||
set_property(TARGET ${TARGET} PROPERTY
|
||||
XCODE_ATTRIBUTE_${XCODE_PROPERTY} "${XCODE_VALUE}")
|
||||
else()
|
||||
set_property(TARGET ${TARGET} PROPERTY
|
||||
XCODE_ATTRIBUTE_${XCODE_PROPERTY}[variant=${XCODE_RELVERSION_I}] "${XCODE_VALUE}")
|
||||
endif()
|
||||
endmacro(set_xcode_property)
|
||||
# This macro lets you find executable programs on the host system.
|
||||
macro(find_host_package)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
|
||||
set(IOS FALSE)
|
||||
find_package(${ARGN})
|
||||
set(IOS TRUE)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
endmacro(find_host_package)
|
57
cmake/platform.cmake
Normal file
57
cmake/platform.cmake
Normal file
@ -0,0 +1,57 @@
|
||||
#cmake has some strange defaults, this should help us a lot
|
||||
#Please use them everywhere
|
||||
|
||||
#WINDOWS = Windows Desktop
|
||||
#WINRT = Windows RT
|
||||
#WP8 = Windows Phone 8
|
||||
#ANDROID = Android
|
||||
#IOS = iOS
|
||||
#MACOSX = MacOS X
|
||||
#LINUX = Linux
|
||||
|
||||
#define PLATFORM_UNKNOWN 0
|
||||
#define PLATFORM_IOS 1
|
||||
#define PLATFORM_ANDROID 2
|
||||
#define PLATFORM_WIN32 3
|
||||
#define PLATFORM_WP8 4
|
||||
#define PLATFORM_WIN10 5
|
||||
#define PLATFORM_LINUX 6
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
if(WINRT)
|
||||
set(SYSTEM_STRING "Windows RT")
|
||||
add_definitions(-DTARGET_PLATFORM=5)
|
||||
elseif(WP8)
|
||||
set(SYSTEM_STRING "Windows Phone 8")
|
||||
add_definitions(-DTARGET_PLATFORM=4)
|
||||
else()
|
||||
set(WINDOWS TRUE)
|
||||
set(SYSTEM_STRING "Windows Desktop")
|
||||
add_definitions(-DTARGET_PLATFORM=3)
|
||||
endif()
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
if(ANDROID)
|
||||
set(SYSTEM_STRING "Android")
|
||||
add_definitions(-DTARGET_PLATFORM=2)
|
||||
else()
|
||||
set(LINUX TRUE)
|
||||
set(SYSTEM_STRING "Linux")
|
||||
add_definitions(-DTARGET_PLATFORM=6)
|
||||
endif()
|
||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
if(IOS)
|
||||
set(SYSTEM_STRING "IOS")
|
||||
add_definitions(-DTARGET_PLATFORM=1)
|
||||
else()
|
||||
set(MACOSX TRUE)
|
||||
set(APPLE TRUE)
|
||||
set(SYSTEM_STRING "Mac OSX")
|
||||
add_definitions(-DTARGET_PLATFORM=6)
|
||||
endif()
|
||||
elseif (EMSCRIPTEN)
|
||||
add_definitions(-DTARGET_PLATFORM=6)
|
||||
else()
|
||||
message(ERROR "unrecognized target platform.")
|
||||
endif()
|
||||
|
||||
SET(CMAKE_INSTALL_RPATH "@executable_path")
|
18
example/CMakeLists.txt
Normal file
18
example/CMakeLists.txt
Normal file
@ -0,0 +1,18 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
project(example)
|
||||
|
||||
include_directories("../src")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
|
||||
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
|
||||
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
|
||||
ENDIF()
|
||||
|
||||
file(GLOB SRC_FILES "*.cpp" )
|
||||
add_executable(example ${SRC_FILES})
|
||||
target_link_libraries(example
|
||||
sxtwl)
|
3
example/golang/go.mod
Normal file
3
example/golang/go.mod
Normal file
@ -0,0 +1,3 @@
|
||||
module sxtwl_example
|
||||
|
||||
go 1.17
|
217
example/golang/main.go
Normal file
217
example/golang/main.go
Normal file
@ -0,0 +1,217 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sxtwl_example/sxtwl"
|
||||
)
|
||||
|
||||
/**
|
||||
* 本例子只给了win64的静态库,如果需要其它库请自行编译
|
||||
$ cd ~/code/sxtwl_cpp
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ cmake .. -DSXTWL_WRAPPER_GO=1
|
||||
$ cmake --build .
|
||||
|
||||
编译好了,请把sxtwl.a及sxtwl_cgo.a放到lib目录下,并在sxtwl目录下的init.go加好链接路径
|
||||
|
||||
|
||||
注: 如果使用win系统的话,请安装mingw32, 作者推荐安装tdm-gcc
|
||||
然后cmake 命令改成 cmake -G "MinGW Makefiles" .. -DSXTWL_WRAPPER_GO=1
|
||||
*/
|
||||
|
||||
var Gan = [...]string{"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"}
|
||||
|
||||
var Zhi = [...]string{"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"}
|
||||
var ShX = [...]string{"鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"}
|
||||
var MumCn = [...]string{"零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"}
|
||||
var Jqmc = [...]string{"冬至", "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏",
|
||||
"小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降",
|
||||
"立冬", "小雪", "大雪"}
|
||||
var Ymc = [...]string{"正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"}
|
||||
var Rmc = [...]string{"初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十",
|
||||
"十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十",
|
||||
"廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一"}
|
||||
var XiZ = [...]string{"摩羯", "水瓶", "双鱼", "白羊", "金牛", "双子", "巨蟹", "狮子", "处女", "天秤", "天蝎", "射手"}
|
||||
var WeekCn = [...]string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}
|
||||
|
||||
//=============================================================================================
|
||||
//做反推的辅助函数
|
||||
// copy form https://blog.csdn.net/qianguozheng/article/details/52795395
|
||||
func SubString(str string, begin, length int) string {
|
||||
fmt.Println("Substring =", str)
|
||||
rs := []rune(str)
|
||||
lth := len(rs)
|
||||
fmt.Printf("begin=%d, end=%d, lth=%d\n", begin, length, lth)
|
||||
if begin < 0 {
|
||||
begin = 0
|
||||
}
|
||||
if begin >= lth {
|
||||
begin = lth
|
||||
}
|
||||
end := begin + length
|
||||
|
||||
if end > lth {
|
||||
end = lth
|
||||
}
|
||||
fmt.Printf("begin=%d, end=%d, lth=%d\n", begin, length, lth)
|
||||
return string(rs[begin:end])
|
||||
}
|
||||
|
||||
func GetGZ(gzStr string) sxtwl.GZ {
|
||||
tg := -1
|
||||
dz := -1
|
||||
|
||||
for i, v := range Gan {
|
||||
if SubString(gzStr, 0, 1) == v {
|
||||
tg = i
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
for i, v := range Zhi {
|
||||
if SubString(gzStr, 1, 1) == v {
|
||||
tg = i
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return sxtwl.NewGZ(tg, dz)
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
|
||||
func main() {
|
||||
day := sxtwl.DayFromSolar(2021, 11, 7)
|
||||
|
||||
// day := sxtwl.DayFromLunar(2020, 12, 1)
|
||||
// # 如果是想查闰月,第四个参数加一个True即可
|
||||
// # day = sxtwl.DayFromLunar(2020, 12, 1, true)
|
||||
|
||||
fmt.Printf("公历:%v年%v月%v日\n", day.GetSolarYear(), day.GetSolarMonth(), day.GetSolarDay())
|
||||
|
||||
// 星期几
|
||||
fmt.Printf("%v\n", WeekCn[day.GetWeek()])
|
||||
|
||||
// 这个月的第几周
|
||||
fmt.Printf("该日属于这个月的第%v周\n", day.GetWeekIndex())
|
||||
|
||||
//以春节为界的农历(注getLunarYear如果没有传参,或者传true,是以春节为界的)
|
||||
runStr := ""
|
||||
if day.IsLunarLeap() {
|
||||
runStr = "闰"
|
||||
}
|
||||
fmt.Printf("农历:%d年%s%d月%d日\n", day.GetLunarYear(), runStr, day.GetLunarMonth(), day.GetLunarDay())
|
||||
|
||||
//不以立春为界的农历
|
||||
fmt.Printf("农历:%d年%s%d月%d日\n", day.GetLunarYear(true), runStr, day.GetLunarMonth(), day.GetLunarDay())
|
||||
|
||||
// 以春节为界的天干地支
|
||||
yTG := day.GetYearGZ(true)
|
||||
fmt.Printf("以春节为界的年干支:%v", Gan[yTG.GetTg()]+Zhi[yTG.GetDz()])
|
||||
fmt.Printf("以春节为界的生肖:%v", ShX[yTG.GetDz()])
|
||||
|
||||
// 以立春为界的天干地支 (注,如果没有传参,或者传false,是以立春为界的。刚好和getLunarYear相反)
|
||||
yTG = day.GetYearGZ()
|
||||
fmt.Printf("以立春为界的年干支:%v", Gan[yTG.GetTg()]+Zhi[yTG.GetDz()])
|
||||
fmt.Printf("以立春为界的生肖:%v", ShX[yTG.GetDz()])
|
||||
|
||||
//月干支
|
||||
mTG := day.GetMonthGZ()
|
||||
fmt.Printf("月干支:%v", Gan[mTG.GetTg()]+Zhi[mTG.GetDz()])
|
||||
|
||||
//日干支
|
||||
dTG := day.GetDayGZ()
|
||||
fmt.Printf("日干支%v", Gan[dTG.GetTg()]+Zhi[dTG.GetDz()])
|
||||
|
||||
//时干支,传24小时制的时间,分早晚子时
|
||||
hour := 18
|
||||
sTG := day.GetHourGZ((byte)(hour))
|
||||
fmt.Printf("%d时的干支%v", hour, Gan[sTG.GetTg()]+Zhi[sTG.GetDz()])
|
||||
|
||||
// 第二种获取时干支方法
|
||||
//第一个参数为该天的天干,第二个参数为小时
|
||||
hTG := sxtwl.GetShiGz(dTG.GetTg(), (byte)(hour))
|
||||
fmt.Printf("%d时天干地支:%v", (hour), Gan[hTG.GetTg()]+Zhi[hTG.GetDz()])
|
||||
|
||||
// 当日是否有节气
|
||||
if day.HasJieQi() {
|
||||
fmt.Printf("节气:%s", Jqmc[day.GetJieQi()])
|
||||
//获取节气的儒略日数
|
||||
jd := day.GetJieQiJD()
|
||||
// 将儒略日数转换成年月日时秒
|
||||
t := sxtwl.JD2DD(jd)
|
||||
fmt.Printf("节气时间:%v", t)
|
||||
//注意,t.s是小数,需要四舍五入
|
||||
//fmt.Printf("节气时间:%d-%d-%d %d:%d:%d", t.GetY(), t.GetM(), t.GetD(), t.GetH(), t.GetM(), math.Round(t.GetS()))
|
||||
} else {
|
||||
fmt.Println("当天不是节气日")
|
||||
}
|
||||
|
||||
// 四注反查 分别传的是年天干,月天干,日天干,时天干, 开始查询年,结束查询年 返回满足条件的儒略日数
|
||||
jds := sxtwl.SiZhu2Year(GetGZ("辛丑"), GetGZ("己亥"), GetGZ("丙寅"), GetGZ("癸巳"), 2003, 2029)
|
||||
for i := 0; i < int(jds.Size()); i++ {
|
||||
jd := jds.Get(i)
|
||||
t := sxtwl.JD2DD(jd)
|
||||
fmt.Printf("符合条件的时间:%v", t)
|
||||
// print("符合条件的时间:%d-%d-%d %d:%d:%d"%(t.Y, t.M, t.D, t.h, t.m, round(t.s)))
|
||||
}
|
||||
|
||||
// 获取一年中的闰月
|
||||
year := 2020
|
||||
month := sxtwl.GetRunMonth(year)
|
||||
if month >= 0 {
|
||||
fmt.Printf("%d年的闰月是%d", year, month)
|
||||
} else {
|
||||
fmt.Println("没有闰月")
|
||||
}
|
||||
|
||||
// 一个农历月的天数
|
||||
year = 2020 //农历年
|
||||
month = 4 //农历月
|
||||
isRun := false //是否是闰月
|
||||
daynum := sxtwl.GetLunarMonthNum(year, month, isRun)
|
||||
runStr = ""
|
||||
if isRun {
|
||||
runStr = "闰"
|
||||
}
|
||||
fmt.Printf("农历%v年%v%v月的天数:%v", year, runStr, month, daynum)
|
||||
|
||||
//儒略日数转公历
|
||||
jd := sxtwl.J2000
|
||||
t := sxtwl.JD2DD((float64)(jd))
|
||||
|
||||
//公历转儒略日
|
||||
// jd = sxtwl.ToJD(t)
|
||||
|
||||
// 获取某天的后面几天
|
||||
num := 1 //你喜欢写多少天 也多少天,可以写负数,相当于往前
|
||||
day = day.After(num) //获取num天后的日信息
|
||||
fmt.Printf("公历:%d年%d月%d日\n", day.GetSolarYear(), day.GetSolarMonth(), day.GetSolarDay())
|
||||
|
||||
// 同上
|
||||
day = day.Before(num)
|
||||
fmt.Printf("公历:%d年%d月%d日\n", day.GetSolarYear(), day.GetSolarMonth(), day.GetSolarDay())
|
||||
|
||||
// 查找某日前后的节气
|
||||
for true {
|
||||
// 这里可以使用after或者before,不用担心速度,这里的计算在底层仅仅是+1这么简单
|
||||
day = day.After(1)
|
||||
// hasJieQi的接口比getJieQiJD速度要快,你也可以使用getJieQiJD来判断是否有节气。
|
||||
if day.HasJieQi() {
|
||||
fmt.Printf("节气:%s", Jqmc[day.GetJieQi()])
|
||||
//获取节气的儒略日数, 如果说你要计算什么时间的相距多少,直接比对儒略日要方便,相信我。
|
||||
jd := day.GetJieQiJD()
|
||||
|
||||
// 将儒略日数转换成年月日时秒
|
||||
t = sxtwl.JD2DD(jd)
|
||||
fmt.Printf("节气时间:%v", t)
|
||||
// # 注意,t.s是小数,需要四舍五入
|
||||
// print("节气时间:%d-%d-%d %d:%d:%d"%(t.Y, t.M, t.D, t.h, t.m, round(t.s)))
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
8
example/golang/sxtwl/init.go
Normal file
8
example/golang/sxtwl/init.go
Normal file
@ -0,0 +1,8 @@
|
||||
package sxtwl
|
||||
|
||||
/*
|
||||
// 参考:https://kaisawind.gitee.io/2020/10/24/2020-10-24-cgo-build/
|
||||
#cgo windows LDFLAGS:-L${SRCDIR}/../lib/win64 -lsxtwl_go -lsxtwl -lstdc++ -Wl,-rpath=./
|
||||
#cgo linux LDFLAGS:-L${SRCDIR}/../lib/linux -lsxtwl_go -lsxtwl -lm -lstdc++ -Wl,-rpath=./
|
||||
*/
|
||||
import "C"
|
790
example/golang/sxtwl/sxtwl.go
Normal file
790
example/golang/sxtwl/sxtwl.go
Normal file
@ -0,0 +1,790 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 4.0.2
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
// source: swig\sxtwl.i
|
||||
|
||||
package sxtwl
|
||||
|
||||
/*
|
||||
#define intgo swig_intgo
|
||||
typedef void *swig_voidp;
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
typedef int intgo;
|
||||
typedef unsigned int uintgo;
|
||||
|
||||
|
||||
|
||||
typedef struct { char *p; intgo n; } _gostring_;
|
||||
typedef struct { void* array; intgo len; intgo cap; } _goslice_;
|
||||
|
||||
|
||||
typedef long long swig_type_1;
|
||||
typedef long long swig_type_2;
|
||||
typedef long long swig_type_3;
|
||||
typedef long long swig_type_4;
|
||||
extern void _wrap_Swig_free_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern uintptr_t _wrap_Swig_malloc_sxtwl_258d85b6700e030a(swig_intgo arg1);
|
||||
extern uintptr_t _wrap_new_JDList__SWIG_0_sxtwl_258d85b6700e030a(void);
|
||||
extern uintptr_t _wrap_new_JDList__SWIG_1_sxtwl_258d85b6700e030a(swig_type_1 arg1);
|
||||
extern uintptr_t _wrap_new_JDList__SWIG_2_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern swig_type_2 _wrap_JDList_size_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern swig_type_3 _wrap_JDList_capacity_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern void _wrap_JDList_reserve_sxtwl_258d85b6700e030a(uintptr_t arg1, swig_type_4 arg2);
|
||||
extern _Bool _wrap_JDList_isEmpty_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern void _wrap_JDList_clear_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern void _wrap_JDList_add_sxtwl_258d85b6700e030a(uintptr_t arg1, double arg2);
|
||||
extern double _wrap_JDList_get_sxtwl_258d85b6700e030a(uintptr_t arg1, swig_intgo arg2);
|
||||
extern void _wrap_JDList_set_sxtwl_258d85b6700e030a(uintptr_t arg1, swig_intgo arg2, double arg3);
|
||||
extern void _wrap_delete_JDList_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern void _wrap_Time_Y_set_sxtwl_258d85b6700e030a(uintptr_t arg1, swig_intgo arg2);
|
||||
extern swig_intgo _wrap_Time_Y_get_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern void _wrap_Time_M_set_sxtwl_258d85b6700e030a(uintptr_t arg1, swig_intgo arg2);
|
||||
extern swig_intgo _wrap_Time_M_get_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern void _wrap_Time_D_set_sxtwl_258d85b6700e030a(uintptr_t arg1, swig_intgo arg2);
|
||||
extern swig_intgo _wrap_Time_D_get_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern void _wrap_Time_h_set_sxtwl_258d85b6700e030a(uintptr_t arg1, double arg2);
|
||||
extern double _wrap_Time_h_get_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern void _wrap_Time_s_set_sxtwl_258d85b6700e030a(uintptr_t arg1, double arg2);
|
||||
extern double _wrap_Time_s_get_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern uintptr_t _wrap_new_Time_sxtwl_258d85b6700e030a(void);
|
||||
extern void _wrap_delete_Time_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern uintptr_t _wrap_new_GZ__SWIG_0_sxtwl_258d85b6700e030a(void);
|
||||
extern uintptr_t _wrap_new_GZ__SWIG_1_sxtwl_258d85b6700e030a(char arg1, char arg2);
|
||||
extern void _wrap_GZ_tg_set_sxtwl_258d85b6700e030a(uintptr_t arg1, char arg2);
|
||||
extern char _wrap_GZ_tg_get_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern void _wrap_GZ_dz_set_sxtwl_258d85b6700e030a(uintptr_t arg1, char arg2);
|
||||
extern char _wrap_GZ_dz_get_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern void _wrap_delete_GZ_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern uintptr_t _wrap_Day_fromSolar_sxtwl_258d85b6700e030a(swig_intgo arg1, char arg2, swig_intgo arg3);
|
||||
extern uintptr_t _wrap_Day_fromLunar__SWIG_0_sxtwl_258d85b6700e030a(swig_intgo arg1, char arg2, swig_intgo arg3, _Bool arg4);
|
||||
extern uintptr_t _wrap_Day_fromLunar__SWIG_1_sxtwl_258d85b6700e030a(swig_intgo arg1, char arg2, swig_intgo arg3);
|
||||
extern uintptr_t _wrap_Day_after_sxtwl_258d85b6700e030a(uintptr_t arg1, swig_intgo arg2);
|
||||
extern uintptr_t _wrap_Day_before_sxtwl_258d85b6700e030a(uintptr_t arg1, swig_intgo arg2);
|
||||
extern swig_intgo _wrap_Day_getLunarDay_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern char _wrap_Day_getLunarMonth_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern swig_intgo _wrap_Day_getLunarYear__SWIG_0_sxtwl_258d85b6700e030a(uintptr_t arg1, _Bool arg2);
|
||||
extern swig_intgo _wrap_Day_getLunarYear__SWIG_1_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern uintptr_t _wrap_Day_getYearGZ__SWIG_0_sxtwl_258d85b6700e030a(uintptr_t arg1, _Bool arg2);
|
||||
extern uintptr_t _wrap_Day_getYearGZ__SWIG_1_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern uintptr_t _wrap_Day_getMonthGZ_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern uintptr_t _wrap_Day_getDayGZ_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern uintptr_t _wrap_Day_getHourGZ_sxtwl_258d85b6700e030a(uintptr_t arg1, char arg2);
|
||||
extern _Bool _wrap_Day_isLunarLeap_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern swig_intgo _wrap_Day_getSolarYear_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern char _wrap_Day_getSolarMonth_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern swig_intgo _wrap_Day_getSolarDay_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern char _wrap_Day_getWeek_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern char _wrap_Day_getWeekIndex_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern _Bool _wrap_Day_hasJieQi_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern char _wrap_Day_getJieQi_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern double _wrap_Day_getJieQiJD_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern char _wrap_Day_getConstellation_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern void _wrap_delete_Day_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
extern uintptr_t _wrap_fromSolar_sxtwl_258d85b6700e030a(swig_intgo arg1, char arg2, swig_intgo arg3);
|
||||
extern uintptr_t _wrap_fromLunar__SWIG_0_sxtwl_258d85b6700e030a(swig_intgo arg1, char arg2, swig_intgo arg3, _Bool arg4);
|
||||
extern uintptr_t _wrap_fromLunar__SWIG_1_sxtwl_258d85b6700e030a(swig_intgo arg1, char arg2, swig_intgo arg3);
|
||||
extern uintptr_t _wrap_siZhu2Year_sxtwl_258d85b6700e030a(uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, swig_intgo arg5, swig_intgo arg6);
|
||||
extern uintptr_t _wrap_getShiGz_sxtwl_258d85b6700e030a(char arg1, char arg2);
|
||||
extern char _wrap_getRunMonth_sxtwl_258d85b6700e030a(swig_intgo arg1);
|
||||
extern char _wrap_getLunarMonthNum__SWIG_0_sxtwl_258d85b6700e030a(swig_intgo arg1, char arg2, _Bool arg3);
|
||||
extern char _wrap_getLunarMonthNum__SWIG_1_sxtwl_258d85b6700e030a(swig_intgo arg1, char arg2);
|
||||
extern uintptr_t _wrap_JD2DD_sxtwl_258d85b6700e030a(double arg1);
|
||||
extern double _wrap_toJD_sxtwl_258d85b6700e030a(uintptr_t arg1);
|
||||
#undef intgo
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import "unsafe"
|
||||
import _ "runtime/cgo"
|
||||
import "sync"
|
||||
|
||||
|
||||
type _ unsafe.Pointer
|
||||
|
||||
|
||||
|
||||
var Swig_escape_always_false bool
|
||||
var Swig_escape_val interface{}
|
||||
|
||||
|
||||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
|
||||
|
||||
type _ sync.Mutex
|
||||
|
||||
func Swig_free(arg1 uintptr) {
|
||||
_swig_i_0 := arg1
|
||||
C._wrap_Swig_free_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0))
|
||||
}
|
||||
|
||||
func Swig_malloc(arg1 int) (_swig_ret uintptr) {
|
||||
var swig_r uintptr
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (uintptr)(C._wrap_Swig_malloc_sxtwl_258d85b6700e030a(C.swig_intgo(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
type SwigcptrJDList uintptr
|
||||
|
||||
func (p SwigcptrJDList) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrJDList) SwigIsJDList() {
|
||||
}
|
||||
|
||||
func NewJDList__SWIG_0() (_swig_ret JDList) {
|
||||
var swig_r JDList
|
||||
swig_r = (JDList)(SwigcptrJDList(C._wrap_new_JDList__SWIG_0_sxtwl_258d85b6700e030a()))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func NewJDList__SWIG_1(arg1 int64) (_swig_ret JDList) {
|
||||
var swig_r JDList
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (JDList)(SwigcptrJDList(C._wrap_new_JDList__SWIG_1_sxtwl_258d85b6700e030a(C.swig_type_1(_swig_i_0))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func NewJDList__SWIG_2(arg1 JDList) (_swig_ret JDList) {
|
||||
var swig_r JDList
|
||||
_swig_i_0 := arg1.Swigcptr()
|
||||
swig_r = (JDList)(SwigcptrJDList(C._wrap_new_JDList__SWIG_2_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func NewJDList(a ...interface{}) JDList {
|
||||
argc := len(a)
|
||||
if argc == 0 {
|
||||
return NewJDList__SWIG_0()
|
||||
}
|
||||
if argc == 1 {
|
||||
if _, ok := a[0].(int64); !ok {
|
||||
goto check_2
|
||||
}
|
||||
return NewJDList__SWIG_1(a[0].(int64))
|
||||
}
|
||||
check_2:
|
||||
if argc == 1 {
|
||||
return NewJDList__SWIG_2(a[0].(JDList))
|
||||
}
|
||||
panic("No match for overloaded function call")
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrJDList) Size() (_swig_ret int64) {
|
||||
var swig_r int64
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (int64)(C._wrap_JDList_size_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrJDList) Capacity() (_swig_ret int64) {
|
||||
var swig_r int64
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (int64)(C._wrap_JDList_capacity_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrJDList) Reserve(arg2 int64) {
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
C._wrap_JDList_reserve_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C.swig_type_4(_swig_i_1))
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrJDList) IsEmpty() (_swig_ret bool) {
|
||||
var swig_r bool
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (bool)(C._wrap_JDList_isEmpty_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrJDList) Clear() {
|
||||
_swig_i_0 := arg1
|
||||
C._wrap_JDList_clear_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0))
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrJDList) Add(arg2 float64) {
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
C._wrap_JDList_add_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C.double(_swig_i_1))
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrJDList) Get(arg2 int) (_swig_ret float64) {
|
||||
var swig_r float64
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
swig_r = (float64)(C._wrap_JDList_get_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C.swig_intgo(_swig_i_1)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrJDList) Set(arg2 int, arg3 float64) {
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
_swig_i_2 := arg3
|
||||
C._wrap_JDList_set_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C.swig_intgo(_swig_i_1), C.double(_swig_i_2))
|
||||
}
|
||||
|
||||
func DeleteJDList(arg1 JDList) {
|
||||
_swig_i_0 := arg1.Swigcptr()
|
||||
C._wrap_delete_JDList_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0))
|
||||
}
|
||||
|
||||
type JDList interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsJDList()
|
||||
Size() (_swig_ret int64)
|
||||
Capacity() (_swig_ret int64)
|
||||
Reserve(arg2 int64)
|
||||
IsEmpty() (_swig_ret bool)
|
||||
Clear()
|
||||
Add(arg2 float64)
|
||||
Get(arg2 int) (_swig_ret float64)
|
||||
Set(arg2 int, arg3 float64)
|
||||
}
|
||||
|
||||
const J2000 int = 2451545
|
||||
type SwigcptrTime uintptr
|
||||
|
||||
func (p SwigcptrTime) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrTime) SwigIsTime() {
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrTime) SetY(arg2 int) {
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
C._wrap_Time_Y_set_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C.swig_intgo(_swig_i_1))
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrTime) GetY() (_swig_ret int) {
|
||||
var swig_r int
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (int)(C._wrap_Time_Y_get_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrTime) SetM(arg2 int) {
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
C._wrap_Time_M_set_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C.swig_intgo(_swig_i_1))
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrTime) GetM() (_swig_ret int) {
|
||||
var swig_r int
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (int)(C._wrap_Time_M_get_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrTime) SetD(arg2 int) {
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
C._wrap_Time_D_set_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C.swig_intgo(_swig_i_1))
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrTime) GetD() (_swig_ret int) {
|
||||
var swig_r int
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (int)(C._wrap_Time_D_get_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrTime) SetH(arg2 float64) {
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
C._wrap_Time_h_set_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C.double(_swig_i_1))
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrTime) GetH() (_swig_ret float64) {
|
||||
var swig_r float64
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (float64)(C._wrap_Time_h_get_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrTime) SetS(arg2 float64) {
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
C._wrap_Time_s_set_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C.double(_swig_i_1))
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrTime) GetS() (_swig_ret float64) {
|
||||
var swig_r float64
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (float64)(C._wrap_Time_s_get_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func NewTime() (_swig_ret Time) {
|
||||
var swig_r Time
|
||||
swig_r = (Time)(SwigcptrTime(C._wrap_new_Time_sxtwl_258d85b6700e030a()))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func DeleteTime(arg1 Time) {
|
||||
_swig_i_0 := arg1.Swigcptr()
|
||||
C._wrap_delete_Time_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0))
|
||||
}
|
||||
|
||||
type Time interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsTime()
|
||||
SetY(arg2 int)
|
||||
GetY() (_swig_ret int)
|
||||
SetM(arg2 int)
|
||||
GetM() (_swig_ret int)
|
||||
SetD(arg2 int)
|
||||
GetD() (_swig_ret int)
|
||||
SetH(arg2 float64)
|
||||
GetH() (_swig_ret float64)
|
||||
SetS(arg2 float64)
|
||||
GetS() (_swig_ret float64)
|
||||
}
|
||||
|
||||
type SwigcptrGZ uintptr
|
||||
|
||||
func (p SwigcptrGZ) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrGZ) SwigIsGZ() {
|
||||
}
|
||||
|
||||
func NewGZ__SWIG_0() (_swig_ret GZ) {
|
||||
var swig_r GZ
|
||||
swig_r = (GZ)(SwigcptrGZ(C._wrap_new_GZ__SWIG_0_sxtwl_258d85b6700e030a()))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func NewGZ__SWIG_1(arg1 byte, arg2 byte) (_swig_ret GZ) {
|
||||
var swig_r GZ
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
swig_r = (GZ)(SwigcptrGZ(C._wrap_new_GZ__SWIG_1_sxtwl_258d85b6700e030a(C.char(_swig_i_0), C.char(_swig_i_1))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func NewGZ(a ...interface{}) GZ {
|
||||
argc := len(a)
|
||||
if argc == 0 {
|
||||
return NewGZ__SWIG_0()
|
||||
}
|
||||
if argc == 2 {
|
||||
return NewGZ__SWIG_1(a[0].(byte), a[1].(byte))
|
||||
}
|
||||
panic("No match for overloaded function call")
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrGZ) SetTg(arg2 byte) {
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
C._wrap_GZ_tg_set_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C.char(_swig_i_1))
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrGZ) GetTg() (_swig_ret byte) {
|
||||
var swig_r byte
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (byte)(C._wrap_GZ_tg_get_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrGZ) SetDz(arg2 byte) {
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
C._wrap_GZ_dz_set_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C.char(_swig_i_1))
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrGZ) GetDz() (_swig_ret byte) {
|
||||
var swig_r byte
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (byte)(C._wrap_GZ_dz_get_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func DeleteGZ(arg1 GZ) {
|
||||
_swig_i_0 := arg1.Swigcptr()
|
||||
C._wrap_delete_GZ_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0))
|
||||
}
|
||||
|
||||
type GZ interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsGZ()
|
||||
SetTg(arg2 byte)
|
||||
GetTg() (_swig_ret byte)
|
||||
SetDz(arg2 byte)
|
||||
GetDz() (_swig_ret byte)
|
||||
}
|
||||
|
||||
type SwigcptrDay uintptr
|
||||
|
||||
func (p SwigcptrDay) Swigcptr() uintptr {
|
||||
return (uintptr)(p)
|
||||
}
|
||||
|
||||
func (p SwigcptrDay) SwigIsDay() {
|
||||
}
|
||||
|
||||
func DayFromSolar(arg1 int, arg2 byte, arg3 int) (_swig_ret Day) {
|
||||
var swig_r Day
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
_swig_i_2 := arg3
|
||||
swig_r = (Day)(SwigcptrDay(C._wrap_Day_fromSolar_sxtwl_258d85b6700e030a(C.swig_intgo(_swig_i_0), C.char(_swig_i_1), C.swig_intgo(_swig_i_2))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func DayFromLunar__SWIG_0(arg1 int, arg2 byte, arg3 int, arg4 bool) (_swig_ret Day) {
|
||||
var swig_r Day
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
_swig_i_2 := arg3
|
||||
_swig_i_3 := arg4
|
||||
swig_r = (Day)(SwigcptrDay(C._wrap_Day_fromLunar__SWIG_0_sxtwl_258d85b6700e030a(C.swig_intgo(_swig_i_0), C.char(_swig_i_1), C.swig_intgo(_swig_i_2), C._Bool(_swig_i_3))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func DayFromLunar__SWIG_1(arg1 int, arg2 byte, arg3 int) (_swig_ret Day) {
|
||||
var swig_r Day
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
_swig_i_2 := arg3
|
||||
swig_r = (Day)(SwigcptrDay(C._wrap_Day_fromLunar__SWIG_1_sxtwl_258d85b6700e030a(C.swig_intgo(_swig_i_0), C.char(_swig_i_1), C.swig_intgo(_swig_i_2))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func DayFromLunar(a ...interface{}) Day {
|
||||
argc := len(a)
|
||||
if argc == 3 {
|
||||
return DayFromLunar__SWIG_1(a[0].(int), a[1].(byte), a[2].(int))
|
||||
}
|
||||
if argc == 4 {
|
||||
return DayFromLunar__SWIG_0(a[0].(int), a[1].(byte), a[2].(int), a[3].(bool))
|
||||
}
|
||||
panic("No match for overloaded function call")
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) After(arg2 int) (_swig_ret Day) {
|
||||
var swig_r Day
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
swig_r = (Day)(SwigcptrDay(C._wrap_Day_after_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C.swig_intgo(_swig_i_1))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) Before(arg2 int) (_swig_ret Day) {
|
||||
var swig_r Day
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
swig_r = (Day)(SwigcptrDay(C._wrap_Day_before_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C.swig_intgo(_swig_i_1))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetLunarDay() (_swig_ret int) {
|
||||
var swig_r int
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (int)(C._wrap_Day_getLunarDay_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetLunarMonth() (_swig_ret byte) {
|
||||
var swig_r byte
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (byte)(C._wrap_Day_getLunarMonth_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetLunarYear__SWIG_0(arg2 bool) (_swig_ret int) {
|
||||
var swig_r int
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
swig_r = (int)(C._wrap_Day_getLunarYear__SWIG_0_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C._Bool(_swig_i_1)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetLunarYear__SWIG_1() (_swig_ret int) {
|
||||
var swig_r int
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (int)(C._wrap_Day_getLunarYear__SWIG_1_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (p SwigcptrDay) GetLunarYear(a ...interface{}) int {
|
||||
argc := len(a)
|
||||
if argc == 0 {
|
||||
return p.GetLunarYear__SWIG_1()
|
||||
}
|
||||
if argc == 1 {
|
||||
return p.GetLunarYear__SWIG_0(a[0].(bool))
|
||||
}
|
||||
panic("No match for overloaded function call")
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetYearGZ__SWIG_0(arg2 bool) (_swig_ret GZ) {
|
||||
var swig_r GZ
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
swig_r = (GZ)(SwigcptrGZ(C._wrap_Day_getYearGZ__SWIG_0_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C._Bool(_swig_i_1))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetYearGZ__SWIG_1() (_swig_ret GZ) {
|
||||
var swig_r GZ
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (GZ)(SwigcptrGZ(C._wrap_Day_getYearGZ__SWIG_1_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (p SwigcptrDay) GetYearGZ(a ...interface{}) GZ {
|
||||
argc := len(a)
|
||||
if argc == 0 {
|
||||
return p.GetYearGZ__SWIG_1()
|
||||
}
|
||||
if argc == 1 {
|
||||
return p.GetYearGZ__SWIG_0(a[0].(bool))
|
||||
}
|
||||
panic("No match for overloaded function call")
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetMonthGZ() (_swig_ret GZ) {
|
||||
var swig_r GZ
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (GZ)(SwigcptrGZ(C._wrap_Day_getMonthGZ_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetDayGZ() (_swig_ret GZ) {
|
||||
var swig_r GZ
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (GZ)(SwigcptrGZ(C._wrap_Day_getDayGZ_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetHourGZ(arg2 byte) (_swig_ret GZ) {
|
||||
var swig_r GZ
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
swig_r = (GZ)(SwigcptrGZ(C._wrap_Day_getHourGZ_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C.char(_swig_i_1))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) IsLunarLeap() (_swig_ret bool) {
|
||||
var swig_r bool
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (bool)(C._wrap_Day_isLunarLeap_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetSolarYear() (_swig_ret int) {
|
||||
var swig_r int
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (int)(C._wrap_Day_getSolarYear_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetSolarMonth() (_swig_ret byte) {
|
||||
var swig_r byte
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (byte)(C._wrap_Day_getSolarMonth_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetSolarDay() (_swig_ret int) {
|
||||
var swig_r int
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (int)(C._wrap_Day_getSolarDay_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetWeek() (_swig_ret byte) {
|
||||
var swig_r byte
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (byte)(C._wrap_Day_getWeek_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetWeekIndex() (_swig_ret byte) {
|
||||
var swig_r byte
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (byte)(C._wrap_Day_getWeekIndex_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) HasJieQi() (_swig_ret bool) {
|
||||
var swig_r bool
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (bool)(C._wrap_Day_hasJieQi_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetJieQi() (_swig_ret byte) {
|
||||
var swig_r byte
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (byte)(C._wrap_Day_getJieQi_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetJieQiJD() (_swig_ret float64) {
|
||||
var swig_r float64
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (float64)(C._wrap_Day_getJieQiJD_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func (arg1 SwigcptrDay) GetConstellation() (_swig_ret byte) {
|
||||
var swig_r byte
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (byte)(C._wrap_Day_getConstellation_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func DeleteDay(arg1 Day) {
|
||||
_swig_i_0 := arg1.Swigcptr()
|
||||
C._wrap_delete_Day_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0))
|
||||
}
|
||||
|
||||
type Day interface {
|
||||
Swigcptr() uintptr
|
||||
SwigIsDay()
|
||||
After(arg2 int) (_swig_ret Day)
|
||||
Before(arg2 int) (_swig_ret Day)
|
||||
GetLunarDay() (_swig_ret int)
|
||||
GetLunarMonth() (_swig_ret byte)
|
||||
GetLunarYear(a ...interface{}) int
|
||||
GetYearGZ(a ...interface{}) GZ
|
||||
GetMonthGZ() (_swig_ret GZ)
|
||||
GetDayGZ() (_swig_ret GZ)
|
||||
GetHourGZ(arg2 byte) (_swig_ret GZ)
|
||||
IsLunarLeap() (_swig_ret bool)
|
||||
GetSolarYear() (_swig_ret int)
|
||||
GetSolarMonth() (_swig_ret byte)
|
||||
GetSolarDay() (_swig_ret int)
|
||||
GetWeek() (_swig_ret byte)
|
||||
GetWeekIndex() (_swig_ret byte)
|
||||
HasJieQi() (_swig_ret bool)
|
||||
GetJieQi() (_swig_ret byte)
|
||||
GetJieQiJD() (_swig_ret float64)
|
||||
GetConstellation() (_swig_ret byte)
|
||||
}
|
||||
|
||||
func FromSolar(arg1 int, arg2 byte, arg3 int) (_swig_ret Day) {
|
||||
var swig_r Day
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
_swig_i_2 := arg3
|
||||
swig_r = (Day)(SwigcptrDay(C._wrap_fromSolar_sxtwl_258d85b6700e030a(C.swig_intgo(_swig_i_0), C.char(_swig_i_1), C.swig_intgo(_swig_i_2))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func FromLunar__SWIG_0(arg1 int, arg2 byte, arg3 int, arg4 bool) (_swig_ret Day) {
|
||||
var swig_r Day
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
_swig_i_2 := arg3
|
||||
_swig_i_3 := arg4
|
||||
swig_r = (Day)(SwigcptrDay(C._wrap_fromLunar__SWIG_0_sxtwl_258d85b6700e030a(C.swig_intgo(_swig_i_0), C.char(_swig_i_1), C.swig_intgo(_swig_i_2), C._Bool(_swig_i_3))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func FromLunar__SWIG_1(arg1 int, arg2 byte, arg3 int) (_swig_ret Day) {
|
||||
var swig_r Day
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
_swig_i_2 := arg3
|
||||
swig_r = (Day)(SwigcptrDay(C._wrap_fromLunar__SWIG_1_sxtwl_258d85b6700e030a(C.swig_intgo(_swig_i_0), C.char(_swig_i_1), C.swig_intgo(_swig_i_2))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func FromLunar(a ...interface{}) Day {
|
||||
argc := len(a)
|
||||
if argc == 3 {
|
||||
return FromLunar__SWIG_1(a[0].(int), a[1].(byte), a[2].(int))
|
||||
}
|
||||
if argc == 4 {
|
||||
return FromLunar__SWIG_0(a[0].(int), a[1].(byte), a[2].(int), a[3].(bool))
|
||||
}
|
||||
panic("No match for overloaded function call")
|
||||
}
|
||||
|
||||
func SiZhu2Year(arg1 GZ, arg2 GZ, arg3 GZ, arg4 GZ, arg5 int, arg6 int) (_swig_ret JDList) {
|
||||
var swig_r JDList
|
||||
_swig_i_0 := arg1.Swigcptr()
|
||||
_swig_i_1 := arg2.Swigcptr()
|
||||
_swig_i_2 := arg3.Swigcptr()
|
||||
_swig_i_3 := arg4.Swigcptr()
|
||||
_swig_i_4 := arg5
|
||||
_swig_i_5 := arg6
|
||||
swig_r = (JDList)(SwigcptrJDList(C._wrap_siZhu2Year_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0), C.uintptr_t(_swig_i_1), C.uintptr_t(_swig_i_2), C.uintptr_t(_swig_i_3), C.swig_intgo(_swig_i_4), C.swig_intgo(_swig_i_5))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func GetShiGz(arg1 byte, arg2 byte) (_swig_ret GZ) {
|
||||
var swig_r GZ
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
swig_r = (GZ)(SwigcptrGZ(C._wrap_getShiGz_sxtwl_258d85b6700e030a(C.char(_swig_i_0), C.char(_swig_i_1))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func GetRunMonth(arg1 int) (_swig_ret byte) {
|
||||
var swig_r byte
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (byte)(C._wrap_getRunMonth_sxtwl_258d85b6700e030a(C.swig_intgo(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func GetLunarMonthNum__SWIG_0(arg1 int, arg2 byte, arg3 bool) (_swig_ret byte) {
|
||||
var swig_r byte
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
_swig_i_2 := arg3
|
||||
swig_r = (byte)(C._wrap_getLunarMonthNum__SWIG_0_sxtwl_258d85b6700e030a(C.swig_intgo(_swig_i_0), C.char(_swig_i_1), C._Bool(_swig_i_2)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func GetLunarMonthNum__SWIG_1(arg1 int, arg2 byte) (_swig_ret byte) {
|
||||
var swig_r byte
|
||||
_swig_i_0 := arg1
|
||||
_swig_i_1 := arg2
|
||||
swig_r = (byte)(C._wrap_getLunarMonthNum__SWIG_1_sxtwl_258d85b6700e030a(C.swig_intgo(_swig_i_0), C.char(_swig_i_1)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func GetLunarMonthNum(a ...interface{}) byte {
|
||||
argc := len(a)
|
||||
if argc == 2 {
|
||||
return GetLunarMonthNum__SWIG_1(a[0].(int), a[1].(byte))
|
||||
}
|
||||
if argc == 3 {
|
||||
return GetLunarMonthNum__SWIG_0(a[0].(int), a[1].(byte), a[2].(bool))
|
||||
}
|
||||
panic("No match for overloaded function call")
|
||||
}
|
||||
|
||||
func JD2DD(arg1 float64) (_swig_ret Time) {
|
||||
var swig_r Time
|
||||
_swig_i_0 := arg1
|
||||
swig_r = (Time)(SwigcptrTime(C._wrap_JD2DD_sxtwl_258d85b6700e030a(C.double(_swig_i_0))))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
func ToJD(arg1 Time) (_swig_ret float64) {
|
||||
var swig_r float64
|
||||
_swig_i_0 := arg1.Swigcptr()
|
||||
swig_r = (float64)(C._wrap_toJD_sxtwl_258d85b6700e030a(C.uintptr_t(_swig_i_0)))
|
||||
return swig_r
|
||||
}
|
||||
|
||||
|
203
example/main.cpp
Normal file
203
example/main.cpp
Normal file
@ -0,0 +1,203 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include "const.h"
|
||||
#include "sxtwl.h"
|
||||
|
||||
|
||||
//===============================================================
|
||||
#ifdef _WIN32
|
||||
class MBuf : public std::stringbuf
|
||||
{
|
||||
public:
|
||||
int sync()
|
||||
{
|
||||
fputs(str().c_str(), stdout);
|
||||
str("");
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
//===============================================================
|
||||
|
||||
static const char *Gan[] = {"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"};
|
||||
static const char *Zhi[] = {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"};
|
||||
static const char *ShX[] = {"鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"};
|
||||
static const char *numCn[] = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"}; //中文数字
|
||||
static const char *jqmc[] = {"冬至", "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪"};
|
||||
static const char *ymc[] = { "正", "二", "三", "四", "五", "六", "七", "八", "九", "十","十一", "十二"}; //月名称,建寅
|
||||
static const char *rmc[] = {"初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一"};
|
||||
static const char *WeekCn[] = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
|
||||
|
||||
|
||||
GZ getGZ(std::string tgStr, std::string dzStr) {
|
||||
int tg = -1;
|
||||
int dz = -1;
|
||||
for (size_t i = 0; i < 10; i++)
|
||||
{
|
||||
if (std::string(Gan[i]) == tgStr) {
|
||||
tg = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < 12; i++)
|
||||
{
|
||||
if (std::string(Zhi[i]) == dzStr) {
|
||||
dz = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return GZ(tg, dz);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void printDay(Day& day)
|
||||
{
|
||||
|
||||
std::cout << "\n===================================================" << std::endl;
|
||||
|
||||
// 公历
|
||||
std::cout << "公历:" << day.getSolarYear() << "年"
|
||||
<< (int)day.getSolarMonth() << "月"
|
||||
<< day.getSolarDay() << "日" << std::endl;
|
||||
|
||||
// 农历
|
||||
std::cout << "农历:" << (day.isLunarLeap()? "闰":"")
|
||||
<< ymc[day.getLunarMonth() - 1] << "月"
|
||||
<< rmc[day.getLunarDay() - 1] << "日" << std::endl;
|
||||
|
||||
// 星期几
|
||||
std::cout << "星期:" << WeekCn[day.getWeek()] << std::endl;
|
||||
|
||||
//年天二地支
|
||||
std::cout << "天干:"
|
||||
<< Gan[day.getYearGZ().tg] << Zhi[day.getYearGZ().dz] << "年"
|
||||
<< Gan[day.getMonthGZ().tg] << Zhi[day.getMonthGZ().dz] << "月"
|
||||
<< Gan[day.getMonthGZ().tg] << Zhi[day.getMonthGZ().dz] << "日"
|
||||
<< std::endl;
|
||||
};
|
||||
|
||||
int round_double(double number)
|
||||
{
|
||||
return (number > 0.0) ? (number + 0.5) : (number - 0.5);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
//#ifdef _WIN32
|
||||
////http://m.blog.csdn.net/article/details?id=52789570
|
||||
//https://stackoverflow.com/questions/45575863/how-to-print-utf-8-strings-to-stdcout-on-windows
|
||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||
MBuf buf;
|
||||
std::cout.rdbuf(&buf);
|
||||
//#endif
|
||||
|
||||
|
||||
|
||||
|
||||
GZ hourGZ = sxtwl::getShiGz(0, 23, false);
|
||||
|
||||
do {
|
||||
Day* day = sxtwl::fromSolar(2021, 11, 14);
|
||||
day->getHourGZ(8);
|
||||
auto ret = sxtwl::siZhu2Year(day->getYearGZ(), day->getMonthGZ(), day->getDayGZ(), getGZ("癸", "巳"), 2021, 2025);
|
||||
printf("%d", ret.size());
|
||||
} while (false);
|
||||
|
||||
do {
|
||||
Day* day = sxtwl::fromSolar(1392, 1, 1);
|
||||
for (int i = 0; i < 365; ++i) {
|
||||
day = day->after(1);
|
||||
if (day->hasJieQi()) {
|
||||
auto jd = day->getJieQiJD();
|
||||
auto t = sxtwl::JD2DD(jd);
|
||||
std::cout <<jqmc[day->getJieQi()] << ": " << t.getYear() << "-" << t.getMonth() << "-"
|
||||
<< t.getDay() << " " << int(t.getHour()) << ":" << int(t.getMin()) << ":" << round_double(t.getSec())
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
} while (false);
|
||||
|
||||
|
||||
|
||||
|
||||
// 获取一年当中的闰月
|
||||
for(auto i = 1; i <= 3000; ++i)
|
||||
{
|
||||
auto lunMonth = (int)sxtwl::getRunMonth(i);
|
||||
if(lunMonth <= 0) continue;
|
||||
printf("%d年 闰%d月\n", i, lunMonth);
|
||||
}
|
||||
|
||||
//从阳历获取一个day对像
|
||||
Day* day = sxtwl::fromSolar(118, 10, 3);
|
||||
printDay(*day);
|
||||
for(auto i = 0; i < 100; ++i){
|
||||
day = day->after(1);
|
||||
printDay(*day);
|
||||
}
|
||||
|
||||
// 阳历转阴历
|
||||
{
|
||||
Day* day = sxtwl::fromSolar(2021, 11, 7);
|
||||
std::cout << "农历:" << day->getLunarYear() << "年" << (int)day->getLunarMonth() << "月" << day-> getLunarDay() << "日" << std::endl;
|
||||
|
||||
|
||||
day = sxtwl::fromLunar( day->getLunarYear(), day->getLunarMonth(), day-> getLunarDay(), day->isLunarLeap());
|
||||
std::cout << "公历:" << day->getSolarYear() << "年" << (int)day->getSolarMonth() << "月" << day-> getSolarDay() << "日" << std::endl;
|
||||
|
||||
sxtwl::getShiGz(day->getDayGZ().tg, 0);
|
||||
|
||||
auto c = day->getConstellation();
|
||||
printf("%c", c);
|
||||
|
||||
if( day->hasJieQi()){
|
||||
auto jd = day->getJieQiJD();
|
||||
auto t = sxtwl::JD2DD(jd);
|
||||
jd = sxtwl::toJD(t);
|
||||
}
|
||||
|
||||
auto ret = sxtwl::siZhu2Year(day->getYearGZ(), day->getMonthGZ(), day->getDayGZ(),
|
||||
GZ(0, 0)
|
||||
, 2003, 2029);
|
||||
|
||||
|
||||
/* printf("finish");*/
|
||||
|
||||
}
|
||||
{
|
||||
|
||||
|
||||
|
||||
Day* day = sxtwl::fromSolar(202, 1, 20);
|
||||
if (day->hasJieQi()) {
|
||||
auto t = sxtwl::JD2DD(day->getJieQiJD());
|
||||
std::cout << jqmc[day->getJieQi()] << ": " << t.getYear() << "-" << t.getMonth() << "-"
|
||||
<< t.getDay() << " " << int(t.getHour()) << ":" << int(t.getMin()) << ":" << round_double(t.getSec())
|
||||
<< std::endl;
|
||||
}
|
||||
delete day;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
auto ret = sxtwl::getJieQiByYear(202);
|
||||
|
||||
for (auto it = ret.begin(); it != ret.end(); ++it) {
|
||||
auto t = sxtwl::JD2DD(it->jd);
|
||||
std::cout << jqmc[it->jqIndex] << ": " << t.getYear() << "-" << t.getMonth() << "-"
|
||||
<< t.getDay() << " " << int(t.getHour()) << ":" << int(t.getMin()) << ":" << round_double(t.getSec())
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
Time t(202, 1, 23, 12, 0, 0);
|
||||
auto jd = sxtwl::toJD(t) - J2000;
|
||||
//===========================================================================
|
||||
return 0;
|
||||
}
|
189
example/main.py
Normal file
189
example/main.py
Normal file
@ -0,0 +1,189 @@
|
||||
import sxtwl
|
||||
|
||||
## 一些常量文字的定义。
|
||||
Gan = ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"]
|
||||
Zhi = ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
|
||||
ShX = ["鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"]
|
||||
numCn = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"]
|
||||
jqmc = ["冬至", "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏",
|
||||
"小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑","白露", "秋分", "寒露", "霜降",
|
||||
"立冬", "小雪", "大雪"]
|
||||
ymc = [ "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二" ]
|
||||
rmc = ["初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十",
|
||||
"十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十",
|
||||
"廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一"]
|
||||
XiZ = ['摩羯', '水瓶', '双鱼', '白羊', '金牛', '双子', '巨蟹', '狮子', '处女', '天秤', '天蝎', '射手']
|
||||
WeekCn = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
|
||||
|
||||
|
||||
# 从公历年月日获取一天的信息
|
||||
day = sxtwl.fromSolar(2021, 11, 7)
|
||||
|
||||
# 从农历年月日获取一天的信息
|
||||
# day = sxtwl.fromLunar(2020, 12, 1)
|
||||
# 如果是想查闰月,第四个参数加一个True即可
|
||||
# day = sxtwl.fromLunar(2020, 4, 1, True)
|
||||
|
||||
# 公历的年月日
|
||||
s = "公历:%d年%d月%d日" % (day.getSolarYear(), day.getSolarMonth(), day.getSolarDay())
|
||||
print(s)
|
||||
|
||||
# 星期几
|
||||
print(WeekCn[day.getWeek()])
|
||||
|
||||
# 这个月的第几周
|
||||
print('该日属于这个月的第%d周'%(day.getWeekIndex(),))
|
||||
|
||||
# 星座
|
||||
print("星座:", XiZ[day.getConstellation()])
|
||||
|
||||
# 以春节为界的农历(注getLunarYear如果没有传参,或者传true,是以春节为界的)
|
||||
s = "农历:%d年%s%d月%d日" % (day.getLunarYear(), '闰' if day.isLunarLeap() else '', day.getLunarMonth(), day.getLunarDay())
|
||||
print(s)
|
||||
|
||||
# 不以立春为界的农历
|
||||
s = "农历:%d年%s%d月%d日" % (day.getLunarYear(False), '闰' if day.isLunarLeap() else '', day.getLunarMonth(), day.getLunarDay())
|
||||
print(s)
|
||||
|
||||
# 使用中文表示农历
|
||||
s = "农历:%d年%s%d月%d日" % (day.getLunarYear(False), '闰' if day.isLunarLeap() else '', ymc[day.getLunarMonth() - 1], rmc[day.getLunarDay() - 1])
|
||||
print(s)
|
||||
|
||||
# 以春节为界的天干地支
|
||||
yTG = day.getYearGZ(True)
|
||||
print("以春节为界的年干支", Gan[yTG.tg] + Zhi[yTG.dz])
|
||||
print("以春节为界的生肖:", ShX[yTG.dz])
|
||||
|
||||
# 以立春为界的天干地支 (注,如果没有传参,或者传false,是以立春为界的。刚好和getLunarYear相反)
|
||||
yTG = day.getYearGZ()
|
||||
print("以立春为界的年干支", Gan[yTG.tg] + Zhi[yTG.dz])
|
||||
print("以立春为界的生肖:", ShX[yTG.dz])
|
||||
|
||||
#月干支
|
||||
mTG = day.getMonthGZ()
|
||||
print("月干支", Gan[mTG.tg] + Zhi[mTG.dz])
|
||||
|
||||
#日干支
|
||||
dTG = day.getDayGZ()
|
||||
print("日干支", Gan[dTG.tg] + Zhi[dTG.dz])
|
||||
|
||||
#时干支,传24小时制的时间,默认分早晚子时
|
||||
hour = 18
|
||||
sTG = day.getHourGZ(hour)
|
||||
print("%d时的干支"%(hour, ), Gan[sTG.tg] + Zhi[sTG.dz])
|
||||
|
||||
|
||||
# 如果想非早晚子时,第二个参数设置成false(注意,如果使用非早晚子时,那么Day要使用第二天的,相当于23点换日)
|
||||
hour = 23
|
||||
sTG = day.getHourGZ(hour, False)
|
||||
print("%d时的干支"%(hour, ), Gan[sTG.tg] + Zhi[sTG.dz])
|
||||
|
||||
|
||||
#时干支
|
||||
for hour in range(24):
|
||||
# 第一个参数为该天的天干,第二个参数为小时
|
||||
hTG = sxtwl.getShiGz(dTG.tg, hour)
|
||||
print("%d时天干地支:"%(hour), Gan[hTG.tg] + Zhi[hTG.dz])
|
||||
|
||||
|
||||
# 当日是否有节气
|
||||
if day.hasJieQi():
|
||||
print('节气:%s'% jqmc[day.getJieQi()])
|
||||
#获取节气的儒略日数
|
||||
jd = day.getJieQiJD()
|
||||
# 将儒略日数转换成年月日时秒
|
||||
t = sxtwl.JD2DD(jd )
|
||||
|
||||
# 注意,t.s是小数,需要四舍五入
|
||||
print("节气时间:%d-%d-%d %d:%d:%d"%(t.Y, t.M, t.D, t.h, t.m, round(t.s)))
|
||||
else:
|
||||
print("当天不是节气日")
|
||||
|
||||
###==================================================================================
|
||||
# 四柱反查工具方法
|
||||
# 实际项目中不要这样子搞哈,因为汉字utf-8,GBK2312不同的编码。建议还是直接使用天干地支的数字索引
|
||||
def getGZ(gzStr):
|
||||
tg = -1
|
||||
dz = -1
|
||||
for i, v in enumerate(Gan):
|
||||
if gzStr[0] == v:
|
||||
tg = i
|
||||
break
|
||||
|
||||
for i, v in enumerate(Zhi):
|
||||
if gzStr[1] == v:
|
||||
dz = i
|
||||
break
|
||||
return sxtwl.GZ(tg, dz)
|
||||
###==================================================================================
|
||||
|
||||
# 四注反查 分别传的是年天干,月天干,日天干,时天干, 开始查询年,结束查询年 返回满足条件的儒略日数
|
||||
jds = sxtwl.siZhu2Year(getGZ('辛丑'), getGZ('己亥'), getGZ('丙寅'), getGZ('癸巳'), 2003, 2029);
|
||||
for jd in jds:
|
||||
t = sxtwl.JD2DD(jd )
|
||||
print("符合条件的时间:%d-%d-%d %d:%d:%d"%(t.Y, t.M, t.D, t.h, t.m, round(t.s)))
|
||||
|
||||
|
||||
# 获取一年中的闰月
|
||||
year = 2020
|
||||
month = sxtwl.getRunMonth(year)
|
||||
if month >= 0:
|
||||
print("%d年的闰月是%d"%(year, month) )
|
||||
else:
|
||||
print("没有闰月")
|
||||
|
||||
|
||||
# 一个农历月的天数
|
||||
year = 2020 #农历年
|
||||
month = 4 #农历月
|
||||
isRun = False #是否是闰月
|
||||
daynum = sxtwl.getLunarMonthNum(year, month, isRun)
|
||||
print("农历%d年%s%d月的天数:"%(year, '闰'if isRun else '', month), daynum)
|
||||
|
||||
|
||||
#儒略日数转公历
|
||||
jd = sxtwl.J2000
|
||||
t = sxtwl.JD2DD(jd )
|
||||
|
||||
#公历转儒略日
|
||||
jd = sxtwl.toJD(t)
|
||||
|
||||
# 获取某天的后面几天
|
||||
num = 1 #你喜欢写多少天 也多少天,可以写负数,相当于往前
|
||||
day = day.after(num) #获取num天后的日信息
|
||||
s = "公历:%d年%d月%d日" % (day.getSolarYear(), day.getSolarMonth(), day.getSolarDay())
|
||||
print(s)
|
||||
|
||||
# 同上
|
||||
day = day.before(num)
|
||||
s = "公历:%d年%d月%d日" % (day.getSolarYear(), day.getSolarMonth(), day.getSolarDay())
|
||||
print(s)
|
||||
|
||||
|
||||
# 查找某日前后的节气
|
||||
while True:
|
||||
# 这里可以使用after或者before,不用担心速度,这里的计算在底层仅仅是+1这么简单
|
||||
day = day.after(1)
|
||||
# hasJieQi的接口比getJieQiJD速度要快,你也可以使用getJieQiJD来判断是否有节气。
|
||||
if day.hasJieQi():
|
||||
print('节气:%s'% jqmc[day.getJieQi()])
|
||||
#获取节气的儒略日数, 如果说你要计算什么时间的相距多少,直接比对儒略日要方便,相信我。
|
||||
jd = day.getJieQiJD()
|
||||
|
||||
# 将儒略日数转换成年月日时秒
|
||||
t = sxtwl.JD2DD(jd )
|
||||
|
||||
# 注意,t.s是小数,需要四舍五入
|
||||
print("节气时间:%d-%d-%d %d:%d:%d"%(t.Y, t.M, t.D, t.h, t.m, round(t.s)))
|
||||
|
||||
break
|
||||
|
||||
### 快速获取一年的节气时间 (注意,网页版的寿星天文历,202年1月份的大寒显示是不对的)
|
||||
ret = sxtwl.getJieQiByYear(202)
|
||||
|
||||
for v in ret:
|
||||
# 将儒略日数转换成年月日时秒
|
||||
t = sxtwl.JD2DD(v.jd)
|
||||
print('节气:%s 节气时间:%d-%d-%d %d:%d:%d'% (jqmc[v.jqIndex],t.Y, t.M, t.D, t.h, t.m, round(t.s)))
|
||||
|
||||
|
26
export.sh
Normal file
26
export.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#php
|
||||
# swig -c++ -php5 -outcurrentdir -outdir export/php5 swig/sxtwl.i
|
||||
# mv sxtwl_wrap.cxx export/php5/sxtwl_wrap.cxx
|
||||
|
||||
swig -c++ -php7 -outcurrentdir -outdir export/php7 swig/sxtwl.i
|
||||
mv sxtwl_wrap.cxx export/php7/sxtwl_wrap.cxx
|
||||
|
||||
# lua
|
||||
swig -c++ -lua -outcurrentdir -outdir export/lua swig/sxtwl.i
|
||||
mv sxtwl_wrap.cxx export/lua/sxtwl_wrap.cxx
|
||||
|
||||
# java
|
||||
swig -c++ -java -outcurrentdir -outdir export/java -package com.seantone.sxtwl swig/sxtwl.i
|
||||
mv sxtwl_wrap.cxx export/java/sxtwl_wrap.cxx
|
||||
|
||||
# C#
|
||||
swig -c++ -csharp -outcurrentdir -outdir export/C# swig/sxtwl.i
|
||||
mv sxtwl_wrap.cxx export/C#/sxtwl_wrap.cxx
|
||||
|
||||
# go
|
||||
swig -c++ -go -cgo -intgosize 32 -outdir export/golang swig/sxtwl.i
|
||||
mv swig/sxtwl_wrap.cxx export/golang/sxtwl_wrap.cxx
|
||||
|
||||
# python
|
||||
swig -c++ -python -outdir python swig/sxtwl.i
|
||||
mv swig/sxtwl_wrap.cxx python/sxtwl_wrap.cxx
|
189
export/C#/Day.cs
Normal file
189
export/C#/Day.cs
Normal file
@ -0,0 +1,189 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated />
|
||||
//
|
||||
// This file was automatically generated by SWIG (https://www.swig.org).
|
||||
// Version 4.1.1
|
||||
//
|
||||
// Do not make changes to this file unless you know what you are doing - modify
|
||||
// the SWIG interface file instead.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
public class Day : global::System.IDisposable {
|
||||
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
|
||||
protected bool swigCMemOwn;
|
||||
|
||||
internal Day(global::System.IntPtr cPtr, bool cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Day obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
|
||||
internal static global::System.Runtime.InteropServices.HandleRef swigRelease(Day obj) {
|
||||
if (obj != null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new global::System.ApplicationException("Cannot release ownership as memory is not owned");
|
||||
global::System.Runtime.InteropServices.HandleRef ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.Dispose();
|
||||
return ptr;
|
||||
} else {
|
||||
return new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
~Day() {
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
global::System.GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
sxtwlPINVOKE.delete_Day(swigCPtr);
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Day fromSolar(int _year, byte _month, int _day) {
|
||||
global::System.IntPtr cPtr = sxtwlPINVOKE.Day_fromSolar(_year, _month, _day);
|
||||
Day ret = (cPtr == global::System.IntPtr.Zero) ? null : new Day(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Day fromLunar(int year, byte month, int day, bool isRun) {
|
||||
global::System.IntPtr cPtr = sxtwlPINVOKE.Day_fromLunar__SWIG_0(year, month, day, isRun);
|
||||
Day ret = (cPtr == global::System.IntPtr.Zero) ? null : new Day(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Day fromLunar(int year, byte month, int day) {
|
||||
global::System.IntPtr cPtr = sxtwlPINVOKE.Day_fromLunar__SWIG_1(year, month, day);
|
||||
Day ret = (cPtr == global::System.IntPtr.Zero) ? null : new Day(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Day after(int day) {
|
||||
global::System.IntPtr cPtr = sxtwlPINVOKE.Day_after(swigCPtr, day);
|
||||
Day ret = (cPtr == global::System.IntPtr.Zero) ? null : new Day(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Day before(int day) {
|
||||
global::System.IntPtr cPtr = sxtwlPINVOKE.Day_before(swigCPtr, day);
|
||||
Day ret = (cPtr == global::System.IntPtr.Zero) ? null : new Day(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int getLunarDay() {
|
||||
int ret = sxtwlPINVOKE.Day_getLunarDay(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public byte getLunarMonth() {
|
||||
byte ret = sxtwlPINVOKE.Day_getLunarMonth(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int getLunarYear(bool chineseNewYearBoundary) {
|
||||
int ret = sxtwlPINVOKE.Day_getLunarYear__SWIG_0(swigCPtr, chineseNewYearBoundary);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int getLunarYear() {
|
||||
int ret = sxtwlPINVOKE.Day_getLunarYear__SWIG_1(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public GZ getYearGZ(bool chineseNewYearBoundary) {
|
||||
GZ ret = new GZ(sxtwlPINVOKE.Day_getYearGZ__SWIG_0(swigCPtr, chineseNewYearBoundary), true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public GZ getYearGZ() {
|
||||
GZ ret = new GZ(sxtwlPINVOKE.Day_getYearGZ__SWIG_1(swigCPtr), true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public GZ getMonthGZ() {
|
||||
GZ ret = new GZ(sxtwlPINVOKE.Day_getMonthGZ(swigCPtr), true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public GZ getDayGZ() {
|
||||
GZ ret = new GZ(sxtwlPINVOKE.Day_getDayGZ(swigCPtr), true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public GZ getHourGZ(byte hour, bool isZaoWanZiShi) {
|
||||
GZ ret = new GZ(sxtwlPINVOKE.Day_getHourGZ__SWIG_0(swigCPtr, hour, isZaoWanZiShi), true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public GZ getHourGZ(byte hour) {
|
||||
GZ ret = new GZ(sxtwlPINVOKE.Day_getHourGZ__SWIG_1(swigCPtr, hour), true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public bool isLunarLeap() {
|
||||
bool ret = sxtwlPINVOKE.Day_isLunarLeap(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int getSolarYear() {
|
||||
int ret = sxtwlPINVOKE.Day_getSolarYear(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public byte getSolarMonth() {
|
||||
byte ret = sxtwlPINVOKE.Day_getSolarMonth(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int getSolarDay() {
|
||||
int ret = sxtwlPINVOKE.Day_getSolarDay(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public byte getWeek() {
|
||||
byte ret = sxtwlPINVOKE.Day_getWeek(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public byte getWeekIndex() {
|
||||
byte ret = sxtwlPINVOKE.Day_getWeekIndex(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public bool hasJieQi() {
|
||||
bool ret = sxtwlPINVOKE.Day_hasJieQi(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public byte getJieQi() {
|
||||
byte ret = sxtwlPINVOKE.Day_getJieQi(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public double getJieQiJD() {
|
||||
double ret = sxtwlPINVOKE.Day_getJieQiJD(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public byte getConstellation() {
|
||||
byte ret = sxtwlPINVOKE.Day_getConstellation(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
85
export/C#/GZ.cs
Normal file
85
export/C#/GZ.cs
Normal file
@ -0,0 +1,85 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated />
|
||||
//
|
||||
// This file was automatically generated by SWIG (https://www.swig.org).
|
||||
// Version 4.1.1
|
||||
//
|
||||
// Do not make changes to this file unless you know what you are doing - modify
|
||||
// the SWIG interface file instead.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
public class GZ : global::System.IDisposable {
|
||||
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
|
||||
protected bool swigCMemOwn;
|
||||
|
||||
internal GZ(global::System.IntPtr cPtr, bool cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(GZ obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
|
||||
internal static global::System.Runtime.InteropServices.HandleRef swigRelease(GZ obj) {
|
||||
if (obj != null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new global::System.ApplicationException("Cannot release ownership as memory is not owned");
|
||||
global::System.Runtime.InteropServices.HandleRef ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.Dispose();
|
||||
return ptr;
|
||||
} else {
|
||||
return new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
~GZ() {
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
global::System.GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
sxtwlPINVOKE.delete_GZ(swigCPtr);
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GZ() : this(sxtwlPINVOKE.new_GZ__SWIG_0(), true) {
|
||||
}
|
||||
|
||||
public GZ(byte tg, byte dz) : this(sxtwlPINVOKE.new_GZ__SWIG_1(tg, dz), true) {
|
||||
}
|
||||
|
||||
public byte tg {
|
||||
set {
|
||||
sxtwlPINVOKE.GZ_tg_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
byte ret = sxtwlPINVOKE.GZ_tg_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public byte dz {
|
||||
set {
|
||||
sxtwlPINVOKE.GZ_dz_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
byte ret = sxtwlPINVOKE.GZ_dz_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
355
export/C#/JDList.cs
Normal file
355
export/C#/JDList.cs
Normal file
@ -0,0 +1,355 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated />
|
||||
//
|
||||
// This file was automatically generated by SWIG (https://www.swig.org).
|
||||
// Version 4.1.1
|
||||
//
|
||||
// Do not make changes to this file unless you know what you are doing - modify
|
||||
// the SWIG interface file instead.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
public class JDList : global::System.IDisposable, global::System.Collections.IEnumerable, global::System.Collections.Generic.IList<double>
|
||||
{
|
||||
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
|
||||
protected bool swigCMemOwn;
|
||||
|
||||
internal JDList(global::System.IntPtr cPtr, bool cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(JDList obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
|
||||
internal static global::System.Runtime.InteropServices.HandleRef swigRelease(JDList obj) {
|
||||
if (obj != null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new global::System.ApplicationException("Cannot release ownership as memory is not owned");
|
||||
global::System.Runtime.InteropServices.HandleRef ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.Dispose();
|
||||
return ptr;
|
||||
} else {
|
||||
return new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
~JDList() {
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
global::System.GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
sxtwlPINVOKE.delete_JDList(swigCPtr);
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JDList(global::System.Collections.IEnumerable c) : this() {
|
||||
if (c == null)
|
||||
throw new global::System.ArgumentNullException("c");
|
||||
foreach (double element in c) {
|
||||
this.Add(element);
|
||||
}
|
||||
}
|
||||
|
||||
public JDList(global::System.Collections.Generic.IEnumerable<double> c) : this() {
|
||||
if (c == null)
|
||||
throw new global::System.ArgumentNullException("c");
|
||||
foreach (double element in c) {
|
||||
this.Add(element);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsFixedSize {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReadOnly {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public double this[int index] {
|
||||
get {
|
||||
return getitem(index);
|
||||
}
|
||||
set {
|
||||
setitem(index, value);
|
||||
}
|
||||
}
|
||||
|
||||
public int Capacity {
|
||||
get {
|
||||
return (int)capacity();
|
||||
}
|
||||
set {
|
||||
if (value < 0 || (uint)value < size())
|
||||
throw new global::System.ArgumentOutOfRangeException("Capacity");
|
||||
reserve((uint)value);
|
||||
}
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return (int)size();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSynchronized {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyTo(double[] array)
|
||||
{
|
||||
CopyTo(0, array, 0, this.Count);
|
||||
}
|
||||
|
||||
public void CopyTo(double[] array, int arrayIndex)
|
||||
{
|
||||
CopyTo(0, array, arrayIndex, this.Count);
|
||||
}
|
||||
|
||||
public void CopyTo(int index, double[] array, int arrayIndex, int count)
|
||||
{
|
||||
if (array == null)
|
||||
throw new global::System.ArgumentNullException("array");
|
||||
if (index < 0)
|
||||
throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero");
|
||||
if (arrayIndex < 0)
|
||||
throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
|
||||
if (count < 0)
|
||||
throw new global::System.ArgumentOutOfRangeException("count", "Value is less than zero");
|
||||
if (array.Rank > 1)
|
||||
throw new global::System.ArgumentException("Multi dimensional array.", "array");
|
||||
if (index+count > this.Count || arrayIndex+count > array.Length)
|
||||
throw new global::System.ArgumentException("Number of elements to copy is too large.");
|
||||
for (int i=0; i<count; i++)
|
||||
array.SetValue(getitemcopy(index+i), arrayIndex+i);
|
||||
}
|
||||
|
||||
public double[] ToArray() {
|
||||
double[] array = new double[this.Count];
|
||||
this.CopyTo(array);
|
||||
return array;
|
||||
}
|
||||
|
||||
global::System.Collections.Generic.IEnumerator<double> global::System.Collections.Generic.IEnumerable<double>.GetEnumerator() {
|
||||
return new JDListEnumerator(this);
|
||||
}
|
||||
|
||||
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() {
|
||||
return new JDListEnumerator(this);
|
||||
}
|
||||
|
||||
public JDListEnumerator GetEnumerator() {
|
||||
return new JDListEnumerator(this);
|
||||
}
|
||||
|
||||
// Type-safe enumerator
|
||||
/// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown
|
||||
/// whenever the collection is modified. This has been done for changes in the size of the
|
||||
/// collection but not when one of the elements of the collection is modified as it is a bit
|
||||
/// tricky to detect unmanaged code that modifies the collection under our feet.
|
||||
public sealed class JDListEnumerator : global::System.Collections.IEnumerator
|
||||
, global::System.Collections.Generic.IEnumerator<double>
|
||||
{
|
||||
private JDList collectionRef;
|
||||
private int currentIndex;
|
||||
private object currentObject;
|
||||
private int currentSize;
|
||||
|
||||
public JDListEnumerator(JDList collection) {
|
||||
collectionRef = collection;
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
currentSize = collectionRef.Count;
|
||||
}
|
||||
|
||||
// Type-safe iterator Current
|
||||
public double Current {
|
||||
get {
|
||||
if (currentIndex == -1)
|
||||
throw new global::System.InvalidOperationException("Enumeration not started.");
|
||||
if (currentIndex > currentSize - 1)
|
||||
throw new global::System.InvalidOperationException("Enumeration finished.");
|
||||
if (currentObject == null)
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
return (double)currentObject;
|
||||
}
|
||||
}
|
||||
|
||||
// Type-unsafe IEnumerator.Current
|
||||
object global::System.Collections.IEnumerator.Current {
|
||||
get {
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveNext() {
|
||||
int size = collectionRef.Count;
|
||||
bool moveOkay = (currentIndex+1 < size) && (size == currentSize);
|
||||
if (moveOkay) {
|
||||
currentIndex++;
|
||||
currentObject = collectionRef[currentIndex];
|
||||
} else {
|
||||
currentObject = null;
|
||||
}
|
||||
return moveOkay;
|
||||
}
|
||||
|
||||
public void Reset() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
if (collectionRef.Count != currentSize) {
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
sxtwlPINVOKE.JDList_Clear(swigCPtr);
|
||||
}
|
||||
|
||||
public void Add(double x) {
|
||||
sxtwlPINVOKE.JDList_Add(swigCPtr, x);
|
||||
}
|
||||
|
||||
private uint size() {
|
||||
uint ret = sxtwlPINVOKE.JDList_size(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private uint capacity() {
|
||||
uint ret = sxtwlPINVOKE.JDList_capacity(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void reserve(uint n) {
|
||||
sxtwlPINVOKE.JDList_reserve(swigCPtr, n);
|
||||
}
|
||||
|
||||
public JDList() : this(sxtwlPINVOKE.new_JDList__SWIG_0(), true) {
|
||||
}
|
||||
|
||||
public JDList(JDList other) : this(sxtwlPINVOKE.new_JDList__SWIG_1(JDList.getCPtr(other)), true) {
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public JDList(int capacity) : this(sxtwlPINVOKE.new_JDList__SWIG_2(capacity), true) {
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
private double getitemcopy(int index) {
|
||||
double ret = sxtwlPINVOKE.JDList_getitemcopy(swigCPtr, index);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
return ret;
|
||||
}
|
||||
|
||||
private double getitem(int index) {
|
||||
double ret = sxtwlPINVOKE.JDList_getitem(swigCPtr, index);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void setitem(int index, double val) {
|
||||
sxtwlPINVOKE.JDList_setitem(swigCPtr, index, val);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public void AddRange(JDList values) {
|
||||
sxtwlPINVOKE.JDList_AddRange(swigCPtr, JDList.getCPtr(values));
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public JDList GetRange(int index, int count) {
|
||||
global::System.IntPtr cPtr = sxtwlPINVOKE.JDList_GetRange(swigCPtr, index, count);
|
||||
JDList ret = (cPtr == global::System.IntPtr.Zero) ? null : new JDList(cPtr, true);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void Insert(int index, double x) {
|
||||
sxtwlPINVOKE.JDList_Insert(swigCPtr, index, x);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public void InsertRange(int index, JDList values) {
|
||||
sxtwlPINVOKE.JDList_InsertRange(swigCPtr, index, JDList.getCPtr(values));
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public void RemoveAt(int index) {
|
||||
sxtwlPINVOKE.JDList_RemoveAt(swigCPtr, index);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public void RemoveRange(int index, int count) {
|
||||
sxtwlPINVOKE.JDList_RemoveRange(swigCPtr, index, count);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public static JDList Repeat(double value, int count) {
|
||||
global::System.IntPtr cPtr = sxtwlPINVOKE.JDList_Repeat(value, count);
|
||||
JDList ret = (cPtr == global::System.IntPtr.Zero) ? null : new JDList(cPtr, true);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void Reverse() {
|
||||
sxtwlPINVOKE.JDList_Reverse__SWIG_0(swigCPtr);
|
||||
}
|
||||
|
||||
public void Reverse(int index, int count) {
|
||||
sxtwlPINVOKE.JDList_Reverse__SWIG_1(swigCPtr, index, count);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public void SetRange(int index, JDList values) {
|
||||
sxtwlPINVOKE.JDList_SetRange(swigCPtr, index, JDList.getCPtr(values));
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public bool Contains(double value) {
|
||||
bool ret = sxtwlPINVOKE.JDList_Contains(swigCPtr, value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int IndexOf(double value) {
|
||||
int ret = sxtwlPINVOKE.JDList_IndexOf(swigCPtr, value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int LastIndexOf(double value) {
|
||||
int ret = sxtwlPINVOKE.JDList_LastIndexOf(swigCPtr, value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public bool Remove(double value) {
|
||||
bool ret = sxtwlPINVOKE.JDList_Remove(swigCPtr, value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
336
export/C#/JQList.cs
Normal file
336
export/C#/JQList.cs
Normal file
@ -0,0 +1,336 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated />
|
||||
//
|
||||
// This file was automatically generated by SWIG (https://www.swig.org).
|
||||
// Version 4.1.1
|
||||
//
|
||||
// Do not make changes to this file unless you know what you are doing - modify
|
||||
// the SWIG interface file instead.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
public class JQList : global::System.IDisposable, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerable<JieQiInfo>
|
||||
{
|
||||
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
|
||||
protected bool swigCMemOwn;
|
||||
|
||||
internal JQList(global::System.IntPtr cPtr, bool cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(JQList obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
|
||||
internal static global::System.Runtime.InteropServices.HandleRef swigRelease(JQList obj) {
|
||||
if (obj != null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new global::System.ApplicationException("Cannot release ownership as memory is not owned");
|
||||
global::System.Runtime.InteropServices.HandleRef ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.Dispose();
|
||||
return ptr;
|
||||
} else {
|
||||
return new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
~JQList() {
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
global::System.GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
sxtwlPINVOKE.delete_JQList(swigCPtr);
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JQList(global::System.Collections.IEnumerable c) : this() {
|
||||
if (c == null)
|
||||
throw new global::System.ArgumentNullException("c");
|
||||
foreach (JieQiInfo element in c) {
|
||||
this.Add(element);
|
||||
}
|
||||
}
|
||||
|
||||
public JQList(global::System.Collections.Generic.IEnumerable<JieQiInfo> c) : this() {
|
||||
if (c == null)
|
||||
throw new global::System.ArgumentNullException("c");
|
||||
foreach (JieQiInfo element in c) {
|
||||
this.Add(element);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsFixedSize {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReadOnly {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public JieQiInfo this[int index] {
|
||||
get {
|
||||
return getitem(index);
|
||||
}
|
||||
set {
|
||||
setitem(index, value);
|
||||
}
|
||||
}
|
||||
|
||||
public int Capacity {
|
||||
get {
|
||||
return (int)capacity();
|
||||
}
|
||||
set {
|
||||
if (value < 0 || (uint)value < size())
|
||||
throw new global::System.ArgumentOutOfRangeException("Capacity");
|
||||
reserve((uint)value);
|
||||
}
|
||||
}
|
||||
|
||||
public int Count {
|
||||
get {
|
||||
return (int)size();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSynchronized {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyTo(JieQiInfo[] array)
|
||||
{
|
||||
CopyTo(0, array, 0, this.Count);
|
||||
}
|
||||
|
||||
public void CopyTo(JieQiInfo[] array, int arrayIndex)
|
||||
{
|
||||
CopyTo(0, array, arrayIndex, this.Count);
|
||||
}
|
||||
|
||||
public void CopyTo(int index, JieQiInfo[] array, int arrayIndex, int count)
|
||||
{
|
||||
if (array == null)
|
||||
throw new global::System.ArgumentNullException("array");
|
||||
if (index < 0)
|
||||
throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero");
|
||||
if (arrayIndex < 0)
|
||||
throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
|
||||
if (count < 0)
|
||||
throw new global::System.ArgumentOutOfRangeException("count", "Value is less than zero");
|
||||
if (array.Rank > 1)
|
||||
throw new global::System.ArgumentException("Multi dimensional array.", "array");
|
||||
if (index+count > this.Count || arrayIndex+count > array.Length)
|
||||
throw new global::System.ArgumentException("Number of elements to copy is too large.");
|
||||
for (int i=0; i<count; i++)
|
||||
array.SetValue(getitemcopy(index+i), arrayIndex+i);
|
||||
}
|
||||
|
||||
public JieQiInfo[] ToArray() {
|
||||
JieQiInfo[] array = new JieQiInfo[this.Count];
|
||||
this.CopyTo(array);
|
||||
return array;
|
||||
}
|
||||
|
||||
global::System.Collections.Generic.IEnumerator<JieQiInfo> global::System.Collections.Generic.IEnumerable<JieQiInfo>.GetEnumerator() {
|
||||
return new JQListEnumerator(this);
|
||||
}
|
||||
|
||||
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() {
|
||||
return new JQListEnumerator(this);
|
||||
}
|
||||
|
||||
public JQListEnumerator GetEnumerator() {
|
||||
return new JQListEnumerator(this);
|
||||
}
|
||||
|
||||
// Type-safe enumerator
|
||||
/// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown
|
||||
/// whenever the collection is modified. This has been done for changes in the size of the
|
||||
/// collection but not when one of the elements of the collection is modified as it is a bit
|
||||
/// tricky to detect unmanaged code that modifies the collection under our feet.
|
||||
public sealed class JQListEnumerator : global::System.Collections.IEnumerator
|
||||
, global::System.Collections.Generic.IEnumerator<JieQiInfo>
|
||||
{
|
||||
private JQList collectionRef;
|
||||
private int currentIndex;
|
||||
private object currentObject;
|
||||
private int currentSize;
|
||||
|
||||
public JQListEnumerator(JQList collection) {
|
||||
collectionRef = collection;
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
currentSize = collectionRef.Count;
|
||||
}
|
||||
|
||||
// Type-safe iterator Current
|
||||
public JieQiInfo Current {
|
||||
get {
|
||||
if (currentIndex == -1)
|
||||
throw new global::System.InvalidOperationException("Enumeration not started.");
|
||||
if (currentIndex > currentSize - 1)
|
||||
throw new global::System.InvalidOperationException("Enumeration finished.");
|
||||
if (currentObject == null)
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
return (JieQiInfo)currentObject;
|
||||
}
|
||||
}
|
||||
|
||||
// Type-unsafe IEnumerator.Current
|
||||
object global::System.Collections.IEnumerator.Current {
|
||||
get {
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveNext() {
|
||||
int size = collectionRef.Count;
|
||||
bool moveOkay = (currentIndex+1 < size) && (size == currentSize);
|
||||
if (moveOkay) {
|
||||
currentIndex++;
|
||||
currentObject = collectionRef[currentIndex];
|
||||
} else {
|
||||
currentObject = null;
|
||||
}
|
||||
return moveOkay;
|
||||
}
|
||||
|
||||
public void Reset() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
if (collectionRef.Count != currentSize) {
|
||||
throw new global::System.InvalidOperationException("Collection modified.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
currentIndex = -1;
|
||||
currentObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
sxtwlPINVOKE.JQList_Clear(swigCPtr);
|
||||
}
|
||||
|
||||
public void Add(JieQiInfo x) {
|
||||
sxtwlPINVOKE.JQList_Add(swigCPtr, JieQiInfo.getCPtr(x));
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
private uint size() {
|
||||
uint ret = sxtwlPINVOKE.JQList_size(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private uint capacity() {
|
||||
uint ret = sxtwlPINVOKE.JQList_capacity(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void reserve(uint n) {
|
||||
sxtwlPINVOKE.JQList_reserve(swigCPtr, n);
|
||||
}
|
||||
|
||||
public JQList() : this(sxtwlPINVOKE.new_JQList__SWIG_0(), true) {
|
||||
}
|
||||
|
||||
public JQList(JQList other) : this(sxtwlPINVOKE.new_JQList__SWIG_1(JQList.getCPtr(other)), true) {
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public JQList(int capacity) : this(sxtwlPINVOKE.new_JQList__SWIG_2(capacity), true) {
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
private JieQiInfo getitemcopy(int index) {
|
||||
JieQiInfo ret = new JieQiInfo(sxtwlPINVOKE.JQList_getitemcopy(swigCPtr, index), true);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
return ret;
|
||||
}
|
||||
|
||||
private JieQiInfo getitem(int index) {
|
||||
JieQiInfo ret = new JieQiInfo(sxtwlPINVOKE.JQList_getitem(swigCPtr, index), false);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void setitem(int index, JieQiInfo val) {
|
||||
sxtwlPINVOKE.JQList_setitem(swigCPtr, index, JieQiInfo.getCPtr(val));
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public void AddRange(JQList values) {
|
||||
sxtwlPINVOKE.JQList_AddRange(swigCPtr, JQList.getCPtr(values));
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public JQList GetRange(int index, int count) {
|
||||
global::System.IntPtr cPtr = sxtwlPINVOKE.JQList_GetRange(swigCPtr, index, count);
|
||||
JQList ret = (cPtr == global::System.IntPtr.Zero) ? null : new JQList(cPtr, true);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void Insert(int index, JieQiInfo x) {
|
||||
sxtwlPINVOKE.JQList_Insert(swigCPtr, index, JieQiInfo.getCPtr(x));
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public void InsertRange(int index, JQList values) {
|
||||
sxtwlPINVOKE.JQList_InsertRange(swigCPtr, index, JQList.getCPtr(values));
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public void RemoveAt(int index) {
|
||||
sxtwlPINVOKE.JQList_RemoveAt(swigCPtr, index);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public void RemoveRange(int index, int count) {
|
||||
sxtwlPINVOKE.JQList_RemoveRange(swigCPtr, index, count);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public static JQList Repeat(JieQiInfo value, int count) {
|
||||
global::System.IntPtr cPtr = sxtwlPINVOKE.JQList_Repeat(JieQiInfo.getCPtr(value), count);
|
||||
JQList ret = (cPtr == global::System.IntPtr.Zero) ? null : new JQList(cPtr, true);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void Reverse() {
|
||||
sxtwlPINVOKE.JQList_Reverse__SWIG_0(swigCPtr);
|
||||
}
|
||||
|
||||
public void Reverse(int index, int count) {
|
||||
sxtwlPINVOKE.JQList_Reverse__SWIG_1(swigCPtr, index, count);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
public void SetRange(int index, JQList values) {
|
||||
sxtwlPINVOKE.JQList_SetRange(swigCPtr, index, JQList.getCPtr(values));
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
}
|
||||
|
||||
}
|
82
export/C#/JieQiInfo.cs
Normal file
82
export/C#/JieQiInfo.cs
Normal file
@ -0,0 +1,82 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated />
|
||||
//
|
||||
// This file was automatically generated by SWIG (https://www.swig.org).
|
||||
// Version 4.1.1
|
||||
//
|
||||
// Do not make changes to this file unless you know what you are doing - modify
|
||||
// the SWIG interface file instead.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
public class JieQiInfo : global::System.IDisposable {
|
||||
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
|
||||
protected bool swigCMemOwn;
|
||||
|
||||
internal JieQiInfo(global::System.IntPtr cPtr, bool cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(JieQiInfo obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
|
||||
internal static global::System.Runtime.InteropServices.HandleRef swigRelease(JieQiInfo obj) {
|
||||
if (obj != null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new global::System.ApplicationException("Cannot release ownership as memory is not owned");
|
||||
global::System.Runtime.InteropServices.HandleRef ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.Dispose();
|
||||
return ptr;
|
||||
} else {
|
||||
return new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
~JieQiInfo() {
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
global::System.GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
sxtwlPINVOKE.delete_JieQiInfo(swigCPtr);
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double jd {
|
||||
set {
|
||||
sxtwlPINVOKE.JieQiInfo_jd_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
double ret = sxtwlPINVOKE.JieQiInfo_jd_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public byte jqIndex {
|
||||
set {
|
||||
sxtwlPINVOKE.JieQiInfo_jqIndex_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
byte ret = sxtwlPINVOKE.JieQiInfo_jqIndex_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public JieQiInfo() : this(sxtwlPINVOKE.new_JieQiInfo(), true) {
|
||||
}
|
||||
|
||||
}
|
179
export/C#/Time.cs
Normal file
179
export/C#/Time.cs
Normal file
@ -0,0 +1,179 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated />
|
||||
//
|
||||
// This file was automatically generated by SWIG (https://www.swig.org).
|
||||
// Version 4.1.1
|
||||
//
|
||||
// Do not make changes to this file unless you know what you are doing - modify
|
||||
// the SWIG interface file instead.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
public class Time : global::System.IDisposable {
|
||||
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
|
||||
protected bool swigCMemOwn;
|
||||
|
||||
internal Time(global::System.IntPtr cPtr, bool cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
|
||||
}
|
||||
|
||||
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Time obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
|
||||
internal static global::System.Runtime.InteropServices.HandleRef swigRelease(Time obj) {
|
||||
if (obj != null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new global::System.ApplicationException("Cannot release ownership as memory is not owned");
|
||||
global::System.Runtime.InteropServices.HandleRef ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.Dispose();
|
||||
return ptr;
|
||||
} else {
|
||||
return new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
~Time() {
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
global::System.GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
lock(this) {
|
||||
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
sxtwlPINVOKE.delete_Time(swigCPtr);
|
||||
}
|
||||
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Time() : this(sxtwlPINVOKE.new_Time__SWIG_0(), true) {
|
||||
}
|
||||
|
||||
public Time(int year, int month, int day, double hour, double min, double sec) : this(sxtwlPINVOKE.new_Time__SWIG_1(year, month, day, hour, min, sec), true) {
|
||||
}
|
||||
|
||||
public int Y {
|
||||
set {
|
||||
sxtwlPINVOKE.Time_Y_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
int ret = sxtwlPINVOKE.Time_Y_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public int M {
|
||||
set {
|
||||
sxtwlPINVOKE.Time_M_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
int ret = sxtwlPINVOKE.Time_M_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public int D {
|
||||
set {
|
||||
sxtwlPINVOKE.Time_D_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
int ret = sxtwlPINVOKE.Time_D_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public double h {
|
||||
set {
|
||||
sxtwlPINVOKE.Time_h_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
double ret = sxtwlPINVOKE.Time_h_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public double m {
|
||||
set {
|
||||
sxtwlPINVOKE.Time_m_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
double ret = sxtwlPINVOKE.Time_m_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public double s {
|
||||
set {
|
||||
sxtwlPINVOKE.Time_s_set(swigCPtr, value);
|
||||
}
|
||||
get {
|
||||
double ret = sxtwlPINVOKE.Time_s_get(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public int getYear() {
|
||||
int ret = sxtwlPINVOKE.Time_getYear(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setYear(int year) {
|
||||
sxtwlPINVOKE.Time_setYear(swigCPtr, year);
|
||||
}
|
||||
|
||||
public void setMonth(int month) {
|
||||
sxtwlPINVOKE.Time_setMonth(swigCPtr, month);
|
||||
}
|
||||
|
||||
public int getMonth() {
|
||||
int ret = sxtwlPINVOKE.Time_getMonth(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int getDay() {
|
||||
int ret = sxtwlPINVOKE.Time_getDay(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setDay(int day) {
|
||||
sxtwlPINVOKE.Time_setDay(swigCPtr, day);
|
||||
}
|
||||
|
||||
public double getHour() {
|
||||
double ret = sxtwlPINVOKE.Time_getHour(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setHour(double hour) {
|
||||
sxtwlPINVOKE.Time_setHour(swigCPtr, hour);
|
||||
}
|
||||
|
||||
public double getMin() {
|
||||
double ret = sxtwlPINVOKE.Time_getMin(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setMour(double min) {
|
||||
sxtwlPINVOKE.Time_setMour(swigCPtr, min);
|
||||
}
|
||||
|
||||
public double getSec() {
|
||||
double ret = sxtwlPINVOKE.Time_getSec(swigCPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setSec(double sec) {
|
||||
sxtwlPINVOKE.Time_setSec(swigCPtr, sec);
|
||||
}
|
||||
|
||||
}
|
79
export/C#/sxtwl.cs
Normal file
79
export/C#/sxtwl.cs
Normal file
@ -0,0 +1,79 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated />
|
||||
//
|
||||
// This file was automatically generated by SWIG (https://www.swig.org).
|
||||
// Version 4.1.1
|
||||
//
|
||||
// Do not make changes to this file unless you know what you are doing - modify
|
||||
// the SWIG interface file instead.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
public class sxtwl {
|
||||
public static Day fromSolar(int year, byte month, int day) {
|
||||
global::System.IntPtr cPtr = sxtwlPINVOKE.fromSolar(year, month, day);
|
||||
Day ret = (cPtr == global::System.IntPtr.Zero) ? null : new Day(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Day fromLunar(int year, byte month, int day, bool isRun) {
|
||||
global::System.IntPtr cPtr = sxtwlPINVOKE.fromLunar__SWIG_0(year, month, day, isRun);
|
||||
Day ret = (cPtr == global::System.IntPtr.Zero) ? null : new Day(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Day fromLunar(int year, byte month, int day) {
|
||||
global::System.IntPtr cPtr = sxtwlPINVOKE.fromLunar__SWIG_1(year, month, day);
|
||||
Day ret = (cPtr == global::System.IntPtr.Zero) ? null : new Day(cPtr, false);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static JDList siZhu2Year(GZ year, GZ yue, GZ ri, GZ shi, int fromYear, int toYear) {
|
||||
JDList ret = new JDList(sxtwlPINVOKE.siZhu2Year(GZ.getCPtr(year), GZ.getCPtr(yue), GZ.getCPtr(ri), GZ.getCPtr(shi), fromYear, toYear), true);
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static GZ getShiGz(byte dayTg, byte hour, bool isZaoWanZiShi) {
|
||||
GZ ret = new GZ(sxtwlPINVOKE.getShiGz__SWIG_0(dayTg, hour, isZaoWanZiShi), true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static GZ getShiGz(byte dayTg, byte hour) {
|
||||
GZ ret = new GZ(sxtwlPINVOKE.getShiGz__SWIG_1(dayTg, hour), true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static byte getRunMonth(int By) {
|
||||
byte ret = sxtwlPINVOKE.getRunMonth(By);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static byte getLunarMonthNum(int By, byte month, bool isRun) {
|
||||
byte ret = sxtwlPINVOKE.getLunarMonthNum__SWIG_0(By, month, isRun);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static byte getLunarMonthNum(int By, byte month) {
|
||||
byte ret = sxtwlPINVOKE.getLunarMonthNum__SWIG_1(By, month);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Time JD2DD(double jd) {
|
||||
Time ret = new Time(sxtwlPINVOKE.JD2DD(jd), true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static double toJD(Time time) {
|
||||
double ret = sxtwlPINVOKE.toJD(Time.getCPtr(time));
|
||||
if (sxtwlPINVOKE.SWIGPendingException.Pending) throw sxtwlPINVOKE.SWIGPendingException.Retrieve();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static JQList getJieQiByYear(int year) {
|
||||
JQList ret = new JQList(sxtwlPINVOKE.getJieQiByYear(year), true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static readonly int J2000 = sxtwlPINVOKE.J2000_get();
|
||||
}
|
575
export/C#/sxtwlPINVOKE.cs
Normal file
575
export/C#/sxtwlPINVOKE.cs
Normal file
@ -0,0 +1,575 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated />
|
||||
//
|
||||
// This file was automatically generated by SWIG (https://www.swig.org).
|
||||
// Version 4.1.1
|
||||
//
|
||||
// Do not make changes to this file unless you know what you are doing - modify
|
||||
// the SWIG interface file instead.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class sxtwlPINVOKE {
|
||||
|
||||
protected class SWIGExceptionHelper {
|
||||
|
||||
public delegate void ExceptionDelegate(string message);
|
||||
public delegate void ExceptionArgumentDelegate(string message, string paramName);
|
||||
|
||||
static ExceptionDelegate applicationDelegate = new ExceptionDelegate(SetPendingApplicationException);
|
||||
static ExceptionDelegate arithmeticDelegate = new ExceptionDelegate(SetPendingArithmeticException);
|
||||
static ExceptionDelegate divideByZeroDelegate = new ExceptionDelegate(SetPendingDivideByZeroException);
|
||||
static ExceptionDelegate indexOutOfRangeDelegate = new ExceptionDelegate(SetPendingIndexOutOfRangeException);
|
||||
static ExceptionDelegate invalidCastDelegate = new ExceptionDelegate(SetPendingInvalidCastException);
|
||||
static ExceptionDelegate invalidOperationDelegate = new ExceptionDelegate(SetPendingInvalidOperationException);
|
||||
static ExceptionDelegate ioDelegate = new ExceptionDelegate(SetPendingIOException);
|
||||
static ExceptionDelegate nullReferenceDelegate = new ExceptionDelegate(SetPendingNullReferenceException);
|
||||
static ExceptionDelegate outOfMemoryDelegate = new ExceptionDelegate(SetPendingOutOfMemoryException);
|
||||
static ExceptionDelegate overflowDelegate = new ExceptionDelegate(SetPendingOverflowException);
|
||||
static ExceptionDelegate systemDelegate = new ExceptionDelegate(SetPendingSystemException);
|
||||
|
||||
static ExceptionArgumentDelegate argumentDelegate = new ExceptionArgumentDelegate(SetPendingArgumentException);
|
||||
static ExceptionArgumentDelegate argumentNullDelegate = new ExceptionArgumentDelegate(SetPendingArgumentNullException);
|
||||
static ExceptionArgumentDelegate argumentOutOfRangeDelegate = new ExceptionArgumentDelegate(SetPendingArgumentOutOfRangeException);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="SWIGRegisterExceptionCallbacks_sxtwl")]
|
||||
public static extern void SWIGRegisterExceptionCallbacks_sxtwl(
|
||||
ExceptionDelegate applicationDelegate,
|
||||
ExceptionDelegate arithmeticDelegate,
|
||||
ExceptionDelegate divideByZeroDelegate,
|
||||
ExceptionDelegate indexOutOfRangeDelegate,
|
||||
ExceptionDelegate invalidCastDelegate,
|
||||
ExceptionDelegate invalidOperationDelegate,
|
||||
ExceptionDelegate ioDelegate,
|
||||
ExceptionDelegate nullReferenceDelegate,
|
||||
ExceptionDelegate outOfMemoryDelegate,
|
||||
ExceptionDelegate overflowDelegate,
|
||||
ExceptionDelegate systemExceptionDelegate);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="SWIGRegisterExceptionArgumentCallbacks_sxtwl")]
|
||||
public static extern void SWIGRegisterExceptionCallbacksArgument_sxtwl(
|
||||
ExceptionArgumentDelegate argumentDelegate,
|
||||
ExceptionArgumentDelegate argumentNullDelegate,
|
||||
ExceptionArgumentDelegate argumentOutOfRangeDelegate);
|
||||
|
||||
static void SetPendingApplicationException(string message) {
|
||||
SWIGPendingException.Set(new global::System.ApplicationException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingArithmeticException(string message) {
|
||||
SWIGPendingException.Set(new global::System.ArithmeticException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingDivideByZeroException(string message) {
|
||||
SWIGPendingException.Set(new global::System.DivideByZeroException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingIndexOutOfRangeException(string message) {
|
||||
SWIGPendingException.Set(new global::System.IndexOutOfRangeException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingInvalidCastException(string message) {
|
||||
SWIGPendingException.Set(new global::System.InvalidCastException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingInvalidOperationException(string message) {
|
||||
SWIGPendingException.Set(new global::System.InvalidOperationException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingIOException(string message) {
|
||||
SWIGPendingException.Set(new global::System.IO.IOException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingNullReferenceException(string message) {
|
||||
SWIGPendingException.Set(new global::System.NullReferenceException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingOutOfMemoryException(string message) {
|
||||
SWIGPendingException.Set(new global::System.OutOfMemoryException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingOverflowException(string message) {
|
||||
SWIGPendingException.Set(new global::System.OverflowException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingSystemException(string message) {
|
||||
SWIGPendingException.Set(new global::System.SystemException(message, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
|
||||
static void SetPendingArgumentException(string message, string paramName) {
|
||||
SWIGPendingException.Set(new global::System.ArgumentException(message, paramName, SWIGPendingException.Retrieve()));
|
||||
}
|
||||
static void SetPendingArgumentNullException(string message, string paramName) {
|
||||
global::System.Exception e = SWIGPendingException.Retrieve();
|
||||
if (e != null) message = message + " Inner Exception: " + e.Message;
|
||||
SWIGPendingException.Set(new global::System.ArgumentNullException(paramName, message));
|
||||
}
|
||||
static void SetPendingArgumentOutOfRangeException(string message, string paramName) {
|
||||
global::System.Exception e = SWIGPendingException.Retrieve();
|
||||
if (e != null) message = message + " Inner Exception: " + e.Message;
|
||||
SWIGPendingException.Set(new global::System.ArgumentOutOfRangeException(paramName, message));
|
||||
}
|
||||
|
||||
static SWIGExceptionHelper() {
|
||||
SWIGRegisterExceptionCallbacks_sxtwl(
|
||||
applicationDelegate,
|
||||
arithmeticDelegate,
|
||||
divideByZeroDelegate,
|
||||
indexOutOfRangeDelegate,
|
||||
invalidCastDelegate,
|
||||
invalidOperationDelegate,
|
||||
ioDelegate,
|
||||
nullReferenceDelegate,
|
||||
outOfMemoryDelegate,
|
||||
overflowDelegate,
|
||||
systemDelegate);
|
||||
|
||||
SWIGRegisterExceptionCallbacksArgument_sxtwl(
|
||||
argumentDelegate,
|
||||
argumentNullDelegate,
|
||||
argumentOutOfRangeDelegate);
|
||||
}
|
||||
}
|
||||
|
||||
protected static SWIGExceptionHelper swigExceptionHelper = new SWIGExceptionHelper();
|
||||
|
||||
public class SWIGPendingException {
|
||||
[global::System.ThreadStatic]
|
||||
private static global::System.Exception pendingException = null;
|
||||
private static int numExceptionsPending = 0;
|
||||
private static global::System.Object exceptionsLock = null;
|
||||
|
||||
public static bool Pending {
|
||||
get {
|
||||
bool pending = false;
|
||||
if (numExceptionsPending > 0)
|
||||
if (pendingException != null)
|
||||
pending = true;
|
||||
return pending;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Set(global::System.Exception e) {
|
||||
if (pendingException != null)
|
||||
throw new global::System.ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e);
|
||||
pendingException = e;
|
||||
lock(exceptionsLock) {
|
||||
numExceptionsPending++;
|
||||
}
|
||||
}
|
||||
|
||||
public static global::System.Exception Retrieve() {
|
||||
global::System.Exception e = null;
|
||||
if (numExceptionsPending > 0) {
|
||||
if (pendingException != null) {
|
||||
e = pendingException;
|
||||
pendingException = null;
|
||||
lock(exceptionsLock) {
|
||||
numExceptionsPending--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
static SWIGPendingException() {
|
||||
exceptionsLock = new global::System.Object();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected class SWIGStringHelper {
|
||||
|
||||
public delegate string SWIGStringDelegate(string message);
|
||||
static SWIGStringDelegate stringDelegate = new SWIGStringDelegate(CreateString);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="SWIGRegisterStringCallback_sxtwl")]
|
||||
public static extern void SWIGRegisterStringCallback_sxtwl(SWIGStringDelegate stringDelegate);
|
||||
|
||||
static string CreateString(string cString) {
|
||||
return cString;
|
||||
}
|
||||
|
||||
static SWIGStringHelper() {
|
||||
SWIGRegisterStringCallback_sxtwl(stringDelegate);
|
||||
}
|
||||
}
|
||||
|
||||
static protected SWIGStringHelper swigStringHelper = new SWIGStringHelper();
|
||||
|
||||
|
||||
static sxtwlPINVOKE() {
|
||||
}
|
||||
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_Clear")]
|
||||
public static extern void JDList_Clear(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_Add")]
|
||||
public static extern void JDList_Add(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_size")]
|
||||
public static extern uint JDList_size(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_capacity")]
|
||||
public static extern uint JDList_capacity(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_reserve")]
|
||||
public static extern void JDList_reserve(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_new_JDList__SWIG_0")]
|
||||
public static extern global::System.IntPtr new_JDList__SWIG_0();
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_new_JDList__SWIG_1")]
|
||||
public static extern global::System.IntPtr new_JDList__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_new_JDList__SWIG_2")]
|
||||
public static extern global::System.IntPtr new_JDList__SWIG_2(int jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_getitemcopy")]
|
||||
public static extern double JDList_getitemcopy(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_getitem")]
|
||||
public static extern double JDList_getitem(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_setitem")]
|
||||
public static extern void JDList_setitem(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, double jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_AddRange")]
|
||||
public static extern void JDList_AddRange(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_GetRange")]
|
||||
public static extern global::System.IntPtr JDList_GetRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_Insert")]
|
||||
public static extern void JDList_Insert(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, double jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_InsertRange")]
|
||||
public static extern void JDList_InsertRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_RemoveAt")]
|
||||
public static extern void JDList_RemoveAt(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_RemoveRange")]
|
||||
public static extern void JDList_RemoveRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_Repeat")]
|
||||
public static extern global::System.IntPtr JDList_Repeat(double jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_Reverse__SWIG_0")]
|
||||
public static extern void JDList_Reverse__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_Reverse__SWIG_1")]
|
||||
public static extern void JDList_Reverse__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_SetRange")]
|
||||
public static extern void JDList_SetRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_Contains")]
|
||||
public static extern bool JDList_Contains(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_IndexOf")]
|
||||
public static extern int JDList_IndexOf(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_LastIndexOf")]
|
||||
public static extern int JDList_LastIndexOf(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JDList_Remove")]
|
||||
public static extern bool JDList_Remove(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_delete_JDList")]
|
||||
public static extern void delete_JDList(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_Clear")]
|
||||
public static extern void JQList_Clear(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_Add")]
|
||||
public static extern void JQList_Add(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_size")]
|
||||
public static extern uint JQList_size(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_capacity")]
|
||||
public static extern uint JQList_capacity(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_reserve")]
|
||||
public static extern void JQList_reserve(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_new_JQList__SWIG_0")]
|
||||
public static extern global::System.IntPtr new_JQList__SWIG_0();
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_new_JQList__SWIG_1")]
|
||||
public static extern global::System.IntPtr new_JQList__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_new_JQList__SWIG_2")]
|
||||
public static extern global::System.IntPtr new_JQList__SWIG_2(int jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_getitemcopy")]
|
||||
public static extern global::System.IntPtr JQList_getitemcopy(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_getitem")]
|
||||
public static extern global::System.IntPtr JQList_getitem(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_setitem")]
|
||||
public static extern void JQList_setitem(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_AddRange")]
|
||||
public static extern void JQList_AddRange(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_GetRange")]
|
||||
public static extern global::System.IntPtr JQList_GetRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_Insert")]
|
||||
public static extern void JQList_Insert(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_InsertRange")]
|
||||
public static extern void JQList_InsertRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_RemoveAt")]
|
||||
public static extern void JQList_RemoveAt(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_RemoveRange")]
|
||||
public static extern void JQList_RemoveRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_Repeat")]
|
||||
public static extern global::System.IntPtr JQList_Repeat(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_Reverse__SWIG_0")]
|
||||
public static extern void JQList_Reverse__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_Reverse__SWIG_1")]
|
||||
public static extern void JQList_Reverse__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JQList_SetRange")]
|
||||
public static extern void JQList_SetRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, global::System.Runtime.InteropServices.HandleRef jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_delete_JQList")]
|
||||
public static extern void delete_JQList(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_J2000_get")]
|
||||
public static extern int J2000_get();
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_new_Time__SWIG_0")]
|
||||
public static extern global::System.IntPtr new_Time__SWIG_0();
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_new_Time__SWIG_1")]
|
||||
public static extern global::System.IntPtr new_Time__SWIG_1(int jarg1, int jarg2, int jarg3, double jarg4, double jarg5, double jarg6);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_Y_set")]
|
||||
public static extern void Time_Y_set(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_Y_get")]
|
||||
public static extern int Time_Y_get(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_M_set")]
|
||||
public static extern void Time_M_set(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_M_get")]
|
||||
public static extern int Time_M_get(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_D_set")]
|
||||
public static extern void Time_D_set(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_D_get")]
|
||||
public static extern int Time_D_get(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_h_set")]
|
||||
public static extern void Time_h_set(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_h_get")]
|
||||
public static extern double Time_h_get(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_m_set")]
|
||||
public static extern void Time_m_set(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_m_get")]
|
||||
public static extern double Time_m_get(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_s_set")]
|
||||
public static extern void Time_s_set(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_s_get")]
|
||||
public static extern double Time_s_get(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_getYear")]
|
||||
public static extern int Time_getYear(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_setYear")]
|
||||
public static extern void Time_setYear(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_setMonth")]
|
||||
public static extern void Time_setMonth(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_getMonth")]
|
||||
public static extern int Time_getMonth(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_getDay")]
|
||||
public static extern int Time_getDay(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_setDay")]
|
||||
public static extern void Time_setDay(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_getHour")]
|
||||
public static extern double Time_getHour(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_setHour")]
|
||||
public static extern void Time_setHour(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_getMin")]
|
||||
public static extern double Time_getMin(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_setMour")]
|
||||
public static extern void Time_setMour(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_getSec")]
|
||||
public static extern double Time_getSec(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Time_setSec")]
|
||||
public static extern void Time_setSec(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_delete_Time")]
|
||||
public static extern void delete_Time(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_new_GZ__SWIG_0")]
|
||||
public static extern global::System.IntPtr new_GZ__SWIG_0();
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_new_GZ__SWIG_1")]
|
||||
public static extern global::System.IntPtr new_GZ__SWIG_1(byte jarg1, byte jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_GZ_tg_set")]
|
||||
public static extern void GZ_tg_set(global::System.Runtime.InteropServices.HandleRef jarg1, byte jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_GZ_tg_get")]
|
||||
public static extern byte GZ_tg_get(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_GZ_dz_set")]
|
||||
public static extern void GZ_dz_set(global::System.Runtime.InteropServices.HandleRef jarg1, byte jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_GZ_dz_get")]
|
||||
public static extern byte GZ_dz_get(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_delete_GZ")]
|
||||
public static extern void delete_GZ(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_fromSolar")]
|
||||
public static extern global::System.IntPtr Day_fromSolar(int jarg1, byte jarg2, int jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_fromLunar__SWIG_0")]
|
||||
public static extern global::System.IntPtr Day_fromLunar__SWIG_0(int jarg1, byte jarg2, int jarg3, bool jarg4);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_fromLunar__SWIG_1")]
|
||||
public static extern global::System.IntPtr Day_fromLunar__SWIG_1(int jarg1, byte jarg2, int jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_after")]
|
||||
public static extern global::System.IntPtr Day_after(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_before")]
|
||||
public static extern global::System.IntPtr Day_before(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getLunarDay")]
|
||||
public static extern int Day_getLunarDay(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getLunarMonth")]
|
||||
public static extern byte Day_getLunarMonth(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getLunarYear__SWIG_0")]
|
||||
public static extern int Day_getLunarYear__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getLunarYear__SWIG_1")]
|
||||
public static extern int Day_getLunarYear__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getYearGZ__SWIG_0")]
|
||||
public static extern global::System.IntPtr Day_getYearGZ__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, bool jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getYearGZ__SWIG_1")]
|
||||
public static extern global::System.IntPtr Day_getYearGZ__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getMonthGZ")]
|
||||
public static extern global::System.IntPtr Day_getMonthGZ(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getDayGZ")]
|
||||
public static extern global::System.IntPtr Day_getDayGZ(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getHourGZ__SWIG_0")]
|
||||
public static extern global::System.IntPtr Day_getHourGZ__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1, byte jarg2, bool jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getHourGZ__SWIG_1")]
|
||||
public static extern global::System.IntPtr Day_getHourGZ__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, byte jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_isLunarLeap")]
|
||||
public static extern bool Day_isLunarLeap(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getSolarYear")]
|
||||
public static extern int Day_getSolarYear(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getSolarMonth")]
|
||||
public static extern byte Day_getSolarMonth(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getSolarDay")]
|
||||
public static extern int Day_getSolarDay(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getWeek")]
|
||||
public static extern byte Day_getWeek(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getWeekIndex")]
|
||||
public static extern byte Day_getWeekIndex(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_hasJieQi")]
|
||||
public static extern bool Day_hasJieQi(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getJieQi")]
|
||||
public static extern byte Day_getJieQi(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getJieQiJD")]
|
||||
public static extern double Day_getJieQiJD(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_Day_getConstellation")]
|
||||
public static extern byte Day_getConstellation(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_delete_Day")]
|
||||
public static extern void delete_Day(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JieQiInfo_jd_set")]
|
||||
public static extern void JieQiInfo_jd_set(global::System.Runtime.InteropServices.HandleRef jarg1, double jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JieQiInfo_jd_get")]
|
||||
public static extern double JieQiInfo_jd_get(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JieQiInfo_jqIndex_set")]
|
||||
public static extern void JieQiInfo_jqIndex_set(global::System.Runtime.InteropServices.HandleRef jarg1, byte jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JieQiInfo_jqIndex_get")]
|
||||
public static extern byte JieQiInfo_jqIndex_get(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_new_JieQiInfo")]
|
||||
public static extern global::System.IntPtr new_JieQiInfo();
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_delete_JieQiInfo")]
|
||||
public static extern void delete_JieQiInfo(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_fromSolar")]
|
||||
public static extern global::System.IntPtr fromSolar(int jarg1, byte jarg2, int jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_fromLunar__SWIG_0")]
|
||||
public static extern global::System.IntPtr fromLunar__SWIG_0(int jarg1, byte jarg2, int jarg3, bool jarg4);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_fromLunar__SWIG_1")]
|
||||
public static extern global::System.IntPtr fromLunar__SWIG_1(int jarg1, byte jarg2, int jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_siZhu2Year")]
|
||||
public static extern global::System.IntPtr siZhu2Year(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, global::System.Runtime.InteropServices.HandleRef jarg3, global::System.Runtime.InteropServices.HandleRef jarg4, int jarg5, int jarg6);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_getShiGz__SWIG_0")]
|
||||
public static extern global::System.IntPtr getShiGz__SWIG_0(byte jarg1, byte jarg2, bool jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_getShiGz__SWIG_1")]
|
||||
public static extern global::System.IntPtr getShiGz__SWIG_1(byte jarg1, byte jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_getRunMonth")]
|
||||
public static extern byte getRunMonth(int jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_getLunarMonthNum__SWIG_0")]
|
||||
public static extern byte getLunarMonthNum__SWIG_0(int jarg1, byte jarg2, bool jarg3);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_getLunarMonthNum__SWIG_1")]
|
||||
public static extern byte getLunarMonthNum__SWIG_1(int jarg1, byte jarg2);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_JD2DD")]
|
||||
public static extern global::System.IntPtr JD2DD(double jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_toJD")]
|
||||
public static extern double toJD(global::System.Runtime.InteropServices.HandleRef jarg1);
|
||||
|
||||
[global::System.Runtime.InteropServices.DllImport("sxtwl", EntryPoint="CSharp_getJieQiByYear")]
|
||||
public static extern global::System.IntPtr getJieQiByYear(int jarg1);
|
||||
}
|
2313
export/C#/sxtwl_wrap.cxx
Normal file
2313
export/C#/sxtwl_wrap.cxx
Normal file
File diff suppressed because it is too large
Load Diff
1179
export/golang/sxtwl.go
Normal file
1179
export/golang/sxtwl.go
Normal file
File diff suppressed because it is too large
Load Diff
1685
export/golang/sxtwl_wrap.cxx
Normal file
1685
export/golang/sxtwl_wrap.cxx
Normal file
File diff suppressed because it is too large
Load Diff
156
export/java/Day.java
Normal file
156
export/java/Day.java
Normal file
@ -0,0 +1,156 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (https://www.swig.org).
|
||||
* Version 4.1.1
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing - modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package com.seantone.sxtwl;
|
||||
|
||||
public class Day {
|
||||
private transient long swigCPtr;
|
||||
protected transient boolean swigCMemOwn;
|
||||
|
||||
protected Day(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
protected static long getCPtr(Day obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
|
||||
protected static long swigRelease(Day obj) {
|
||||
long ptr = 0;
|
||||
if (obj != null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new RuntimeException("Cannot release ownership as memory is not owned");
|
||||
ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.delete();
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void finalize() {
|
||||
delete();
|
||||
}
|
||||
|
||||
public synchronized void delete() {
|
||||
if (swigCPtr != 0) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
sxtwlJNI.delete_Day(swigCPtr);
|
||||
}
|
||||
swigCPtr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static Day fromSolar(int _year, short _month, int _day) {
|
||||
long cPtr = sxtwlJNI.Day_fromSolar(_year, _month, _day);
|
||||
return (cPtr == 0) ? null : new Day(cPtr, false);
|
||||
}
|
||||
|
||||
public static Day fromLunar(int year, short month, int day, boolean isRun) {
|
||||
long cPtr = sxtwlJNI.Day_fromLunar__SWIG_0(year, month, day, isRun);
|
||||
return (cPtr == 0) ? null : new Day(cPtr, false);
|
||||
}
|
||||
|
||||
public static Day fromLunar(int year, short month, int day) {
|
||||
long cPtr = sxtwlJNI.Day_fromLunar__SWIG_1(year, month, day);
|
||||
return (cPtr == 0) ? null : new Day(cPtr, false);
|
||||
}
|
||||
|
||||
public Day after(int day) {
|
||||
long cPtr = sxtwlJNI.Day_after(swigCPtr, this, day);
|
||||
return (cPtr == 0) ? null : new Day(cPtr, false);
|
||||
}
|
||||
|
||||
public Day before(int day) {
|
||||
long cPtr = sxtwlJNI.Day_before(swigCPtr, this, day);
|
||||
return (cPtr == 0) ? null : new Day(cPtr, false);
|
||||
}
|
||||
|
||||
public int getLunarDay() {
|
||||
return sxtwlJNI.Day_getLunarDay(swigCPtr, this);
|
||||
}
|
||||
|
||||
public short getLunarMonth() {
|
||||
return sxtwlJNI.Day_getLunarMonth(swigCPtr, this);
|
||||
}
|
||||
|
||||
public int getLunarYear(boolean chineseNewYearBoundary) {
|
||||
return sxtwlJNI.Day_getLunarYear__SWIG_0(swigCPtr, this, chineseNewYearBoundary);
|
||||
}
|
||||
|
||||
public int getLunarYear() {
|
||||
return sxtwlJNI.Day_getLunarYear__SWIG_1(swigCPtr, this);
|
||||
}
|
||||
|
||||
public GZ getYearGZ(boolean chineseNewYearBoundary) {
|
||||
return new GZ(sxtwlJNI.Day_getYearGZ__SWIG_0(swigCPtr, this, chineseNewYearBoundary), true);
|
||||
}
|
||||
|
||||
public GZ getYearGZ() {
|
||||
return new GZ(sxtwlJNI.Day_getYearGZ__SWIG_1(swigCPtr, this), true);
|
||||
}
|
||||
|
||||
public GZ getMonthGZ() {
|
||||
return new GZ(sxtwlJNI.Day_getMonthGZ(swigCPtr, this), true);
|
||||
}
|
||||
|
||||
public GZ getDayGZ() {
|
||||
return new GZ(sxtwlJNI.Day_getDayGZ(swigCPtr, this), true);
|
||||
}
|
||||
|
||||
public GZ getHourGZ(short hour, boolean isZaoWanZiShi) {
|
||||
return new GZ(sxtwlJNI.Day_getHourGZ__SWIG_0(swigCPtr, this, hour, isZaoWanZiShi), true);
|
||||
}
|
||||
|
||||
public GZ getHourGZ(short hour) {
|
||||
return new GZ(sxtwlJNI.Day_getHourGZ__SWIG_1(swigCPtr, this, hour), true);
|
||||
}
|
||||
|
||||
public boolean isLunarLeap() {
|
||||
return sxtwlJNI.Day_isLunarLeap(swigCPtr, this);
|
||||
}
|
||||
|
||||
public int getSolarYear() {
|
||||
return sxtwlJNI.Day_getSolarYear(swigCPtr, this);
|
||||
}
|
||||
|
||||
public short getSolarMonth() {
|
||||
return sxtwlJNI.Day_getSolarMonth(swigCPtr, this);
|
||||
}
|
||||
|
||||
public int getSolarDay() {
|
||||
return sxtwlJNI.Day_getSolarDay(swigCPtr, this);
|
||||
}
|
||||
|
||||
public short getWeek() {
|
||||
return sxtwlJNI.Day_getWeek(swigCPtr, this);
|
||||
}
|
||||
|
||||
public short getWeekIndex() {
|
||||
return sxtwlJNI.Day_getWeekIndex(swigCPtr, this);
|
||||
}
|
||||
|
||||
public boolean hasJieQi() {
|
||||
return sxtwlJNI.Day_hasJieQi(swigCPtr, this);
|
||||
}
|
||||
|
||||
public short getJieQi() {
|
||||
return sxtwlJNI.Day_getJieQi(swigCPtr, this);
|
||||
}
|
||||
|
||||
public double getJieQiJD() {
|
||||
return sxtwlJNI.Day_getJieQiJD(swigCPtr, this);
|
||||
}
|
||||
|
||||
public short getConstellation() {
|
||||
return sxtwlJNI.Day_getConstellation(swigCPtr, this);
|
||||
}
|
||||
|
||||
}
|
75
export/java/GZ.java
Normal file
75
export/java/GZ.java
Normal file
@ -0,0 +1,75 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (https://www.swig.org).
|
||||
* Version 4.1.1
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing - modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package com.seantone.sxtwl;
|
||||
|
||||
public class GZ {
|
||||
private transient long swigCPtr;
|
||||
protected transient boolean swigCMemOwn;
|
||||
|
||||
protected GZ(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
protected static long getCPtr(GZ obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
|
||||
protected static long swigRelease(GZ obj) {
|
||||
long ptr = 0;
|
||||
if (obj != null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new RuntimeException("Cannot release ownership as memory is not owned");
|
||||
ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.delete();
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void finalize() {
|
||||
delete();
|
||||
}
|
||||
|
||||
public synchronized void delete() {
|
||||
if (swigCPtr != 0) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
sxtwlJNI.delete_GZ(swigCPtr);
|
||||
}
|
||||
swigCPtr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public GZ() {
|
||||
this(sxtwlJNI.new_GZ__SWIG_0(), true);
|
||||
}
|
||||
|
||||
public GZ(short tg, short dz) {
|
||||
this(sxtwlJNI.new_GZ__SWIG_1(tg, dz), true);
|
||||
}
|
||||
|
||||
public void setTg(short value) {
|
||||
sxtwlJNI.GZ_tg_set(swigCPtr, this, value);
|
||||
}
|
||||
|
||||
public short getTg() {
|
||||
return sxtwlJNI.GZ_tg_get(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void setDz(short value) {
|
||||
sxtwlJNI.GZ_dz_set(swigCPtr, this, value);
|
||||
}
|
||||
|
||||
public short getDz() {
|
||||
return sxtwlJNI.GZ_dz_get(swigCPtr, this);
|
||||
}
|
||||
|
||||
}
|
156
export/java/JDList.java
Normal file
156
export/java/JDList.java
Normal file
@ -0,0 +1,156 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (https://www.swig.org).
|
||||
* Version 4.1.1
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing - modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package com.seantone.sxtwl;
|
||||
|
||||
public class JDList extends java.util.AbstractList<Double> implements java.util.RandomAccess {
|
||||
private transient long swigCPtr;
|
||||
protected transient boolean swigCMemOwn;
|
||||
|
||||
protected JDList(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
protected static long getCPtr(JDList obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
|
||||
protected static long swigRelease(JDList obj) {
|
||||
long ptr = 0;
|
||||
if (obj != null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new RuntimeException("Cannot release ownership as memory is not owned");
|
||||
ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.delete();
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void finalize() {
|
||||
delete();
|
||||
}
|
||||
|
||||
public synchronized void delete() {
|
||||
if (swigCPtr != 0) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
sxtwlJNI.delete_JDList(swigCPtr);
|
||||
}
|
||||
swigCPtr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public JDList(double[] initialElements) {
|
||||
this();
|
||||
reserve(initialElements.length);
|
||||
|
||||
for (double element : initialElements) {
|
||||
add(element);
|
||||
}
|
||||
}
|
||||
|
||||
public JDList(Iterable<Double> initialElements) {
|
||||
this();
|
||||
for (double element : initialElements) {
|
||||
add(element);
|
||||
}
|
||||
}
|
||||
|
||||
public Double get(int index) {
|
||||
return doGet(index);
|
||||
}
|
||||
|
||||
public Double set(int index, Double e) {
|
||||
return doSet(index, e);
|
||||
}
|
||||
|
||||
public boolean add(Double e) {
|
||||
modCount++;
|
||||
doAdd(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void add(int index, Double e) {
|
||||
modCount++;
|
||||
doAdd(index, e);
|
||||
}
|
||||
|
||||
public Double remove(int index) {
|
||||
modCount++;
|
||||
return doRemove(index);
|
||||
}
|
||||
|
||||
protected void removeRange(int fromIndex, int toIndex) {
|
||||
modCount++;
|
||||
doRemoveRange(fromIndex, toIndex);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return doSize();
|
||||
}
|
||||
|
||||
public JDList() {
|
||||
this(sxtwlJNI.new_JDList__SWIG_0(), true);
|
||||
}
|
||||
|
||||
public JDList(JDList other) {
|
||||
this(sxtwlJNI.new_JDList__SWIG_1(JDList.getCPtr(other), other), true);
|
||||
}
|
||||
|
||||
public long capacity() {
|
||||
return sxtwlJNI.JDList_capacity(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void reserve(long n) {
|
||||
sxtwlJNI.JDList_reserve(swigCPtr, this, n);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return sxtwlJNI.JDList_isEmpty(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
sxtwlJNI.JDList_clear(swigCPtr, this);
|
||||
}
|
||||
|
||||
public JDList(int count, double value) {
|
||||
this(sxtwlJNI.new_JDList__SWIG_2(count, value), true);
|
||||
}
|
||||
|
||||
private int doSize() {
|
||||
return sxtwlJNI.JDList_doSize(swigCPtr, this);
|
||||
}
|
||||
|
||||
private void doAdd(double x) {
|
||||
sxtwlJNI.JDList_doAdd__SWIG_0(swigCPtr, this, x);
|
||||
}
|
||||
|
||||
private void doAdd(int index, double x) {
|
||||
sxtwlJNI.JDList_doAdd__SWIG_1(swigCPtr, this, index, x);
|
||||
}
|
||||
|
||||
private double doRemove(int index) {
|
||||
return sxtwlJNI.JDList_doRemove(swigCPtr, this, index);
|
||||
}
|
||||
|
||||
private double doGet(int index) {
|
||||
return sxtwlJNI.JDList_doGet(swigCPtr, this, index);
|
||||
}
|
||||
|
||||
private double doSet(int index, double val) {
|
||||
return sxtwlJNI.JDList_doSet(swigCPtr, this, index, val);
|
||||
}
|
||||
|
||||
private void doRemoveRange(int fromIndex, int toIndex) {
|
||||
sxtwlJNI.JDList_doRemoveRange(swigCPtr, this, fromIndex, toIndex);
|
||||
}
|
||||
|
||||
}
|
156
export/java/JQList.java
Normal file
156
export/java/JQList.java
Normal file
@ -0,0 +1,156 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (https://www.swig.org).
|
||||
* Version 4.1.1
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing - modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package com.seantone.sxtwl;
|
||||
|
||||
public class JQList extends java.util.AbstractList<JieQiInfo> implements java.util.RandomAccess {
|
||||
private transient long swigCPtr;
|
||||
protected transient boolean swigCMemOwn;
|
||||
|
||||
protected JQList(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
protected static long getCPtr(JQList obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
|
||||
protected static long swigRelease(JQList obj) {
|
||||
long ptr = 0;
|
||||
if (obj != null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new RuntimeException("Cannot release ownership as memory is not owned");
|
||||
ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.delete();
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void finalize() {
|
||||
delete();
|
||||
}
|
||||
|
||||
public synchronized void delete() {
|
||||
if (swigCPtr != 0) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
sxtwlJNI.delete_JQList(swigCPtr);
|
||||
}
|
||||
swigCPtr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public JQList(JieQiInfo[] initialElements) {
|
||||
this();
|
||||
reserve(initialElements.length);
|
||||
|
||||
for (JieQiInfo element : initialElements) {
|
||||
add(element);
|
||||
}
|
||||
}
|
||||
|
||||
public JQList(Iterable<JieQiInfo> initialElements) {
|
||||
this();
|
||||
for (JieQiInfo element : initialElements) {
|
||||
add(element);
|
||||
}
|
||||
}
|
||||
|
||||
public JieQiInfo get(int index) {
|
||||
return doGet(index);
|
||||
}
|
||||
|
||||
public JieQiInfo set(int index, JieQiInfo e) {
|
||||
return doSet(index, e);
|
||||
}
|
||||
|
||||
public boolean add(JieQiInfo e) {
|
||||
modCount++;
|
||||
doAdd(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void add(int index, JieQiInfo e) {
|
||||
modCount++;
|
||||
doAdd(index, e);
|
||||
}
|
||||
|
||||
public JieQiInfo remove(int index) {
|
||||
modCount++;
|
||||
return doRemove(index);
|
||||
}
|
||||
|
||||
protected void removeRange(int fromIndex, int toIndex) {
|
||||
modCount++;
|
||||
doRemoveRange(fromIndex, toIndex);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return doSize();
|
||||
}
|
||||
|
||||
public JQList() {
|
||||
this(sxtwlJNI.new_JQList__SWIG_0(), true);
|
||||
}
|
||||
|
||||
public JQList(JQList other) {
|
||||
this(sxtwlJNI.new_JQList__SWIG_1(JQList.getCPtr(other), other), true);
|
||||
}
|
||||
|
||||
public long capacity() {
|
||||
return sxtwlJNI.JQList_capacity(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void reserve(long n) {
|
||||
sxtwlJNI.JQList_reserve(swigCPtr, this, n);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return sxtwlJNI.JQList_isEmpty(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
sxtwlJNI.JQList_clear(swigCPtr, this);
|
||||
}
|
||||
|
||||
public JQList(int count, JieQiInfo value) {
|
||||
this(sxtwlJNI.new_JQList__SWIG_2(count, JieQiInfo.getCPtr(value), value), true);
|
||||
}
|
||||
|
||||
private int doSize() {
|
||||
return sxtwlJNI.JQList_doSize(swigCPtr, this);
|
||||
}
|
||||
|
||||
private void doAdd(JieQiInfo x) {
|
||||
sxtwlJNI.JQList_doAdd__SWIG_0(swigCPtr, this, JieQiInfo.getCPtr(x), x);
|
||||
}
|
||||
|
||||
private void doAdd(int index, JieQiInfo x) {
|
||||
sxtwlJNI.JQList_doAdd__SWIG_1(swigCPtr, this, index, JieQiInfo.getCPtr(x), x);
|
||||
}
|
||||
|
||||
private JieQiInfo doRemove(int index) {
|
||||
return new JieQiInfo(sxtwlJNI.JQList_doRemove(swigCPtr, this, index), true);
|
||||
}
|
||||
|
||||
private JieQiInfo doGet(int index) {
|
||||
return new JieQiInfo(sxtwlJNI.JQList_doGet(swigCPtr, this, index), false);
|
||||
}
|
||||
|
||||
private JieQiInfo doSet(int index, JieQiInfo val) {
|
||||
return new JieQiInfo(sxtwlJNI.JQList_doSet(swigCPtr, this, index, JieQiInfo.getCPtr(val), val), true);
|
||||
}
|
||||
|
||||
private void doRemoveRange(int fromIndex, int toIndex) {
|
||||
sxtwlJNI.JQList_doRemoveRange(swigCPtr, this, fromIndex, toIndex);
|
||||
}
|
||||
|
||||
}
|
71
export/java/JieQiInfo.java
Normal file
71
export/java/JieQiInfo.java
Normal file
@ -0,0 +1,71 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (https://www.swig.org).
|
||||
* Version 4.1.1
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing - modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package com.seantone.sxtwl;
|
||||
|
||||
public class JieQiInfo {
|
||||
private transient long swigCPtr;
|
||||
protected transient boolean swigCMemOwn;
|
||||
|
||||
protected JieQiInfo(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
protected static long getCPtr(JieQiInfo obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
|
||||
protected static long swigRelease(JieQiInfo obj) {
|
||||
long ptr = 0;
|
||||
if (obj != null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new RuntimeException("Cannot release ownership as memory is not owned");
|
||||
ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.delete();
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void finalize() {
|
||||
delete();
|
||||
}
|
||||
|
||||
public synchronized void delete() {
|
||||
if (swigCPtr != 0) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
sxtwlJNI.delete_JieQiInfo(swigCPtr);
|
||||
}
|
||||
swigCPtr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setJd(double value) {
|
||||
sxtwlJNI.JieQiInfo_jd_set(swigCPtr, this, value);
|
||||
}
|
||||
|
||||
public double getJd() {
|
||||
return sxtwlJNI.JieQiInfo_jd_get(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void setJqIndex(short value) {
|
||||
sxtwlJNI.JieQiInfo_jqIndex_set(swigCPtr, this, value);
|
||||
}
|
||||
|
||||
public short getJqIndex() {
|
||||
return sxtwlJNI.JieQiInfo_jqIndex_get(swigCPtr, this);
|
||||
}
|
||||
|
||||
public JieQiInfo() {
|
||||
this(sxtwlJNI.new_JieQiInfo(), true);
|
||||
}
|
||||
|
||||
}
|
155
export/java/Time.java
Normal file
155
export/java/Time.java
Normal file
@ -0,0 +1,155 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (https://www.swig.org).
|
||||
* Version 4.1.1
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing - modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package com.seantone.sxtwl;
|
||||
|
||||
public class Time {
|
||||
private transient long swigCPtr;
|
||||
protected transient boolean swigCMemOwn;
|
||||
|
||||
protected Time(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
protected static long getCPtr(Time obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
|
||||
protected static long swigRelease(Time obj) {
|
||||
long ptr = 0;
|
||||
if (obj != null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new RuntimeException("Cannot release ownership as memory is not owned");
|
||||
ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.delete();
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void finalize() {
|
||||
delete();
|
||||
}
|
||||
|
||||
public synchronized void delete() {
|
||||
if (swigCPtr != 0) {
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
sxtwlJNI.delete_Time(swigCPtr);
|
||||
}
|
||||
swigCPtr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Time() {
|
||||
this(sxtwlJNI.new_Time__SWIG_0(), true);
|
||||
}
|
||||
|
||||
public Time(int year, int month, int day, double hour, double min, double sec) {
|
||||
this(sxtwlJNI.new_Time__SWIG_1(year, month, day, hour, min, sec), true);
|
||||
}
|
||||
|
||||
public void setY(int value) {
|
||||
sxtwlJNI.Time_Y_set(swigCPtr, this, value);
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return sxtwlJNI.Time_Y_get(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void setM(int value) {
|
||||
sxtwlJNI.Time_M_set(swigCPtr, this, value);
|
||||
}
|
||||
|
||||
public int getM() {
|
||||
return sxtwlJNI.Time_M_get(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void setD(int value) {
|
||||
sxtwlJNI.Time_D_set(swigCPtr, this, value);
|
||||
}
|
||||
|
||||
public int getD() {
|
||||
return sxtwlJNI.Time_D_get(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void setH(double value) {
|
||||
sxtwlJNI.Time_h_set(swigCPtr, this, value);
|
||||
}
|
||||
|
||||
public double getH() {
|
||||
return sxtwlJNI.Time_h_get(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void setM(double value) {
|
||||
sxtwlJNI.Time_m_set(swigCPtr, this, value);
|
||||
}
|
||||
|
||||
public double getM() {
|
||||
return sxtwlJNI.Time_m_get(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void setS(double value) {
|
||||
sxtwlJNI.Time_s_set(swigCPtr, this, value);
|
||||
}
|
||||
|
||||
public double getS() {
|
||||
return sxtwlJNI.Time_s_get(swigCPtr, this);
|
||||
}
|
||||
|
||||
public int getYear() {
|
||||
return sxtwlJNI.Time_getYear(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void setYear(int year) {
|
||||
sxtwlJNI.Time_setYear(swigCPtr, this, year);
|
||||
}
|
||||
|
||||
public void setMonth(int month) {
|
||||
sxtwlJNI.Time_setMonth(swigCPtr, this, month);
|
||||
}
|
||||
|
||||
public int getMonth() {
|
||||
return sxtwlJNI.Time_getMonth(swigCPtr, this);
|
||||
}
|
||||
|
||||
public int getDay() {
|
||||
return sxtwlJNI.Time_getDay(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void setDay(int day) {
|
||||
sxtwlJNI.Time_setDay(swigCPtr, this, day);
|
||||
}
|
||||
|
||||
public double getHour() {
|
||||
return sxtwlJNI.Time_getHour(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void setHour(double hour) {
|
||||
sxtwlJNI.Time_setHour(swigCPtr, this, hour);
|
||||
}
|
||||
|
||||
public double getMin() {
|
||||
return sxtwlJNI.Time_getMin(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void setMour(double min) {
|
||||
sxtwlJNI.Time_setMour(swigCPtr, this, min);
|
||||
}
|
||||
|
||||
public double getSec() {
|
||||
return sxtwlJNI.Time_getSec(swigCPtr, this);
|
||||
}
|
||||
|
||||
public void setSec(double sec) {
|
||||
sxtwlJNI.Time_setSec(swigCPtr, this, sec);
|
||||
}
|
||||
|
||||
}
|
63
export/java/sxtwl.java
Normal file
63
export/java/sxtwl.java
Normal file
@ -0,0 +1,63 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (https://www.swig.org).
|
||||
* Version 4.1.1
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing - modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package com.seantone.sxtwl;
|
||||
|
||||
public class sxtwl implements sxtwlConstants {
|
||||
public static Day fromSolar(int year, short month, int day) {
|
||||
long cPtr = sxtwlJNI.fromSolar(year, month, day);
|
||||
return (cPtr == 0) ? null : new Day(cPtr, false);
|
||||
}
|
||||
|
||||
public static Day fromLunar(int year, short month, int day, boolean isRun) {
|
||||
long cPtr = sxtwlJNI.fromLunar__SWIG_0(year, month, day, isRun);
|
||||
return (cPtr == 0) ? null : new Day(cPtr, false);
|
||||
}
|
||||
|
||||
public static Day fromLunar(int year, short month, int day) {
|
||||
long cPtr = sxtwlJNI.fromLunar__SWIG_1(year, month, day);
|
||||
return (cPtr == 0) ? null : new Day(cPtr, false);
|
||||
}
|
||||
|
||||
public static JDList siZhu2Year(GZ year, GZ yue, GZ ri, GZ shi, int fromYear, int toYear) {
|
||||
return new JDList(sxtwlJNI.siZhu2Year(GZ.getCPtr(year), year, GZ.getCPtr(yue), yue, GZ.getCPtr(ri), ri, GZ.getCPtr(shi), shi, fromYear, toYear), true);
|
||||
}
|
||||
|
||||
public static GZ getShiGz(short dayTg, short hour, boolean isZaoWanZiShi) {
|
||||
return new GZ(sxtwlJNI.getShiGz__SWIG_0(dayTg, hour, isZaoWanZiShi), true);
|
||||
}
|
||||
|
||||
public static GZ getShiGz(short dayTg, short hour) {
|
||||
return new GZ(sxtwlJNI.getShiGz__SWIG_1(dayTg, hour), true);
|
||||
}
|
||||
|
||||
public static short getRunMonth(int By) {
|
||||
return sxtwlJNI.getRunMonth(By);
|
||||
}
|
||||
|
||||
public static short getLunarMonthNum(int By, short month, boolean isRun) {
|
||||
return sxtwlJNI.getLunarMonthNum__SWIG_0(By, month, isRun);
|
||||
}
|
||||
|
||||
public static short getLunarMonthNum(int By, short month) {
|
||||
return sxtwlJNI.getLunarMonthNum__SWIG_1(By, month);
|
||||
}
|
||||
|
||||
public static Time JD2DD(double jd) {
|
||||
return new Time(sxtwlJNI.JD2DD(jd), true);
|
||||
}
|
||||
|
||||
public static double toJD(Time time) {
|
||||
return sxtwlJNI.toJD(Time.getCPtr(time), time);
|
||||
}
|
||||
|
||||
public static JQList getJieQiByYear(int year) {
|
||||
return new JQList(sxtwlJNI.getJieQiByYear(year), true);
|
||||
}
|
||||
|
||||
}
|
13
export/java/sxtwlConstants.java
Normal file
13
export/java/sxtwlConstants.java
Normal file
@ -0,0 +1,13 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (https://www.swig.org).
|
||||
* Version 4.1.1
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing - modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package com.seantone.sxtwl;
|
||||
|
||||
public interface sxtwlConstants {
|
||||
public final static int J2000 = sxtwlJNI.J2000_get();
|
||||
}
|
121
export/java/sxtwlJNI.java
Normal file
121
export/java/sxtwlJNI.java
Normal file
@ -0,0 +1,121 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (https://www.swig.org).
|
||||
* Version 4.1.1
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing - modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package com.seantone.sxtwl;
|
||||
|
||||
public class sxtwlJNI {
|
||||
public final static native long new_JDList__SWIG_0();
|
||||
public final static native long new_JDList__SWIG_1(long jarg1, JDList jarg1_);
|
||||
public final static native long JDList_capacity(long jarg1, JDList jarg1_);
|
||||
public final static native void JDList_reserve(long jarg1, JDList jarg1_, long jarg2);
|
||||
public final static native boolean JDList_isEmpty(long jarg1, JDList jarg1_);
|
||||
public final static native void JDList_clear(long jarg1, JDList jarg1_);
|
||||
public final static native long new_JDList__SWIG_2(int jarg1, double jarg2);
|
||||
public final static native int JDList_doSize(long jarg1, JDList jarg1_);
|
||||
public final static native void JDList_doAdd__SWIG_0(long jarg1, JDList jarg1_, double jarg2);
|
||||
public final static native void JDList_doAdd__SWIG_1(long jarg1, JDList jarg1_, int jarg2, double jarg3);
|
||||
public final static native double JDList_doRemove(long jarg1, JDList jarg1_, int jarg2);
|
||||
public final static native double JDList_doGet(long jarg1, JDList jarg1_, int jarg2);
|
||||
public final static native double JDList_doSet(long jarg1, JDList jarg1_, int jarg2, double jarg3);
|
||||
public final static native void JDList_doRemoveRange(long jarg1, JDList jarg1_, int jarg2, int jarg3);
|
||||
public final static native void delete_JDList(long jarg1);
|
||||
public final static native long new_JQList__SWIG_0();
|
||||
public final static native long new_JQList__SWIG_1(long jarg1, JQList jarg1_);
|
||||
public final static native long JQList_capacity(long jarg1, JQList jarg1_);
|
||||
public final static native void JQList_reserve(long jarg1, JQList jarg1_, long jarg2);
|
||||
public final static native boolean JQList_isEmpty(long jarg1, JQList jarg1_);
|
||||
public final static native void JQList_clear(long jarg1, JQList jarg1_);
|
||||
public final static native long new_JQList__SWIG_2(int jarg1, long jarg2, JieQiInfo jarg2_);
|
||||
public final static native int JQList_doSize(long jarg1, JQList jarg1_);
|
||||
public final static native void JQList_doAdd__SWIG_0(long jarg1, JQList jarg1_, long jarg2, JieQiInfo jarg2_);
|
||||
public final static native void JQList_doAdd__SWIG_1(long jarg1, JQList jarg1_, int jarg2, long jarg3, JieQiInfo jarg3_);
|
||||
public final static native long JQList_doRemove(long jarg1, JQList jarg1_, int jarg2);
|
||||
public final static native long JQList_doGet(long jarg1, JQList jarg1_, int jarg2);
|
||||
public final static native long JQList_doSet(long jarg1, JQList jarg1_, int jarg2, long jarg3, JieQiInfo jarg3_);
|
||||
public final static native void JQList_doRemoveRange(long jarg1, JQList jarg1_, int jarg2, int jarg3);
|
||||
public final static native void delete_JQList(long jarg1);
|
||||
public final static native int J2000_get();
|
||||
public final static native long new_Time__SWIG_0();
|
||||
public final static native long new_Time__SWIG_1(int jarg1, int jarg2, int jarg3, double jarg4, double jarg5, double jarg6);
|
||||
public final static native void Time_Y_set(long jarg1, Time jarg1_, int jarg2);
|
||||
public final static native int Time_Y_get(long jarg1, Time jarg1_);
|
||||
public final static native void Time_M_set(long jarg1, Time jarg1_, int jarg2);
|
||||
public final static native int Time_M_get(long jarg1, Time jarg1_);
|
||||
public final static native void Time_D_set(long jarg1, Time jarg1_, int jarg2);
|
||||
public final static native int Time_D_get(long jarg1, Time jarg1_);
|
||||
public final static native void Time_h_set(long jarg1, Time jarg1_, double jarg2);
|
||||
public final static native double Time_h_get(long jarg1, Time jarg1_);
|
||||
public final static native void Time_m_set(long jarg1, Time jarg1_, double jarg2);
|
||||
public final static native double Time_m_get(long jarg1, Time jarg1_);
|
||||
public final static native void Time_s_set(long jarg1, Time jarg1_, double jarg2);
|
||||
public final static native double Time_s_get(long jarg1, Time jarg1_);
|
||||
public final static native int Time_getYear(long jarg1, Time jarg1_);
|
||||
public final static native void Time_setYear(long jarg1, Time jarg1_, int jarg2);
|
||||
public final static native void Time_setMonth(long jarg1, Time jarg1_, int jarg2);
|
||||
public final static native int Time_getMonth(long jarg1, Time jarg1_);
|
||||
public final static native int Time_getDay(long jarg1, Time jarg1_);
|
||||
public final static native void Time_setDay(long jarg1, Time jarg1_, int jarg2);
|
||||
public final static native double Time_getHour(long jarg1, Time jarg1_);
|
||||
public final static native void Time_setHour(long jarg1, Time jarg1_, double jarg2);
|
||||
public final static native double Time_getMin(long jarg1, Time jarg1_);
|
||||
public final static native void Time_setMour(long jarg1, Time jarg1_, double jarg2);
|
||||
public final static native double Time_getSec(long jarg1, Time jarg1_);
|
||||
public final static native void Time_setSec(long jarg1, Time jarg1_, double jarg2);
|
||||
public final static native void delete_Time(long jarg1);
|
||||
public final static native long new_GZ__SWIG_0();
|
||||
public final static native long new_GZ__SWIG_1(short jarg1, short jarg2);
|
||||
public final static native void GZ_tg_set(long jarg1, GZ jarg1_, short jarg2);
|
||||
public final static native short GZ_tg_get(long jarg1, GZ jarg1_);
|
||||
public final static native void GZ_dz_set(long jarg1, GZ jarg1_, short jarg2);
|
||||
public final static native short GZ_dz_get(long jarg1, GZ jarg1_);
|
||||
public final static native void delete_GZ(long jarg1);
|
||||
public final static native long Day_fromSolar(int jarg1, short jarg2, int jarg3);
|
||||
public final static native long Day_fromLunar__SWIG_0(int jarg1, short jarg2, int jarg3, boolean jarg4);
|
||||
public final static native long Day_fromLunar__SWIG_1(int jarg1, short jarg2, int jarg3);
|
||||
public final static native long Day_after(long jarg1, Day jarg1_, int jarg2);
|
||||
public final static native long Day_before(long jarg1, Day jarg1_, int jarg2);
|
||||
public final static native int Day_getLunarDay(long jarg1, Day jarg1_);
|
||||
public final static native short Day_getLunarMonth(long jarg1, Day jarg1_);
|
||||
public final static native int Day_getLunarYear__SWIG_0(long jarg1, Day jarg1_, boolean jarg2);
|
||||
public final static native int Day_getLunarYear__SWIG_1(long jarg1, Day jarg1_);
|
||||
public final static native long Day_getYearGZ__SWIG_0(long jarg1, Day jarg1_, boolean jarg2);
|
||||
public final static native long Day_getYearGZ__SWIG_1(long jarg1, Day jarg1_);
|
||||
public final static native long Day_getMonthGZ(long jarg1, Day jarg1_);
|
||||
public final static native long Day_getDayGZ(long jarg1, Day jarg1_);
|
||||
public final static native long Day_getHourGZ__SWIG_0(long jarg1, Day jarg1_, short jarg2, boolean jarg3);
|
||||
public final static native long Day_getHourGZ__SWIG_1(long jarg1, Day jarg1_, short jarg2);
|
||||
public final static native boolean Day_isLunarLeap(long jarg1, Day jarg1_);
|
||||
public final static native int Day_getSolarYear(long jarg1, Day jarg1_);
|
||||
public final static native short Day_getSolarMonth(long jarg1, Day jarg1_);
|
||||
public final static native int Day_getSolarDay(long jarg1, Day jarg1_);
|
||||
public final static native short Day_getWeek(long jarg1, Day jarg1_);
|
||||
public final static native short Day_getWeekIndex(long jarg1, Day jarg1_);
|
||||
public final static native boolean Day_hasJieQi(long jarg1, Day jarg1_);
|
||||
public final static native short Day_getJieQi(long jarg1, Day jarg1_);
|
||||
public final static native double Day_getJieQiJD(long jarg1, Day jarg1_);
|
||||
public final static native short Day_getConstellation(long jarg1, Day jarg1_);
|
||||
public final static native void delete_Day(long jarg1);
|
||||
public final static native void JieQiInfo_jd_set(long jarg1, JieQiInfo jarg1_, double jarg2);
|
||||
public final static native double JieQiInfo_jd_get(long jarg1, JieQiInfo jarg1_);
|
||||
public final static native void JieQiInfo_jqIndex_set(long jarg1, JieQiInfo jarg1_, short jarg2);
|
||||
public final static native short JieQiInfo_jqIndex_get(long jarg1, JieQiInfo jarg1_);
|
||||
public final static native long new_JieQiInfo();
|
||||
public final static native void delete_JieQiInfo(long jarg1);
|
||||
public final static native long fromSolar(int jarg1, short jarg2, int jarg3);
|
||||
public final static native long fromLunar__SWIG_0(int jarg1, short jarg2, int jarg3, boolean jarg4);
|
||||
public final static native long fromLunar__SWIG_1(int jarg1, short jarg2, int jarg3);
|
||||
public final static native long siZhu2Year(long jarg1, GZ jarg1_, long jarg2, GZ jarg2_, long jarg3, GZ jarg3_, long jarg4, GZ jarg4_, int jarg5, int jarg6);
|
||||
public final static native long getShiGz__SWIG_0(short jarg1, short jarg2, boolean jarg3);
|
||||
public final static native long getShiGz__SWIG_1(short jarg1, short jarg2);
|
||||
public final static native short getRunMonth(int jarg1);
|
||||
public final static native short getLunarMonthNum__SWIG_0(int jarg1, short jarg2, boolean jarg3);
|
||||
public final static native short getLunarMonthNum__SWIG_1(int jarg1, short jarg2);
|
||||
public final static native long JD2DD(double jarg1);
|
||||
public final static native double toJD(long jarg1, Time jarg1_);
|
||||
public final static native long getJieQiByYear(int jarg1);
|
||||
}
|
2156
export/java/sxtwl_wrap.cxx
Normal file
2156
export/java/sxtwl_wrap.cxx
Normal file
File diff suppressed because it is too large
Load Diff
7122
export/lua/sxtwl_wrap.cxx
Normal file
7122
export/lua/sxtwl_wrap.cxx
Normal file
File diff suppressed because it is too large
Load Diff
126
export/php7/php_sxtwl.h
Normal file
126
export/php7/php_sxtwl.h
Normal file
@ -0,0 +1,126 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (https://www.swig.org).
|
||||
* Version 4.1.1
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing - modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#ifndef PHP_SXTWL_H
|
||||
#define PHP_SXTWL_H
|
||||
|
||||
extern zend_module_entry sxtwl_module_entry;
|
||||
#define phpext_sxtwl_ptr &sxtwl_module_entry
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
# define PHP_SXTWL_API __declspec(dllexport)
|
||||
#else
|
||||
# define PHP_SXTWL_API
|
||||
#endif
|
||||
|
||||
static PHP_METHOD(JDList,__construct);
|
||||
static PHP_METHOD(JDList,size);
|
||||
static PHP_METHOD(JDList,capacity);
|
||||
static PHP_METHOD(JDList,reserve);
|
||||
static PHP_METHOD(JDList,clear);
|
||||
static PHP_METHOD(JDList,push);
|
||||
static PHP_METHOD(JDList,is_empty);
|
||||
static PHP_METHOD(JDList,pop);
|
||||
static PHP_METHOD(JDList,get);
|
||||
static PHP_METHOD(JDList,set);
|
||||
PHP_METHOD(JDList,__set);
|
||||
PHP_METHOD(JDList,__get);
|
||||
PHP_METHOD(JDList,__isset);
|
||||
static PHP_METHOD(JQList,__construct);
|
||||
static PHP_METHOD(JQList,size);
|
||||
static PHP_METHOD(JQList,capacity);
|
||||
static PHP_METHOD(JQList,reserve);
|
||||
static PHP_METHOD(JQList,clear);
|
||||
static PHP_METHOD(JQList,push);
|
||||
static PHP_METHOD(JQList,is_empty);
|
||||
static PHP_METHOD(JQList,pop);
|
||||
static PHP_METHOD(JQList,get);
|
||||
static PHP_METHOD(JQList,set);
|
||||
PHP_METHOD(JQList,__set);
|
||||
PHP_METHOD(JQList,__get);
|
||||
PHP_METHOD(JQList,__isset);
|
||||
static PHP_METHOD(Time,__construct);
|
||||
static PHP_METHOD(Time,Y_set);
|
||||
static PHP_METHOD(Time,Y_get);
|
||||
static PHP_METHOD(Time,M_set);
|
||||
static PHP_METHOD(Time,M_get);
|
||||
static PHP_METHOD(Time,D_set);
|
||||
static PHP_METHOD(Time,D_get);
|
||||
static PHP_METHOD(Time,h_set);
|
||||
static PHP_METHOD(Time,h_get);
|
||||
static PHP_METHOD(Time,m_set);
|
||||
static PHP_METHOD(Time,m_get);
|
||||
static PHP_METHOD(Time,s_set);
|
||||
static PHP_METHOD(Time,s_get);
|
||||
static PHP_METHOD(Time,getYear);
|
||||
static PHP_METHOD(Time,setYear);
|
||||
static PHP_METHOD(Time,setMonth);
|
||||
static PHP_METHOD(Time,getMonth);
|
||||
static PHP_METHOD(Time,getDay);
|
||||
static PHP_METHOD(Time,setDay);
|
||||
static PHP_METHOD(Time,getHour);
|
||||
static PHP_METHOD(Time,setHour);
|
||||
static PHP_METHOD(Time,getMin);
|
||||
static PHP_METHOD(Time,setMour);
|
||||
static PHP_METHOD(Time,getSec);
|
||||
static PHP_METHOD(Time,setSec);
|
||||
PHP_METHOD(Time,__set);
|
||||
PHP_METHOD(Time,__get);
|
||||
PHP_METHOD(Time,__isset);
|
||||
static PHP_METHOD(GZ,__construct);
|
||||
static PHP_METHOD(GZ,tg_set);
|
||||
static PHP_METHOD(GZ,tg_get);
|
||||
static PHP_METHOD(GZ,dz_set);
|
||||
static PHP_METHOD(GZ,dz_get);
|
||||
PHP_METHOD(GZ,__set);
|
||||
PHP_METHOD(GZ,__get);
|
||||
PHP_METHOD(GZ,__isset);
|
||||
static PHP_METHOD(Day,fromSolar);
|
||||
static PHP_METHOD(Day,fromLunar);
|
||||
static PHP_METHOD(Day,after);
|
||||
static PHP_METHOD(Day,before);
|
||||
static PHP_METHOD(Day,getLunarDay);
|
||||
static PHP_METHOD(Day,getLunarMonth);
|
||||
static PHP_METHOD(Day,getLunarYear);
|
||||
static PHP_METHOD(Day,getYearGZ);
|
||||
static PHP_METHOD(Day,getMonthGZ);
|
||||
static PHP_METHOD(Day,getDayGZ);
|
||||
static PHP_METHOD(Day,getHourGZ);
|
||||
static PHP_METHOD(Day,isLunarLeap);
|
||||
static PHP_METHOD(Day,getSolarYear);
|
||||
static PHP_METHOD(Day,getSolarMonth);
|
||||
static PHP_METHOD(Day,getSolarDay);
|
||||
static PHP_METHOD(Day,getWeek);
|
||||
static PHP_METHOD(Day,getWeekIndex);
|
||||
static PHP_METHOD(Day,hasJieQi);
|
||||
static PHP_METHOD(Day,getJieQi);
|
||||
static PHP_METHOD(Day,getJieQiJD);
|
||||
static PHP_METHOD(Day,getConstellation);
|
||||
PHP_METHOD(Day,__set);
|
||||
PHP_METHOD(Day,__get);
|
||||
PHP_METHOD(Day,__isset);
|
||||
static PHP_METHOD(JieQiInfo,jd_set);
|
||||
static PHP_METHOD(JieQiInfo,jd_get);
|
||||
static PHP_METHOD(JieQiInfo,jqIndex_set);
|
||||
static PHP_METHOD(JieQiInfo,jqIndex_get);
|
||||
static PHP_METHOD(JieQiInfo,__construct);
|
||||
PHP_METHOD(JieQiInfo,__set);
|
||||
PHP_METHOD(JieQiInfo,__get);
|
||||
PHP_METHOD(JieQiInfo,__isset);
|
||||
static PHP_FUNCTION(fromSolar);
|
||||
static ZEND_NAMED_FUNCTION(_wrap_fromLunar);
|
||||
static PHP_FUNCTION(siZhu2Year);
|
||||
static ZEND_NAMED_FUNCTION(_wrap_getShiGz);
|
||||
static PHP_FUNCTION(getRunMonth);
|
||||
static ZEND_NAMED_FUNCTION(_wrap_getLunarMonthNum);
|
||||
static PHP_FUNCTION(JD2DD);
|
||||
static PHP_FUNCTION(toJD);
|
||||
static PHP_FUNCTION(getJieQiByYear);
|
||||
PHP_MINIT_FUNCTION(sxtwl);
|
||||
|
||||
#endif /* PHP_SXTWL_H */
|
436
export/php7/sxtwl.php
Normal file
436
export/php7/sxtwl.php
Normal file
@ -0,0 +1,436 @@
|
||||
<?php
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 4.0.2
|
||||
*
|
||||
* This file is not intended to be easily readable and contains a number of
|
||||
* coding conventions designed to improve portability and efficiency. Do not make
|
||||
* changes to this file unless you know what you are doing--modify the SWIG
|
||||
* interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
// Try to load our extension if it's not already loaded.
|
||||
if (!extension_loaded('sxtwl')) {
|
||||
if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {
|
||||
if (!dl('php_sxtwl.dll')) return;
|
||||
} else {
|
||||
// PHP_SHLIB_SUFFIX gives 'dylib' on MacOS X but modules are 'so'.
|
||||
if (PHP_SHLIB_SUFFIX === 'dylib') {
|
||||
if (!dl('sxtwl.so')) return;
|
||||
} else {
|
||||
if (!dl('sxtwl.'.PHP_SHLIB_SUFFIX)) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
abstract class sxtwl {
|
||||
const J2000 = J2000;
|
||||
|
||||
static function fromSolar($year,$month,$day) {
|
||||
$r=fromSolar($year,$month,$day);
|
||||
if (is_resource($r)) {
|
||||
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
|
||||
if (class_exists($c)) return new $c($r);
|
||||
return new Day($r);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
static function fromLunar($year,$month,$day,$isRun=false) {
|
||||
$r=fromLunar($year,$month,$day,$isRun);
|
||||
if (!is_resource($r)) return $r;
|
||||
return new Day($r);
|
||||
}
|
||||
|
||||
static function siZhu2Year($year,$yue,$ri,$shi,$fromYear,$toYear) {
|
||||
$r=siZhu2Year($year,$yue,$ri,$shi,$fromYear,$toYear);
|
||||
if (is_resource($r)) {
|
||||
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
|
||||
if (class_exists($c)) return new $c($r);
|
||||
return new JDList($r);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
static function getShiGz($dayTg,$hour,$isZaoWanZiShi=true) {
|
||||
$r=getShiGz($dayTg,$hour,$isZaoWanZiShi);
|
||||
if (is_resource($r)) {
|
||||
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
|
||||
if (class_exists($c)) return new $c($r);
|
||||
return new GZ($r);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
static function getRunMonth($By) {
|
||||
return getRunMonth($By);
|
||||
}
|
||||
|
||||
static function getLunarMonthNum($By,$month,$isRun=false) {
|
||||
return getLunarMonthNum($By,$month,$isRun);
|
||||
}
|
||||
|
||||
static function JD2DD($jd) {
|
||||
$r=JD2DD($jd);
|
||||
if (is_resource($r)) {
|
||||
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
|
||||
if (class_exists($c)) return new $c($r);
|
||||
return new Time($r);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
static function toJD($time) {
|
||||
return toJD($time);
|
||||
}
|
||||
}
|
||||
|
||||
/* PHP Proxy Classes */
|
||||
class JDList {
|
||||
public $_cPtr=null;
|
||||
protected $_pData=array();
|
||||
|
||||
function __set($var,$value) {
|
||||
if ($var === 'thisown') return swig_sxtwl_alter_newobject($this->_cPtr,$value);
|
||||
$this->_pData[$var] = $value;
|
||||
}
|
||||
|
||||
function __get($var) {
|
||||
if ($var === 'thisown') return swig_sxtwl_get_newobject($this->_cPtr);
|
||||
return $this->_pData[$var];
|
||||
}
|
||||
|
||||
function __isset($var) {
|
||||
if ($var === 'thisown') return true;
|
||||
return array_key_exists($var, $this->_pData);
|
||||
}
|
||||
|
||||
function __construct($n_or_other=null) {
|
||||
if (is_resource($n_or_other) && get_resource_type($n_or_other) === '_p_std__vectorT_double_t') {
|
||||
$this->_cPtr=$n_or_other;
|
||||
return;
|
||||
}
|
||||
switch (func_num_args()) {
|
||||
case 0: $this->_cPtr=new_JDList(); break;
|
||||
default: $this->_cPtr=new_JDList($n_or_other);
|
||||
}
|
||||
}
|
||||
|
||||
function size() {
|
||||
return JDList_size($this->_cPtr);
|
||||
}
|
||||
|
||||
function capacity() {
|
||||
return JDList_capacity($this->_cPtr);
|
||||
}
|
||||
|
||||
function reserve($n) {
|
||||
JDList_reserve($this->_cPtr,$n);
|
||||
}
|
||||
|
||||
function clear() {
|
||||
JDList_clear($this->_cPtr);
|
||||
}
|
||||
|
||||
function push($x) {
|
||||
JDList_push($this->_cPtr,$x);
|
||||
}
|
||||
|
||||
function is_empty() {
|
||||
return JDList_is_empty($this->_cPtr);
|
||||
}
|
||||
|
||||
function pop() {
|
||||
return JDList_pop($this->_cPtr);
|
||||
}
|
||||
|
||||
function get($i) {
|
||||
return JDList_get($this->_cPtr,$i);
|
||||
}
|
||||
|
||||
function set($i,$val) {
|
||||
JDList_set($this->_cPtr,$i,$val);
|
||||
}
|
||||
}
|
||||
|
||||
class Time {
|
||||
public $_cPtr=null;
|
||||
protected $_pData=array();
|
||||
|
||||
function __set($var,$value) {
|
||||
$func = 'Time_'.$var.'_set';
|
||||
if (function_exists($func)) return call_user_func($func,$this->_cPtr,$value);
|
||||
if ($var === 'thisown') return swig_sxtwl_alter_newobject($this->_cPtr,$value);
|
||||
$this->_pData[$var] = $value;
|
||||
}
|
||||
|
||||
function __get($var) {
|
||||
$func = 'Time_'.$var.'_get';
|
||||
if (function_exists($func)) return call_user_func($func,$this->_cPtr);
|
||||
if ($var === 'thisown') return swig_sxtwl_get_newobject($this->_cPtr);
|
||||
return $this->_pData[$var];
|
||||
}
|
||||
|
||||
function __isset($var) {
|
||||
if (function_exists('Time_'.$var.'_get')) return true;
|
||||
if ($var === 'thisown') return true;
|
||||
return array_key_exists($var, $this->_pData);
|
||||
}
|
||||
|
||||
function __construct($year=null,$month=null,$day=null,$hour=null,$min=null,$sec=null) {
|
||||
if (is_resource($year) && get_resource_type($year) === '_p_Time') {
|
||||
$this->_cPtr=$year;
|
||||
return;
|
||||
}
|
||||
switch (func_num_args()) {
|
||||
case 0: $this->_cPtr=new_Time(); break;
|
||||
case 1: $this->_cPtr=new_Time($year); break;
|
||||
case 2: $this->_cPtr=new_Time($year,$month); break;
|
||||
case 3: $this->_cPtr=new_Time($year,$month,$day); break;
|
||||
case 4: $this->_cPtr=new_Time($year,$month,$day,$hour); break;
|
||||
case 5: $this->_cPtr=new_Time($year,$month,$day,$hour,$min); break;
|
||||
default: $this->_cPtr=new_Time($year,$month,$day,$hour,$min,$sec);
|
||||
}
|
||||
}
|
||||
|
||||
function getYear() {
|
||||
return Time_getYear($this->_cPtr);
|
||||
}
|
||||
|
||||
function setYear($year) {
|
||||
Time_setYear($this->_cPtr,$year);
|
||||
}
|
||||
|
||||
function setMonth($month) {
|
||||
Time_setMonth($this->_cPtr,$month);
|
||||
}
|
||||
|
||||
function getMonth() {
|
||||
return Time_getMonth($this->_cPtr);
|
||||
}
|
||||
|
||||
function getDay() {
|
||||
return Time_getDay($this->_cPtr);
|
||||
}
|
||||
|
||||
function setDay($day) {
|
||||
Time_setDay($this->_cPtr,$day);
|
||||
}
|
||||
|
||||
function getHour() {
|
||||
return Time_getHour($this->_cPtr);
|
||||
}
|
||||
|
||||
function setHour($hour) {
|
||||
Time_setHour($this->_cPtr,$hour);
|
||||
}
|
||||
|
||||
function getMin() {
|
||||
return Time_getMin($this->_cPtr);
|
||||
}
|
||||
|
||||
function setMour($min) {
|
||||
Time_setMour($this->_cPtr,$min);
|
||||
}
|
||||
|
||||
function getSec() {
|
||||
return Time_getSec($this->_cPtr);
|
||||
}
|
||||
|
||||
function setSec($sec) {
|
||||
Time_setSec($this->_cPtr,$sec);
|
||||
}
|
||||
}
|
||||
|
||||
class GZ {
|
||||
public $_cPtr=null;
|
||||
protected $_pData=array();
|
||||
|
||||
function __set($var,$value) {
|
||||
if ($var === 'tg') return GZ_tg_set($this->_cPtr,$value);
|
||||
if ($var === 'dz') return GZ_dz_set($this->_cPtr,$value);
|
||||
if ($var === 'thisown') return swig_sxtwl_alter_newobject($this->_cPtr,$value);
|
||||
$this->_pData[$var] = $value;
|
||||
}
|
||||
|
||||
function __get($var) {
|
||||
if ($var === 'tg') return GZ_tg_get($this->_cPtr);
|
||||
if ($var === 'dz') return GZ_dz_get($this->_cPtr);
|
||||
if ($var === 'thisown') return swig_sxtwl_get_newobject($this->_cPtr);
|
||||
return $this->_pData[$var];
|
||||
}
|
||||
|
||||
function __isset($var) {
|
||||
if (function_exists('GZ_'.$var.'_get')) return true;
|
||||
if ($var === 'thisown') return true;
|
||||
return array_key_exists($var, $this->_pData);
|
||||
}
|
||||
|
||||
function __construct($tg=null,$dz=null) {
|
||||
if (is_resource($tg) && get_resource_type($tg) === '_p_GZ') {
|
||||
$this->_cPtr=$tg;
|
||||
return;
|
||||
}
|
||||
switch (func_num_args()) {
|
||||
case 0: $this->_cPtr=new_GZ(); break;
|
||||
case 1: $this->_cPtr=new_GZ($tg); break;
|
||||
default: $this->_cPtr=new_GZ($tg,$dz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Day {
|
||||
public $_cPtr=null;
|
||||
protected $_pData=array();
|
||||
|
||||
function __set($var,$value) {
|
||||
if ($var === 'thisown') return swig_sxtwl_alter_newobject($this->_cPtr,$value);
|
||||
$this->_pData[$var] = $value;
|
||||
}
|
||||
|
||||
function __get($var) {
|
||||
if ($var === 'thisown') return swig_sxtwl_get_newobject($this->_cPtr);
|
||||
return $this->_pData[$var];
|
||||
}
|
||||
|
||||
function __isset($var) {
|
||||
if ($var === 'thisown') return true;
|
||||
return array_key_exists($var, $this->_pData);
|
||||
}
|
||||
function __construct($h) {
|
||||
$this->_cPtr=$h;
|
||||
}
|
||||
|
||||
static function fromSolar($_year,$_month,$_day) {
|
||||
$r=Day_fromSolar($_year,$_month,$_day);
|
||||
if (is_resource($r)) {
|
||||
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
|
||||
if (class_exists($c)) return new $c($r);
|
||||
return new Day($r);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
static function fromLunar($year,$month,$day,$isRun=false) {
|
||||
$r=Day_fromLunar($year,$month,$day,$isRun);
|
||||
if (!is_resource($r)) return $r;
|
||||
return new Day($r);
|
||||
}
|
||||
|
||||
function after($day) {
|
||||
$r=Day_after($this->_cPtr,$day);
|
||||
if (is_resource($r)) {
|
||||
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
|
||||
if (class_exists($c)) return new $c($r);
|
||||
return new Day($r);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function before($day) {
|
||||
$r=Day_before($this->_cPtr,$day);
|
||||
if (is_resource($r)) {
|
||||
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
|
||||
if (class_exists($c)) return new $c($r);
|
||||
return new Day($r);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function getLunarDay() {
|
||||
return Day_getLunarDay($this->_cPtr);
|
||||
}
|
||||
|
||||
function getLunarMonth() {
|
||||
return Day_getLunarMonth($this->_cPtr);
|
||||
}
|
||||
|
||||
function getLunarYear($chineseNewYearBoundary=true) {
|
||||
return Day_getLunarYear($this->_cPtr,$chineseNewYearBoundary);
|
||||
}
|
||||
|
||||
function getYearGZ($chineseNewYearBoundary=false) {
|
||||
$r=Day_getYearGZ($this->_cPtr,$chineseNewYearBoundary);
|
||||
if (is_resource($r)) {
|
||||
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
|
||||
if (class_exists($c)) return new $c($r);
|
||||
return new GZ($r);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function getMonthGZ() {
|
||||
$r=Day_getMonthGZ($this->_cPtr);
|
||||
if (is_resource($r)) {
|
||||
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
|
||||
if (class_exists($c)) return new $c($r);
|
||||
return new GZ($r);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function getDayGZ() {
|
||||
$r=Day_getDayGZ($this->_cPtr);
|
||||
if (is_resource($r)) {
|
||||
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
|
||||
if (class_exists($c)) return new $c($r);
|
||||
return new GZ($r);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function getHourGZ($hour,$isZaoWanZiShi=true) {
|
||||
$r=Day_getHourGZ($this->_cPtr,$hour,$isZaoWanZiShi);
|
||||
if (is_resource($r)) {
|
||||
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
|
||||
if (class_exists($c)) return new $c($r);
|
||||
return new GZ($r);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function isLunarLeap() {
|
||||
return Day_isLunarLeap($this->_cPtr);
|
||||
}
|
||||
|
||||
function getSolarYear() {
|
||||
return Day_getSolarYear($this->_cPtr);
|
||||
}
|
||||
|
||||
function getSolarMonth() {
|
||||
return Day_getSolarMonth($this->_cPtr);
|
||||
}
|
||||
|
||||
function getSolarDay() {
|
||||
return Day_getSolarDay($this->_cPtr);
|
||||
}
|
||||
|
||||
function getWeek() {
|
||||
return Day_getWeek($this->_cPtr);
|
||||
}
|
||||
|
||||
function getWeekIndex() {
|
||||
return Day_getWeekIndex($this->_cPtr);
|
||||
}
|
||||
|
||||
function hasJieQi() {
|
||||
return Day_hasJieQi($this->_cPtr);
|
||||
}
|
||||
|
||||
function getJieQi() {
|
||||
return Day_getJieQi($this->_cPtr);
|
||||
}
|
||||
|
||||
function getJieQiJD() {
|
||||
return Day_getJieQiJD($this->_cPtr);
|
||||
}
|
||||
|
||||
function getConstellation() {
|
||||
return Day_getConstellation($this->_cPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
5672
export/php7/sxtwl_wrap.cxx
Normal file
5672
export/php7/sxtwl_wrap.cxx
Normal file
File diff suppressed because it is too large
Load Diff
1
export/python/README.md
Normal file
1
export/python/README.md
Normal file
@ -0,0 +1 @@
|
||||
python的接口导出目录在工程的根目录下的python目录中
|
290
ndk_build.py
Normal file
290
ndk_build.py
Normal file
@ -0,0 +1,290 @@
|
||||
#-*-coding:utf-8-*-
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import zipfile
|
||||
import hashlib
|
||||
import sys
|
||||
import platform
|
||||
import requests
|
||||
import urllib
|
||||
import subprocess
|
||||
|
||||
#工具类
|
||||
class Utils():
|
||||
#如果目录不存,则创建。
|
||||
@staticmethod
|
||||
def mkDir(dirPath):
|
||||
if os.path.exists(dirPath) and os.path.isdir(dirPath):
|
||||
return
|
||||
parent = os.path.dirname(dirPath)
|
||||
if not (os.path.exists(parent) and os.path.isdir(parent)):
|
||||
Utils.mkDir(parent)
|
||||
|
||||
os.mkdir(dirPath)
|
||||
|
||||
#获取某个目录是否含有某个文件, extList获取指定的文件后缀
|
||||
@staticmethod
|
||||
def getAllDirFiles(dirPath, extList = None):
|
||||
ret = []
|
||||
for file in os.listdir( dirPath):
|
||||
if os.path.isfile(os.path.join(dirPath, file)):
|
||||
ret.append(os.path.join(dirPath, file))
|
||||
else:
|
||||
ret += Utils.getAllDirFiles(os.path.join(dirPath, file))
|
||||
|
||||
#需要过滤某些文件
|
||||
if extList != None:
|
||||
extList = [tmp.lower() for tmp in extList]
|
||||
ret = [path for path in ret if os.path.splitext(path)[1].lower() in extList]
|
||||
return ret
|
||||
|
||||
#清理掉某个数据
|
||||
@staticmethod
|
||||
def cleanFile(path):
|
||||
if not os.path.exists(path):
|
||||
return
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
elif os.path.isfile(path):
|
||||
os.remove(path)
|
||||
|
||||
#将一个文件夹压缩成zip文件
|
||||
@staticmethod
|
||||
def makeZipFile(fileName, fromDir):
|
||||
fileList = Utils.getAllDirFiles(fromDir)
|
||||
with zipfile.ZipFile(fileName , 'w') as zip:
|
||||
for file in fileList:
|
||||
zip.write(file, os.path.relpath(file, fromDir))
|
||||
|
||||
@staticmethod
|
||||
def extractZipFile(fileName, toDir = "."):
|
||||
file_zip = zipfile.ZipFile(fileName, 'r')
|
||||
for file in file_zip.namelist():
|
||||
file_zip.extract(file, toDir)
|
||||
file_zip.close()
|
||||
|
||||
|
||||
@staticmethod
|
||||
def sha256_checksum(filename, block_size=65536):
|
||||
sha256 = hashlib.sha256()
|
||||
with open(filename, 'rb') as f:
|
||||
for block in iter(lambda: f.read(block_size), b''):
|
||||
sha256.update(block)
|
||||
return sha256.hexdigest()
|
||||
|
||||
#获取python文件所在的路径
|
||||
def p():
|
||||
frozen = "not"
|
||||
if getattr(sys, 'frozen',False):
|
||||
frozen = "ever so"
|
||||
return os.path.dirname(sys.executable)
|
||||
|
||||
return os.path.split(os.path.realpath(__file__))[0]
|
||||
|
||||
#下载进度条回调
|
||||
def callbackfunc(blocknum, blocksize, totalsize):
|
||||
'''回调函数
|
||||
@blocknum: 已经下载的数据块
|
||||
@blocksize: 数据块的大小
|
||||
@totalsize: 远程文件的大小
|
||||
'''
|
||||
percent = 100.0 * blocknum * blocksize / totalsize
|
||||
if percent > 100:
|
||||
percent = 100
|
||||
|
||||
max_arrow = 50 #进度条的长度
|
||||
num_arrow = int(percent * max_arrow/100.0)
|
||||
|
||||
process_bar = '\r[' + '>' * num_arrow + '#' * (max_arrow - num_arrow) + ']'\
|
||||
+ '%.2f%%' % percent #带输出的字符串,'\r'表示不换行回到最左边
|
||||
sys.stdout.write(process_bar) #这两句打印字符到终端
|
||||
sys.stdout.flush()
|
||||
|
||||
#andoird sdk 的操作sdk路径
|
||||
class AndroidSDK():
|
||||
def __init__(self):
|
||||
self.ANDROID_SDK = self.getAndroidSDKPath()
|
||||
if self.ANDROID_SDK == None:
|
||||
self.ANDROID_SDK = self.installAndroidSDK()
|
||||
#更新android sdk
|
||||
self.updateSDK(['platforms;android-16'])
|
||||
|
||||
self.cmakeDir = self.getCmakeDir()
|
||||
if self.cmakeDir == None:
|
||||
self.updateSDK(['cmake;3.6.4111459'])
|
||||
self.cmakeDir = self.getCmakeDir()
|
||||
|
||||
self.NDKPath = self.getNDKPath()
|
||||
if self.NDKPath == None:
|
||||
self.updateSDK(['ndk-bundle'])
|
||||
self.NDKPath = self.getNDKPath()
|
||||
|
||||
|
||||
def installAndroidSDK(self):
|
||||
sysstr = platform.system().lower()
|
||||
|
||||
SHA_256 = {
|
||||
"windows":'7e81d69c303e47a4f0e748a6352d85cd0c8fd90a5a95ae4e076b5e5f960d3c7a',
|
||||
'darwin':'ecb29358bc0f13d7c2fa0f9290135a5b608e38434aad9bf7067d0252c160853e',
|
||||
'linux':'92ffee5a1d98d856634e8b71132e8a95d96c83a63fde1099be3d86df3106def9',
|
||||
}
|
||||
|
||||
#是否需要下载包
|
||||
needDownload = True
|
||||
android_sdk_zip = "android_sdk.zip"
|
||||
if os.path.isfile(android_sdk_zip):
|
||||
sha256 = Utils.sha256_checksum(android_sdk_zip)
|
||||
if sha256.lower() == SHA_256[sysstr]:
|
||||
needDownload = False
|
||||
|
||||
print u"下载Android_sdk"
|
||||
#下载包
|
||||
if needDownload:
|
||||
sdk_download_url = 'https://dl.google.com/android/repository/sdk-tools-%s-4333796.zip'%(sysstr, )
|
||||
urllib.urlretrieve(sdk_download_url, android_sdk_zip, callbackfunc)
|
||||
|
||||
#解压文件
|
||||
Utils.extractZipFile(android_sdk_zip, "./android_sdk")
|
||||
os.environ['ANDROID_HOME'] = os.path.realpath("android_sdk")
|
||||
return os.environ['ANDROID_HOME']
|
||||
|
||||
def updateSDK(self, package = [ 'platforms;android-16', 'cmake;3.6.4111459', 'ndk-bundle' ]):
|
||||
sdkmanager = os.path.join(self.ANDROID_SDK, 'tools/bin/sdkmanager')
|
||||
if "windows" == platform.system().lower():
|
||||
sdkmanager = sdkmanager + '.bat'
|
||||
else:
|
||||
cmd = 'chmod +x %s' %(sdkmanager,)
|
||||
os.system(cmd)
|
||||
|
||||
args = ['"%s"' %(key) for key in package]
|
||||
|
||||
args.insert(0, sdkmanager)
|
||||
cmd = 'echo y|' + " ".join(args)
|
||||
os.system(cmd)
|
||||
|
||||
|
||||
#获取sdk里的 cmake 信息
|
||||
def getCmakeDir(self):
|
||||
ndk_cmake_dir = os.path.join(self.ANDROID_SDK, "cmake")
|
||||
if not os.path.isdir(ndk_cmake_dir):
|
||||
return None
|
||||
|
||||
cmake_dir_list = os.listdir(ndk_cmake_dir)
|
||||
list_len = len(cmake_dir_list)
|
||||
if list_len <= 0:
|
||||
return None
|
||||
|
||||
return os.path.join(ndk_cmake_dir, cmake_dir_list[list_len - 1] )
|
||||
|
||||
|
||||
def getNDKPath(self):
|
||||
#通过系统变量来寻找
|
||||
environ_names = [
|
||||
'NDK_ROOT',
|
||||
]
|
||||
|
||||
for name in environ_names:
|
||||
#环境变量里不存在
|
||||
if name not in os.environ.keys():
|
||||
continue
|
||||
|
||||
android_ndk_path = os.environ[name]
|
||||
#验证如果不存在此目录
|
||||
if not os.path.isdir(android_ndk_path):
|
||||
continue
|
||||
|
||||
return android_ndk_path
|
||||
|
||||
ndk_bundle_dir = os.path.join(self.ANDROID_SDK, "ndk-bundle/toolchains")
|
||||
if os.path.isdir(ndk_bundle_dir):
|
||||
return os.path.join(self.ANDROID_SDK, "ndk-bundle")
|
||||
|
||||
|
||||
# 根据系统变量android sdk的路径
|
||||
def getAndroidSDKPath(self):
|
||||
environ_names = [
|
||||
'ANDROID_HOME',
|
||||
'ANDROID_SDK_ROOT'
|
||||
]
|
||||
|
||||
for name in environ_names:
|
||||
#环境变量里不存在
|
||||
if name not in os.environ.keys():
|
||||
continue
|
||||
|
||||
android_sdk_path = os.environ[name]
|
||||
#验证如果不存在此目录
|
||||
if not os.path.isdir(android_sdk_path):
|
||||
continue
|
||||
|
||||
return android_sdk_path
|
||||
|
||||
#没有找到相应的sdk路径
|
||||
return None
|
||||
|
||||
|
||||
if '__main__' == __name__:
|
||||
android_sdk = AndroidSDK()
|
||||
ANDROID_SDK = android_sdk.getAndroidSDKPath()
|
||||
ANDROID_NDK =android_sdk.getNDKPath()
|
||||
|
||||
ANDROID_CMAKE = os.path.join(android_sdk.getCmakeDir(), 'bin/cmake')
|
||||
ANDROID_NINJA=os.path.join(android_sdk.getCmakeDir(),'bin/ninja')
|
||||
|
||||
if "windows" == platform.system().lower():
|
||||
ANDROID_CMAKE = ANDROID_CMAKE + '.exe'
|
||||
ANDROID_NINJA = ANDROID_NINJA + '.exe'
|
||||
|
||||
pyPath = p()
|
||||
buildDir = os.path.join(pyPath, "build")
|
||||
outDir = os.path.join(pyPath, "out")
|
||||
|
||||
|
||||
Utils().cleanFile(outDir)
|
||||
Utils().mkDir(outDir)
|
||||
|
||||
#需要打包的abi
|
||||
abiList = [
|
||||
'armeabi',
|
||||
'armeabi-v7a',
|
||||
"arm64-v8a",
|
||||
"x86",
|
||||
'x86_64',
|
||||
'mips',
|
||||
'mips64',
|
||||
]
|
||||
for abi in abiList:
|
||||
os.chdir(pyPath)
|
||||
Utils().cleanFile(buildDir)
|
||||
Utils().mkDir(buildDir)
|
||||
os.chdir(buildDir)
|
||||
|
||||
cmd = '''%s -DANDROID_ABI=%s \
|
||||
-DANDROID_PLATFORM=android-16 \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DANDROID_NDK=%s \
|
||||
-DCMAKE_CXX_FLAGS=-std=c++11 -frtti -fexceptions \
|
||||
-DCMAKE_TOOLCHAIN_FILE=%s/build/cmake/android.toolchain.cmake \
|
||||
-DCMAKE_MAKE_PROGRAM=%s -G "Ninja" \
|
||||
-DCONSOLE=1 \
|
||||
-DSXTWL_WRAPPER_JAVA=1 ..'''%(ANDROID_CMAKE,abi,ANDROID_NDK,ANDROID_NDK,ANDROID_NINJA )
|
||||
|
||||
os.system(cmd)
|
||||
os.system("%s --build ."%(ANDROID_CMAKE, ))
|
||||
|
||||
outSoPath = os.path.join(outDir, "jniLibs/" + abi)
|
||||
Utils().cleanFile(outSoPath)
|
||||
Utils().mkDir(outSoPath)
|
||||
|
||||
outJavaPath = os.path.join(outDir, "java/com/huoyaojing")
|
||||
if not os.path.isdir(outJavaPath):
|
||||
Utils().mkDir(outJavaPath)
|
||||
fileList = Utils.getAllDirFiles(buildDir, [".java"])
|
||||
for tmp in fileList:
|
||||
basename = os.path.basename(tmp)
|
||||
shutil.move(tmp, os.path.join(outJavaPath, basename))
|
||||
|
||||
|
||||
shutil.move(os.path.join(buildDir, "libsxtwl_java.so"),os.path.join(outSoPath, "libsxtwl_java.so"))
|
||||
|
106
python/.gitignore
vendored
Normal file
106
python/.gitignore
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
sxtwl.egg-info
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
.idea/
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
workspace.xml
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
.idea/workspace.xml
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
|
||||
/src
|
1
python/MANIFEST.in
Normal file
1
python/MANIFEST.in
Normal file
@ -0,0 +1 @@
|
||||
recursive-include src *.h
|
244
python/README.md
Normal file
244
python/README.md
Normal file
@ -0,0 +1,244 @@
|
||||
### 介绍
|
||||
|
||||
sxtwl_cpp是参考[寿星天文历](http://www.nongli.net/sxwnl/)并使用C++实现日历库。因为其依据天文历法算法实现,故其可查询范围广(BC722年以后与实历相符,支持1800年以前及2200年以后的日历查询)。支持Android、IOS、Windows、MacOS、Linux等平台。使用swig暴露接口给python,lua,java等语言使用。
|
||||
|
||||
|
||||
### 安装方法
|
||||
|
||||
```
|
||||
pip install sxtwl
|
||||
```
|
||||
|
||||
旧工程代码兼容
|
||||
如果有已使用V1.x版本的工程,想兼容代码
|
||||
```
|
||||
pip install sxtwl==1.1.0
|
||||
```
|
||||
或者在requirements.txt里修改
|
||||
```
|
||||
sxtwl 1.1.0
|
||||
```
|
||||
|
||||
具体使用方法参考:
|
||||
https://pypi.org/project/sxtwl/
|
||||
|
||||
本项目 [GitHub](https://github.com/yuangu/sxtwl_cpp) / [Gitee(码云)](https://gitee.com/yuangu/sxtwl)。
|
||||
|
||||
|
||||
### 使用方法
|
||||
|
||||
<font color='red'> 注:因为pip上传后不能二次修改,参考事例可能会有错误无法修改,如果发现下面例子不能用,请以为准: [传送门](https://github.com/yuangu/sxtwl_cpp/blob/master/example/main.py) </font>
|
||||
|
||||
|
||||
1. 因为考虑到繁体和简体字的原因,所以本库不以硬编码的形式显示结果。下面是参考的简单索引
|
||||
```
|
||||
Gan = ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"]
|
||||
Zhi = ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
|
||||
ShX = ["鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"]
|
||||
numCn = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"]
|
||||
jqmc = ["冬至", "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏",
|
||||
"小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑","白露", "秋分", "寒露", "霜降",
|
||||
"立冬", "小雪", "大雪"]
|
||||
ymc = ["十一", "十二", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十" ]
|
||||
rmc = ["初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十",
|
||||
"十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十",
|
||||
"廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一"]
|
||||
XiZ = ['摩羯', '水瓶', '双鱼', '白羊', '金牛', '双子', '巨蟹', '狮子', '处女', '天秤', '天蝎', '射手']
|
||||
WeekCn = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
|
||||
```
|
||||
|
||||
2. 引入本库
|
||||
```
|
||||
import sxtwl
|
||||
|
||||
# 从公历年月日获取一天的信息
|
||||
day = sxtwl.fromSolar(2021, 11, 7)
|
||||
|
||||
# 从农历年月日获取一天的信息
|
||||
day = sxtwl.fromLunar(2020, 12, 1)
|
||||
```
|
||||
|
||||
3. 获取某天的信息(这里的信息有,阴历,阳历,二十四节气,天干地支,星期几等)
|
||||
|
||||
```
|
||||
# 公历的年月日
|
||||
s = "公历:%d年%d月%d日" % (day.getSolarYear(), day.getSolarMonth(), day.getSolarDay())
|
||||
print(s)
|
||||
|
||||
# 星期几
|
||||
print(WeekCn[day.getWeek()])
|
||||
|
||||
# 这个月的第几周
|
||||
print('该日属于这个月的第%d周'%(day.getWeekIndex(),))
|
||||
|
||||
# 星座(有bug?待修复)
|
||||
print("星座:", XiZ[day.getConstellation()])
|
||||
|
||||
# 以春节为界的农历(注getLunarYear如果没有传参,或者传true,是以春节为界的)
|
||||
s = "农历:%d年%s%d月%d日" % (day.getLunarYear(),
|
||||
'闰' if day.isLunarLeap() else '', day.getLunarMonth(), day.getLunarDay())
|
||||
print(s)
|
||||
|
||||
# 以立春为界的农历
|
||||
s = "农历:%d年%s%d月%d日" % (day.getLunarYear(False),
|
||||
'闰' if day.isLunarLeap() else '', day.getLunarMonth(), day.getLunarDay())
|
||||
print(s)
|
||||
|
||||
|
||||
# 以春节为界的天干地支
|
||||
yTG = day.getYearGZ(True)
|
||||
print("以春节为界的年干支", Gan[yTG.tg] + Zhi[yTG.dz])
|
||||
print("以春节为界的生肖:", ShX[yTG.dz])
|
||||
|
||||
# 以立春为界的天干地支 (注,如果没有传参,或者传false,是以立春为界的。刚好和getLunarYear相反)
|
||||
yTG = day.getYearGZ()
|
||||
print("以立春为界的年干支", Gan[yTG.tg] + Zhi[yTG.dz])
|
||||
print("以立春为界的生肖:", ShX[yTG.dz])
|
||||
|
||||
#月干支
|
||||
mTG = day.getMonthGZ()
|
||||
print("月干支", Gan[mTG.tg] + Zhi[mTG.dz])
|
||||
|
||||
#日干支
|
||||
dTG = day.getDayGZ()
|
||||
print("日干支", Gan[dTG.tg] + Zhi[dTG.dz])
|
||||
|
||||
|
||||
#时干支,传24小时制的时间,分早晚子时
|
||||
hour = 18
|
||||
sTG = day.getHourGZ(hour)
|
||||
print("%d时的干支"%(hour, ), Gan[sTG.tg] + Zhi[sTG.dz])
|
||||
|
||||
|
||||
#时干支
|
||||
for hour in range(24):
|
||||
# 第一个参数为该天的天干,第二个参数为小时
|
||||
hTG = sxtwl.getShiGz(dTG.tg, hour)
|
||||
print("%d时天干地支:"%(hour), Gan[hTG.tg] + Zhi[hTG.dz])
|
||||
|
||||
|
||||
# 当日是否有节气
|
||||
if day.hasJieQi():
|
||||
print('节气:%s'% jqmc[day.getJieQi()])
|
||||
#获取节气的儒略日数
|
||||
jd = day.getJieQiJD()
|
||||
# 将儒略日数转换成年月日时秒
|
||||
t = sxtwl.JD2DD(jd )
|
||||
|
||||
# 注意,t.s是小数,需要四舍五入
|
||||
print("节气时间:%d-%d-%d %d:%d:%d"%(t.Y, t.M, t.D, t.h, t.m, round(t.s)))
|
||||
else:
|
||||
print("当天不是节气日")
|
||||
|
||||
```
|
||||
|
||||
4. 获取某日的前几天或者后几天的信息 (可以用到很多场景中)
|
||||
```
|
||||
# 获取某天的后面几天
|
||||
num = 1 #你喜欢写多少天 也多少天,可以写负数,相当于往前
|
||||
day = day.after(num) #获取num天后的日信息
|
||||
s = "公历:%d年%d月%d日" % (day.getSolarYear(), day.getSolarMonth(), day.getSolarDay())
|
||||
print(s)
|
||||
|
||||
# 同上
|
||||
day = day.before(num)
|
||||
s = "公历:%d年%d月%d日" % (day.getSolarYear(), day.getSolarMonth(), day.getSolarDay())
|
||||
print(s)
|
||||
```
|
||||
|
||||
|
||||
5. 获取一年中的闰月
|
||||
```
|
||||
# 获取一年中的闰月
|
||||
year = 2020
|
||||
month = sxtwl.getRunMonth(year)
|
||||
if month >= 0:
|
||||
print("%d年的闰月是%d"%(year, month) )
|
||||
else:
|
||||
print("没有闰月")
|
||||
```
|
||||
|
||||
6. 获取一个农历月的天数
|
||||
```
|
||||
# 一个农历月的天数
|
||||
year = 2020 #农历年
|
||||
month = 4 #农历月
|
||||
isRun = False #是否是闰月
|
||||
daynum = sxtwl.getLunarMonthNum(year, month, isRun)
|
||||
print("农历%d年%s%d月的天数:"%(year, '闰'if isRun else '', month), daynum)
|
||||
|
||||
```
|
||||
|
||||
7. 儒略日数与公历的互转
|
||||
```
|
||||
#儒略日数转公历
|
||||
jd = sxtwl.J2000
|
||||
t = sxtwl.JD2DD(jd )
|
||||
|
||||
#公历转儒略日
|
||||
jd = sxtwl.toJD(t)
|
||||
```
|
||||
|
||||
|
||||
8. 查找某日之前或者之后的节气
|
||||
```
|
||||
# 查找某日前后的节气,此例为之后,之前把after替换成before
|
||||
while True:
|
||||
# 这里可以使用after或者before,不用担心速度,这里的计算在底层仅仅是+1这么简单
|
||||
day = day.after(1)
|
||||
# hasJieQi的接口比getJieQiJD速度要快,你也可以使用getJieQiJD来判断是否有节气。
|
||||
if day.hasJieQi():
|
||||
print('节气:%s'% jqmc[day.getJieQi()])
|
||||
#获取节气的儒略日数, 如果说你要计算什么时间的相距多少,直接比对儒略日要方便,相信我。
|
||||
jd = day.getJieQiJD()
|
||||
|
||||
# 将儒略日数转换成年月日时秒
|
||||
t = sxtwl.JD2DD(jd )
|
||||
|
||||
# 注意,t.s是小数,需要四舍五入
|
||||
print("节气时间:%d-%d-%d %d:%d:%d"%(t.Y, t.M, t.D, t.h, t.m, round(t.s)))
|
||||
|
||||
break
|
||||
```
|
||||
|
||||
9. 四柱反查 (好像还有bug,待修复)
|
||||
```
|
||||
###==================================================================================
|
||||
# 四柱反查工具方法
|
||||
# 实际项目中不要这样子搞哈,因为汉字utf-8,GBK2312不同的编码。建议还是直接使用天干地支的数字索引
|
||||
def getGZ(gzStr):
|
||||
tg = -1
|
||||
dz = -1
|
||||
for i, v in enumerate(Gan):
|
||||
if gzStr[0] == v:
|
||||
tg = i
|
||||
break
|
||||
|
||||
for i, v in enumerate(Zhi):
|
||||
if gzStr[1] == v:
|
||||
dz = i
|
||||
break
|
||||
return sxtwl.GZ(tg, dz)
|
||||
###==================================================================================
|
||||
|
||||
# 四注反查 分别传的是年天干,月天干,日天干,时天干, 开始查询年,结束查询年 返回满足条件的儒略日数
|
||||
jds = sxtwl.siZhu2Year(getGZ('辛丑'), getGZ('己亥'), getGZ('丙寅'), getGZ('癸巳'), 2003, 2029);
|
||||
for jd in jds:
|
||||
t = sxtwl.JD2DD(jd )
|
||||
print("符合条件的时间:%d-%d-%d %d:%d:%d"%(t.Y, t.M, t.D, t.h, t.m, round(t.s)))
|
||||
|
||||
```
|
||||
|
||||
### 联系作者及广告
|
||||
|
||||
作者微信二维码:
|
||||
|
||||

|
||||
|
||||
请您扫码支持作者的海棠万年历(广告):
|
||||
|
||||

|
||||
|
||||
如果您想请作者喝杯奶茶,扫如下微信支付码:
|
||||
|
||||

|
99
python/setup.py
Normal file
99
python/setup.py
Normal file
@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env python
|
||||
#-*-coding:utf-8-*-
|
||||
|
||||
import setuptools
|
||||
from distutils import ccompiler
|
||||
import os,sys
|
||||
import shutil,os
|
||||
import platform
|
||||
import io
|
||||
import os
|
||||
|
||||
long_description = ""
|
||||
|
||||
try:
|
||||
if sys.version_info < (3, 0) :
|
||||
with open('README.md') as f:
|
||||
long_description = f.read()
|
||||
else:
|
||||
long_description = io.open('README.md', 'r', encoding="utf-8").read()
|
||||
except Exception as e:
|
||||
long_description = ""
|
||||
finally:
|
||||
pass
|
||||
|
||||
# if sys.version_info < (3, 0) and platform.system() == 'Windows':
|
||||
# long_description = long_description.decode("utf-8").encode("gbk")
|
||||
|
||||
if sys.version_info >= (3, 0) and platform.system() == 'Windows':
|
||||
try:
|
||||
if isinstance(long_description, unicode):
|
||||
tmp=copy.deepcopy(long_description)
|
||||
tmp.encode("mbcs")
|
||||
except Exception as e:
|
||||
long_description = ''
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
# if sys.version_info < (3, 0):
|
||||
# with open("README.md", "r") as fh:
|
||||
# long_description = fh.read()
|
||||
# if platform.system() == 'Windows':
|
||||
# long_description = long_description.decode("utf8").encode("gbk")
|
||||
# else:
|
||||
# with open("README.md", "r", encoding='utf-8') as fh:
|
||||
# long_description = "".join(fh.readlines())
|
||||
# #发现了一个有趣的问题:http://www.queasy.me/rbsoaeod.html/questions/43255455/unicode+character+causing+error+with+bdist_wininst+on+python+3+but+not+python+2
|
||||
# try:
|
||||
# long_description.encode("mbcs")
|
||||
# except Exception as e:
|
||||
# long_description = ''
|
||||
# else:
|
||||
# pass
|
||||
|
||||
|
||||
|
||||
if os.path.isdir("../src"):
|
||||
if os.path.isdir("src"):
|
||||
shutil.rmtree("src")
|
||||
shutil.copytree("../src","src")
|
||||
|
||||
extra_compile_args = []
|
||||
if ccompiler.get_default_compiler() == "msvc":
|
||||
extra_compile_args.append("/utf-8")
|
||||
else:
|
||||
extra_compile_args.append('-std=c++11')
|
||||
|
||||
|
||||
sxtwl_module = setuptools.Extension('_sxtwl',
|
||||
sources=[
|
||||
'sxtwl_wrap.cxx',
|
||||
'src/eph.cpp',
|
||||
'src/JD.cpp',
|
||||
'src/SSQ.cpp',
|
||||
'src/sxtwl.cpp',
|
||||
'src/day.cpp',
|
||||
],
|
||||
include_dirs=["./src"],
|
||||
extra_compile_args=extra_compile_args
|
||||
|
||||
)
|
||||
|
||||
|
||||
setuptools.setup(
|
||||
name="sxtwl",
|
||||
version="2.0.6",
|
||||
author="yuangu",
|
||||
author_email="seantone@126.com",
|
||||
description="sxtwl_cpp warpper for python",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
license = "BSD",
|
||||
#package_dir={'src': '../src'},
|
||||
url="https://github.com/yuangu/sxtwl_cpp",
|
||||
packages=setuptools.find_packages(),
|
||||
ext_modules = [sxtwl_module],
|
||||
py_modules = ["sxtwl"],
|
||||
|
||||
)
|
510
python/sxtwl.py
Normal file
510
python/sxtwl.py
Normal file
@ -0,0 +1,510 @@
|
||||
# This file was automatically generated by SWIG (https://www.swig.org).
|
||||
# Version 4.1.1
|
||||
#
|
||||
# Do not make changes to this file unless you know what you are doing - modify
|
||||
# the SWIG interface file instead.
|
||||
|
||||
from sys import version_info as _swig_python_version_info
|
||||
# Import the low-level C/C++ module
|
||||
if __package__ or "." in __name__:
|
||||
from . import _sxtwl
|
||||
else:
|
||||
import _sxtwl
|
||||
|
||||
try:
|
||||
import builtins as __builtin__
|
||||
except ImportError:
|
||||
import __builtin__
|
||||
|
||||
def _swig_repr(self):
|
||||
try:
|
||||
strthis = "proxy of " + self.this.__repr__()
|
||||
except __builtin__.Exception:
|
||||
strthis = ""
|
||||
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
|
||||
|
||||
|
||||
def _swig_setattr_nondynamic_instance_variable(set):
|
||||
def set_instance_attr(self, name, value):
|
||||
if name == "this":
|
||||
set(self, name, value)
|
||||
elif name == "thisown":
|
||||
self.this.own(value)
|
||||
elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
|
||||
set(self, name, value)
|
||||
else:
|
||||
raise AttributeError("You cannot add instance attributes to %s" % self)
|
||||
return set_instance_attr
|
||||
|
||||
|
||||
def _swig_setattr_nondynamic_class_variable(set):
|
||||
def set_class_attr(cls, name, value):
|
||||
if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
|
||||
set(cls, name, value)
|
||||
else:
|
||||
raise AttributeError("You cannot add class attributes to %s" % cls)
|
||||
return set_class_attr
|
||||
|
||||
|
||||
def _swig_add_metaclass(metaclass):
|
||||
"""Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
|
||||
def wrapper(cls):
|
||||
return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
|
||||
return wrapper
|
||||
|
||||
|
||||
class _SwigNonDynamicMeta(type):
|
||||
"""Meta class to enforce nondynamic attributes (no new attributes) for a class"""
|
||||
__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)
|
||||
|
||||
|
||||
class SwigPyIterator(object):
|
||||
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
raise AttributeError("No constructor defined - class is abstract")
|
||||
__repr__ = _swig_repr
|
||||
__swig_destroy__ = _sxtwl.delete_SwigPyIterator
|
||||
|
||||
def value(self):
|
||||
return _sxtwl.SwigPyIterator_value(self)
|
||||
|
||||
def incr(self, n=1):
|
||||
return _sxtwl.SwigPyIterator_incr(self, n)
|
||||
|
||||
def decr(self, n=1):
|
||||
return _sxtwl.SwigPyIterator_decr(self, n)
|
||||
|
||||
def distance(self, x):
|
||||
return _sxtwl.SwigPyIterator_distance(self, x)
|
||||
|
||||
def equal(self, x):
|
||||
return _sxtwl.SwigPyIterator_equal(self, x)
|
||||
|
||||
def copy(self):
|
||||
return _sxtwl.SwigPyIterator_copy(self)
|
||||
|
||||
def next(self):
|
||||
return _sxtwl.SwigPyIterator_next(self)
|
||||
|
||||
def __next__(self):
|
||||
return _sxtwl.SwigPyIterator___next__(self)
|
||||
|
||||
def previous(self):
|
||||
return _sxtwl.SwigPyIterator_previous(self)
|
||||
|
||||
def advance(self, n):
|
||||
return _sxtwl.SwigPyIterator_advance(self, n)
|
||||
|
||||
def __eq__(self, x):
|
||||
return _sxtwl.SwigPyIterator___eq__(self, x)
|
||||
|
||||
def __ne__(self, x):
|
||||
return _sxtwl.SwigPyIterator___ne__(self, x)
|
||||
|
||||
def __iadd__(self, n):
|
||||
return _sxtwl.SwigPyIterator___iadd__(self, n)
|
||||
|
||||
def __isub__(self, n):
|
||||
return _sxtwl.SwigPyIterator___isub__(self, n)
|
||||
|
||||
def __add__(self, n):
|
||||
return _sxtwl.SwigPyIterator___add__(self, n)
|
||||
|
||||
def __sub__(self, *args):
|
||||
return _sxtwl.SwigPyIterator___sub__(self, *args)
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
# Register SwigPyIterator in _sxtwl:
|
||||
_sxtwl.SwigPyIterator_swigregister(SwigPyIterator)
|
||||
class JDList(object):
|
||||
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
||||
__repr__ = _swig_repr
|
||||
|
||||
def iterator(self):
|
||||
return _sxtwl.JDList_iterator(self)
|
||||
def __iter__(self):
|
||||
return self.iterator()
|
||||
|
||||
def __nonzero__(self):
|
||||
return _sxtwl.JDList___nonzero__(self)
|
||||
|
||||
def __bool__(self):
|
||||
return _sxtwl.JDList___bool__(self)
|
||||
|
||||
def __len__(self):
|
||||
return _sxtwl.JDList___len__(self)
|
||||
|
||||
def __getslice__(self, i, j):
|
||||
return _sxtwl.JDList___getslice__(self, i, j)
|
||||
|
||||
def __setslice__(self, *args):
|
||||
return _sxtwl.JDList___setslice__(self, *args)
|
||||
|
||||
def __delslice__(self, i, j):
|
||||
return _sxtwl.JDList___delslice__(self, i, j)
|
||||
|
||||
def __delitem__(self, *args):
|
||||
return _sxtwl.JDList___delitem__(self, *args)
|
||||
|
||||
def __getitem__(self, *args):
|
||||
return _sxtwl.JDList___getitem__(self, *args)
|
||||
|
||||
def __setitem__(self, *args):
|
||||
return _sxtwl.JDList___setitem__(self, *args)
|
||||
|
||||
def pop(self):
|
||||
return _sxtwl.JDList_pop(self)
|
||||
|
||||
def append(self, x):
|
||||
return _sxtwl.JDList_append(self, x)
|
||||
|
||||
def empty(self):
|
||||
return _sxtwl.JDList_empty(self)
|
||||
|
||||
def size(self):
|
||||
return _sxtwl.JDList_size(self)
|
||||
|
||||
def swap(self, v):
|
||||
return _sxtwl.JDList_swap(self, v)
|
||||
|
||||
def begin(self):
|
||||
return _sxtwl.JDList_begin(self)
|
||||
|
||||
def end(self):
|
||||
return _sxtwl.JDList_end(self)
|
||||
|
||||
def rbegin(self):
|
||||
return _sxtwl.JDList_rbegin(self)
|
||||
|
||||
def rend(self):
|
||||
return _sxtwl.JDList_rend(self)
|
||||
|
||||
def clear(self):
|
||||
return _sxtwl.JDList_clear(self)
|
||||
|
||||
def get_allocator(self):
|
||||
return _sxtwl.JDList_get_allocator(self)
|
||||
|
||||
def pop_back(self):
|
||||
return _sxtwl.JDList_pop_back(self)
|
||||
|
||||
def erase(self, *args):
|
||||
return _sxtwl.JDList_erase(self, *args)
|
||||
|
||||
def __init__(self, *args):
|
||||
_sxtwl.JDList_swiginit(self, _sxtwl.new_JDList(*args))
|
||||
|
||||
def push_back(self, x):
|
||||
return _sxtwl.JDList_push_back(self, x)
|
||||
|
||||
def front(self):
|
||||
return _sxtwl.JDList_front(self)
|
||||
|
||||
def back(self):
|
||||
return _sxtwl.JDList_back(self)
|
||||
|
||||
def assign(self, n, x):
|
||||
return _sxtwl.JDList_assign(self, n, x)
|
||||
|
||||
def resize(self, *args):
|
||||
return _sxtwl.JDList_resize(self, *args)
|
||||
|
||||
def insert(self, *args):
|
||||
return _sxtwl.JDList_insert(self, *args)
|
||||
|
||||
def reserve(self, n):
|
||||
return _sxtwl.JDList_reserve(self, n)
|
||||
|
||||
def capacity(self):
|
||||
return _sxtwl.JDList_capacity(self)
|
||||
__swig_destroy__ = _sxtwl.delete_JDList
|
||||
|
||||
# Register JDList in _sxtwl:
|
||||
_sxtwl.JDList_swigregister(JDList)
|
||||
class JQList(object):
|
||||
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
||||
__repr__ = _swig_repr
|
||||
|
||||
def iterator(self):
|
||||
return _sxtwl.JQList_iterator(self)
|
||||
def __iter__(self):
|
||||
return self.iterator()
|
||||
|
||||
def __nonzero__(self):
|
||||
return _sxtwl.JQList___nonzero__(self)
|
||||
|
||||
def __bool__(self):
|
||||
return _sxtwl.JQList___bool__(self)
|
||||
|
||||
def __len__(self):
|
||||
return _sxtwl.JQList___len__(self)
|
||||
|
||||
def __getslice__(self, i, j):
|
||||
return _sxtwl.JQList___getslice__(self, i, j)
|
||||
|
||||
def __setslice__(self, *args):
|
||||
return _sxtwl.JQList___setslice__(self, *args)
|
||||
|
||||
def __delslice__(self, i, j):
|
||||
return _sxtwl.JQList___delslice__(self, i, j)
|
||||
|
||||
def __delitem__(self, *args):
|
||||
return _sxtwl.JQList___delitem__(self, *args)
|
||||
|
||||
def __getitem__(self, *args):
|
||||
return _sxtwl.JQList___getitem__(self, *args)
|
||||
|
||||
def __setitem__(self, *args):
|
||||
return _sxtwl.JQList___setitem__(self, *args)
|
||||
|
||||
def pop(self):
|
||||
return _sxtwl.JQList_pop(self)
|
||||
|
||||
def append(self, x):
|
||||
return _sxtwl.JQList_append(self, x)
|
||||
|
||||
def empty(self):
|
||||
return _sxtwl.JQList_empty(self)
|
||||
|
||||
def size(self):
|
||||
return _sxtwl.JQList_size(self)
|
||||
|
||||
def swap(self, v):
|
||||
return _sxtwl.JQList_swap(self, v)
|
||||
|
||||
def begin(self):
|
||||
return _sxtwl.JQList_begin(self)
|
||||
|
||||
def end(self):
|
||||
return _sxtwl.JQList_end(self)
|
||||
|
||||
def rbegin(self):
|
||||
return _sxtwl.JQList_rbegin(self)
|
||||
|
||||
def rend(self):
|
||||
return _sxtwl.JQList_rend(self)
|
||||
|
||||
def clear(self):
|
||||
return _sxtwl.JQList_clear(self)
|
||||
|
||||
def get_allocator(self):
|
||||
return _sxtwl.JQList_get_allocator(self)
|
||||
|
||||
def pop_back(self):
|
||||
return _sxtwl.JQList_pop_back(self)
|
||||
|
||||
def erase(self, *args):
|
||||
return _sxtwl.JQList_erase(self, *args)
|
||||
|
||||
def __init__(self, *args):
|
||||
_sxtwl.JQList_swiginit(self, _sxtwl.new_JQList(*args))
|
||||
|
||||
def push_back(self, x):
|
||||
return _sxtwl.JQList_push_back(self, x)
|
||||
|
||||
def front(self):
|
||||
return _sxtwl.JQList_front(self)
|
||||
|
||||
def back(self):
|
||||
return _sxtwl.JQList_back(self)
|
||||
|
||||
def assign(self, n, x):
|
||||
return _sxtwl.JQList_assign(self, n, x)
|
||||
|
||||
def resize(self, *args):
|
||||
return _sxtwl.JQList_resize(self, *args)
|
||||
|
||||
def insert(self, *args):
|
||||
return _sxtwl.JQList_insert(self, *args)
|
||||
|
||||
def reserve(self, n):
|
||||
return _sxtwl.JQList_reserve(self, n)
|
||||
|
||||
def capacity(self):
|
||||
return _sxtwl.JQList_capacity(self)
|
||||
__swig_destroy__ = _sxtwl.delete_JQList
|
||||
|
||||
# Register JQList in _sxtwl:
|
||||
_sxtwl.JQList_swigregister(JQList)
|
||||
J2000 = _sxtwl.J2000
|
||||
class Time(object):
|
||||
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
||||
__repr__ = _swig_repr
|
||||
|
||||
def __init__(self, *args):
|
||||
_sxtwl.Time_swiginit(self, _sxtwl.new_Time(*args))
|
||||
Y = property(_sxtwl.Time_Y_get, _sxtwl.Time_Y_set)
|
||||
M = property(_sxtwl.Time_M_get, _sxtwl.Time_M_set)
|
||||
D = property(_sxtwl.Time_D_get, _sxtwl.Time_D_set)
|
||||
h = property(_sxtwl.Time_h_get, _sxtwl.Time_h_set)
|
||||
m = property(_sxtwl.Time_m_get, _sxtwl.Time_m_set)
|
||||
s = property(_sxtwl.Time_s_get, _sxtwl.Time_s_set)
|
||||
|
||||
def getYear(self):
|
||||
return _sxtwl.Time_getYear(self)
|
||||
|
||||
def setYear(self, year):
|
||||
return _sxtwl.Time_setYear(self, year)
|
||||
|
||||
def setMonth(self, month):
|
||||
return _sxtwl.Time_setMonth(self, month)
|
||||
|
||||
def getMonth(self):
|
||||
return _sxtwl.Time_getMonth(self)
|
||||
|
||||
def getDay(self):
|
||||
return _sxtwl.Time_getDay(self)
|
||||
|
||||
def setDay(self, day):
|
||||
return _sxtwl.Time_setDay(self, day)
|
||||
|
||||
def getHour(self):
|
||||
return _sxtwl.Time_getHour(self)
|
||||
|
||||
def setHour(self, hour):
|
||||
return _sxtwl.Time_setHour(self, hour)
|
||||
|
||||
def getMin(self):
|
||||
return _sxtwl.Time_getMin(self)
|
||||
|
||||
def setMour(self, min):
|
||||
return _sxtwl.Time_setMour(self, min)
|
||||
|
||||
def getSec(self):
|
||||
return _sxtwl.Time_getSec(self)
|
||||
|
||||
def setSec(self, sec):
|
||||
return _sxtwl.Time_setSec(self, sec)
|
||||
__swig_destroy__ = _sxtwl.delete_Time
|
||||
|
||||
# Register Time in _sxtwl:
|
||||
_sxtwl.Time_swigregister(Time)
|
||||
class GZ(object):
|
||||
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
||||
__repr__ = _swig_repr
|
||||
|
||||
def __init__(self, *args):
|
||||
_sxtwl.GZ_swiginit(self, _sxtwl.new_GZ(*args))
|
||||
tg = property(_sxtwl.GZ_tg_get, _sxtwl.GZ_tg_set)
|
||||
dz = property(_sxtwl.GZ_dz_get, _sxtwl.GZ_dz_set)
|
||||
__swig_destroy__ = _sxtwl.delete_GZ
|
||||
|
||||
# Register GZ in _sxtwl:
|
||||
_sxtwl.GZ_swigregister(GZ)
|
||||
class Day(object):
|
||||
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
raise AttributeError("No constructor defined")
|
||||
__repr__ = _swig_repr
|
||||
|
||||
@staticmethod
|
||||
def fromSolar(_year, _month, _day):
|
||||
return _sxtwl.Day_fromSolar(_year, _month, _day)
|
||||
|
||||
@staticmethod
|
||||
def fromLunar(year, month, day, isRun=False):
|
||||
return _sxtwl.Day_fromLunar(year, month, day, isRun)
|
||||
|
||||
def after(self, day):
|
||||
return _sxtwl.Day_after(self, day)
|
||||
|
||||
def before(self, day):
|
||||
return _sxtwl.Day_before(self, day)
|
||||
|
||||
def getLunarDay(self):
|
||||
return _sxtwl.Day_getLunarDay(self)
|
||||
|
||||
def getLunarMonth(self):
|
||||
return _sxtwl.Day_getLunarMonth(self)
|
||||
|
||||
def getLunarYear(self, chineseNewYearBoundary=True):
|
||||
return _sxtwl.Day_getLunarYear(self, chineseNewYearBoundary)
|
||||
|
||||
def getYearGZ(self, chineseNewYearBoundary=False):
|
||||
return _sxtwl.Day_getYearGZ(self, chineseNewYearBoundary)
|
||||
|
||||
def getMonthGZ(self):
|
||||
return _sxtwl.Day_getMonthGZ(self)
|
||||
|
||||
def getDayGZ(self):
|
||||
return _sxtwl.Day_getDayGZ(self)
|
||||
|
||||
def getHourGZ(self, hour, isZaoWanZiShi=True):
|
||||
return _sxtwl.Day_getHourGZ(self, hour, isZaoWanZiShi)
|
||||
|
||||
def isLunarLeap(self):
|
||||
return _sxtwl.Day_isLunarLeap(self)
|
||||
|
||||
def getSolarYear(self):
|
||||
return _sxtwl.Day_getSolarYear(self)
|
||||
|
||||
def getSolarMonth(self):
|
||||
return _sxtwl.Day_getSolarMonth(self)
|
||||
|
||||
def getSolarDay(self):
|
||||
return _sxtwl.Day_getSolarDay(self)
|
||||
|
||||
def getWeek(self):
|
||||
return _sxtwl.Day_getWeek(self)
|
||||
|
||||
def getWeekIndex(self):
|
||||
return _sxtwl.Day_getWeekIndex(self)
|
||||
|
||||
def hasJieQi(self):
|
||||
return _sxtwl.Day_hasJieQi(self)
|
||||
|
||||
def getJieQi(self):
|
||||
return _sxtwl.Day_getJieQi(self)
|
||||
|
||||
def getJieQiJD(self):
|
||||
return _sxtwl.Day_getJieQiJD(self)
|
||||
|
||||
def getConstellation(self):
|
||||
return _sxtwl.Day_getConstellation(self)
|
||||
__swig_destroy__ = _sxtwl.delete_Day
|
||||
|
||||
# Register Day in _sxtwl:
|
||||
_sxtwl.Day_swigregister(Day)
|
||||
class JieQiInfo(object):
|
||||
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
||||
__repr__ = _swig_repr
|
||||
jd = property(_sxtwl.JieQiInfo_jd_get, _sxtwl.JieQiInfo_jd_set)
|
||||
jqIndex = property(_sxtwl.JieQiInfo_jqIndex_get, _sxtwl.JieQiInfo_jqIndex_set)
|
||||
|
||||
def __init__(self):
|
||||
_sxtwl.JieQiInfo_swiginit(self, _sxtwl.new_JieQiInfo())
|
||||
__swig_destroy__ = _sxtwl.delete_JieQiInfo
|
||||
|
||||
# Register JieQiInfo in _sxtwl:
|
||||
_sxtwl.JieQiInfo_swigregister(JieQiInfo)
|
||||
|
||||
def fromSolar(year, month, day):
|
||||
return _sxtwl.fromSolar(year, month, day)
|
||||
|
||||
def fromLunar(year, month, day, isRun=False):
|
||||
return _sxtwl.fromLunar(year, month, day, isRun)
|
||||
|
||||
def siZhu2Year(year, yue, ri, shi, fromYear, toYear):
|
||||
return _sxtwl.siZhu2Year(year, yue, ri, shi, fromYear, toYear)
|
||||
|
||||
def getShiGz(dayTg, hour, isZaoWanZiShi=True):
|
||||
return _sxtwl.getShiGz(dayTg, hour, isZaoWanZiShi)
|
||||
|
||||
def getRunMonth(By):
|
||||
return _sxtwl.getRunMonth(By)
|
||||
|
||||
def getLunarMonthNum(By, month, isRun=False):
|
||||
return _sxtwl.getLunarMonthNum(By, month, isRun)
|
||||
|
||||
def JD2DD(jd):
|
||||
return _sxtwl.JD2DD(jd)
|
||||
|
||||
def toJD(time):
|
||||
return _sxtwl.toJD(time)
|
||||
|
||||
def getJieQiByYear(year):
|
||||
return _sxtwl.getJieQiByYear(year)
|
||||
|
13109
python/sxtwl_wrap.cxx
Normal file
13109
python/sxtwl_wrap.cxx
Normal file
File diff suppressed because it is too large
Load Diff
34
src/CMakeLists.txt
Normal file
34
src/CMakeLists.txt
Normal file
@ -0,0 +1,34 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
project(sxtwl)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
file(GLOB SRC_FILES "*.cpp" )
|
||||
|
||||
if(UNIX)
|
||||
add_compile_options(-fPIC)
|
||||
elseif(MSVC)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
add_library(sxtwl STATIC ${SRC_FILES})
|
||||
|
||||
# 安装库文件
|
||||
install(TARGETS sxtwl
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
)
|
||||
|
||||
# 安装头文件
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/const.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/day.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/eph.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/JD.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/SSQ.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sxtwl.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XL.h
|
||||
DESTINATION include
|
||||
)
|
89
src/JD.cpp
Normal file
89
src/JD.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
#include "JD.h"
|
||||
#include "const.h"
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
//https://github.com/guolisen/YiEngine/blob/2ce67dc91fd5fea8e394a5af60dc1e56c5044452/src/DateTime/JulianDay.cpp
|
||||
//公历转儒略日
|
||||
double JD::DD2JD(int y, uint8_t m, double d)
|
||||
{
|
||||
int n = 0, G = 0;
|
||||
//判断是否为格里高利历日1582*372+10*31+15
|
||||
if (y * 372 + m * 31 + (int)(d) >= 588829)
|
||||
{
|
||||
G = 1;
|
||||
}
|
||||
if (m <= 2)
|
||||
{
|
||||
m += 12, y--;
|
||||
}
|
||||
//加百年闰
|
||||
if (G)
|
||||
{
|
||||
n = int2(y / 100), n = 2 - n + int(n / 4);
|
||||
}
|
||||
|
||||
return int2(365.25*(y + 4716)) + int2(30.6001*(m + 1)) + d + n - 1524.5;
|
||||
|
||||
}
|
||||
|
||||
//儒略日数转公历
|
||||
Time JD::JD2DD(double jd)
|
||||
{
|
||||
Time r;
|
||||
int D = int2(jd + 0.5);
|
||||
float F = jd + 0.5 - D, c; //取得日数的整数部份A及小数部分F
|
||||
if (D >= 2299161)
|
||||
{
|
||||
c = int((D - 1867216.25) / 36524.25), D += 1 + c - int2(c / 4);
|
||||
}
|
||||
D += 1524; r.Y = int2((D - 122.1) / 365.25);//年数
|
||||
D -= int2(365.25*r.Y); r.M = int2(D / 30.601); //月数
|
||||
D -= int2(30.601*r.M); r.D = D; //日数
|
||||
if (r.M > 13)
|
||||
{
|
||||
r.M -= 13, r.Y -= 4715;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.M -= 1, r.Y -= 4716;
|
||||
}
|
||||
//日的小数转为时分秒
|
||||
F *= 24; r.h = int2(F); F -= r.h;
|
||||
F *= 60; r.m = int2(F); F -= r.m;
|
||||
F *= 60; r.s = F;
|
||||
return r;
|
||||
}
|
||||
|
||||
double JD::toJD(Time& time)
|
||||
{
|
||||
return JD::DD2JD(time.Y, time.M, time.D + ((time.s / 60 + time.m) / 60 + time.h) / 24);
|
||||
}
|
||||
|
||||
//提取jd中的时间(去除日期);
|
||||
std::string JD::timeStr(double jd)
|
||||
{
|
||||
int h, m, s;
|
||||
jd += 0.5; jd = (jd - int2(jd));
|
||||
s = int2(jd * 86400 + 0.5);
|
||||
h = int2(s / 3600); s -= h * 3600;
|
||||
m = int2(s / 60); s -= m * 60;
|
||||
std::string ret = "";
|
||||
char buff[11];
|
||||
memset(buff, 0, 11);
|
||||
std::snprintf(buff, sizeof(buff), "0%d", h);
|
||||
ret.append(buff + strlen(buff) - 2);
|
||||
ret += ":";
|
||||
|
||||
memset(buff, 0, 11);
|
||||
std::snprintf(buff, sizeof(buff), "0%d", m);
|
||||
ret.append(buff + strlen(buff) - 2);
|
||||
ret += ":";
|
||||
|
||||
memset(buff, 0, 11);
|
||||
std::snprintf(buff, sizeof(buff), "0%d", s);
|
||||
ret.append(buff + strlen(buff) - 2);
|
||||
|
||||
return ret;
|
||||
}
|
84
src/JD.h
Normal file
84
src/JD.h
Normal file
@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
struct Time
|
||||
{
|
||||
int Y, M, D;
|
||||
double h, m, s;
|
||||
Time(){};
|
||||
Time(int year, int month, int day, double hour, double min, double sec){
|
||||
this->Y = year; this->M = month; this->D = day;
|
||||
this->h = hour; this->m = min; this->s = sec;
|
||||
}
|
||||
|
||||
int getYear() {
|
||||
return Y;
|
||||
}
|
||||
|
||||
void setYear(int year) {
|
||||
Y = year;
|
||||
}
|
||||
|
||||
void setMonth(int month) {
|
||||
M = month;
|
||||
}
|
||||
|
||||
int getMonth() {
|
||||
return M;
|
||||
}
|
||||
|
||||
int getDay() {
|
||||
return D;
|
||||
}
|
||||
|
||||
void setDay(int day) {
|
||||
D = day;
|
||||
}
|
||||
|
||||
double getHour() {
|
||||
return h;
|
||||
}
|
||||
|
||||
void setHour(double hour) {
|
||||
h = hour;
|
||||
}
|
||||
|
||||
double getMin() {
|
||||
return m;
|
||||
}
|
||||
|
||||
void setMour(double min) {
|
||||
m = min;
|
||||
}
|
||||
|
||||
|
||||
double getSec() {
|
||||
return s;
|
||||
}
|
||||
|
||||
void setSec(double sec) {
|
||||
s = sec;
|
||||
}
|
||||
|
||||
std::string toStr() {
|
||||
std::stringstream ss;
|
||||
ss << getYear() << "-" << getMonth() << "-" << getDay() << ' '
|
||||
<< getHour() << ":" << getMin() << ":" << (int)getSec();
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class JD
|
||||
{
|
||||
public :
|
||||
//公历转儒略日
|
||||
static double DD2JD(int y, uint8_t m, double d);
|
||||
static Time JD2DD(double jd);
|
||||
|
||||
static double toJD(Time& time);
|
||||
static std::string timeStr( double jd);
|
||||
};
|
374
src/SSQ.cpp
Normal file
374
src/SSQ.cpp
Normal file
@ -0,0 +1,374 @@
|
||||
#include "SSQ.h"
|
||||
#include <math.h>
|
||||
#include "const.h"
|
||||
#include "eph.h"
|
||||
|
||||
SSQ::SSQ()
|
||||
{
|
||||
|
||||
std::string suoS = "", qiS = "";
|
||||
// 619-01-21开始16598个朔日修正表 d0=1947168
|
||||
suoS = "EqoFscDcrFpmEsF2DfFideFelFpFfFfFiaipqti1ksttikptikqckstekqttgkqttgkqteksttikptikq2fjstgjqttjkqttgkqt";
|
||||
suoS += "ekstfkptikq2tijstgjiFkirFsAeACoFsiDaDiADc1AFbBfgdfikijFifegF1FhaikgFag1E2btaieeibggiffdeigFfqDfaiBkF";
|
||||
suoS += "1kEaikhkigeidhhdiegcFfakF1ggkidbiaedksaFffckekidhhdhdikcikiakicjF1deedFhFccgicdekgiFbiaikcfi1kbFibef";
|
||||
suoS += "gEgFdcFkFeFkdcfkF1kfkcickEiFkDacFiEfbiaejcFfffkhkdgkaiei1ehigikhdFikfckF1dhhdikcfgjikhfjicjicgiehdik";
|
||||
suoS += "cikggcifgiejF1jkieFhegikggcikFegiegkfjebhigikggcikdgkaFkijcfkcikfkcifikiggkaeeigefkcdfcfkhkdgkegieid";
|
||||
suoS += "hijcFfakhfgeidieidiegikhfkfckfcjbdehdikggikgkfkicjicjF1dbidikFiggcifgiejkiegkigcdiegfggcikdbgfgefjF1";
|
||||
suoS += "kfegikggcikdgFkeeijcfkcikfkekcikdgkabhkFikaffcfkhkdgkegbiaekfkiakicjhfgqdq2fkiakgkfkhfkfcjiekgFebicg";
|
||||
suoS += "gbedF1jikejbbbiakgbgkacgiejkijjgigfiakggfggcibFifjefjF1kfekdgjcibFeFkijcfkfhkfkeaieigekgbhkfikidfcje";
|
||||
suoS += "aibgekgdkiffiffkiakF1jhbakgdki1dj1ikfkicjicjieeFkgdkicggkighdF1jfgkgfgbdkicggfggkidFkiekgijkeigfiski";
|
||||
suoS += "ggfaidheigF1jekijcikickiggkidhhdbgcfkFikikhkigeidieFikggikhkffaffijhidhhakgdkhkijF1kiakF1kfheakgdkif";
|
||||
suoS += "iggkigicjiejkieedikgdfcggkigieeiejfgkgkigbgikicggkiaideeijkefjeijikhkiggkiaidheigcikaikffikijgkiahi1";
|
||||
suoS += "hhdikgjfifaakekighie1hiaikggikhkffakicjhiahaikggikhkijF1kfejfeFhidikggiffiggkigicjiekgieeigikggiffig";
|
||||
suoS += "gkidheigkgfjkeigiegikifiggkidhedeijcfkFikikhkiggkidhh1ehigcikaffkhkiggkidhh1hhigikekfiFkFikcidhh1hit";
|
||||
suoS += "cikggikhkfkicjicghiediaikggikhkijbjfejfeFhaikggifikiggkigiejkikgkgieeigikggiffiggkigieeigekijcijikgg";
|
||||
suoS += "ifikiggkideedeijkefkfckikhkiggkidhh1ehijcikaffkhkiggkidhh1hhigikhkikFikfckcidhh1hiaikgjikhfjicjicgie";
|
||||
suoS += "hdikcikggifikigiejfejkieFhegikggifikiggfghigkfjeijkhigikggifikiggkigieeijcijcikfksikifikiggkidehdeij";
|
||||
suoS += "cfdckikhkiggkhghh1ehijikifffffkhsFngErD1pAfBoDd1BlEtFqA2AqoEpDqElAEsEeB2BmADlDkqBtC1FnEpDqnEmFsFsAFn";
|
||||
suoS += "llBbFmDsDiCtDmAB2BmtCgpEplCpAEiBiEoFqFtEqsDcCnFtADnFlEgdkEgmEtEsCtDmADqFtAFrAtEcCqAE1BoFqC1F1DrFtBmF";
|
||||
suoS += "tAC2ACnFaoCgADcADcCcFfoFtDlAFgmFqBq2bpEoAEmkqnEeCtAE1bAEqgDfFfCrgEcBrACfAAABqAAB1AAClEnFeCtCgAADqDoB";
|
||||
suoS += "mtAAACbFiAAADsEtBqAB2FsDqpFqEmFsCeDtFlCeDtoEpClEqAAFrAFoCgFmFsFqEnAEcCqFeCtFtEnAEeFtAAEkFnErAABbFkAD";
|
||||
suoS += "nAAeCtFeAfBoAEpFtAABtFqAApDcCGJ";
|
||||
|
||||
//1645-09-23开始7567个节气修正表
|
||||
qiS = "FrcFs22AFsckF2tsDtFqEtF1posFdFgiFseFtmelpsEfhkF2anmelpFlF1ikrotcnEqEq2FfqmcDsrFor22FgFrcgDscFs22FgEe";
|
||||
qiS += "FtE2sfFs22sCoEsaF2tsD1FpeE2eFsssEciFsFnmelpFcFhkF2tcnEqEpFgkrotcnEqrEtFermcDsrE222FgBmcmr22DaEfnaF22";
|
||||
qiS += "2sD1FpeForeF2tssEfiFpEoeFssD1iFstEqFppDgFstcnEqEpFg11FscnEqrAoAF2ClAEsDmDtCtBaDlAFbAEpAAAAAD2FgBiBqo";
|
||||
qiS += "BbnBaBoAAAAAAAEgDqAdBqAFrBaBoACdAAf1AACgAAAeBbCamDgEifAE2AABa1C1BgFdiAAACoCeE1ADiEifDaAEqAAFe1AcFbcA";
|
||||
qiS += "AAAAF1iFaAAACpACmFmAAAAAAAACrDaAAADG0";
|
||||
|
||||
|
||||
|
||||
SB = jieya(suoS); //定朔修正表解压
|
||||
QB = jieya(qiS); //定气修正表解压
|
||||
|
||||
|
||||
//朔直线拟合参数
|
||||
long double suoKBTmp[] = {
|
||||
1457698.231017,29.53067166, // -721-12-17 h=0.00032 古历·春秋
|
||||
1546082.512234,29.53085106, // -479-12-11 h=0.00053 古历·战国
|
||||
1640640.735300,29.53060000, // -221-10-31 h=0.01010 古历·秦汉
|
||||
1642472.151543,29.53085439, // -216-11-04 h=0.00040 古历·秦汉
|
||||
|
||||
1683430.509300,29.53086148, // -104-12-25 h=0.00313 汉书·律历志(太初历)平气平朔
|
||||
1752148.041079,29.53085097, // 85-02-13 h=0.00049 后汉书·律历志(四分历)
|
||||
1807665.420323,29.53059851, // 237-02-12 h=0.00033 晋书·律历志(景初历)
|
||||
1883618.114100,29.53060000, // 445-01-24 h=0.00030 宋书·律历志(何承天元嘉历)
|
||||
1907360.704700,29.53060000, // 510-01-26 h=0.00030 宋书·律历志(祖冲之大明历)
|
||||
1936596.224900,29.53060000, // 590-02-10 h=0.01010 随书·律历志(开皇历)
|
||||
1939135.675300,29.53060000, // 597-01-24 h=0.00890 随书·律历志(大业历)
|
||||
1947168.00// 619-01-21
|
||||
};
|
||||
|
||||
suoKB = new std::vector<long double>(suoKBTmp, suoKBTmp + sizeof(suoKBTmp) / sizeof(long double));
|
||||
|
||||
long double qiKBTmp[] = {
|
||||
1640650.479938,15.21842500, // -221-11-09 h=0.01709 古历·秦汉
|
||||
1642476.703182,15.21874996, // -216-11-09 h=0.01557 古历·秦汉
|
||||
|
||||
1683430.515601,15.218750011, // -104-12-25 h=0.01560 汉书·律历志(太初历)平气平朔 回归年=365.25000
|
||||
1752157.640664,15.218749978, // 85-02-23 h=0.01559 后汉书·律历志(四分历) 回归年=365.25000
|
||||
1807675.003759,15.218620279, // 237-02-22 h=0.00010 晋书·律历志(景初历) 回归年=365.24689
|
||||
1883627.765182,15.218612292, // 445-02-03 h=0.00026 宋书·律历志(何承天元嘉历) 回归年=365.24670
|
||||
1907369.128100,15.218449176, // 510-02-03 h=0.00027 宋书·律历志(祖冲之大明历) 回归年=365.24278
|
||||
1936603.140413,15.218425000, // 590-02-17 h=0.00149 随书·律历志(开皇历) 回归年=365.24220
|
||||
1939145.524180,15.218466998, // 597-02-03 h=0.00121 随书·律历志(大业历) 回归年=365.24321
|
||||
1947180.798300,15.218524844, // 619-02-03 h=0.00052 新唐书·历志(戊寅元历)平气定朔 回归年=365.24460
|
||||
1964362.041824,15.218533526, // 666-02-17 h=0.00059 新唐书·历志(麟德历) 回归年=365.24480
|
||||
1987372.340971,15.218513908, // 729-02-16 h=0.00096 新唐书·历志(大衍历,至德历) 回归年=365.24433
|
||||
1999653.819126,15.218530782, // 762-10-03 h=0.00093 新唐书·历志(五纪历) 回归年=365.24474
|
||||
2007445.469786,15.218535181, // 784-02-01 h=0.00059 新唐书·历志(正元历,观象历) 回归年=365.24484
|
||||
2021324.917146,15.218526248, // 822-02-01 h=0.00022 新唐书·历志(宣明历) 回归年=365.24463
|
||||
2047257.232342,15.218519654, // 893-01-31 h=0.00015 新唐书·历志(崇玄历) 回归年=365.24447
|
||||
2070282.898213,15.218425000, // 956-02-16 h=0.00149 旧五代·历志(钦天历) 回归年=365.24220
|
||||
2073204.872850,15.218515221, // 964-02-16 h=0.00166 宋史·律历志(应天历) 回归年=365.24437
|
||||
2080144.500926,15.218530782, // 983-02-16 h=0.00093 宋史·律历志(乾元历) 回归年=365.24474
|
||||
2086703.688963,15.218523776, // 1001-01-31 h=0.00067 宋史·律历志(仪天历,崇天历) 回归年=365.24457
|
||||
2110033.182763,15.218425000, // 1064-12-15 h=0.00669 宋史·律历志(明天历) 回归年=365.24220
|
||||
2111190.300888,15.218425000, // 1068-02-15 h=0.00149 宋史·律历志(崇天历) 回归年=365.24220
|
||||
2113731.271005,15.218515671, // 1075-01-30 h=0.00038 李锐补修(奉元历) 回归年=365.24438
|
||||
2120670.840263,15.218425000, // 1094-01-30 h=0.00149 宋史·律历志 回归年=365.24220
|
||||
2123973.309063,15.218425000, // 1103-02-14 h=0.00669 李锐补修(占天历) 回归年=365.24220
|
||||
2125068.997336,15.218477932, // 1106-02-14 h=0.00056 宋史·律历志(纪元历) 回归年=365.24347
|
||||
2136026.312633,15.218472436, // 1136-02-14 h=0.00088 宋史·律历志(统元历,乾道历,淳熙历) 回归年=365.24334
|
||||
2156099.495538,15.218425000, // 1191-01-29 h=0.00149 宋史·律历志(会元历) 回归年=365.24220
|
||||
2159021.324663,15.218425000, // 1199-01-29 h=0.00149 宋史·律历志(统天历) 回归年=365.24220
|
||||
2162308.575254,15.218461742, // 1208-01-30 h=0.00146 宋史·律历志(开禧历) 回归年=365.24308
|
||||
2178485.706538,15.218425000, // 1252-05-15 h=0.04606 淳祐历 回归年=365.24220
|
||||
2178759.662849,15.218445786, // 1253-02-13 h=0.00231 会天历 回归年=365.24270
|
||||
2185334.020800,15.218425000, // 1271-02-13 h=0.00520 宋史·律历志(成天历) 回归年=365.24220
|
||||
2187525.481425,15.218425000, // 1277-02-12 h=0.00520 本天历 回归年=365.24220
|
||||
2188621.191481,15.218437494, // 1280-02-13 h=0.00015 元史·历志(郭守敬授时历) 回归年=365.24250
|
||||
2322147.76// 1645-09-21
|
||||
};
|
||||
|
||||
qiKB = new std::vector<long double>(qiKBTmp, qiKBTmp + sizeof(qiKBTmp) / sizeof(long double));
|
||||
}
|
||||
|
||||
SSQ::~SSQ()
|
||||
{
|
||||
delete suoKB;
|
||||
delete qiKB;
|
||||
}
|
||||
|
||||
void str_replace(std::string & str, const std::string strsrc, const std::string strdst)
|
||||
{
|
||||
std::string::size_type pos = 0;//位置
|
||||
std::string::size_type srclen = strsrc.size();//要替换的字符串大小
|
||||
std::string::size_type dstlen = strdst.size();//目标字符串大小
|
||||
while ((pos = str.find(strsrc, pos)) != std::string::npos)
|
||||
{
|
||||
str.replace(pos, srclen, strdst);
|
||||
pos += dstlen;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string SSQ::jieya(std::string s) { //气朔解压缩
|
||||
std::string o = "0000000000", o2 = o + o;
|
||||
str_replace(s, "J", "00");
|
||||
str_replace(s, "I", "000");
|
||||
str_replace(s, "H", "0000");
|
||||
str_replace(s, "G", "00000");
|
||||
str_replace(s, "t", "02");
|
||||
str_replace(s, "s", "002");
|
||||
str_replace(s, "r", "0002");
|
||||
str_replace(s, "q", "00002");
|
||||
str_replace(s, "p", "000002");
|
||||
str_replace(s, "o", "0000002");
|
||||
str_replace(s, "n", "00000002");
|
||||
str_replace(s, "m", "000000002");
|
||||
str_replace(s, "l", "0000000002");
|
||||
str_replace(s, "k", "01");
|
||||
str_replace(s, "j", "0101");
|
||||
str_replace(s, "i", "001");
|
||||
str_replace(s, "h", "001001");
|
||||
str_replace(s, "g", "0001");
|
||||
str_replace(s, "f", "00001");
|
||||
str_replace(s, "e", "000001");
|
||||
str_replace(s, "d", "0000001");
|
||||
str_replace(s, "c", "00000001");
|
||||
str_replace(s, "b", "000000001");
|
||||
str_replace(s, "a", "0000000001");
|
||||
str_replace(s, "A", o2 + o2 + o2);
|
||||
str_replace(s, "B", o2 + o2 + o);
|
||||
str_replace(s, "C", o2 + o2);
|
||||
str_replace(s, "D", o2 + o);
|
||||
str_replace(s, "E", o2);
|
||||
str_replace(s, "F", o);
|
||||
return s;
|
||||
}
|
||||
|
||||
int SSQ::calc(long double jd, QSType qs)
|
||||
{
|
||||
jd += 2451545;
|
||||
int i;
|
||||
long double D;
|
||||
std::string n;
|
||||
std::vector<long double> B = *suoKB;
|
||||
long double pc = 14;
|
||||
//如果查的是气朔
|
||||
if (qs == QType)
|
||||
{
|
||||
B = *qiKB, pc = 7;
|
||||
}
|
||||
|
||||
long double f1 = B[0] - pc, f2 = B[B.size() - 1] - pc, f3 = 2436935;
|
||||
|
||||
if (jd < f1 || jd >= f3)
|
||||
{
|
||||
//平气朔表中首个之前,使用现代天文算法。1960.1.1以后,使用现代天文算法 (这一部分调用了qi_high和so_high,所以需星历表支持)
|
||||
if (qs == QType)
|
||||
{
|
||||
return floor(qi_high(floor((jd + pc - 2451259) / 365.2422 * 24) * PI / 12) + 0.5); //2451259是1999.3.21,太阳视黄经为0,春分.定气计算
|
||||
}
|
||||
else
|
||||
{
|
||||
return floor(so_high(floor((jd + pc - 2451551) / 29.5306) * PI * 2) + 0.5); //2451551是2000.1.7的那个朔日,黄经差为0.定朔计算
|
||||
}
|
||||
}
|
||||
|
||||
if (jd >= f1 && jd < f2) { //平气或平朔
|
||||
for (i = 0; i < B.size(); i += 2) if (jd + pc < B[i + 2]) break;
|
||||
D = B[i] + B[i + 1] * floor((jd + pc - B[i]) / B[i + 1]);
|
||||
D = floor(D + 0.5);
|
||||
if (D == 1683460) D++; //如果使用太初历计算-103年1月24日的朔日,结果得到的是23日,这里修正为24日(实历)。修正后仍不影响-103的无中置闰。如果使用秦汉历,得到的是24日,本行D不会被执行。
|
||||
return D - 2451545;
|
||||
}
|
||||
|
||||
if (jd >= f2 && jd < f3) { //定气或定朔
|
||||
if (qs == QType) {
|
||||
D = floor(qi_low(floor((jd + pc - 2451259) / 365.2422 * 24) * PI / 12) + 0.5); //2451259是1999.3.21,太阳视黄经为0,春分.定气计算
|
||||
n = QB.substr(floor((jd - f2) / 365.2422 * 24), 1); //找定气修正值
|
||||
}
|
||||
else {
|
||||
D = floor(so_low(floor((jd + pc - 2451551) / 29.5306) * PI * 2) + 0.5); //2451551是2000.1.7的那个朔日,黄经差为0.定朔计算
|
||||
n = SB.substr(floor((jd - f2) / 29.5306), 1); //找定朔修正值
|
||||
}
|
||||
if (n == "1") return D + 1;
|
||||
if (n == "2") return D - 1;
|
||||
return D;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
long double SSQ::qi_high(long double W)
|
||||
{
|
||||
long double t = XL::S_aLon_t2(W) * 36525;
|
||||
t = t - dt_T(t) + 8.0 / 24.0;
|
||||
long double v = fmod(t + 0.5, 1) * 86400;
|
||||
if (v < 1200 || v >86400 - 1200) t = XL::S_aLon_t(W) * 36525 - dt_T(t) + 8.0 / 24.0;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
long double SSQ::so_high(long double W)
|
||||
{ //较高精度朔
|
||||
long double t = XL::MS_aLon_t2(W) * 36525;
|
||||
t = t - dt_T(t) + 8.0 / 24.0;
|
||||
long double v = fmod(t + 0.5, 1) * 86400;
|
||||
if (v < 1800 || v >86400 - 1800) t = XL::MS_aLon_t(W) * 36525 - dt_T(t) + 8.0 / 24.0;
|
||||
return t;
|
||||
}
|
||||
|
||||
long double SSQ::so_low(long double W) { //低精度定朔计算,在2000年至600,误差在2小时以内(仍比古代日历精准很多)
|
||||
long double v = 7771.37714500204;
|
||||
long double t = (W + 1.08472) / v, L;
|
||||
t -= (-0.0000331*t*t
|
||||
+ 0.10976 *cos(0.785 + 8328.6914*t)
|
||||
+ 0.02224 *cos(0.187 + 7214.0629*t)
|
||||
- 0.03342 *cos(4.669 + 628.3076*t)) / v
|
||||
+ (32 * (t + 1.8)*(t + 1.8) - 20) / 86400 / 36525;
|
||||
return t * 36525 + 8.0 / 24.0;
|
||||
}
|
||||
|
||||
long double SSQ::qi_low(long double W) { //最大误差小于30分钟,平均5分
|
||||
long double t, L, v = 628.3319653318;
|
||||
t = (W - 4.895062166) / v; //第一次估算,误差2天以内
|
||||
t -= (53 * t*t + 334116 * cos(4.67 + 628.307585*t) + 2061 * cos(2.678 + 628.3076*t)*t) / v / 10000000; //第二次估算,误差2小时以内
|
||||
|
||||
L = 48950621.66 + 6283319653.318*t + 53 * t*t //平黄经
|
||||
+ 334166 * cos(4.669257 + 628.307585*t) //地球椭圆轨道级数展开
|
||||
+ 3489 * cos(4.6261 + 1256.61517*t) //地球椭圆轨道级数展开
|
||||
+ 2060.6 * cos(2.67823 + 628.307585*t) * t //一次泊松项
|
||||
- 994 - 834 * sin(2.1824 - 33.75705*t); //光行差与章动修正
|
||||
|
||||
t -= (L / 10000000 - W) / 628.332 + (32 * (t + 1.8)*(t + 1.8) - 20) / 86400 / 36525;
|
||||
return t * 36525 + 8.0 / 24.0;
|
||||
}
|
||||
|
||||
|
||||
//农历排月序计算,可定出农历,有效范围:两个冬至之间(冬至一 <= d < 冬至二)
|
||||
void SSQ::calcY(int jd) {
|
||||
std::vector<long double>& A = ZQ;
|
||||
std::vector<int>& B = HS; //中气表,日月合朔表(整日)
|
||||
int i, k;
|
||||
long double W, w;
|
||||
|
||||
//该年的气
|
||||
|
||||
W = int2((jd - 355 + 183) / 365.2422)*365.2422 + 355; //355是2000.12冬至,得到较靠近jd的冬至估计值
|
||||
if (calc(W, QType) > jd)
|
||||
{
|
||||
W -= 365.2422;
|
||||
}
|
||||
|
||||
//25个节气时刻(北京时间),从冬至开始到下一个冬至以后;
|
||||
A.clear();
|
||||
for (i = 0; i < 25; i++)
|
||||
{
|
||||
int t = calc(W + 15.2184*i, QType);
|
||||
A.push_back(t);
|
||||
}
|
||||
|
||||
ZQ_pe1 = calc(W - 15.2, QType); ZQ_pe2 = calc(W - 30.4, QType); //补算二气,确保一年中所有月份的“气”全部被计算在内
|
||||
//今年"首朔"的日月黄经差w
|
||||
w = calc(A[0], SType); //求较靠近冬至的朔日
|
||||
if (w > A[0])
|
||||
{
|
||||
w -= 29.53;
|
||||
}
|
||||
|
||||
//该年所有朔,包含14个月的始末
|
||||
B.clear();
|
||||
for (i = 0; i < 15; i++)
|
||||
{
|
||||
B.push_back( calc(w + 29.5306*i, SType) );
|
||||
}
|
||||
|
||||
|
||||
//月大小
|
||||
leap = 0;
|
||||
dx.clear();
|
||||
ym.clear();
|
||||
for (i = 0; i < 14; i++) {
|
||||
dx.push_back( HS[i + 1] - HS[i] ); //月大小
|
||||
ym.push_back(i); //月序初始化
|
||||
}
|
||||
|
||||
|
||||
//-721年至-104年的后九月及月建问题,与朔有关,与气无关
|
||||
int YY = int2((ZQ[0] + 10 + 180) / 365.2422) + 2000; //确定年份
|
||||
if (YY >= -721 && YY <= -104) {
|
||||
int ns[12];
|
||||
int yy;
|
||||
for (i = 0; i < 3; i++) {
|
||||
yy = YY + i - 1;
|
||||
//颁行历年首, 闰月名称, 月建
|
||||
if (yy >= -721)
|
||||
{
|
||||
ns[i] = calc(1457698 - J2000 + int2(0.342 + (yy + 721)*12.368422)*29.5306, SType);
|
||||
//ns[i + 3] = '十三';
|
||||
ns[i + 6] = 2; //春秋历,ly为-722.12.17
|
||||
}
|
||||
|
||||
if (yy >= -479)
|
||||
{
|
||||
|
||||
ns[i] = calc(1546083 - J2000 + int2(0.500 + (yy + 479)*12.368422)*29.5306, SType);
|
||||
//ns[i + 3] = '十三';
|
||||
ns[i + 6] = 2; //战国历,ly为-480.12.11
|
||||
}
|
||||
if (yy >= -220) {
|
||||
ns[i] = calc(1640641 - J2000 + int2(0.866 + (yy + 220)*12.369000)*29.5306, SType);
|
||||
// ns[i + 3] = '后九';
|
||||
ns[i + 6] = 11; //秦汉历,ly为-221.10.31
|
||||
}
|
||||
}
|
||||
|
||||
int nn, f1;
|
||||
for (i = 0; i < 14; i++) {
|
||||
for (nn = 2; nn >= 0; nn--) if (HS[i] >= ns[nn]) break;
|
||||
f1 = int2((HS[i] - ns[nn] + 15) / 29.5306); //该月积数
|
||||
if (f1 < 12) ym[i] = (f1 + ns[nn + 6]) % 12; else ym[i] = ns[nn + 3];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//无中气置闰法确定闰月,(气朔结合法,数据源需有冬至开始的的气和朔)
|
||||
if (B[13] <= A[24]) { //第13月的月末没有超过冬至(不含冬至),说明今年含有13个月
|
||||
for (i = 1; B[i + 1] > A[2 * i] && i < 13; i++); //在13个月中找第1个没有中气的月份
|
||||
leap = i;
|
||||
for (; i < 14; i++) ym[i]--;
|
||||
}
|
||||
|
||||
//名称转换(月建别名)
|
||||
for (i = 0; i < 14; i++) {
|
||||
int Dm = HS[i] + J2000, v2 = ym[i]; //Dm初一的儒略日,v2为月建序号
|
||||
int mc = v2 % 12; //月建对应的默认月名称:建子十一,建丑十二,建寅为正……
|
||||
if (Dm >= 1724360 && Dm <= 1729794) mc = (v2 + 1) % 12; // 8.01.15至 23.12.02 建子为十二,其它顺推
|
||||
else if (Dm >= 1807724 && Dm <= 1808699) mc = (v2 + 1) % 12; //237.04.12至239.12.13 建子为十二,其它顺推
|
||||
else if (Dm >= 1999349 && Dm <= 1999467) mc = (v2 + 2) % 12; //761.12.02至762.03.30 建子为正月,其它顺推
|
||||
else if (Dm >= 1973067 && Dm <= 1977052) { if (v2 % 12 == 0) mc = 2; if (v2 == 2) mc = 2; } //689.12.18至700.11.15 建子为正月,建寅为一月,其它不变
|
||||
|
||||
if (Dm == 1729794 || Dm == 1808699)
|
||||
{
|
||||
mc = 12;
|
||||
// mc = '拾贰'; //239.12.13及23.12.02均为十二月,为避免两个连续十二月,此处改名
|
||||
}
|
||||
ym[i] = mc;
|
||||
}
|
||||
}
|
||||
|
38
src/SSQ.h
Normal file
38
src/SSQ.h
Normal file
@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
typedef enum
|
||||
{
|
||||
QType, //气
|
||||
SType //朔
|
||||
} QSType;
|
||||
|
||||
class SSQ
|
||||
{
|
||||
public:
|
||||
SSQ();
|
||||
~SSQ();
|
||||
int calc(long double jd, QSType type);
|
||||
//较高精度气;
|
||||
long double qi_high(long double);
|
||||
//较高精度朔
|
||||
long double so_high(long double);
|
||||
long double so_low(long double W);
|
||||
long double qi_low(long double W);
|
||||
|
||||
void calcY(int jd);
|
||||
|
||||
std::string jieya(std::string s);
|
||||
|
||||
std::vector<long double>* suoKB;
|
||||
std::vector<long double>* qiKB;
|
||||
|
||||
|
||||
std::vector<long double> ZQ;
|
||||
long double ZQ_pe1, ZQ_pe2;
|
||||
std::vector<int> HS;
|
||||
std::vector<int> ym;
|
||||
std::vector<int> dx;
|
||||
int leap;
|
||||
std::string SB, QB;
|
||||
};
|
75
src/XL.cpp
Normal file
75
src/XL.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
//#include "XL.h"
|
||||
//#include "const.h"
|
||||
//#include <math.h>
|
||||
//
|
||||
//long double XL::S_aLon_t(long double W)
|
||||
//{
|
||||
// long double t, v = 628.3319653318;
|
||||
// t = (W - 1.75347 - PI) / v; v = E_v(t); //v的精度0.03%,详见原文
|
||||
// t += (W - S_aLon(t, 10)) / v; v = E_v(t); //再算一次v有助于提高精度,不算也可以
|
||||
// t += (W - S_aLon(t, -1)) / v;
|
||||
// return t;
|
||||
//}
|
||||
//
|
||||
////地球速度,t是世纪数,误差小于万分3
|
||||
//long double XL::E_v(long double t)
|
||||
//{
|
||||
// long double f = 628.307585*t;
|
||||
// return 628.332 + 21 * sin(1.527 + f) + 0.44 * sin(1.48 + f * 2)
|
||||
// + 0.129*sin(5.82 + f)*t + 0.00055*sin(4.21 + f)*t*t;
|
||||
//}
|
||||
//
|
||||
////太阳视黄经
|
||||
//long double XL::S_aLon(long double t, long double n) {
|
||||
// return E_Lon(t, n) + nutationLon2(t) + gxc_sunLon(t) + PI; //注意,这里的章动计算很耗时
|
||||
//};
|
||||
//
|
||||
//long double XL::E_Lon(long double t, long double n)
|
||||
//{
|
||||
// return XL0_calc(0, 0, t, n);
|
||||
//}
|
||||
//
|
||||
//long double XL::XL0_calc(long double xt, int zn, long double t, int n)
|
||||
//{
|
||||
// static long double XL0_xzb[] = { //行星星历修正表
|
||||
// //经(角秒),纬(角秒), 距(10-6AU)
|
||||
// -0.08631, +0.00039, -0.00008, //水星
|
||||
// -0.07447, +0.00006, +0.00017, //金星
|
||||
// -0.07135, -0.00026, -0.00176, //火星
|
||||
// -0.20239, +0.00273, -0.00347, //木星
|
||||
// -0.25486, +0.00276, +0.42926, //土星
|
||||
// +0.24588, +0.00345, -14.46266, //天王星
|
||||
// -0.95116, +0.02481, +58.30651 //海王星
|
||||
// };
|
||||
//
|
||||
// t /= 10; //转为儒略千年数
|
||||
// int i, j, v = 0, tn = 1, c;
|
||||
// long double F = XL0[xt], n1, n2, N;
|
||||
// var n0, pn = zn * 6 + 1, N0 = F[pn + 1] - F[pn]; //N0序列总数
|
||||
// for (i = 0; i < 6; i++, tn *= t) {
|
||||
// n1 = F[pn + i], n2 = F[pn + 1 + i], n0 = n2 - n1;
|
||||
// if (!n0) continue;
|
||||
// if (n < 0) N = n2; //确定项数
|
||||
// else { N = int2(3 * n*n0 / N0 + 0.5) + n1; if (i) N += 3; if (N > n2) N = n2; }
|
||||
// for (j = n1, c = 0; j < N; j += 3) c += F[j] * Math.cos(F[j + 1] + t*F[j + 2]);
|
||||
// v += c*tn;
|
||||
// }
|
||||
// v /= F[0];
|
||||
// if (xt == 0) { //地球
|
||||
// var t2 = t*t, t3 = t2*t; //千年数的各次方
|
||||
// if (zn == 0) v += (-0.0728 - 2.7702*t - 1.1019*t2 - 0.0996*t3) / rad;
|
||||
// if (zn == 1) v += (+0.0000 + 0.0004*t + 0.0004*t2 - 0.0026*t3) / rad;
|
||||
// if (zn == 2) v += (-0.0020 + 0.0044*t + 0.0213*t2 - 0.0250*t3) / 1000000;
|
||||
// }
|
||||
// else { //其它行星
|
||||
// var dv = XL0_xzb[(xt - 1) * 3 + zn];
|
||||
// if (zn == 0) v += -3 * t / rad;
|
||||
// if (zn == 2) v += dv / 1000000;
|
||||
// else v += dv / rad;
|
||||
// }
|
||||
// return v;
|
||||
//}
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
22
src/XL.h
Normal file
22
src/XL.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
class XL
|
||||
{
|
||||
public:
|
||||
//已知太阳视黄经反求时间
|
||||
static long double S_aLon_t(long double W);
|
||||
|
||||
//地球速度,t是世纪数,误差小于万分3
|
||||
static long double E_v(long double t);
|
||||
|
||||
//太阳视黄经
|
||||
static long double S_aLon(long double t, long double n);
|
||||
|
||||
//地球经度计算,返回Date分点黄经,传入世纪数、取项数
|
||||
static long double E_Lon(long double t, long double n);
|
||||
|
||||
//xt星体,zn坐标号,t儒略世纪数,n计算项数
|
||||
static long double XL0_calc(long double xt, int zn, long double t, int n);
|
||||
|
||||
|
||||
};
|
46
src/const.h
Normal file
46
src/const.h
Normal file
@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
#include <math.h>
|
||||
|
||||
//PI
|
||||
#define PI (3.141592653589793)
|
||||
|
||||
//地球赤道半径(千米)
|
||||
#define cs_rEar (6378.1366)
|
||||
//平均半径
|
||||
#define cs_rEarA (0.99834*cs_rEar)
|
||||
//地球极赤半径比
|
||||
#define cs_ba (0.99664719)
|
||||
//地球极赤半径比的平方
|
||||
#define cs_ba2 (cs_ba*cs_ba)
|
||||
//天文单位长度(千米)
|
||||
#define cs_AU (1.49597870691e8)
|
||||
//sin(太阳视差)
|
||||
#define cs_sinP (cs_rEar / cs_AU)
|
||||
//太阳视差
|
||||
#define cs_PI ( Math.asin(cs_sinP))
|
||||
//光速(行米/秒)
|
||||
#define cs_GS ( 299792.458)
|
||||
//每天文单位的光行时间(儒略世纪)
|
||||
#define cs_Agx ( cs_AU / cs_GS / 86400 / 36525)
|
||||
//#define cs_xxHH ( new Array(116, 584, 780, 399, 378, 370, 367, 367)) //行星会合周期
|
||||
//#define xxName ( new Array('地球', '水星', '金星', '火星', '木星', '土星', '天王星', '海王星', '冥王星'))
|
||||
//每弧度的角秒数
|
||||
#define rad ( 180 * 3600 / PI)
|
||||
//每弧度的度数
|
||||
#define radd ( 180 / PI)
|
||||
#define pi2 ( PI * 2)
|
||||
#define pi_2 ( PI / 2)
|
||||
#define J2000 ( 2451545)
|
||||
//
|
||||
#define cs_k ( 0.2725076) //月亮与地球的半径比(用于半影计算)
|
||||
#define cs_k2 ( 0.2722810) //月亮与地球的半径比(用于本影计算)
|
||||
#define cs_k0 ( 109.1222) //太阳与地球的半径比(对应959.64)
|
||||
#define cs_sMoon ( cs_k*cs_rEar*1.0000036*rad) //用于月亮视半径计算
|
||||
#define cs_sMoon2 ( cs_k2*cs_rEar*1.0000036*rad) //用于月亮视半径计算
|
||||
#define cs_sSun ( 959.64) //用于太阳视半径计算
|
||||
|
||||
//转整型
|
||||
//#define int2(v) ((v)>=0?(int)(v):((int)(v)-1))
|
||||
#define int2(v) ((int)floor(v))
|
||||
//求余
|
||||
#define fmod2(v, n) ((v%n + n) % n)
|
330
src/day.cpp
Normal file
330
src/day.cpp
Normal file
@ -0,0 +1,330 @@
|
||||
#include "day.h"
|
||||
#include "eph.h"
|
||||
#include "JD.h"
|
||||
|
||||
namespace sxtwl
|
||||
{
|
||||
GZ getShiGz(uint8_t dayTg, uint8_t hour, bool isZaoWanZiShi = true);
|
||||
};
|
||||
|
||||
void Day::checkSSQ()
|
||||
{
|
||||
if (!SSQPtr->ZQ.size() || this->d0 < SSQPtr->ZQ[0] || this->d0 >= SSQPtr->ZQ[24])
|
||||
{
|
||||
SSQPtr->calcY(this->d0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定已经计算过阴历信息
|
||||
*/
|
||||
void Day::checkLunarData()
|
||||
{
|
||||
// 已经计算过了
|
||||
if (this->Ldn != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this->checkSSQ();
|
||||
|
||||
int mk = int2((this->d0 - SSQPtr->HS[0]) / 30);
|
||||
if (mk < 13 && SSQPtr->HS[mk + 1] <= this->d0)
|
||||
{
|
||||
mk++; //农历所在月的序数
|
||||
}
|
||||
|
||||
//if (this.d0 == SSQPtr->HS[mk]) { //月的信息
|
||||
this->Lmc = SSQPtr->ym[mk]; //月名称
|
||||
this->Ldn = SSQPtr->dx[mk]; //月大小
|
||||
this->Lleap = (SSQPtr->leap != 0 && SSQPtr->leap == mk); //闰状况
|
||||
//}
|
||||
|
||||
// 阴历所处的日
|
||||
this->Ldi = this->d0 - SSQPtr->HS[mk];
|
||||
}
|
||||
|
||||
void Day::checkSolarData()
|
||||
{
|
||||
if (this->m != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Time t = JD::JD2DD(this->d0 + J2000);
|
||||
this->y = t.Y;
|
||||
this->d = t.D;
|
||||
this->m = t.M;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算节气数据
|
||||
*/
|
||||
void Day::checkJQData()
|
||||
{
|
||||
if (this->qk != -2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->qk = -1;
|
||||
this->getJieQiJD();
|
||||
|
||||
//this->checkSSQ();
|
||||
|
||||
//int qk = int2((this->d0 - SSQPtr->ZQ[0] - 7) / 15.2184);
|
||||
//////节气的取值范围是0-23
|
||||
//if (qk < 23 && this->d0 >= SSQPtr->ZQ[qk + 1])
|
||||
//{
|
||||
// qk++;
|
||||
//}
|
||||
|
||||
//this->qk = -1;
|
||||
//if (this->d0 == SSQPtr->ZQ[qk])
|
||||
//{
|
||||
// this->qk = qk;
|
||||
//}
|
||||
}
|
||||
|
||||
Day *Day::after(int day)
|
||||
{
|
||||
return new Day(this->d0 + day);
|
||||
}
|
||||
|
||||
Day *Day::before(int day)
|
||||
{
|
||||
return new Day(this->d0 - day);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取阴历日期
|
||||
*/
|
||||
int Day::getLunarDay()
|
||||
{
|
||||
this->checkLunarData();
|
||||
return this->Ldi + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取阴历月
|
||||
*/
|
||||
uint8_t Day::getLunarMonth()
|
||||
{
|
||||
this->checkLunarData();
|
||||
static const int yueIndex[12] = { 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
return yueIndex[this->Lmc];
|
||||
}
|
||||
|
||||
int Day::getLunarYear(bool chineseNewYearBoundary)
|
||||
{
|
||||
// 以立春为界
|
||||
if (chineseNewYearBoundary == false)
|
||||
{
|
||||
if (this->Lyear == 0)
|
||||
{
|
||||
this->checkSSQ();
|
||||
long double D = SSQPtr->ZQ[3] + (this->d0 < SSQPtr->ZQ[3] ? -365 : 0) + 365.25 * 16 - 35; //以立春为界定纪年
|
||||
this->Lyear = int2(D / 365.2422 + 0.5);
|
||||
}
|
||||
return this->Lyear + 1984;
|
||||
}
|
||||
// 以春节为界
|
||||
if (this->Lyear0 == 0)
|
||||
{
|
||||
this->checkSSQ();
|
||||
int D = SSQPtr->HS[2]; //一般第3个月为春节
|
||||
for (int j = 0; j < 14; j++)
|
||||
{ //找春节
|
||||
if (SSQPtr->ym[j] != 2 || SSQPtr->leap == j && j)
|
||||
continue;
|
||||
D = SSQPtr->HS[j];
|
||||
if (this->d0 < D)
|
||||
{
|
||||
D -= 365;
|
||||
break;
|
||||
} //无需再找下一个正月
|
||||
}
|
||||
D = D + 5810; //计算该年春节与1984年平均春节(立春附近)相差天数估计
|
||||
this->Lyear0 = int2(D / 365.2422 + 0.5);
|
||||
}
|
||||
return this->Lyear0 + 1984;
|
||||
}
|
||||
|
||||
GZ Day::getYearGZ(bool chineseNewYearBoundary)
|
||||
{
|
||||
//以春节为界
|
||||
if (chineseNewYearBoundary)
|
||||
{
|
||||
if (this->Lyear3 == NULL)
|
||||
{
|
||||
int year = this->getLunarYear(chineseNewYearBoundary) - 1984;
|
||||
int D = year + 12000;
|
||||
this->Lyear3 = new GZ(D % 10, D % 12);
|
||||
}
|
||||
return *(this->Lyear3);
|
||||
}
|
||||
|
||||
// 以立春为界
|
||||
if (this->Lyear2 == NULL)
|
||||
{
|
||||
int year = this->getLunarYear(false) - 1984;
|
||||
int D = year + 12000;
|
||||
this->Lyear2 = new GZ(D % 10, D % 12);
|
||||
}
|
||||
return *(this->Lyear2);
|
||||
}
|
||||
|
||||
GZ Day::getMonthGZ()
|
||||
{
|
||||
if (this->Lmonth2 == NULL)
|
||||
{
|
||||
this->checkSSQ();
|
||||
int mk = int2((this->d0 - SSQPtr->ZQ[0]) / 30.43685);
|
||||
//相对大雪的月数计算,mk的取值范围0-12
|
||||
if (mk < 12 && this->d0 >= SSQPtr->ZQ[2 * mk + 1])
|
||||
mk++;
|
||||
//相对于1998年12月7(大雪)的月数,900000为正数基数
|
||||
int D = mk + int2((SSQPtr->ZQ[12] + 390) / 365.2422) * 12 + 900000;
|
||||
this->Lmonth2 = new GZ(D % 10, D % 12);
|
||||
}
|
||||
return *(this->Lmonth2);
|
||||
}
|
||||
|
||||
GZ Day::getDayGZ()
|
||||
{
|
||||
if (this->Lday2 == NULL)
|
||||
{
|
||||
int D = this->d0 - 6 + 9000000;
|
||||
this->Lday2 = new GZ(D % 10, D % 12);
|
||||
}
|
||||
return *(this->Lday2);
|
||||
}
|
||||
|
||||
GZ Day::getHourGZ(uint8_t hour, bool isZaoWanZiShi)
|
||||
{
|
||||
GZ dayGZ = this->getDayGZ();
|
||||
return sxtwl::getShiGz(dayGZ.tg, hour, isZaoWanZiShi);
|
||||
}
|
||||
|
||||
bool Day::isLunarLeap()
|
||||
{
|
||||
this->checkLunarData();
|
||||
return this->Lleap;
|
||||
}
|
||||
|
||||
int Day::getSolarYear()
|
||||
{
|
||||
this->checkSolarData();
|
||||
return this->y;
|
||||
}
|
||||
|
||||
uint8_t Day::getSolarMonth()
|
||||
{
|
||||
this->checkSolarData();
|
||||
return this->m;
|
||||
}
|
||||
|
||||
int Day::getSolarDay()
|
||||
{
|
||||
this->checkSolarData();
|
||||
return this->d;
|
||||
}
|
||||
|
||||
uint8_t Day::getWeek()
|
||||
{
|
||||
if (this->week == 0xFF)
|
||||
{
|
||||
this->week = (this->d0 + J2000 + 1 + 7000000) % 7;
|
||||
}
|
||||
return this->week;
|
||||
}
|
||||
|
||||
// 处于该月的第几周
|
||||
uint8_t Day::getWeekIndex()
|
||||
{
|
||||
int i = (this->getSolarDay() - 1) % 7;
|
||||
|
||||
int w0 = 0;
|
||||
if (this->getWeek() >= i)
|
||||
{
|
||||
w0 = this->getWeek() - i;
|
||||
}
|
||||
else
|
||||
{
|
||||
w0 = this->getWeek() + 7 - i;
|
||||
}
|
||||
return int2((w0 + this->getSolarDay() - 1) / 7) + 1;
|
||||
}
|
||||
//是否有节气
|
||||
bool Day::hasJieQi()
|
||||
{
|
||||
this->checkJQData();
|
||||
return this->qk != -1;
|
||||
}
|
||||
// 获取节气
|
||||
uint8_t Day::getJieQi()
|
||||
{
|
||||
this->checkJQData();
|
||||
return this->qk;
|
||||
}
|
||||
|
||||
|
||||
|
||||
double Day::getJieQiJD()
|
||||
{
|
||||
if (this->jqjd != 0)
|
||||
{
|
||||
return this->jqjd;
|
||||
}
|
||||
|
||||
long double d, xn, jd2 = this->d0 + dt_T(this->d0) - (long double)8 / (long double)24;
|
||||
long double w = XL::S_aLon(jd2 / 36525, 3);
|
||||
w = int2((w - 0.13) / pi2 * 24) * pi2 / 24;
|
||||
int D = 0;
|
||||
|
||||
do
|
||||
{
|
||||
d = qi_accurate(w);
|
||||
D = int2(d + 0.5);
|
||||
// 计算出的节令值
|
||||
xn = int2(w / pi2 * 24 + 24000006.01) % 24;
|
||||
w += pi2 / 24;
|
||||
if (D > this->d0)
|
||||
break;
|
||||
if (D < this->d0)
|
||||
continue;
|
||||
if (D == this->d0)
|
||||
{
|
||||
Time t1 = JD::JD2DD(d);
|
||||
Time t2 = JD::JD2DD(D + J2000);
|
||||
|
||||
t2.h = t1.h;
|
||||
t2.m = t1.m;
|
||||
t2.s = t1.s;
|
||||
|
||||
auto jd = JD::toJD(t2);
|
||||
|
||||
this->jqjd = jd;
|
||||
this->qk = xn;
|
||||
break;
|
||||
}
|
||||
} while (D + 12 < this->d0);
|
||||
|
||||
return this->jqjd; //+ J2000;
|
||||
}
|
||||
|
||||
// 获取星座
|
||||
uint8_t Day::getConstellation()
|
||||
{
|
||||
if (this->XiZ == 0xFF)
|
||||
{
|
||||
this->checkSSQ();
|
||||
int mk = int2((this->d0 - SSQPtr->ZQ[0] - 15) / 30.43685);
|
||||
//星座所在月的序数,(如果j=13,ob.d0不会超过第14号中气)
|
||||
if (mk < 11 && this->d0 >= SSQPtr->ZQ[2 * mk + 2])
|
||||
{
|
||||
mk++;
|
||||
}
|
||||
this->XiZ = (mk + 12) % 12;
|
||||
}
|
||||
return this->XiZ;
|
||||
}
|
216
src/day.h
Normal file
216
src/day.h
Normal file
@ -0,0 +1,216 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <memory>
|
||||
#include "JD.h"
|
||||
#include "const.h"
|
||||
#include "SSQ.h"
|
||||
|
||||
static std::unique_ptr<SSQ> SSQPtr(new SSQ());
|
||||
|
||||
struct GZ
|
||||
{
|
||||
GZ(){};
|
||||
GZ(uint8_t tg, uint8_t dz) : tg(tg), dz(dz)
|
||||
{
|
||||
}
|
||||
uint8_t tg;
|
||||
uint8_t dz;
|
||||
};
|
||||
|
||||
class Day
|
||||
{
|
||||
private:
|
||||
int d0; //儒略日
|
||||
|
||||
int y; //公历年
|
||||
uint8_t m; //公历月
|
||||
int d;
|
||||
|
||||
int Lmc; //阴历月的月
|
||||
uint8_t Ldi; //阴历月的日
|
||||
int Ldn; //该阴历月的总天数
|
||||
bool Lleap; //是不是阴历的润月
|
||||
|
||||
int Lyear; //以立春为界, 定农历纪年(10进制,1984年起算)
|
||||
int Lyear0; //以正月初一为界,农历纪年(10进制,1984年起算)
|
||||
|
||||
uint8_t week; //星期几
|
||||
int8_t qk; //节令值
|
||||
uint8_t XiZ; //星座
|
||||
double jqjd; //节气最体的时间
|
||||
|
||||
GZ *Lyear2; //干支纪年(立春)
|
||||
GZ *Lyear3; //干支纪年(正月 春节)
|
||||
GZ *Lmonth2; //月天干地支
|
||||
GZ *Lday2; // 日天干地支
|
||||
|
||||
private:
|
||||
Day(int d0)
|
||||
{
|
||||
this->d0 = d0;
|
||||
this->Ldn = 0;
|
||||
this->m = 0;
|
||||
this->qk = -2;
|
||||
this->Lyear = 0;
|
||||
this->Lyear0 = 0;
|
||||
|
||||
this->Lyear2 = NULL;
|
||||
this->Lyear3 = NULL;
|
||||
this->Lmonth2 = NULL;
|
||||
this->Lday2 = NULL;
|
||||
|
||||
this->week = 0xFF;
|
||||
this->XiZ = 0xFF;
|
||||
this->jqjd = 0;
|
||||
};
|
||||
|
||||
void checkSSQ();
|
||||
void checkLunarData();
|
||||
void checkSolarData();
|
||||
void checkJQData();
|
||||
|
||||
public:
|
||||
virtual ~Day()
|
||||
{
|
||||
if (this->Lyear2)
|
||||
{
|
||||
delete this->Lyear2;
|
||||
this->Lyear2 = NULL;
|
||||
}
|
||||
|
||||
if (this->Lyear3)
|
||||
{
|
||||
delete this->Lyear3;
|
||||
this->Lyear3 = NULL;
|
||||
}
|
||||
|
||||
if (this->Lmonth2)
|
||||
{
|
||||
delete this->Lmonth2;
|
||||
this->Lmonth2 = NULL;
|
||||
}
|
||||
|
||||
if (this->Lday2)
|
||||
{
|
||||
delete this->Lday2;
|
||||
this->Lday2 = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
// 注意非早晚子时的时候,day要算第二天
|
||||
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();
|
||||
public:
|
||||
static Day *fromSolar(int _year, uint8_t _month, int _day)
|
||||
{
|
||||
Time *t = new Time();
|
||||
t->h = 12, t->m = 0, t->s = 0.1;
|
||||
t->Y = _year;
|
||||
t->M = _month;
|
||||
t->D = _day;
|
||||
int d0 = int2(JD::toJD(*t)) - J2000;
|
||||
return new Day(d0);
|
||||
}
|
||||
|
||||
static Day *fromLunar(int year, uint8_t month, int day, bool isRun = false)
|
||||
{
|
||||
Time *t = new Time();
|
||||
t->h = 12, t->m = 0, t->s = 0.1;
|
||||
t->Y = year;
|
||||
t->M = 1;
|
||||
t->D = 1;
|
||||
if (month > 10)
|
||||
{
|
||||
t->Y = year + 1;
|
||||
}
|
||||
|
||||
int Bd0 = int2(JD::toJD(*t)) - J2000;
|
||||
if (!SSQPtr->ZQ.size() || Bd0 < SSQPtr->ZQ[0] || Bd0 >= SSQPtr->ZQ[24])
|
||||
{
|
||||
SSQPtr->calcY(Bd0);
|
||||
}
|
||||
|
||||
static const int yueIndex[12] = {11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
int yue = 0;
|
||||
|
||||
for (int i = 0; i < sizeof(yueIndex); ++i)
|
||||
{
|
||||
if (yueIndex[i] == month)
|
||||
{
|
||||
yue = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int mk = 0;
|
||||
int leap = SSQPtr->leap - 1;
|
||||
|
||||
for (int i = 0; i < SSQPtr->ym.size(); ++i)
|
||||
{
|
||||
int it = SSQPtr->ym[i];
|
||||
if (leap < 0)
|
||||
{
|
||||
if (it == yue)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (yue < leap && it == yue)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (yue == leap && it == yue && isRun)
|
||||
{
|
||||
++mk;
|
||||
break;
|
||||
}
|
||||
|
||||
if (yue == leap && it == yue && !isRun)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (yue > leap && it == yue)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
++mk;
|
||||
}
|
||||
|
||||
int bdi = SSQPtr->HS[mk];
|
||||
int jd = bdi + day - 1;
|
||||
|
||||
return new Day(jd);
|
||||
}
|
||||
};
|
1170
src/eph.cpp
Normal file
1170
src/eph.cpp
Normal file
File diff suppressed because one or more lines are too long
172
src/eph.h
Normal file
172
src/eph.h
Normal file
@ -0,0 +1,172 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct Vector3
|
||||
{
|
||||
Vector3(long double x, long double y, long double z) :
|
||||
x(x), y(y), z(z)
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
Vector3(const Vector3& v) :
|
||||
x(v.x), y(v.y), z(v.z)
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Vector3() {};
|
||||
long double x, y, z;
|
||||
|
||||
long double& operator [](const uint64_t index)////重载[]操作符,作为左值
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: return x;
|
||||
case 1: return y;
|
||||
case 2: return z;
|
||||
default: return x;
|
||||
}
|
||||
|
||||
};
|
||||
const long double& operator [](const uint64_t index) const////重载[]操作符,作为右值
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: return x;
|
||||
case 1: return y;
|
||||
case 2: return z;
|
||||
default: return x;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
struct Vector2
|
||||
{
|
||||
Vector2(long double x, long double y) :
|
||||
x(x), y(y)
|
||||
{
|
||||
|
||||
};
|
||||
Vector2() {};
|
||||
long double x, y;
|
||||
|
||||
long double& operator [](const uint64_t index)////重载[]操作符,作为左值
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: return x;
|
||||
case 1: return y;
|
||||
default: return x;
|
||||
}
|
||||
|
||||
};
|
||||
const long double& operator [](const uint64_t index) const////重载[]操作符,作为右值
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: return x;
|
||||
case 1: return y;
|
||||
default: return x;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//=================================数学工具=========================================
|
||||
|
||||
//对超过0-2PI的角度转为0-2PI;
|
||||
long double rad2mrad(long double v);
|
||||
//对超过-PI到PI的角度转为-PI到PI;
|
||||
long double rad2rrad(long double v);
|
||||
//临界余数(a与最近的整倍数b相差的距离);
|
||||
long double mod2(long double a, long double b);
|
||||
//球面转直角坐标;
|
||||
Vector3 llr2xyz(Vector3 JW);
|
||||
//直角坐标转球;
|
||||
Vector3 xyz2llr(Vector3 xyz);
|
||||
//球面坐标旋转;
|
||||
Vector3 llrConv(Vector3 JW, long double E);
|
||||
//赤道坐标转为地平坐标;
|
||||
Vector3 CD2DP(Vector3 z, long double L, long double fa, long double gst);
|
||||
//求角度差;
|
||||
long double j1_j2(long double J1, long double W1, long double J2, long double W2);
|
||||
//日心球面转地心球面,Z星体球面坐标,A地球球面坐标;
|
||||
//本含数是通用的球面坐标中心平移函数,行星计算中将反复使用;
|
||||
Vector3 h2g(Vector3 z, Vector3 a);
|
||||
//视差角(不是视差);
|
||||
long double shiChaJ(long double gst, long double L, long double fa, long double J, long double W);
|
||||
|
||||
//物件XL : 日月黄道平分点坐标、视坐标、速度、已知经度反求时间等方面的计算
|
||||
namespace XL
|
||||
{
|
||||
//=====================
|
||||
//星历函数(日月球面坐标计算)
|
||||
|
||||
long double E_Lon(long double t, int n); //地球经度计算,返回Date分点黄经,传入世纪数、取项数
|
||||
long double M_Lon(long double t, int n); //月球经度计算,返回Date分点黄经,传入世纪数,n是项数比例
|
||||
//地球速度,t是世纪数,误差小于万分3 //=========================
|
||||
long double E_v(long double t);
|
||||
|
||||
|
||||
//月球速度计算,传入世经数
|
||||
long double M_v(long double t);
|
||||
|
||||
//=========================
|
||||
//月日视黄经的差值
|
||||
long double MS_aLon(long double t, long double Mn, long double Sn);
|
||||
|
||||
//太阳视黄经
|
||||
long double S_aLon(long double t, long double n);
|
||||
|
||||
//=========================
|
||||
//已知地球真黄经求时间
|
||||
long double E_Lon_t(long double W);
|
||||
|
||||
//已知真月球黄经求时间
|
||||
long double M_Lon_t(long double W);
|
||||
|
||||
//已知月日视黄经差求时间
|
||||
long double MS_aLon_t(long double W);
|
||||
|
||||
//已知太阳视黄经反求时间
|
||||
long double S_aLon_t(long double W);
|
||||
|
||||
//已知月日视黄经差求时间,高速低精度,误差不超过600秒(只验算了几千年)
|
||||
long double MS_aLon_t2(long double W);
|
||||
//已知太阳视黄经反求时间,高速低精度,最大误差不超过600秒
|
||||
long double S_aLon_t2(long double W);
|
||||
|
||||
long double moonIll(long double t);
|
||||
|
||||
//转入地平纬度及地月质心距离,返回站心视半径(角秒)
|
||||
long double moonRad(long double r, long double h);
|
||||
|
||||
//求月亮近点时间和距离,t为儒略世纪数力学时
|
||||
Vector2 moonMinR(long double t, long double min);
|
||||
|
||||
Vector3 moonNode(long double t, long double asc);
|
||||
|
||||
//地球近远点
|
||||
Vector2 earthMinR(long double t, long double min);
|
||||
};
|
||||
|
||||
|
||||
//=================================deltat T计算=====================================
|
||||
long double dt_T(long double t);
|
||||
|
||||
|
||||
//精气
|
||||
inline long double qi_accurate(long double W)
|
||||
{
|
||||
long double t = XL::S_aLon_t(W) * 36525;
|
||||
return t - dt_T(t) + (long double)8.0 / (long double)24.0;
|
||||
}
|
||||
|
||||
inline long double so_accurate(long double W)
|
||||
{
|
||||
long double t = XL::MS_aLon_t(W) * 36525;
|
||||
return t - dt_T(t) + (long double)8.0 / (long double)24.0;
|
||||
} //精朔
|
746
src/sxtwl.cpp
Normal file
746
src/sxtwl.cpp
Normal file
@ -0,0 +1,746 @@
|
||||
#include "sxtwl.h"
|
||||
#include "const.h"
|
||||
#include "JD.h"
|
||||
#include "eph.h"
|
||||
#include "SSQ.h"
|
||||
#include <cmath>
|
||||
|
||||
//获取干支索引
|
||||
short getGanZhiIndex(GZ value)
|
||||
{
|
||||
short index = 0;
|
||||
for (int i = 0; i < 6; ++i)
|
||||
{
|
||||
if ((value.tg + i * 10) % 12 == value.dz)
|
||||
{
|
||||
index = value.tg + i * 10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
namespace sxtwl
|
||||
{
|
||||
|
||||
Day* fromSolar(int year, uint8_t month, int day)
|
||||
{
|
||||
return Day::fromSolar(year, month, day);
|
||||
}
|
||||
|
||||
Day* fromLunar(int year, uint8_t month, int day, bool isRun)
|
||||
{
|
||||
return Day::fromLunar(year, month, day, isRun);
|
||||
}
|
||||
|
||||
//通过四柱获取年月日
|
||||
std::vector<double> siZhu2Year(GZ yearGz, GZ yueGz, GZ riGz, GZ shiGz, int fromYear, int toYear)
|
||||
{
|
||||
auto fromDiff = fromYear - 1984;
|
||||
|
||||
///月
|
||||
/*
|
||||
甲己之年丙作首,乙庚之岁戊为头。
|
||||
丙辛岁首寻庚起,丁壬壬位顺行流。
|
||||
若言戊癸何方求,甲寅之上好追求*/
|
||||
|
||||
int startYueTg = 0, startYueDz = 0;
|
||||
if (yearGz.tg == 0 || yearGz.tg == 5)
|
||||
{
|
||||
startYueTg = 2;
|
||||
startYueDz = 2;
|
||||
}
|
||||
|
||||
if (yearGz.tg == 1 || yearGz.tg == 6)
|
||||
{
|
||||
startYueTg = 4;
|
||||
startYueDz = 2;
|
||||
}
|
||||
|
||||
if (yearGz.tg == 2 || yearGz.tg == 7)
|
||||
{
|
||||
startYueTg = 6;
|
||||
startYueDz = 2;
|
||||
}
|
||||
|
||||
if (yearGz.tg == 3 || yearGz.tg == 8)
|
||||
{
|
||||
startYueTg = 8;
|
||||
startYueDz = 2;
|
||||
}
|
||||
|
||||
if (yearGz.tg == 4 || yearGz.tg == 9)
|
||||
{
|
||||
startYueTg = 0;
|
||||
startYueDz = 2;
|
||||
}
|
||||
|
||||
auto mayBeDzMoth = yueGz.dz - startYueDz;
|
||||
if (mayBeDzMoth < 0)
|
||||
{
|
||||
mayBeDzMoth = mayBeDzMoth + 12;
|
||||
}
|
||||
|
||||
auto mayBeTGMoth = yueGz.tg - startYueTg;
|
||||
if (mayBeTGMoth < 0)
|
||||
{
|
||||
mayBeTGMoth = mayBeTGMoth + 10;
|
||||
}
|
||||
|
||||
std::vector<double> ret;
|
||||
//说明没有合适的
|
||||
if (!(mayBeTGMoth == mayBeDzMoth || mayBeTGMoth + 10 == mayBeDzMoth))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
///时
|
||||
// 甲己日起甲子时
|
||||
// 乙庚日起丙子时
|
||||
// 丙辛日起戊子时
|
||||
// 丁壬日起庚子时
|
||||
// 戊葵日起壬子时
|
||||
|
||||
uint8_t startHourtg = 0;
|
||||
if (riGz.tg == 0 || riGz.tg == 5)
|
||||
{
|
||||
startHourtg = 0;
|
||||
}
|
||||
if (riGz.tg == 1 || riGz.tg == 6)
|
||||
{
|
||||
startHourtg = 2;
|
||||
}
|
||||
if (riGz.tg == 2 || riGz.tg == 7)
|
||||
{
|
||||
startHourtg = 4;
|
||||
}
|
||||
|
||||
if (riGz.tg == 3 || riGz.tg == 8)
|
||||
{
|
||||
startHourtg = 6;
|
||||
}
|
||||
|
||||
if (riGz.tg == 4 || riGz.tg == 9)
|
||||
{
|
||||
startHourtg = 8;
|
||||
}
|
||||
|
||||
auto mayBeTGHour = shiGz.tg - startHourtg;
|
||||
if (mayBeTGHour < 0)
|
||||
{
|
||||
mayBeTGHour = mayBeTGHour + 10;
|
||||
}
|
||||
|
||||
//说明没有合适的
|
||||
if (!(mayBeTGHour == shiGz.dz || mayBeTGHour + 10 == shiGz.dz || (shiGz.dz == 12 && mayBeTGHour + 10 == 12))) //晚子时
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
///年
|
||||
GZ fromYearGz;
|
||||
if (fromDiff < 0)
|
||||
{
|
||||
fromYearGz.tg = fromDiff * -1 % 10;
|
||||
if (fromYearGz.tg > 0)
|
||||
{
|
||||
fromYearGz.tg = 10 - fromYearGz.tg;
|
||||
}
|
||||
fromYearGz.dz = fromDiff * -1 % 12;
|
||||
|
||||
if (fromYearGz.dz > 0)
|
||||
{
|
||||
fromYearGz.dz = 12 - fromYearGz.dz;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fromYearGz.tg = fromDiff % 10;
|
||||
fromYearGz.dz = fromDiff % 12;
|
||||
}
|
||||
|
||||
//获取起始年天干支所在的位置
|
||||
auto fromGzPos = getGanZhiIndex(fromYearGz);
|
||||
//所查询的年需要的天干地支位置
|
||||
auto needGzPos = getGanZhiIndex(yearGz);
|
||||
|
||||
int startMatchBeYear = 60;
|
||||
if (needGzPos >= fromGzPos)
|
||||
{
|
||||
startMatchBeYear = needGzPos - fromGzPos + fromYear;
|
||||
}
|
||||
else
|
||||
{
|
||||
startMatchBeYear = needGzPos + (60 - fromGzPos) + fromYear;
|
||||
}
|
||||
|
||||
std::vector<int> matchYears;
|
||||
|
||||
int loop = 0;
|
||||
while (startMatchBeYear + loop * 60 <= toYear)
|
||||
{
|
||||
matchYears.push_back(startMatchBeYear + loop * 60);
|
||||
loop += 1;
|
||||
}
|
||||
|
||||
//理论是是第几个小时 (晚子时算成13)
|
||||
int hour = (shiGz.dz % 13) * 2 - 1;
|
||||
if (hour < 0)
|
||||
hour = 0;
|
||||
|
||||
//获取这个月应当需要落下的节气
|
||||
int jiqiIndex = 3 + (mayBeDzMoth * 2);
|
||||
bool needAddOne = false; //需要算到下一年
|
||||
if (jiqiIndex > 24)
|
||||
{
|
||||
jiqiIndex = jiqiIndex - 24;
|
||||
needAddOne = true;
|
||||
}
|
||||
|
||||
//遍历符条件的年
|
||||
for (auto it = matchYears.begin(); it != matchYears.end(); ++it)
|
||||
{
|
||||
int year = *it;
|
||||
if (needAddOne)
|
||||
{
|
||||
year = year + 1;
|
||||
}
|
||||
|
||||
//计算1月1号的信息
|
||||
Time t;
|
||||
t.h = 12, t.m = 0, t.s = 0.1;
|
||||
t.Y = year;
|
||||
t.M = 9;
|
||||
t.D = 1;
|
||||
|
||||
//公历月首的儒略日,中午;
|
||||
int Bd0 = int2(JD::toJD(t)) - J2000;
|
||||
|
||||
GZ startGz;
|
||||
GZ endGz;
|
||||
long double startJD = 0;
|
||||
long double endJD = 0;
|
||||
Time startT;
|
||||
Time endT;
|
||||
|
||||
//纪月处理,1998年12月7(大雪)开始连续进行节气计数,0为甲子
|
||||
for (int i = 1; i >= 0; --i)
|
||||
{
|
||||
int index = jiqiIndex + 2 * i;
|
||||
//定节气范围
|
||||
if (i == 1 && jiqiIndex == 23)
|
||||
{
|
||||
if (!SSQPtr->ZQ.size() || Bd0 + 360 < SSQPtr->ZQ[0] || Bd0 + 360 >= SSQPtr->ZQ[24])
|
||||
{
|
||||
SSQPtr->calcY(Bd0 + 360);
|
||||
}
|
||||
index = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!SSQPtr->ZQ.size() || Bd0 < SSQPtr->ZQ[0] || Bd0 >= SSQPtr->ZQ[24])
|
||||
{
|
||||
SSQPtr->calcY(Bd0);
|
||||
}
|
||||
}
|
||||
|
||||
int mk = int2((SSQPtr->ZQ[index] - SSQPtr->ZQ[0]) / 30.43685);
|
||||
//相对大雪的月数计算,mk的取值范围0-12
|
||||
if (mk < 12 && SSQPtr->ZQ[index] >= SSQPtr->ZQ[2 * mk + 1])
|
||||
{
|
||||
mk++;
|
||||
}
|
||||
|
||||
int D = mk + int2((SSQPtr->ZQ[12] + 390) / 365.2422) * 12 + 900000; //相对于1998年12月7(大雪)的月数,900000为正数基数
|
||||
|
||||
////纪日,2000年1月7日起算
|
||||
D = SSQPtr->ZQ[index] - 6 + 9000000;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
startJD = SSQPtr->ZQ[index];
|
||||
startT = JD::JD2DD(startJD + J2000);
|
||||
startGz.tg = D % 10;
|
||||
startGz.dz = D % 12;
|
||||
|
||||
//获取准确节气的时间
|
||||
auto jd2 = SSQPtr->ZQ[0] + dt_T(SSQPtr->ZQ[0]) - (8.0 / 24.0);
|
||||
auto w = XL::S_aLon(jd2 / 36525, 3);
|
||||
w = int2((w - 0.13) / pi2 * 24) * pi2 / 24;
|
||||
|
||||
for (int i = 0; i <= index; ++i)
|
||||
{
|
||||
long double d = 0;
|
||||
while (true)
|
||||
{
|
||||
d = qi_accurate(w);
|
||||
D = int2(d + 0.5);
|
||||
auto xn = int2(w / pi2 * 24 + 24000006.01) % 24;
|
||||
w += pi2 / 24;
|
||||
if (D < SSQPtr->ZQ[i])
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
if (index != i)
|
||||
continue;
|
||||
Time t1 = JD::JD2DD(d);
|
||||
startT.h = t1.h;
|
||||
startT.m = t1.m;
|
||||
startT.s = t1.s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
endJD = SSQPtr->ZQ[index];
|
||||
endT = JD::JD2DD(endJD + J2000);
|
||||
endGz.tg = D % 10;
|
||||
endGz.dz = D % 12;
|
||||
|
||||
//获取准确节气的时间
|
||||
auto jd2 = SSQPtr->ZQ[0] + dt_T(SSQPtr->ZQ[0]) - (8.0 / 24.0);
|
||||
auto w = XL::S_aLon(jd2 / 36525, 3);
|
||||
w = int2((w - 0.13) / pi2 * 24) * pi2 / 24;
|
||||
|
||||
for (int i = 0; i <= index; ++i)
|
||||
{
|
||||
long double d = 0;
|
||||
while (true)
|
||||
{
|
||||
d = qi_accurate(w);
|
||||
D = int2(d + 0.5);
|
||||
auto xn = int2(w / pi2 * 24 + 24000006.01) % 24;
|
||||
w += pi2 / 24;
|
||||
if (D < SSQPtr->ZQ[i])
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
if (index != i)
|
||||
continue;
|
||||
Time t1 = JD::JD2DD(d);
|
||||
endT.h = t1.h;
|
||||
endT.m = t1.m;
|
||||
endT.s = t1.s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int diff = getGanZhiIndex(riGz) - getGanZhiIndex(startGz);
|
||||
long double startDay = 0;
|
||||
if (diff < 0)
|
||||
{
|
||||
|
||||
diff = 60 + diff;
|
||||
}
|
||||
|
||||
startDay = startJD + diff;
|
||||
|
||||
/*Time st = JD::JD2DD(startJD + J2000);
|
||||
Time et = JD::JD2DD(endJD + J2000);*/
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
Time mayBet = JD::JD2DD(startDay + J2000);
|
||||
mayBet.h = hour;
|
||||
mayBet.m = 0;
|
||||
mayBet.s = 0;
|
||||
|
||||
if (diff == 0)
|
||||
{
|
||||
bool isMatch = false;
|
||||
|
||||
//此时算上一个月的
|
||||
if (hour > t.h)
|
||||
{
|
||||
isMatch = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hour != 0 || hour != 23)
|
||||
{
|
||||
mayBet.h = hour;
|
||||
mayBet.m = 59;
|
||||
mayBet.s = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mayBet.h = hour;
|
||||
mayBet.m = 59;
|
||||
mayBet.s = 0;
|
||||
}
|
||||
|
||||
if (mayBet.h >= t.h && t.m < 59)
|
||||
{
|
||||
isMatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isMatch)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else if (diff == int2(endJD - startJD))
|
||||
{
|
||||
bool isMatch = false;
|
||||
|
||||
//此时算上一个月的
|
||||
if (hour < endT.h)
|
||||
{
|
||||
isMatch = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mayBet.h == endT.h && endT.m > 0)
|
||||
{
|
||||
isMatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isMatch)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (diff > int2(endJD - startJD))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ret.push_back(JD::toJD(mayBet));
|
||||
} while (false);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
GZ getShiGz(uint8_t dayTg, uint8_t hour, bool isZaoWanZiShi)
|
||||
{
|
||||
GZ ret;
|
||||
// 甲己日起甲子时
|
||||
// 乙庚日起丙子时
|
||||
// 丙辛日起戊子时
|
||||
// 丁壬日起庚子时
|
||||
// 戊葵日起壬子时
|
||||
|
||||
uint8_t step = (hour + 1) / 2;
|
||||
if (step >= 12)
|
||||
{
|
||||
ret.dz = 0;
|
||||
}
|
||||
|
||||
// 如果非早晚子时,以及时间为23点,则算第二日的起始子时
|
||||
if (!isZaoWanZiShi && hour == 23)
|
||||
{
|
||||
step = 0;
|
||||
}
|
||||
|
||||
switch (dayTg)
|
||||
{
|
||||
case 0: //甲
|
||||
case 5: //己
|
||||
ret.tg = 0 + step;
|
||||
break;
|
||||
case 1: //乙
|
||||
case 6: //庚
|
||||
ret.tg = 2 + step;
|
||||
break;
|
||||
|
||||
case 2: //丙
|
||||
case 7: //辛
|
||||
ret.tg = 4 + step;
|
||||
break;
|
||||
case 3: //丁
|
||||
case 8: //壬
|
||||
ret.tg = 6 + step;
|
||||
break;
|
||||
case 4: //戊
|
||||
case 9: //葵
|
||||
ret.tg = 8 + step;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
ret.tg = ret.tg % 10;
|
||||
ret.dz = step % 12;
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t getRunMonth(int By)
|
||||
{
|
||||
//计算1月1号的信息
|
||||
Time t;
|
||||
t.h = 12, t.m = 0, t.s = 0.1;
|
||||
t.Y = By;
|
||||
t.M = 1;
|
||||
t.D = 1;
|
||||
|
||||
//公历月首的儒略日,中午;
|
||||
int Bd0 = int2(JD::toJD(t)) - J2000;
|
||||
|
||||
if (!SSQPtr->ZQ.size() || Bd0 < SSQPtr->ZQ[0] || Bd0 >= SSQPtr->ZQ[24])
|
||||
{
|
||||
SSQPtr->calcY(Bd0);
|
||||
}
|
||||
|
||||
//{ "十一", "十二", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十" }
|
||||
// static int mkIndex[] = { 11, 12, 1,2,3,4,5,6,7, 8,9,10 };
|
||||
static int yueIndex[] = { 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
|
||||
//需要排除11月和12月的,这个可能属于上一个月的信息
|
||||
int leap = SSQPtr->leap - 1;
|
||||
if (leap > 1)
|
||||
{
|
||||
return yueIndex[leap];
|
||||
}
|
||||
|
||||
//看看11月和12月是否有闰
|
||||
t.Y = By + 1;
|
||||
Bd0 = int2(JD::toJD(t)) - J2000;
|
||||
if (!SSQPtr->ZQ.size() || Bd0 < SSQPtr->ZQ[0] || Bd0 >= SSQPtr->ZQ[24])
|
||||
{
|
||||
SSQPtr->calcY(Bd0);
|
||||
}
|
||||
leap = SSQPtr->leap - 1;
|
||||
if (leap > 1 || leap < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return yueIndex[leap];
|
||||
}
|
||||
|
||||
uint8_t getLunarMonthNum(int year, uint8_t month, bool isRun)
|
||||
{
|
||||
if (month > 10)
|
||||
{
|
||||
year = year + 1;
|
||||
}
|
||||
|
||||
//计算1月1号的信息
|
||||
Time t;
|
||||
t.h = 12, t.m = 0, t.s = 0.1;
|
||||
t.Y = year;
|
||||
t.M = 1;
|
||||
t.D = 1;
|
||||
|
||||
//公历月首的儒略日,中午;
|
||||
int Bd0 = int2(JD::toJD(t)) - J2000;
|
||||
|
||||
if (!SSQPtr->ZQ.size() || Bd0 < SSQPtr->ZQ[0] || Bd0 >= SSQPtr->ZQ[24])
|
||||
{
|
||||
SSQPtr->calcY(Bd0);
|
||||
}
|
||||
|
||||
//{ "十一", "十二", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十" }
|
||||
// static int mkIndex[] = { 11, 12, 1,2,3,4,5,6,7, 8,9,10 };
|
||||
static int yueIndex[] = { 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
|
||||
int yue = 0;
|
||||
|
||||
for (int i = 0; i < sizeof(yueIndex); ++i)
|
||||
{
|
||||
if (*(yueIndex + i) == month)
|
||||
{
|
||||
yue = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int mk = 0;
|
||||
int leap = SSQPtr->leap - 1;
|
||||
|
||||
if (isRun && ((leap < 0) || (leap >= 0 && month != yueIndex[leap])))
|
||||
{
|
||||
//throw CalendarException(ErrorCode_NotRun);
|
||||
}
|
||||
|
||||
for (auto it = SSQPtr->ym.begin(); it != SSQPtr->ym.end(); ++it)
|
||||
{
|
||||
|
||||
if (leap < 0)
|
||||
{
|
||||
if (*it == yue)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (yue < leap && *it == yue)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (yue == leap && *it == yue && isRun)
|
||||
{
|
||||
++mk;
|
||||
break;
|
||||
}
|
||||
|
||||
if (yue == leap && *it == yue && !isRun)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (yue > leap && *it == yue)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
++mk;
|
||||
}
|
||||
|
||||
//阴历首月的儒略日
|
||||
int bdi = SSQPtr->HS[mk];
|
||||
|
||||
return SSQPtr->HS[mk + 1] - SSQPtr->HS[mk];
|
||||
}
|
||||
|
||||
//儒略日数转公历
|
||||
Time JD2DD(double jd)
|
||||
{
|
||||
return JD::JD2DD(jd);
|
||||
}
|
||||
|
||||
//公历转儒略日
|
||||
double toJD(Time& time)
|
||||
{
|
||||
return JD::toJD(time);
|
||||
}
|
||||
|
||||
std::vector<JieQiInfo> getJieQiByYear(int year)
|
||||
{
|
||||
std::vector<JieQiInfo> ret;
|
||||
|
||||
Time t(year, 1, 1, 12, 0, 0);
|
||||
auto jd = sxtwl::toJD(t) - J2000;
|
||||
/*Day* day = Day::fromSolar(year, 1, 1);
|
||||
|
||||
auto jd = day->getJD();
|
||||
delete day;*/
|
||||
|
||||
|
||||
if (!SSQPtr->ZQ.size() || jd < SSQPtr->ZQ[0] || jd >= SSQPtr->ZQ[24])
|
||||
{
|
||||
SSQPtr->calcY(jd);
|
||||
}
|
||||
|
||||
long double d, xn, jd2 = jd + dt_T(jd) - (long double)8 / (long double)24;
|
||||
long double w = XL::S_aLon(jd2 / 36525, 3);
|
||||
w = int2((w - 0.13) / pi2 * 24) * pi2 / 24;
|
||||
int D = 0;
|
||||
|
||||
bool startLiChun = false;
|
||||
for (auto it = SSQPtr->ZQ.begin(); it != SSQPtr->ZQ.end(); ++it)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
d = qi_accurate(w);
|
||||
D = int2(d + 0.5);
|
||||
xn = int2(w / pi2 * 24 + 24000006.01) % 24;
|
||||
w += pi2 / 24;
|
||||
// 这里可能会有误差,实际的不等相等
|
||||
if ( abs(int2(*it) - D) <= 5 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (D < *it) continue;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (xn == 3 && !startLiChun)
|
||||
{
|
||||
startLiChun = true;
|
||||
}
|
||||
|
||||
if (!startLiChun)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Time t1 = JD::JD2DD(d);
|
||||
Time t2 = JD::JD2DD(D + J2000);
|
||||
|
||||
t2.h = t1.h;
|
||||
t2.m = t1.m;
|
||||
t2.s = t1.s;
|
||||
|
||||
|
||||
auto jd = JD::toJD(t2);
|
||||
|
||||
|
||||
JieQiInfo tmp;
|
||||
tmp.jd = jd;
|
||||
tmp.jqIndex = xn;
|
||||
|
||||
ret.push_back(tmp);
|
||||
|
||||
}
|
||||
|
||||
t = Time(year + 1, 1, 1, 12, 0, 0);
|
||||
jd = sxtwl::toJD(t) - J2000;
|
||||
/*jd = SSQPtr->ZQ[24] + 1;*/
|
||||
|
||||
SSQPtr->calcY(jd);
|
||||
|
||||
jd2 = jd + dt_T(jd) - (long double)8 / (long double)24;;
|
||||
w = XL::S_aLon(jd2 / 36525, 3);
|
||||
w = int2((w - 0.13) / pi2 * 24) * pi2 / 24;
|
||||
|
||||
|
||||
for (auto it = SSQPtr->ZQ.begin(); it != SSQPtr->ZQ.end(); ++it)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
d = qi_accurate(w);
|
||||
D = int2(d + 0.5);
|
||||
xn = int2(w / pi2 * 24 + 24000006.01) % 24;
|
||||
w += pi2 / 24;
|
||||
// 这里可能会有误差,实际的不等相等
|
||||
if (abs(int2(*it) - D) <= 5)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (D < *it) continue;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (xn == ret[ret.size() - 1].jqIndex)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Time t1 = JD::JD2DD(d);
|
||||
Time t2 = JD::JD2DD(*it + J2000);
|
||||
|
||||
t2.h = t1.h;
|
||||
t2.m = t1.m;
|
||||
t2.s = t1.s;
|
||||
|
||||
|
||||
auto jd = JD::toJD(t2);
|
||||
|
||||
JieQiInfo tmp;
|
||||
tmp.jd = jd;
|
||||
tmp.jqIndex = xn;
|
||||
|
||||
ret.push_back(tmp);
|
||||
|
||||
|
||||
if (ret.size() >= 25) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
33
src/sxtwl.h
Normal file
33
src/sxtwl.h
Normal file
@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
#include "SSQ.h"
|
||||
#include <functional>
|
||||
#include "day.h"
|
||||
|
||||
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);
|
||||
};
|
121
swig/sxtwl.i
Normal file
121
swig/sxtwl.i
Normal file
@ -0,0 +1,121 @@
|
||||
%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);
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user