一、层次结构

Object<-----Calendar<-----EastAsianLunisolarCalendar<-----ChineseLunisolarCalendar(农历)

二、用法

1、支持的最大,最小日期

System.Globalization.ChineseLunisolarCalendar cc =new System.Globalization.ChineseLunisolarCalendar();
s1=cc.MinSupportedDateTime.ToString("");//02/19/1901 00:00:00
s2=cc.MaxSupportedDateTime.ToString("");//01/28/2101 23:59:59

2、单位农历天数

System.Globalization.ChineseLunisolarCalendar cc =new System.Globalization.ChineseLunisolarCalendar();
s1=cc.GetMonthsInYear(DateTime.Now.Year).ToString();//12,一年中有几个月,13表示当年有闰月。
s2=cc.GetDaysInYear(DateTime.Now.Year).ToString();//354,一年中有多少天
s3=cc.GetDaysInMonth(DateTime.Now.Year,DateTime.Now.Month).ToString();//29 ,当月中有多少天

3、天干、地支

System.Globalization.ChineseLunisolarCalendar cc =new System.Globalization.ChineseLunisolarCalendar();
s1=cc.GetSexagenaryYear(DateTime.Now ).ToString();//36,天干
s2=cc.GetTerrestrialBranch().ToString();//12,地支

4、农历年、月、日

System.Globalization.ChineseLunisolarCalendar cc =new System.Globalization.ChineseLunisolarCalendar();
s1=cc.GetYear(DateTime.Now).ToString();//;2019
s2=cc.GetMonth(DateTime.Now).ToString();//;5,注意:其返回值为1-13的数,如果该年四月有闰月,4月返回4,闰4月则返回5
s3=cc.GetDayOfMonth(DateTime.Now).ToString();//;23

5、闰年与闰月

System.Globalization.ChineseLunisolarCalendar cc =new System.Globalization.ChineseLunisolarCalendar();
s1=cc.IsLeapYear(DateTime.Now.Year).ToString();//;False
s2=cc.GetLeapMonth(DateTime.Now.Year).ToString();//;0,注意:表示所闰月份。如果返回5,表示闰4月。

6、显示农历大写月份

string[] monthName = {"正",  "二", "三", "四", "五", "六", "七", "八", "九", "十", "东", "腊" };
System.Globalization.ChineseLunisolarCalendar cc = new System.Globalization.ChineseLunisolarCalendar();
int currentMonth = cc.GetMonth(DateTime.Today);
int leapMonth = cc.GetLeapMonth(DateTime.Today.Year);
string realMonth;
if (currentMonth < leapMonth)
realMonth = monthName[currentMonth];
else if (currentMonth == leapMonth)
realMonth = "闰" + monthName[currentMonth - ];
else
realMonth = monthName[currentMonth - ];
s1 = realMonth.ToString();//;五

中文日历Calendar的更多相关文章

  1. [习题]日历(Calendar)控件的障眼法(.Visible属性),使用时才出现?不用就消失?

    原文出處  http://www.dotblogs.com.tw/mis2000lab/archive/2013/09/02/calendar_icon_visible.aspx [习题]日历(Cal ...

  2. jQuery ui 中文日历

    jQuery ui 中文日历 <link href="css/jquery-ui-1.10.4.custom.min.css" rel="stylesheet&qu ...

  3. [习题]输入自己的生日(年/月/日)#2 -- 日历(Calendar)控件的时光跳跃,一次跳回五年、十年前?--TodaysDate属性、VisibleDate属性

    原文出處  http://www.dotblogs.com.tw/mis2000lab/archive/2013/06/10/calendar_visibledate_birthday_dropdow ...

  4. [Swift实际操作]七、常见概念-(7)日历Calendar和日期组件DateComponents

    本文将为你演示日历和日期组件的使用.通过日历的日期部件,可以获得日期的各个部分. 首先引入需要用到的界面工具框架 import UIKit 初始化一个日期对象,其值为当前的日期. let dt = D ...

  5. [Swift实际操作]七、常见概念-(8)日历Calendar和时区TimerZone

    本文将为你演示日历的一些属性,以及如何利用日历,查询是否为昨天.今天和明天. 首先引入需要用到的界面工具框架 import UIKit 然后生成一个日历对象,并获得用户当前的日历. var calen ...

  6. day18 时间:time:,日历:calendar,可以运算的时间:datatime,系统:sys, 操作系统:os,系统路径操作:os.path,跨文件夹移动文件,递归删除的思路,递归遍历打印目标路径中所有的txt文件,项目开发周期

    复习 ''' 1.跨文件夹导包 - 不用考虑包的情况下直接导入文件夹(包)下的具体模块 2.__name__: py自执行 '__main__' | py被导入执行 '模块名' 3.包:一系列模块的集 ...

  7. 七:日期类Date、日期格式化SimpleDateFormat、日历Calendar

    日期的格式转换:

  8. Java Calendar实现控制台日历

    public static void main(String[] args) throws IOException { //初始化日历对象 Calendar calendar = Calendar.g ...

  9. Java中的Calendar日历用法详解

    第一部分 Calendar介绍 public abstract class Calendar implements Serializable, Cloneable, Comparable<Cal ...

随机推荐

  1. mysql子查询用法

    mysql子查询用法 1 可以当值来用<pre>select id from hcyuyin_share where id=(select id from hcyuyin_share li ...

  2. [.Net Core] - Asp.Net Core 编译成功,发布失败之解决

    背景 Asp.Net Core 项目编译成功,发布失败. 错误 Assets file 'D:\……\obj\project.assets.json' doesn't have a target fo ...

  3. 【转】linux卸载mysql

    查看是否安装了MySQL执行命令rpm -qa | grep mysql 执行过程[root@localhost ~]# rpm -qa | grep mysqlmysql-community-lib ...

  4. Mysql 定时备份(mysqldump)

    #!/bin/bash today=`date +%Y-%m-%d` deleday=`date -d '7 day ago' +%Y-%m-%d` path=/home/data/mysqlback ...

  5. 前端小tite(随笔)

    前端 自定义居中#照片 万能s居中 .second-listleft{/*固定位置*/ position: relative; float: left; width: 25%; height: 100 ...

  6. Linux中request_irq()中断申请与处理说明

    1.  中断的理解 中断你可以理解为就是一种电信号,是由硬件设备产生的然后发送给处理器,处理器接收到中断后,就会马上向操作系统反映此信号,之后就是系统的工作了. 这里有两个注意的地方,第一中断是随时都 ...

  7. docker 实践四:数据管理

    这篇是关于 docker 的数据管理. 注:环境为 CentOS7,docker 19.03. 一般容器中管理数据主要有两种方式: 数据卷(Data Volumes):容器内数据直接映射到本地主机环境 ...

  8. dotnet Core学习之旅(三):创建项目

    [重要:文中所有外链不能确保永久有效]>创建解决方案 在VSCode上,可以使用来自开源力量的vscode扩展vscode-solution-explorer来增强VSCode对.NET项目的支 ...

  9. Android--文件存取

    import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.FileNotFoundExc ...

  10. AS3.0 位图翻转、旋转

    /* * * *-------------------------* * | *** 位图翻转.旋转 *** | * *-------------------------* * * 作 者:fengz ...