惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Security Archives - TechRepublic
Security Archives - TechRepublic
O
OpenAI News
W
WeLiveSecurity
Hacker News: Ask HN
Hacker News: Ask HN
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Troy Hunt's Blog
L
LINUX DO - 最新话题
SecWiki News
SecWiki News
Schneier on Security
Schneier on Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
H
Heimdal Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Palo Alto Networks Blog
Project Zero
Project Zero
Attack and Defense Labs
Attack and Defense Labs
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Tor Project blog
Scott Helme
Scott Helme
T
Threat Research - Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
Spread Privacy
Spread Privacy
Cisco Talos Blog
Cisco Talos Blog
T
Threatpost
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
Google DeepMind News
Google DeepMind News
P
Privacy & Cybersecurity Law Blog
Know Your Adversary
Know Your Adversary
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
L
Lohrmann on Cybersecurity
Cloudbric
Cloudbric
I
Intezer
The Hacker News
The Hacker News
L
LINUX DO - 热门话题
AI
AI
B
Blog
S
Securelist
P
Proofpoint News Feed
量子位
Jina AI
Jina AI
V2EX - 技术
V2EX - 技术
T
The Exploit Database - CXSecurity.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
CERT Recently Published Vulnerability Notes
J
Java Code Geeks
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

博客园 - g無s所p畏

vs2019(vs2017)配置菜单发布nuget包 不同应用共享redis应用,但分数据库存储数据 常用JS判断各种格式,以及替换函数等 jquery工作小笔记:jquery获取页面上控件的值 Asp.net 常用的正则表达式汇集 SCOPE_IDENTITY()代替 @@IDENTITY iis预览.net发布的网站时遇到的莫名问题:无资源行。 sql 自动补位 数字人民币(RMB)转化为大写字母 2007年工作总结 .NET中AJAX乱码问题解决 图片无缝滚动 千万级通用的分页存储过程 生成验证码图片(含模糊背景) 求助:C#读取邮件 求助:一个能够验证到时、分甚至秒的脚本表达式 SQL中触发器实例讲解 SQL中CONVERT转化函数的用法 获取远程服务器的ip地址以及地区地址
将公历转换成农历的类_C#
g無s所p畏 · 2008-01-11 · via 博客园 - g無s所p畏

 class ClassNongLi
    {
        private string[] sNongLiList;
        private string[] sTGDZList;
        private string sShuXiangList;
        private string sNongLiMonthsList;
        private string sNongLiDaysList;
        private int iMaxGongLiYear;
        private int iMinGongLiYear;

        public ClassNongLi()
        {
            sNongLiList = new string[]   {
          "0100101101101080131 ",
          "0100101011100000219 ",
          "1010010101110000208 ",
          "0101001001101050129 ",
          "1101001001100000216 ",
          "1101100101010000204 ",
          "0110101010101040125 ",
          "0101011010100000213 ",
          "1001101011010000202 ",
          "0100101011101020122 ",
          "0100101011100000210 ",
          "1010010011011060130 ",
          "1010010011010000218 ",
          "1101001001010000206 ",
          "1101010101001050126 ",
          "1011010101010000214 ",
          "0101011010100000204 ",
          "1001011011010020123 ",
          "1001010110110000211 ",
          "0100100110111070201 ",
          "0100100110110000220 ",
          "1010010010110000208 ",
          "1011001001011050128 ",
          "0110101001010000216 ",
          "0110110101000000205 ",
          "1010110110101040124 ",
          "0010101101100000213 ",
          "1001010101110000202 ",
          "0100100101111020123 ",
          "0100100101110000210 ",
          "0110010010110060130 ",
          "1101010010100000217 ",
          "1110101001010000206 ",
          "0110110101001050126 ",
          "0101101011010000214 ",
          "0010101101100000204 ",
          "1001001101110030124 ",
          "1001001011100000211 ",
          "1100100101101070131 ",
          "1100100101010000219 ",
          "1101010010100000208 ",
          "1101101001010060127 ",
          "1011010101010000215 ",
          "0101011010100000205 ",
          "1010101011011040125 ",
          "0010010111010000213 ",
          "1001001011010000202 ",
          "1100100101011020122 ",
          "1010100101010000210 ",
          "1011010010101070129 ",
          "0110110010100000217 ",
          "1011010101010000206 ",
          "0101010110101050127 ",
          "0100110110100000214 ",
          "1010010110110000203 ",
          "0101001010111030124 ",
          "0101001010110000212 ",
          "1010100101010080131 ",
          "1110100101010000218 ",
          "0110101010100000208 ",
          "1010110101010060128 ",
          "1010101101010000215 ",
          "0100101101100000205 ",
          "1010010101110040125 ",
          "1010010101110000213 ",
          "0101001001100000202 ",
          "1110100100110030121 ",
          "1101100101010000209 ",
          "0101101010101070130 ",
          "0101011010100000217 ",
          "1001011011010000206 ",
          "0100101011101050127 ",
          "0100101011010000215 ",
          "1010010011010000203 ",
          "1101001001101040123 ",
          "1101001001010000211 ",
          "1101010100101080131 ",
          "1011010101000000218 ",
          "1011011010100000207 ",
          "1001011011010060128 ",
          "1001010110110000216 ",
          "0100100110110000205 ",
          "1010010010111040125 ",
          "1010010010110000213 ",
          "1011001001011100202 ",
          "0110101001010000220 ",
          "0110110101000000209 ",
          "1010110110101060129 ",
          "1010101101100000217 ",
          "1001001101110000206 ",
          "0100100101111050127 ",
          "0100100101110000215 ",
          "0110010010110000204 ",
          "0110101001010030123 ",
          "1110101001010000210 ",
          "0110101100101080131 ",
          "0101101011000000219 ",
          "1010101101100000207 ",
          "1001001101101050128 ",
          "1001001011100000216 ",
          "1100100101100000205 ",
          "1101010010101040124 ",
          "1101010010100000212 ",
          "1101101001010000201 ",
          "0101101010101020122 ",
          "0101011010100000209 ",
          "1010101011011070129 ",
          "0010010111010000218 ",
          "1001001011010000207 ",
          "1100100101011050126 ",
          "1010100101010000214 ",
          "1011010010100000214 "      
                        };
            sShuXiangList = "鼠牛虎兔龙蛇马羊猴鸡狗猪 ";
            sNongLiMonthsList = "正二三四五六七八九十寒腊 ";
            sNongLiDaysList = "初一初二初三初四初五初六初七初八初九初十十一十二十三十四十五十六十七十八十九二十廿一廿二廿三廿四廿五廿六廿七廿八廿九三十 ";
            iMaxGongLiYear = 2011;
            iMinGongLiYear = 1900;

            string strTG = "甲乙丙丁戊已庚辛壬癸 ";
            string strDZ = "子丑寅卯辰巳午未申酉戌亥 ";
            sTGDZList = new string[60];
            for (int i = 0; i < 60; i++)
            {
                sTGDZList[i] = strTG.Substring(i % 10, 1) + strDZ.Substring(i % 12, 1);
            }

        }

        public string GetNongLiDate(int iGongLiYear, int iGongLiMonth, int iGongLiDay)
        {
            if ((iGongLiYear < iMinGongLiYear) || (iGongLiYear > iMaxGongLiYear))
            {   //如果不是有效公历日期,退出。
                return "无效公历年份 ";
            }

            //   计算农历年
            int iNongLiYear;
            int iNongLiMonth;
            int iNongLiDay;


            iNongLiYear = iGongLiYear;
            //   农历新年月份
            iNongLiMonth = Convert.ToInt32((sNongLiList[iNongLiYear - iMinGongLiYear].Substring(15, 2)));
            //   农历新年日子
            iNongLiDay = Convert.ToInt32((sNongLiList[iNongLiYear - iMinGongLiYear].Substring(17, 2))); ;

            if ((iGongLiMonth < iNongLiMonth) || ((iGongLiMonth == iNongLiMonth) && (iGongLiDay < iNongLiDay)))
            {
                iNongLiYear--;
                //   农历新年月份
                iNongLiMonth = Convert.ToInt32((sNongLiList[iNongLiYear - iMinGongLiYear].Substring(15, 2)));
                //   农历新年日子
                iNongLiDay = Convert.ToInt32((sNongLiList[iNongLiYear - iMinGongLiYear].Substring(17, 2))); ;
            }

            //   计算农历月
            DateTime dtGongLiDate = new DateTime(iGongLiYear, iGongLiMonth, iGongLiDay);
            DateTime dtNongLiDate = new DateTime(iNongLiYear, iNongLiMonth, iNongLiDay);
            TimeSpan tsDateDev = dtGongLiDate - dtNongLiDate;
            int iDays = tsDateDev.Days;

            iNongLiMonth = 1;
            iNongLiDay = 1;
            bool bLeapMonth = false;
            for (int i = 0; i < iDays; i++)
            {
                iNongLiDay++;
                if (iNongLiDay == 30 + Convert.ToInt32(sNongLiList[iNongLiYear - iMinGongLiYear].Substring(iNongLiMonth - 1, 1)) ||
                (bLeapMonth && (iNongLiDay == 30 + Convert.ToInt32(sNongLiList[iNongLiYear - iMinGongLiYear].Substring(12, 1)))))
                {
                    if ((bLeapMonth == false) && (iNongLiMonth == Convert.ToInt32(sNongLiList[iNongLiYear - iMinGongLiYear].Substring(13, 2))))
                    {
                        bLeapMonth = true;
                    }
                    else
                    {
                        bLeapMonth = false;
                        iNongLiMonth++;
                    }
                    iNongLiDay = 1;
                }
                //else
                //{
                //    //ddddddddddddd
                //}
            }

            //   计算农历日
            string strNongLiDay = sNongLiDaysList.Substring((iNongLiDay - 1) * 2, 2);

            //   计算农历月
            string strNongLiMonth = sNongLiMonthsList.Substring(iNongLiMonth - 1, 1) + "月 ";
            if (bLeapMonth)
            {
                strNongLiMonth = "闰 " + strNongLiMonth;
            }

            //   农历年
            string strNongLiYear = Convert.ToString(iNongLiYear, 10) + "年 ";

            //   计算天干地支
            string strTGDZ = sTGDZList[(iNongLiYear - 4) % 60];

            //   计算属相
            string strShuXiang = sShuXiangList.Substring((iNongLiYear - 4) % 12, 1);

            //   返回农历日期
            return strShuXiang + ", " + strTGDZ + ", " + strNongLiYear + strNongLiMonth + strNongLiDay;
        }
    }