CSDN博客

img yuanqingfei

阴历与阳历的对照

发表于2004/7/8 3:28:00  72276人阅读

很多人希望找到自己阴历对应的阳历是多少,对于这个非常简单的问题,万年历对于不经常上网的朋友竟然也是很困难,我决心解决这个问题。

下面我写了个Java小程序,利用了网上一些现有的资源,大家可以直接输入自己的阴历或者阳历生日,点“提交”就可以看到转变后的日期了。希望对大家有用。

http://three.freejsp.net/yuanqingfei/

 

感谢http://www.freejsp.net/?id=yuanqingfei提供空间支持

发信人: hjdwg (小鱼儿), 信区: MathTools        标  题: Re: 谁有阴历与阳历的对照 发信站: BBS 水木清华站 (Sat May 31 21:20:25 2003), 转信 巧了,我曾用matlab做了一个,现在贴上来。 function xx = LunarCalendar(y,m,d) %  function xx = LunarCalendar(y,m,d) %   %  农历查询,改编自某网页之JavaScript,欢迎改动 % %  Author:  hjdwg@0451.com if nargin==0;     cccc=clock;     y=cccc(1);m=cccc(2);d=cccc(3); end Animals={'鼠','牛','虎','兔','龙','蛇','马','羊','猴','鸡','狗','猪'}; solarTerm ={'小寒','大寒','立春','雨水','惊蛰','春分', ...         '清明','谷雨','立夏','小满','芒种','夏至', ...         '小暑','大暑','立秋','处暑','白露','秋分', ...         '寒露','霜降','立冬','小雪','大雪','冬至'}; CnDayStr={'初一', '初二', '初三', '初四', '初五', ...         '初六', '初七', '初八', '初九', '初十', ...         '十一', '十二', '十三', '十四', '十五', ...         '十六', '十七', '十八', '十九', '二十', ...         '廿一', '廿二', '廿三', '廿四', '廿五', ...         '廿六', '廿七', '廿八', '廿九', '三十'}; CnMonthStr= { '正', '二', '三', '四', '五', '六', '七', '八', '九', '十', '冬', '腊'}; monthName = {'JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC'}; lunarInfo=[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]; lYearDays=[384,354,355,383,354,355,384,354,355,384, ...         354,384,354,354,384,354,355,384,355,384, ...         354,354,384,354,354,385,354,355,384,354, ...         383,354,355,384,355,354,384,354,384,354, ...         354,384,355,354,385,354,354,384,354,384, ...         354,355,384,354,355,384,354,383,355,354, ...         384,355,354,384,355,353,384,355,384,354, ...         355,384,354,354,384,354,384,354,355,384, ...         355,354,384,354,384,354,354,384,355,355, ...         384,354,354,383,355,384,354,355,384,354, ...         354,384,354,355,384,354,385,354,354,384, ...         354,354,384,355,384,354,355,384,354,354, ...         384,354,355,384,354,384,354,354,384,355, ...         354,384,355,384,354,354,384,354,354,384, ...         355,355,384,354,384,354,354,384,354,355]; leapDays=[29,0,0,29,0,0,30,0,0,29, ...         0,29,0,0,30,0,0,29,0,30, ...         0,0,29,0,0,30,0,0,29,0, ...         29,0,0,29,0,0,30,0,30,0, ...         0,30,0,0,30,0,0,29,0,29, ...         0,0,30,0,0,30,0,29,0,0, ...         29,0,0,29,0,0,29,0,29,0, ...         0,29,0,0,29,0,29,0,0,30, ...         0,0,29,0,29,0,0,29,0,0, ...         29,0,0,29,0,29,0,0,29,0, ...         0,29,0,0,29,0,29,0,0,29, ...         0,0,29,0,29,0,0,30,0,0, ...         29,0,0,29,0,29,0,0,29,0, ...         0,29,0,29,0,0,30,0,0,29, ...         0,0,29,0,29,0,0,30,0,0]; leapMonth=[8,0,0,5,0,0,4,0,0,2, ...         0,6,0,0,5,0,0,2,0,7, ...         0,0,5,0,0,4,0,0,2,0, ...         6,0,0,5,0,0,3,0,7,0, ...         0,6,0,0,4,0,0,2,0,7, ...         0,0,5,0,0,3,0,8,0,0, ...         6,0,0,4,0,0,3,0,7,0, ...         0,5,0,0,4,0,8,0,0,6, ...         0,0,4,0,10,0,0,6,0,0, ...         5,0,0,3,0,8,0,0,5,0, ...         0,4,0,0,2,0,7,0,0,5, ...         0,0,4,0,9,0,0,6,0,0, ...         4,0,0,2,0,6,0,0,5,0, ...         0,3,0,7,0,0,6,0,0,5, ...         0,0,2,0,7,0,0,5,0,0];        offset=datenum(y,m,d)-datenum(1900,1,31)+1; dayCyl = offset + 40; monCyl = 14; cumLYearDays=cumsum([0,lYearDays]); LunarYear=find(offset>cumLYearDays); LunarYear=LunarYear(end); monCyl=monCyl+(LunarYear-1)*12;yearCyl = LunarYear+36; offset=offset-cumLYearDays(LunarYear); monthDays=[29,30]; monthDays=monthDays((bitand(lunarInfo(LunarYear),bitshift (65536,-(1:12)))~=0)+1); leap = leapMonth(LunarYear); if leap,     monthDays=[monthDays(1:leap),leapDays(LunarYear),monthDays(leap+1:end)]; end cumMonthDays=cumsum([0,monthDays]); LunarMonth=find(offset>cumMonthDays);LunarMonth=LunarMonth(end); offset=offset-cumMonthDays(LunarMonth); ch_run_ch=''; if leap      if  LunarMonth==(leap+1),ch_run_ch='闰'; end     if (LunarMonth>leap),LunarMonth=LunarMonth-1;end end monCyl=monCyl+LunarMonth; xx=['农历',Animals{rem(yearCyl-1,12)+1},'年',ch_run_ch,CnMonthStr{LunarMonth},'月',CnDayStr{offset}]; xx={xx;[cyclical(yearCyl),'年  ',cyclical(monCyl),'月  ',cyclical(dayCyl),'日']}; return function ganzhi=cyclical(num) Gan={'甲','乙','丙','丁','戊','己','庚','辛','壬','癸'}; Zhi={'子','丑','寅','卯','辰','巳','午','未','申','酉','戌','亥'}; ganzhi=[Gan{rem(num-1,10)+1},Zhi{rem(num-1,12)+1}]; 【 在 abcxyz2008 (木头) 的大作中提到: 】 : 各位,哪里有阴历与阳历的对照,我已知某一天的阳历日期,想知道阴历是多少,怎么 : 办?哪里有万年历? -- ※ 来源:·BBS 水木清华站 smth.org·[FROM: 211.68.38.167] 顺便把我自己的生日介绍一下,呵呵 >> LunarCalendar(1981,3,23)

ans =

    '农历鸡年二月十八'     '辛酉年  辛卯月  庚子日'

 

 

<script type="text/JavaScript"> alimama_pid="mm_10100948_184213_219218"; alimama_titlecolor="0000FF"; alimama_descolor ="000000"; alimama_bgcolor="FFFFFF"; alimama_bordercolor="E6E6E6"; alimama_linkcolor="008000"; alimama_bottomcolor="FFFFFF"; alimama_anglesize="0"; alimama_bgpic="0"; alimama_icon="0"; alimama_sizecode="31"; alimama_width=180; alimama_height=250; alimama_type=2; </script> <script src="http://a.alimama.cn/inf.js" type=text/javascript> </script>

0 0

相关博文

我的热门文章

img
取 消
img