Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
141 lines (129 loc) · 5.18 KB
/
Copy pathmain.cpp
File metadata and controls
141 lines (129 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include <iostream>
#include <sstream>
#include <vector>
#include "const.h"
#include "lunar.h"
#include "JD.h"
#include "day.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[] = {"初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一"};
void printDay(Day &day)
{
std::cout << "\n===================================================" << std::endl;
;
std::cout << "公历:" << day.y << "年" << (int)day.m << "月" << day.d << "日" << std::endl;
if (day.Lleap)
{
std::cout << "润" << ymc[day.Lmc] << "月" << rmc[day.Ldi] << "日" << std::endl;
}
else
{
std::cout << ymc[day.Lmc] << "月" << rmc[day.Ldi] << "日" << std::endl;
}
std::cout << "儒略历:JD" << J2000 + day.d0 << std::endl;
std::cout << "星期" << numCn[day.week] << std::endl;
std::cout << Gan[day.Lyear2.tg] << Zhi[day.Lyear2.dz] << "年"
<< Gan[day.Lmonth2.tg] << Zhi[day.Lmonth2.dz] << "月"
<< Gan[day.Lday2.tg] << Zhi[day.Lday2.dz] << "日"
<< std::endl;
std::cout << "距冬至" << day.cur_dz << "天" << std::endl;
std::cout << "距夏至" << day.cur_xz << "天" << std::endl;
std::cout << "距立秋" << day.cur_lq << "天" << std::endl;
std::cout << "距芒种" << day.cur_mz << "天" << std::endl;
std::cout << "距小暑" << day.cur_xs << "天" << std::endl;
};
int main()
{
SXDay day;
for (auto i = 1; i < 20; ++i)
{
Lunar lunar;
Day day2 = lunar.getDayBySolar(2017, 5, i);
day.initBySolar(2017, 5, i);
auto day1 = day.getDay();
auto year = day.getYear();
auto month = day.getMonth();
auto lday = day.getLDay();
auto lmonth = day.getLMonth();
auto lyear = day.getLYear();
auto isLun = day.isRun();
auto jqIndex = day.getJQIndex();
auto jqJd = day.getJQJD();
auto time = JD::JD2DD(jqJd + J2000);
printf("");
}
//#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
// Lunar lunar;
//
//
// // 根据天干地支反查
// ///1990-6-15 庚午年 壬午月 辛亥日
//
// GZ yearGz(6, 6);
// GZ yueGz(8, 6);
// GZ riGz(7, 11);
// GZ shiGz(2, 8);
// lunar.siZhu2Year(yearGz, yueGz, riGz, shiGz, 1990, 2100);
//
//
// //=============================================================================================================
// //获取年的润月
// int run_month = lunar.getRunMonth(1990);
// //============================================================================================================
// int month_num = lunar.getLunarMonthNum(1990, 5);
// //=============================================================================================================
// //通过阳历获取当天的信息。(可以用于阳历转阴历,获取当天星期几等功能)
// try
// {
// Day day = lunar.getDayBySolar(2010, 13, 10);
// printDay(day);
// }
// catch (LunarException e)
// {
// std::cout << e.what() << std::endl;
// }
//
// //=============================================================================================================
// //通过阴历获取当天的信息。(可以用于阴历转阳历等,获取当天星期几等功能)
// Day day2 = lunar.getDayByLunar(1995, 12, 10);
// printDay(day2);
// //=============================================================================================================
// Month month = lunar.yueLiCalc(1990, 7);
//
// std::cout << month.y << "年" << (int)month.m << "月" << std::endl;
// std::cout << Gan[month.yearGan] << Zhi[month.yearZhi] << "年" << std::endl;
// std::cout << "生肖:" << ShX[month.ShX] << std::endl;
//
// std::vector<Day> &days = month.days;
// for (auto it = days.begin(); it != days.end(); ++it)
// {
// printDay((*it));
// }
// //=============================================================================================================
// return 0;
}