永发信息网

PowerBuilder 10.5。。根据阳历怎样计算农历公

答案:1  悬赏:30  手机版
解决时间 2021-04-04 11:00
PowerBuilder 10.5。。根据阳历怎样计算农历公
最佳答案

string ls_ret

//农历年1900 到 2050年 每年的信息数据:

long lunarinfo[151] = { &
19416, 19168, 42352, 21717, 53856, 55632, 91476, 22176, 39632, 21970, &
19168, 42422, 42192, 53840,119381, 46400, 54944, 44450, 38320, 84343, &
18800, 42160, 46261, 27216, 27968,109396, 11104, 38256, 21234, 18800, &
25958, 54432, 59984, 28309, 23248, 11104,100067, 37600,116951, 51536, &
54432,120998, 46416, 22176,107956, 9680, 37584, 53938, 43344, 46423, &
27808, 46416, 86869, 19872, 42448, 83315, 21200, 43432, 59728, 27296, &
44710, 43856, 19296, 43748, 42352, 21088, 62051, 55632, 23383, 22176, &
38608, 19925, 19152, 42192, 54484, 53840, 54616, 46400, 46496,103846, &
38320, 18864, 43380, 42160, 45690, 27216, 27968, 44870, 43872, 38256, &
19189, 18800, 25776, 29859, 59984, 27480, 21952, 43872, 38613, 37600, &
51552, 55636, 54432, 55888, 30034, 22176, 43959, 9680, 37584, 51893, &
43344, 46240, 47780, 44368, 21977, 19360, 42416, 86390, 21168, 43312, &
31060, 27296, 44368, 23378, 19296, 42726, 42208, 53856, 60005, 54576, &
23200, 30371, 38608, 19415, 19152, 42192,118966, 53840, 54560, 56645, &
46496, 22224, 21938, 18864, 42359, 42160, 43600,111189, 27936, 44448, &
84835 }

//公历每月的天数
long SolarMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}

//干
string Gan[10] = {"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"}
//支
string Zhi[12] = {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"}
//生肖
string Animals[12] = {"鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"}
//24节气
string SolarTerm[24] = {"小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", &
"小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至"}
//24节气的时间,以分来计
long sTermInfo[24] = {0, 21208, 42467, 63836, 85337, 107014, 128867, 150921, 173149, 195551, 218072, 240693, &
263343, 285989, 308563, 331033, 353350, 375494, 397447, 419210, 440795, 462224, 483532, 504758}

string nStr1[11] = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十"}
string nStr2[5] = {"初", "十", "廿", "卅", " "}
string MonthName[12] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}

long ll_year,ll_mon,ll_day
long ll_lyear,ll_lmon,ll_lday

//年,月,日
ll_year = year(ad_date)
ll_mon = month(ad_date)
ll_day = day(ad_date)

double ld_num
long ll_leap,ll_sumday,ll_leapdays
long ll_info,k,i
long ll_temp,ll_offset
boolean lb_isleap
string ls_bin,ls_code

ll_leap = 0
ll_temp = 0

//计算与1900-1-30 (农历1-1)的天数
ll_offset = daysafter(date("1900-1-30"),ad_date)

//计算农历

for i = 1900 to 2050
//求当年农历年的天数

ll_sumday = 348 //12个小月,每月29
k = 32768 //0x8000

ll_info = lunarinfo[i - 1900 + 1]

// do while k > 8 //0x8
// //与0x8000与操作,可得到是否是大月
// ll_temp = of_bitand(ll_info,k)
//
// if ll_temp = 1 then ll_sumday = ll_sumday + 1 //大月加1
//
// //对k进行二进制右移移一位操作
// ls_bin = of_dectobin(k) //转换成二进制字符串
//
// ls_code = mid(ls_bin,1,len(ls_bin) - 1) //右移一位
//
// k = of_bintodec(ls_code) //转换成十进制
//
// loop

//上一种算法太慢,其实就是判断ll_info的二进制值从右数第5位到第16位有几个1
//下面用字符串方法处理
ls_bin = of_dectobin_fixlen(ll_info,16)

for k = 1 to 12
ll_sumday = ll_sumday + integer(left(right(ls_bin,k + 4),1))
next

//计算农历年闰月的天数

//计算闰月的月份
ll_leap = of_bitand(ll_info,15)//与0xF进行与操作,到最后一位
if ll_leap > 0 then //有闰月,0为无闰月

ll_temp = of_bitand(ll_info, 65536) //与0x10000进行与操作

if ll_temp = 0 then //得到闰月天数
ll_leapdays = 29
else
ll_leapdays = 30
end if
else
ll_leapdays = 0
end if

//农历全年天数
ll_sumday = ll_sumday + ll_leapdays

ll_offset = ll_offset - ll_sumday

if ll_offset < 1 then exit

next

ll_offset = ll_offset + ll_sumday

//农历年
ll_lyear = i

lb_isleap = false

for i = 1 to 12
if ll_leap > 0 and i = ll_leap + 1 and lb_isleap = false then //闰月
lb_isleap = true
i = i - 1

//闰月的天数
ll_temp = ll_leapdays
else
//计算非闰月的天数:ll_lyear年i月的总天数
k = 65536 //0x10000

//对k进行二进制右移移i位操作
ls_bin = of_dectobin(k) //转换成二进制字符串

ls_code = mid(ls_bin,1,len(ls_bin) - i) //右移i位

k = of_bintodec(ls_code) //转换成十进制

if of_bitand(ll_info,k) > 0 then //得到大小月
ll_temp = 30
else
ll_temp = 29
end if

end if
ll_offset = ll_offset - ll_temp

if ll_offset < 0 then exit

next

ll_offset = ll_offset + ll_temp

//农历月
ll_lmon = i

//农历日
ll_lday = ll_offset

date ld_ldate
long ll_days

ld_ldate = date(string(ll_lyear) + "." + string(ll_lmon)+ "." + string(ll_lday))

//转换成农历的写法:

string ls_str,ls_mstr,ls_ystr,ls_astr

//农历年的干、支
ls_ystr = gan[mod(mod(ll_lyear - 1864, 60), 10) + 1] + zhi[mod(mod(ll_lyear - 1864, 60), 12) + 1]

//生肖
ls_astr = Animals[mod(ll_lyear - 1900, 12) + 1]

//月份
choose case ll_lmon
case 11
ls_mstr = '十一'
case 12
ls_mstr = '十二'
case else
if ll_lmon>11 or ll_lmon<=0 then
else
ls_mstr = nstr1[ll_lmon]
end if
end choose

//日期
choose case ll_lday
case 10
ls_str = '初十'
case 20
ls_str = '二十'
case 30
ls_str = '三十'
case else
if int(ll_lday / 10) + 1>=1 and int(ll_lday / 10) + 1<=5 then
ls_str = nstr2[int(ll_lday / 10) + 1]
end if
if mod(ll_lday,10)>11 or mod(ll_lday,10)<=0 then
else
ls_str += nstr1[mod(ll_lday,10)]
end if
end choose

ls_ret = '农历:' + ls_ystr + "年(" + ls_astr + ") ~r~n" + ls_mstr + "月" + ls_str

//计算农历上的节气,从1900.1.6 02:05:00 (小寒)开始

for i = 1 to 24
ld_num = (525948.76 * (ll_year - 1900) + sTerminfo[i]) / (24 * 60)

ll_days = daysafter(date('1900.1.6'),ad_date)

if ld_num - ll_days < 1 and ld_num - ll_days > -1 then
ls_ret = ls_ret + "~r~n节气:" + SolarTerm[i]
exit
end if

next

return ls_ret
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
beats studio wireless 2.0多少美元
发扬体育精神,弘扬爱国传统的诗歌
赞美女孩有才的诗句,赞美女生有那些语言
天津市渤海12号退潮时间
Error: Can't continue timing simulatio
American schools begin in September after
—What’s your full name?—Gina Miller. Gi
心情郁闷的成语(表示人的)
说明江南水乡的意境美
2015全国扫黄举报电话
亚克力雕刻倒角,倒角刀要原线输出吗?然后割
老九门小说和电视剧都有那些出入?
通常的望远镜(或显微镜)可看着由________个
想给本配一个无线鼠标,是usb接收器的好,还
手提电脑为什么玩不了cf
推荐资讯
一起走过原创英文歌用英语怎么说
寺院中的女僧人
丑女无敌 陈家明庆功会上放的那个视频
亲们╭(╯ε╰)╮,说说你们第一次进鬼屋的心
响沙湾旅游
让你判断猪心脏的左右侧,最简单的方法是A.将
工程认价施工方说明依据都有什么?甲方会问什
当你老了自己写的诗歌,别人打架用什么名言或
国庆去宝鸡关山牧场,人会不会太多,周边住宿
适合青少年阅读的1万字以内的全部文学名著有
在我国的能源结构中,燃煤约占70%.(1)某化
景点寻访纪录是什么意思啊
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?