《拓文asp.net网站内容管理系统》官方演示站。
 设为首页  
 收藏本站
 作者:黄振安
 QQ:53854651
首 页 开源拓文.NET编程网站编程网页设计图形图像数据库软件工程留言本
    站内搜索:  
您现在的位置: 拓文网络 → .NET编程 → ASP.NET → 阴历阳历转换[正文]

热 门 文 章

相 关 文 章
  • ASP.NET性能优化
  • 在.NET框架应用程序中发送电子邮件
  • .net打包自动安装数据库
  • asp.net开发wap必备:更好的匹配手机设备
  • 用ashx动态生成文件
  • windows 2003下asp.Net站点无法使用用户名+密码的方
  • ASP.NET中17种正则表达式
  • 提高ASP.Net应用程序性能的十大方法
  • 一个通过web.Mail发送邮件的类
  • 在DataGrid里面根据日期的不同显示new图标
  • 阴历阳历转换
     
    [作者:不详    转贴自:不详    点击数:    更新时间:2006-4-6 16:00:43]


                //返回阴历iLunarYear年的总天数 1901年1月---2050年12月
                public int LunarYearDays(ushort iLunarYear)
                {
                    int Days;
                    uint tmp;
                    if ((iLunarYear < START_YEAR) || (iLunarYear > END_YEAR))
                    { return 0;};
                    Days = 0;
                    for (ushort i=1; i <= 12; i++)
                    {
                        tmp = LunarMonthDays(iLunarYear, i);
                        Days = Days + ((ushort)(tmp>>16) & 0xFFFF); //取高位
                        Days = Days + (ushort)(tmp); //取低位
                    }
                    return Days;
                }
      
                //计算从1901年1月1日过iSpanDays天后的阴历日期
                public void l_CalcLunarDate(out ushort iYear, out ushort iMonth, out ushort iDay, uint iSpanDays)
                {
                    uint tmp;
                    //阳历1901年2月19日为阴历1901年正月初一
                    //阳历1901年1月1日到2月19日共有49天
                    if (iSpanDays < 49)
                    {
                        iYear = START_YEAR - 1;
                        if (iSpanDays < 19)
                        {
                            iMonth = 11;
                            iDay = (ushort)(11 + iSpanDays);
                        }
                        else
                        {
                            iMonth = 12;
                            iDay = (ushort)(iSpanDays - 18);
                        }
                        return;
                    }
                    //下面从阴历1901年正月初一算起
                    iSpanDays = iSpanDays - 49;
                    iYear = START_YEAR;
                    iMonth = 1;
                    iDay = 1;
                    //计算年
                    tmp = (uint)LunarYearDays(iYear);
                    while (iSpanDays >= tmp)
                    {
                        iSpanDays = iSpanDays - tmp;
                        iYear++;
                        tmp = (uint)LunarYearDays(iYear);
                    }
                    //计算月
                    tmp = LunarMonthDays(iYear, iMonth); //取低位
                    while (iSpanDays >= tmp)
                    {
                        iSpanDays = iSpanDays - tmp;
                        if (iMonth == GetLeapMonth(iYear))
                        {
                            tmp = (LunarMonthDays(iYear, iMonth)>>16)&0xFFFF; //取高位
                            if (iSpanDays < tmp)
                            {break;}
                            iSpanDays = iSpanDays - tmp;
                        }
                        iMonth++;
                        tmp = LunarMonthDays(iYear,iMonth); //取低位
                    }
                    //计算日
                    iDay = (ushort)(iDay + iSpanDays);
                }
      
      
                //把iYear年格式化成天干记年法表示的字符串
                public string FormatLunarYear()
                {
                    string strYear;
                    string szText1 = "甲乙丙丁戊己庚辛壬癸";
                    string szText2 = "子丑寅卯辰巳午未申酉戌亥";
                    string szText3 = "鼠牛虎免龙蛇马羊猴鸡狗猪";
                    ushort iYear;
                    iYear = (ushort)(m_Date.Year);
                    strYear = szText1.Substring((iYear - 4) % 10, 1);
                    strYear = strYear + szText2.Substring((iYear - 4) % 12, 1);
                    strYear = strYear + " ";
                    strYear = strYear + szText3.Substring((iYear - 4) % 12, 1);
                    strYear = strYear + "年";
                    return strYear;
                }
            } //class CNDate
      
           
            void Main(DateTime date)
            {
                CNDate dt = new CNDate(DateTime.Today);
               
                Response.Write("今天是:" + dt.Date.ToString() + dt.GetConstellationName()+"<br>");
                Response.Write(dt.l_GetLunarHolDay()+"<br>");
                Response.Write(dt.GetLunarHolDay()+"<br>");
     
                Response.Write("闰月" + dt.GetLeapMonth(UInt16.Parse(date.Year.ToString()))+"<br>");
                Response.Write("2月的天数" + dt.LunarMonthDays(UInt16.Parse(date.Year.ToString()), UInt16.Parse(date.Month.ToString()))+"<br>");
                Response.Write("天数" + dt.LunarYearDays(UInt16.Parse(date.Year.ToString()))+"<br>");
                Response.Write("" + dt.FormatLunarYear()+"<br>");
               
            }
           
            void GetChunJie(int year)
            {
                for(int m=0;m<100;m++)
                {
                    DateTime date1=Convert.ToDateTime(year+"-01-01");               
                    CNDate dt = new CNDate(date1.AddDays(m));
                    if(dt.GetLunarHolDay()=="正月初一")
                    {
                        Response.Write(year+"年的春节是:"+date1.AddDays(m));
                        break;
                    }

                }
            }
        }
    }


    首页 | 1 | 2 | 3 | 4 | 5 | 6 | 尾页  共 6 页
     
    winner 打印本页 关闭窗口

         文 章 评 论
    评论人 查看该文章的评论 发表时间
       笔 名* : 0 50分 60分 70分 80分 90分 100分
    评论内容 *: (最多1000字。当前字数:0)


    没有相关评论,欢迎您参与!

    - 关于本站 - 网站帮助 - 下载声明 - 友情连接 - 网站地图 -
    Copyright © 2005-2006 myTopWin.Com. All Rights Reserved . [桂ICP备06004496号]