{"id":9103,"date":"2015-12-16T21:12:28","date_gmt":"2015-12-16T13:12:28","guid":{"rendered":"http:\/\/bohu.net\/blog\/?p=9103"},"modified":"2023-02-10T23:42:10","modified_gmt":"2023-02-10T15:42:10","slug":"%e5%86%9c%e8%bd%ac%e5%85%ac%e5%85%ac%e8%bd%ac%e5%86%9c-system-globalization-chineselunisolarcalendar-%e5%86%9c%e5%8e%86%e8%bd%ac%e5%85%ac%e5%8e%86%e5%85%ac%e5%8e%86%e8%bd%ac%e5%86%9c%e5%8e%86","status":"publish","type":"post","link":"https:\/\/www.bohu.net\/blog\/9103\/","title":{"rendered":"\u519c\u8f6c\u516c\/\u516c\u8f6c\u519c System.Globalization.ChineseLunisolarCalendar \u519c\u5386\u8f6c\u516c\u5386\/\u516c\u5386\u8f6c\u519c\u5386"},"content":{"rendered":"<p>\u9879\u76ee\u4e2d\u6709\u4e00\u4e2a\u751f\u65e5\u77ed\u4fe1\u63d0\u9192\u529f\u80fd\uff0c\u9700\u8981\u6bcf\u5e74\u63d0\u9192\u3002\u9009\u519c\u5386\uff0c \u6bcf\u5e74\u63d0\u9192\uff0c \u7b2c\u4e8c\u5e74\u7684\u516c\u5386\u662f\u4e0d\u4e00\u6837\u7684\uff0c\u6240\u4ee5\u6bcf\u4e00\u5e74\u7684\u90fd\u9700\u8981\u81ea\u5df1\u8ba1\u7b97\u3002<\/p>\n<p>\u8bbe\u8ba1\u7684\u8981\u6c42 \uff0c\u4ed6\u4eec\u8bf4\u56e0\u4e3a\u5e74\u7eaa\u5927\u7684\u4eba\u662f\u53ea\u8bb0\u5f97\u519c\u5386\u7684\u3002\u3002\u3002<\/p>\n<div>\u7f51\u4e0a\u8d44\u6599\u4e0d\u5c11\uff0c\u516c\u5386\u8f6c\u519c\u5386\u73b0\u6210\u7684\u4e00\u5806\u3002\u90fd\u662f\u7528\u5fae\u8f6f\u7684System.Globalization.ChineseLunisolarCalendar\u7c7b\u5199\u7684\uff0c<\/div>\n<div>\u4f46\u662f\u519c\u5386\u8f6c\u516c\u5386\u7684\u5f88\u5c11\uff0c\u4e5f\u6709\uff0c\u4f46\u90fd\u662f\u53ea\u63d0\u5230\u65b9\u6cd5\u7684\u8c03\u7528\uff0c\u6bd4\u5982\u4e0b\u9762\uff1a<\/div>\n<div><\/div>\n<div>\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-9772 size-full\" src=\"https:\/\/bohu.net\/blog\/wp-content\/uploads\/2015\/12\/20151122234809.png\" alt=\"\" width=\"458\" height=\"110\" srcset=\"https:\/\/www.bohu.net\/blog\/wp-content\/uploads\/2015\/12\/20151122234809.png 458w, https:\/\/www.bohu.net\/blog\/wp-content\/uploads\/2015\/12\/20151122234809-300x72.png 300w\" sizes=\"auto, (max-width: 458px) 85vw, 458px\" \/><\/div>\n<div><\/div>\n<div>\u6b63\u786e\u7684\u5e94\u8be5\u662f1982-10-12 \u3002\u7531\u4e8e \u5e76\u6ca1\u6709\u8be6\u7ec6\u8bf4\u5230\u5173\u952e\u7684\u95f0\u6708\u8ba1\u7b97\uff0c \u6240\u4ee5\u8d77\u521d\u5f88\u56f0\u60d1\uff0c\u4ee5\u4e3a\u8ba1\u7b97\u4e0d\u51c6\u786e\u3002<\/div>\n<div>\n<div>\n<p><img decoding=\"async\" src=\"file:\/\/\/C:\\Users\\Administrator\\Documents\\Tencent Files\\47404844\\Image\\Group\\7@_RLON0O@~W&#96;EQ0EK~A_BS.png\" alt=\"\" \/><\/p>\n<div>\n<p><img decoding=\"async\" src=\"file:\/\/\/C:\\Users\\Administrator\\Documents\\Tencent Files\\47404844\\Image\\Group\\7@_RLON0O@~W&#96;EQ0EK~A_BS.png\" alt=\"\" \/><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9773\" src=\"https:\/\/bohu.net\/blog\/wp-content\/uploads\/2015\/12\/20151122235510.png\" alt=\"\" width=\"148\" height=\"161\" \/><\/p>\n<div><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div>\u68c0\u67e5\u5168\u5e74\u7684\u6708\u4efd\uff0c\u53d1\u73b0\u6709\u56e0\u4e3a\u6709\u95f0\u6708\u7684\u60c5\u51b5\uff0c\u6709\u6da6\u6708\u5219\u5e94\u8be5\u4ece\u8be5\u95f0\u6708\u8d77\u6708\u4efd\u81ea\u52a8\u52a0\u4e00, \u59821982\u5e74\u6da6\u56db\u6708\uff0c\u6216\u5219\u95f0\u4e94\u6708\u4e3a6\u6708\uff0c\u540e\u9762\u7684\u6708\u52a0\u4e00\u5904\u7406\u3002<\/div>\n<div><\/div>\n<div>\u65b9\u4fbf\u7406\u89e3\u81ea\u5df1\u505a\u4e2a\u5bf9\u7167\u56fe\uff1a<\/div>\n<div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-9771 size-full\" src=\"https:\/\/bohu.net\/blog\/wp-content\/uploads\/2015\/12\/20151122233022.png\" alt=\"\" width=\"704\" height=\"269\" srcset=\"https:\/\/www.bohu.net\/blog\/wp-content\/uploads\/2015\/12\/20151122233022.png 704w, https:\/\/www.bohu.net\/blog\/wp-content\/uploads\/2015\/12\/20151122233022-300x115.png 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>\u6b63\u786e\u7684\u65b9\u6cd5\u662f\uff0c\u8981\u5148\u8ba1\u7b97\u5f53\u5e74\u519c\u5386\u751f\u65e5\u4e4b\u524d\u7684\u6708\u4efd\u6709\u6ca1\u6709\u95f0\u6708\uff0c<\/p>\n<p>\u6709\u4e86\u5c31 \u76f4\u63a5\u6784\u9020\u519c\u5386\u65e5\u671f\u5bf9\u8c61\u662f\u5c31\u628a\u519c\u5386\u7684\u6708+1 \u4e3a9\u6708\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9774\" src=\"https:\/\/bohu.net\/blog\/wp-content\/uploads\/2015\/12\/20151122235952.png\" alt=\"\" width=\"402\" height=\"21\" srcset=\"https:\/\/www.bohu.net\/blog\/wp-content\/uploads\/2015\/12\/20151122235952.png 402w, https:\/\/www.bohu.net\/blog\/wp-content\/uploads\/2015\/12\/20151122235952-300x16.png 300w\" sizes=\"auto, (max-width: 402px) 85vw, 402px\" \/><\/p>\n<p>\u53ea\u8981\u660e\u767d\u95f0\u6708\u8fd9\u4e00\u70b9\uff0c\u5176\u5b9e\u5c31\u5f88\u7b80\u5355\u4e86\uff01<\/p>\n<pre class=\"brush:csharp\">\/\/\/\/\/\/\/\/\/\/\/\n\/\/\u516c\u5386\u8f6c\u519c\u5386\n\/\/\/\/\/\/\/\/\/\/\/\n            DateTime date = Convert.ToDateTime(textBox1.Text);\t\/\/\u683c\u5f0f\uff1a2000-1-1\n            ChineseLunisolarCalendar cc = new ChineseLunisolarCalendar();\n\n            if (date &gt; cc.MaxSupportedDateTime || date &lt; cc.MinSupportedDateTime)  \n                MessageBox.Show(\"\u53c2\u6570\u65e5\u671f\u65f6\u95f4\u4e0d\u5728\u652f\u6301\u7684\u8303\u56f4\u5185,\u652f\u6301\u8303\u56f4\uff1a\"+cc.MinSupportedDateTime.ToShortDateString()+\"\u5230\"+cc.MaxSupportedDateTime.ToShortDateString());\n            \n            int year = cc.GetYear(date);\n            int month = cc.GetMonth(date);\n            int dayOfMonth = cc.GetDayOfMonth(date);\n            int leapMonth = cc.GetLeapMonth(year);\n            bool isLeapMonth = cc.IsLeapMonth(year, month);\n            bool isLeapYear = cc.IsLeapYear(year);\n\n            if (isLeapMonth || isLeapYear &amp;&amp; month &gt;= leapMonth)\n                month -= 1;\n\n            textBox2.Text = string.Concat(year, \"-\", month, \"-\", dayOfMonth);<\/pre>\n<pre class=\"brush:csharp\">\/\/\/\/\/\/\/\/\/\/\/\n\/\/\u519c\u5386\u8f6c\u516c\u5386\n\/\/\/\/\/\/\/\/\/\/\/\n\n\t    ChineseLunisolarCalendar cc = new ChineseLunisolarCalendar();\n            DateTime date = Convert.ToDateTime(textBox2.Text);\t\/\/\u683c\u5f0f\uff1a2000-1-1\n            int MonthsInYear = cc.GetMonthsInYear(date.Year);\n            int LeapMonth = cc.GetLeapMonth(date.Year, 1);\n            bool isLeapMonth = cc.IsLeapMonth(date.Year, date.Month);\n            bool isLeapYear = cc.IsLeapYear(date.Year);\n\n            if (isLeapMonth)\n                date = cc.ToDateTime(date.Year, date.Month - 1, date.Day, 0, 0, 0, 0);\n            else if(date.Month &gt; LeapMonth)\n                date = cc.ToDateTime(date.Year, date.Month + 1, date.Day, 0, 0, 0, 0);\n            else\n                date = cc.ToDateTime(date.Year, date.Month, date.Day, 0, 0, 0, 0);\n            \n            textBox1.Text = date.ToString(\"yyyy-MM-dd\");<\/pre>\n<p>\u8fd9\u662f\u4e00\u4e2aWinForm\u505a\u7684\u7684\u5b9e\u4f8bDemo:\u00a0<a href=\"http:\/\/bohu.net\/blog\/wp-content\/uploads\/2015\/11\/WindowsFormsApplication1.zip\">WindowsFormsApplication1<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9879\u76ee\u4e2d\u6709\u4e00\u4e2a\u751f\u65e5\u77ed\u4fe1\u63d0\u9192\u529f\u80fd\uff0c\u9700\u8981\u6bcf\u5e74\u63d0\u9192\u3002\u9009\u519c\u5386\uff0c \u6bcf\u5e74\u63d0\u9192\uff0c \u7b2c\u4e8c\u5e74\u7684\u516c\u5386\u662f\u4e0d\u4e00\u6837\u7684\uff0c\u6240\u4ee5\u6bcf\u4e00\u5e74\u7684\u90fd\u9700\u8981\u81ea &hellip; <a href=\"https:\/\/www.bohu.net\/blog\/9103\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u519c\u8f6c\u516c\/\u516c\u8f6c\u519c System.Globalization.ChineseLunisolarCalendar \u519c\u5386\u8f6c\u516c\u5386\/\u516c\u5386\u8f6c\u519c\u5386\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,4,12,42,26],"tags":[470,582],"class_list":["post-9103","post","type-post","status-publish","format-standard","hentry","category-net","category-c-net","category-windows","category-winform-","category-26","tag-470","tag-582"],"_links":{"self":[{"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/posts\/9103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/comments?post=9103"}],"version-history":[{"count":2,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/posts\/9103\/revisions"}],"predecessor-version":[{"id":9810,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/posts\/9103\/revisions\/9810"}],"wp:attachment":[{"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/media?parent=9103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/categories?post=9103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/tags?post=9103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}