Why are leap years used?

本文详细解释了闰年的概念及其存在的必要性,介绍了格里高利历和儒略历中闰年的计算规则,并探讨了不同历法对季节的影响。

February 29, 2008

Year 2008 is the next leap year, with 29 days in February. February 2008 has five Fridays - it starts and ends on a Friday. Between 1904 and 2096, leap years with same day of week for each date repeat every 28 years which means that the last time February had 5 Fridays was in 1980 and next time will be in 2036.

What is a leap year?

A leap year is a year with one extra day inserted into February, the leap year is 366 days with 29 days in February as opposed to the normal 28 days. (There are a few past exceptions to this)

Which years are leap years?

In the Gregorian calendar, which is the calendar used by most modern countries, the following rules decides which years are leap years:

  1. Every year divisible by 4 is a leap year.
  2. But every year divisible by 100 is NOT a leap year
  3. Unless the year is also divisible by 400, then it is still a leap year.

This means that year 1800, 1900, 2100, 2200, 2300 and 2500 are NOT leap years, while year 2000 and 2400 are leap years.

This actually means year 2000 is kind of special, as it is the first time the third rule is used in many parts of the world.

In the old Julian Calendar, there was only one rule: Every year divisible by 4 is a leap year. This calendar was used before the Gregorian calendar was adopted.

Why are leap years needed?

Leap years are needed so that the calendar is in alignment with the earth's motion around the sun.

Details

Note: The illustration does not have the right dimensions for the earth, sun and orbit path.

The mean time between two successive vernal equinoxes is called a tropical year, and it is about 365.2422 days long. This means that it takes 365.2422 days for the earth to make one revolution around the sun (the time is takes to orbit the sun).

Using a calendar with 365 days would result in an error of 0.2422 days or almost 6 hours per year. After 100 years, this calendar would be more than 24 days ahead of the seasons (tropical year), which is not a desirable situation. It is desirable to align the calendar with the seasons, and make the difference as small as possible.

By adding leap years approximately every 4th year, this difference between the calendar and the seasons can be reduced significantly, and the calendar will follow the seasons much more closely than without leap years.

(One day is here used in the sense of "mean solar day", which is the mean time between two transits of the sun across the meridian of the observer.)

Is there a perfect calendar?

None of the calendars used today are perfect, they go wrong by seconds, minutes, hours or days every year. To make a calendar even better, new leap year rules have to be introduced, complicating the calculation of the calendar even more. The currently used Gregorian calendar may need some modification a few thousand years ahead. A tropical year is approximately 365.242199 days, but it varies from year to year, because of influence by the other planets.

Name of calendar

Introduced

Average year

Approximate
error introduced

Gregorian calendar

AD 1582

365.2425 days

27 seconds (1 day every 3236 years)

Julian calendar

45 BC

365.25 days

11 minutes (1 day every 128 years)

365-day calendar

-

365 days

6 hours (1 day every 4 years)

Lunar calendar

ancient

12-13 moon-months

variable

A calendar like the Julian Calendar (with every 4th year as a leap year) was first introduced by king Ptolemy III, Egypt in 238 BC.
In ancient times, it was very usual to have lunar (moon) calendars, with 12 and/or 13 months every year. To align the calendar with the seasons the 13th month was inserted as a "leap month" every 2-3 years.

Note: Many other calendars have been and are still used throughout the world.

Change from Julian to Gregorian calendar

The Julian calendar had introduced too many leap days, so that vernal equinox did no longer happen around March 21, as it did back in AD 325 during the Council of Nicaea. The introduction of the Gregorian calendar should realign the calendar with the equinox, so a number of days had to be dropped when going from the Julian to the Gregorian calendar. The links below show the calendars with the days dropped when the change to the Gregorian calendar occurred:

  • The Gregorian calendar was first adopted in Italy , Poland , Portugal and Spain in 1582. This was done by dropping 10 days in October (Ottobre).
  • In Great Britain (and to-become USA ), the Gregorian calendar was adopted much later - 11 days were dropped in September 1752.
  • Sweden (and Finland ) had a "double" leap year in 1712 - two days were added to February, so that there was a date February 30, 1712. (This was done because the leap year in 1700 was dropped and Sweden 's calendar was not synchronized with any other calendar - by adding an extra day in 1712, they were back on the Julian calendar).
  • The old Julian calendar is currently (between year 1901-2099) 13 days past the Gregorian calendar (because too many leap years were added).

Other leap years facts

  • The Gregorian calendar has a 400 year long cycle and the calendars have the same week days -- February 29, 2008 is a Friday and February 29, 2408 is a Friday.
  • The Gregorian calendar has 97 leap years during those 400 years.
  • The longest time between two leap years is 8 years. Last time was between 1896 and 1904. The next time will be between 2096 and 2104.

Reference

Gregorian calendar n.[天文]格里历, 阳历

Julian calendar n. 罗马儒略历,公历

vernal equinox n.春分

equinox n.昼夜平分点, 春分或秋分

lunar calendar n.阴历

solar calendar n.阳历

solar day n.[]太阳日

tropical year n.回归年

orbit n.轨道, 势力范围, 生活常规, 眼眶vt....轨道而行vi.进入轨道, 沿轨道飞行, 盘旋

meridian n.子午线, 正午, 顶点, 全盛时期adj.子午线的, 正午的, 顶点的, 全盛时期的

 

TRACKBACK:http://www.timeanddate.com/date/leapyear.html

 
内容概要:本文是一篇关于使用RandLANet模型对SensatUrban数据集进行点云语义分割的实战教程,系统介绍了从环境搭建、数据准备、模型训练与测试到精度评估的完整流程。文章详细说明了在Ubuntu系统下配置TensorFlow 2.2、CUDA及cuDNN等深度学习环境的方法,并指导用户下载和预处理SensatUrban数据集。随后,逐步讲解RandLANet代码的获取与运行方式,包括训练、测试命令的执行与参数含义,以及如何监控训练过程中的关键指标。最后,教程涵盖测试结果分析、向官方平台提交结果、解读评估报告及可视化效果等内容,并针对常见问题提供解决方案。; 适合人群:具备一定深度学习基础,熟悉Python编程和深度学习框架,从事计算机视觉或三维点云相关研究的学生、研究人员及工程师;适合希望动手实践点云语义分割项目的初学者与进阶者。; 使用场景及目标:①掌握RandLANet网络结构及其在点云语义分割任务中的应用;②学会完整部署一个点云分割项目,包括数据处理、模型训练、测试与性能评估;③为参与相关竞赛或科研项目提供技术支撑。; 阅读建议:建议读者结合提供的代码链接和密码访问完整资料,在本地或云端环境中边操作边学习,重点关注数据格式要求与训练参数设置,遇到问题时参考“常见问题与解决技巧”部分及时排查。
内容概要:本文详细介绍了三相异步电机SVPWM-DTC(空间矢量脉宽调制-直接转矩控制)的Simulink仿真实现方法,结合DTC响应快与SVPWM谐波小的优点,构建高性能电机控制系统。文章系统阐述了控制原理,包括定子磁链观测、转矩与磁链误差滞环比较、扇区判断及电压矢量选择,并通过SVPWM技术生成固定频率PWM信号,提升系统稳态性能。同时提供了完整的Simulink建模流程,涵盖电机本体、磁链观测器、误差比较、矢量选择、SVPWM调制、逆变器驱动等模块的搭建与参数设置,给出了仿真调试要点与预期结果,如电流正弦性、转矩响应快、磁链轨迹趋圆等,并提出了模型优化与扩展方向,如改进观测器、自适应滞环、弱磁控制和转速闭环等。; 适合人群:电气工程、自动化及相关专业本科生、研究生,从事电机控制算法开发的工程师,具备一定MATLAB/Simulink和电机控制理论基础的技术人员。; 使用场景及目标:①掌握SVPWM-DTC控制策略的核心原理与实现方式;②在Simulink中独立完成三相异步电机高性能控制系统的建模与仿真;③通过仿真验证控制算法有效性,为实际工程应用提供设计依据。; 阅读建议:学习过程中应结合文中提供的电机参数和模块配置逐步搭建模型,重点关注磁链观测、矢量选择表和SVPWM调制的实现细节,仿真时注意滞环宽度与开关频率的调试,建议配合MATLAB官方工具箱文档进行参数校准与结果分析。
已经博主授权,源码转载自 https://pan.quark.cn/s/bf1e0d5b9490 本文重点阐述了Vue2.0多Tab切换组件的封装实践,详细说明了通过封装Tab切换组件达成多Tab切换功能,从而满足日常应用需求。 知识点1:Vue2.0多Tab切换组件的封装* 借助封装Tab切换组件,达成多Tab切换功能* 支持tab切换、tab定位、tab自动化仿React多Tab实现知识点2:TabItems组件的应用* 在index.vue文件中应用TabItems组件,借助name属性设定tab的标题* 通过:isContTab属性来设定tab的内容* 能够采用子组件作为tab的内容知识点3:TabItems组件的样式* 借助index.less文件来设定TabItems组件的样式* 设定tab的标题样式、背景色彩、边框样式等* 使用animation达成tab的切换动画知识点4:Vue2.0多Tab切换组件的构建* 借助运用Vue2.0框架,达成多Tab切换组件的封装* 使用Vue2.0的组件化理念,达成TabItems组件的封装* 通过运用Vue2.0的指令和绑定机制,达成tab的切换功能知识点5:Vue2.0多Tab切换组件的优势* 达成多Tab切换功能,满足日常应用需求* 支持tab切换、tab定位、tab自动化仿React多Tab实现* 能够满足多样的业务需求,具备良好的扩展性知识点6:Vue2.0多Tab切换组件的应用场景* 能够应用于多样的业务场景,例如:管理系统、电商平台、社交媒体等* 能够满足不同的业务需求,例如:多Tab切换、数据展示、交互式操作等* 能够与其它Vue2.0组件结合运用,达成复杂的业务逻辑Vue2.0多Tab切换组件的封装实例提供了...
<think>我们之前已经讨论过,`lunar_python`库中并没有`getLeapMonth`方法,并且属性`isleap`的正确形式是`isLeap`(注意大小写)。用户现在再次提到没有`getLeumonth`和`isleap`属性,可能是大小写问题或版本问题。 根据用户提供的引用[1]中的代码片段,它展示了一个将农历日期转换为公历日期的Java方法,但这与Python库`lunar_python`无关。引用[2]是C#的示例,也不相关。因此,我们忽略这些引用,专注于Python库的正确使用。 在`lunar_python`库中,我们使用以下方式: 1. 判断一个农历月份是否为闰月:使用`isLeap`属性(注意大写L)。 2. 获取闰月的月份:如果该年有闰月,那么闰月的月份可以通过创建该闰月的日期并获取月份(负数表示闰月)或通过其他方式。 但是,用户可能仍然遇到属性错误,所以我们来详细说明。 步骤: 1. 确认安装的库版本:建议使用最新版。 2. 检查属性的大小写:`isLeap`,不是`isleap`(小写l)或`getLeapMonth`。 下面我们提供完整的示例代码,并解释如何获取闰月信息。 注意:在`lunar_python`库中,农历日期对象`Lunar`有以下相关属性: - `year`: 农历年 - `month`: 农历月(整数,如果是闰月,则月份为负数,例如闰二月为-2) - `day`: 农历日 - `isLeap`: 布尔值,表示当前月份是否为闰月(注意:当月份为负数时,这个属性为True) 另外,我们还可以通过`Lunar`对象的其他方法来获取信息,例如`getMonthInChinese()`会返回包含“闰”字的中文月份(如“闰二月”)。 因此,要获取某一年是否有闰月以及闰月是哪个月,我们可以: 1. 先创建该年农历正月(或其他月份)的对象。 2. 通过该对象获取该年的闰月信息(使用`getLeapMonth`方法?不,实际上,库中并没有这个方法。我们可以通过另一种方式:检查该年每个月的`isLeap`属性,或者使用库提供的静态方法?) 实际上,库中有一个`Lunar`的静态方法`leapMonth(year)`可以获取某年的闰月月份(返回0表示无闰月,否则返回闰月的月份数字)。但是注意,这个方法在文档中可能没有明确说明,我们可以查看源码或尝试使用。 根据`lunar_python`的源码(https://github.com/6tail/lunar-python/blob/master/Python/lunar_python/Lunar.py): 我们发现有一个静态方法`leapMonth`: `def leapMonth(year): ...` 所以,我们可以这样使用: 示例代码: ```python from lunar_python import Lunar # 获取某年的闰月(返回0表示无闰月,否则返回闰月的月份,如2表示闰二月) leap_month = Lunar.leapMonth(2023) if leap_month > 0: print(f"{2023}年有闰月,闰{leap_month}月") else: print(f"{2023}年没有闰月") # 或者,我们可以创建一个闰月日期 # 注意:创建闰月日期时,月份用负数表示,例如闰二月用-2 # 判断一个日期是否是闰月 lunar_date = Lunar.fromYmd(2023, -2, 1) # 2023年闰二月初一 print(f"是否为闰月: {lunar_date.isLeap}") # 输出: True print(f"月份中文: {lunar_date.getMonthInChinese()}") # 输出: 闰二月 ``` 如果用户使用的是旧版本,可能没有`leapMonth`静态方法。因此,我们也可以使用另一种方法:遍历12个月,看是否有闰月。但这样效率较低,不推荐。 因此,解决用户的问题: 1. 使用`Lunar.leapMonth(year)`静态方法获取闰月月份(返回整数,0表示无闰月,正数表示闰几月)。 2. 使用`Lunar`对象的`isLeap`属性判断该日期是否为闰月。 注意:属性`isLeap`在对象创建时就已经确定,它取决于创建时传入的月份是否为负数(或者日期确实是闰月的那一天)。 如果用户尝试使用`lunar.getLeapMonth()`,那是不存在的,应该使用静态方法`Lunar.leapMonth(year)`。 所以,总结如下: 问题:`'Lunar' object has no attribute 'getLeapMonth'` 解决方案:不要使用`getLeapMonth`方法,而是使用静态方法`Lunar.leapMonth(year)`来获取闰月。 问题:`'Lunar' object has no attribute 'isleap'` 解决方案:使用`isLeap`属性(注意大写L),即`lunar.isLeap`。 完整示例: ```python from lunar_python import Lunar # 检查2023年的闰月 year = 2023 leap_month = Lunar.leapMonth(year) if leap_month > 0: print(f"{year}年有闰月,闰{leap_month}月") else: print(f"{year}年没有闰月") # 创建一个闰月日期(闰二月初一) lunar_date = Lunar.fromYmd(year, -leap_month, 1) # 注意:这里leap_month是正数,但我们用负数表示闰月 # 或者,如果leap_month为0,则不能创建,所以先判断 if leap_month > 0: lunar_date = Lunar.fromYmd(year, -leap_month, 1) # 检查这个日期是否是闰月 print(f"是否为闰月: {lunar_date.isLeap}") # 应该输出True # 获取中文月份 print(f"月份中文: {lunar_date.getMonthInChinese()}") # 输出"闰二月" ``` 注意:如果闰月不存在(leap_month为0),则不能传入负数月份,否则会抛出异常。 另外,创建闰月日期时,月份参数为负数,但绝对值是月份数。例如闰二月,则月份参数为-2。 所以,我们使用`-leap_month`来作为月份参数(因为leap_month是正数,例如2,那么-2表示闰二月)。 如果用户只是想判断某个月份是不是闰月,也可以这样创建日期对象,然后使用`isLeap`属性。 但是,如果用户没有具体的日期,只是想获取闰月信息,直接使用`Lunar.leapMonth(year)`即可。 最后,建议用户升级库到最新版本,以确保这些方法可用。 如果升级后仍然有问题,可能是库的API变更,请参考官方文档。 升级命令: ```bash pip install --upgrade lunar_python ``` 现在,我们根据上述内容编写回答。 </think> # 解决 `Lunar` 对象缺少 `getLeapMonth` 和 `isleap` 属性问题 在 `lunar_python` 库中,`Lunar` 对象确实没有 `getLeapMonth` 或 `isleap` 属性。这是常见的 API 使用误解,正确的方法如下: ## 正确获取闰月信息的方法 ### 1. 使用静态方法 `leapMonth(year)` 获取闰月月份 ```python from lunar_python import Lunar # 获取2023年的闰月(返回0表示无闰月,正数表示闰月月份) leap_month = Lunar.leapMonth(2023) print(f"2023年闰月: {'闰' + str(leap_month) + '月' if leap_month > 0 else '无闰月'}") # 输出: 2023年闰月: 闰2月 ``` ### 2. 使用 `isLeap` 属性判断具体日期是否为闰月 ```python # 创建闰二月初一的日期对象(注意负号表示闰月) lunar_date = Lunar.fromYmd(2023, -2, 1) # 使用正确的大小写属性 isLeap print(f"是否为闰月: {lunar_date.isLeap}") # 输出: True print(f"月份中文: {lunar_date.getMonthInChinese()}") # 输出: 闰二月 ``` ### 3. 完整示例:处理闰月信息 ```python def get_leap_info(year, month=None): """获取闰月信息""" leap_month = Lunar.leapMonth(year) info = { "year": year, "leap_month": leap_month, "has_leap": leap_month > 0 } if month: # 创建日期对象(负数月份表示闰月) lunar_date = Lunar.fromYmd(year, -month if month > 0 else month, 1) info.update({ "is_leap": lunar_date.isLeap, "chinese_month": lunar_date.getMonthInChinese() }) return info # 示例用法 print(get_leap_info(2023)) # 获取2023年闰月信息 print(get_leap_info(2023, 2)) # 检查2023年二月是否为闰月 ``` ## 常见问题解决方案 ### 问题1:属性大小写错误 - ❌ 错误写法:`lunar.isleap` - ✅ 正确写法:`lunar.isLeap` (注意大写L) ### 问题2:方法名错误 - ❌ 错误写法:`lunar.getLeapMonth()` - ✅ 正确写法:`Lunar.leapMonth(year)` (静态方法) ### 问题3:创建闰月日期 ```python # 正确创建闰月日期(月份加负号) lunar_date = Lunar.fromYmd(2023, -2, 1) # 闰二月初一 # 错误创建方式(会抛出异常) try: Lunar.fromYmd(2023, 2, 1, is_leap=True) # 无效参数 except Exception as e: print(f"错误: {e}") ``` ## 版本兼容性建议 ```bash # 升级到最新版本(推荐0.3.0+) pip install --upgrade lunar_python ``` ## 闰月转换公历示例 ```python # 将农历闰月日期转换为公历 lunar_date = Lunar.fromYmd(2023, -2, 1) # 2023年闰二月初一 solar_date = lunar_date.getSolar() print(f"公历日期: {solar_date.toYmd()}") # 输出: 2023-03-22 ``` [^1]: 引用[1]中提到的农历转公历逻辑在 `lunar_python` 中已封装为 `getSolar()` 方法
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值