资源简介

(1)实现阴历与阳历的相互转换; (2)实现阳历、阴历与干支历的转换; (3)不仅包含传统阴历月的天数表,还新增历年干支月的天数表; (4)1900年<=历年<=2099年。

资源截图

代码片段和文件信息



classdef clsdate
    % This program converts for date among solardate lunardate and ganzhi-
    % date from (190024) to (20991231) except the conversion from gan-
    % zhidate to solardate and lunardate.
    % 
    % This Class contains 
    % (a) five properties:
    %       year; month; day; hour; isLeap;
    % (b) two static methods:
    %       YearDays=YearInfos2YearDays_GanZhiDate();
    %       YearDays=YearInfos2YearDays_LunarDate();
    % (c) three private methods:
    %       offset=LunarDate2DayOffset(obj);
    %       obj=DayOffset2LunarDate(objoffset);
    %       obj=DayOffset2GanZhiDate(objoffset);
    % (d) five general methods:
    %       obj=clsdate(yearmonthdayisLeap);
    %       obj=SolarDate2LunarDate(obj);
    %       obj=LunarDate2SolarDate(obj);
    %       obj=SolarDate2GanZhiDate(obj);
    %       obj=LunarDate2GanZhiDate(obj);
    %
    % Example:
    % [yymmdd]=datevec(date);
    % yy=2017;mm=7;dd=30;
    % clsdate(yymmdd).YearInfos2YearDays_GanZhiDate();
    % clsdate(yymmdd).SolarDate2LunarDate
    % clsdate(yymmdd).SolarDate2GanZhiDate
    % 
    % yy=2017;mm=6;dd=8;
    % clsdate(yymmdd1).YearInfos2YearDays_LunarDate;
    % clsdate(yymmdd1).LunarDate2SolarDate
    % clsdate(yymmdd1).LunarDate2GanZhiDate
    % 
    % Hunan University shengzhaochen@foxmail.com 2019.1.2
    % 
    % 
    
    properties
        year;
        month;
        day;
        hour;
        isLeap;
    end
    
    methods(Static=true)
        % -----------------------------------------------------------------
        function YearDays=YearInfos2YearDays_GanZhiDate()
            % YearDays=YearInfos2YearDays_GanZhiDate()
            % https://jieqi.51240.com/
            % 
            
            YearInfos_GanZhiDate = [
                %            /* encoding:
                %                       dddddddddddd
                %               bit%    223334332121
                %                       ............
                %               month%  123456789012
                %
                %            b_j = d means that the (j) month has (28+d)...
                %            days where j = ‘123456789012‘ means ...
                %            ‘寅卯辰巳午未申酉戌亥子丑‘ respectively.
                %            */
                ‘223334332121‘;                                                                  %  /* 1900 */
                ‘223343332212‘; ‘132433332212‘; ‘223334322212‘; ‘223334332130‘; ‘223343332212‘;  %  /* 1905 */
                ‘132343332212‘; ‘223334322212‘; ‘223334332130‘; ‘223343332212‘; ‘132343332212‘;  %  /* 1910 */
                ‘223334322212‘; ‘223334332130‘; ‘223343332211‘; ‘223343332212‘; ‘132433422212‘;  %  /* 1915 */
                ‘223334323121‘; ‘223343332211‘; ‘223343332212‘; ‘132433422212‘; ‘223334323121‘;  %  /* 1920 */
                ‘223343332121‘; ‘223343332212‘; ‘132433422212‘; ‘22333432

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件       16849  2019-01-02 13:37  clsdate.m

评论

共有 条评论

相关资源