
正文
包含vb.net如何显示农历的词条
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
vb.net获取年,月,日,时,分,秒
不是 有 函数嘛?
now() 就是 吧
取得 后 再 分离出你所需的,分别赋值 就行了,当然 还是 有 函数的
相关问答
Q1: VB.NET的阳历与农历转换的算法
根据经验, 这个算法非常复杂. 经过查找,终于得到一些资料, 在此愿与大家分享。 首先阴历以月为基本单位,一个月以新月出现的那一天为始直至下一个新月出现的前一天。 由于月亮公转的周期介于29到30天之间,阴历的一个月也就由新月出现时刻的早晚或是29天或是30天。 大月为30天,小月为29天。 与阳历不同的是,大小月在不同的年中不固定。 如春节的前一天常称为大年三十,但有不少年如2000年的阴历十二月只有29天。 由于十二个月的时间较阳历年即地球绕太阳公转一周的时间短11天左右. 为了使阴历年与阳历年保持相对稳定,每隔两三年就需要加入一个闰月。 大约每十九年要加入七个闰月。 而二十四节气则是由地球在绕太阳公转的轨道上的位置确定的。 以每年的冬至为始,每15度为一个节气。 是故二十四节气在阳历的每月中有大概固定的日期。 古时以二十四节气指导农耕,这就是阴历又称农历的原因。 其中阳历下半月的十二个节气又称为中气。 中气出现的时刻和闰月的确定有直接的关系。 阴历的计算有下列四条规则vb.net如何显示农历: 1.所有新月和节气出现的时刻的计算以东经120度即东八区标准时为准。 但计算1929年以前的阴历时应以北京即东经116度25分的当地时为准。 2.新月出现的一天为一个月的第一天。 如某个节气的出现时刻也在这一天,则不论该节气的出现时刻是否比新月晚,一律算落入新的一个月中。 3.每年的冬至总是落在这年的十一月中。 从一年的冬至的第二天起到下一年冬至这一天止的这段时间称为一岁。 如一岁中有十三个新月出现,则这一岁为闰岁,要加入一个闰月。 4.闰岁中第一个没有中气的月为闰月。 因为一岁中只有十二个中气,所以闰岁中至少有一个月没有中气,也存在有两个月没有中气的可能性。 但这种情况下只有第一个没有中气的月为闰月。 闰月的前一个月为几月则该闰月称为闰几月。 根据以上信息, 我们知道农历是根据天文观测进行指定的(也许可以在天文学的书上找到说明)。 为了简化转换计算, 很多程序人员设计了基于"时间段内查表"方法的例程. 更具体的说明和源码请参考下面这些资料vb.net如何显示农历:
Q2: .net时间怎么显示农历
NET类库提供一些基础的农历类System.Globalization.ChineseLunisolarCalendar
不需要自己写算法。直接用就行。
下边的代码是复制的:
using System;
using System.Collections.Generic;
using System.Text;
namespace System
...{
/**//// summary
/// 中国常用农历日期时间类
/// zj53hao@qq.com
/// /summary
class ChinaDateTime
...{
private int year, month, dayOfMonth;
private bool isLeap;
public DateTime time;
/**//// summary
/// 获取当前日期的农历年
/// /summary
public int Year
...{
get ...{ return year; }
}
/**//// summary
/// 获取当前日期的农历月份
/// /summary
public int Month
...{
get ...{ return month; }
}
/**//// summary
/// 获取当前日期的农历月中天数
/// /summary
public int DayOfMonth
...{
get ...{ return dayOfMonth; }
}
/**//// summary
/// 获取当前日期是否为闰月中的日期
/// /summary
public bool IsLeap
...{
get ...{ return isLeap; }
}
System.Globalization.ChineseLunisolarCalendar cc;
/**//// summary
/// 返回指定公历日期的阴历时间
/// /summary
/// param name="time"/param
public ChinaDateTime(DateTime time)
...{
cc = new System.Globalization.ChineseLunisolarCalendar();
if (time cc.MaxSupportedDateTime || time cc.MinSupportedDateTime)
throw new Exception("参数日期时间不在支持的范围内,支持范围:" + cc.MinSupportedDateTime.ToShortDateString()+"到"+cc.MaxSupportedDateTime.ToShortDateString());
year = cc.GetYear(time);
month = cc.GetMonth(time);
dayOfMonth = cc.GetDayOfMonth(time);
isLeap = cc.IsLeapMonth(year, month);
if (isLeap) month -= 1;
this.time = time;
}
/**//// summary
/// 返回当前日前的农历日期。
/// /summary
public static ChinaDateTime Now
...{
get ...{ return new ChinaDateTime(DateTime.Now); }
}
/**//// summary
/// 返回指定农历年,月,日,是否为闰月的农历日期时间
/// /summary
/// param name="Year"/param
/// param name="Month"/param
/// param name="DayOfMonth"/param
/// param name="IsLeap"/param
public ChinaDateTime(int Year, int Month, int DayOfMonth, bool IsLeap)
...{
if (Year = cc.MaxSupportedDateTime.Year || Year = cc.MinSupportedDateTime.Year)
throw new Exception("参数年份时间不在支持的范围内,支持范围:" + cc.MinSupportedDateTime.ToShortDateString() + "到" + cc.MaxSupportedDateTime.ToShortDateString());
if (Month 1 || Month 12)
throw new Exception("月份必须在1~12范围");
cc = new System.Globalization.ChineseLunisolarCalendar();
if(cc.GetLeapMonth(Year)!=MonthIsLeap)
throw new Exception("指定的月份不是当年的闰月");
if (cc.GetDaysInMonth(Year, IsLeap ? Month + 1 : Month) DayOfMonth || DayOfMonth 1)
throw new Exception("指定的月中的天数不在当前月天数有效范围");
year = Year;
month = Month;
dayOfMonth = DayOfMonth;
isLeap = IsLeap;
time = DateTime.Now;
}
/**//// summary
/// 获取当前农历日期的公历时间
/// /summary
public DateTime ToDateTime()
...{
return cc.ToDateTime(year, isLeap ? month + 1 : month, dayOfMonth, time.Hour, time.Minute, time.Second, time.Millisecond);
}
/**//// summary
/// 获取指定农历时间对应的公历时间
/// /summary
/// param name="CnTime"/param
/// returns/returns
public static DateTime ToDateTime(ChinaDateTime CnTime)
...{
return CnTime.ToDateTime();
}
/**//// summary
/// 获取指定公历时间转换为农历时间
/// /summary
/// param name="Time"/param
/// returns/returns
public static ChinaDateTime ToChinaDateTime(DateTime Time)
...{
return new ChinaDateTime(Time);
}
/**//// summary
关于vb.net如何显示农历和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。







