看网上没有swift的24节气,对比着翻译了一下

static func getLunarSpecialDate(iYear:Int,iMonth:Int,iDay:Int) -> String? {
        let chineseDays = [
            "小寒","大寒","立春","雨水","惊蛰","春分",

            "清明","谷雨","立夏","小满","芒种","夏至",

            "小暑","大暑","立秋","处暑","白露","秋分",

            "寒露","霜降","立冬","小雪","大雪","冬至"
        ]
        let array_index = (iYear - START_YEAR) * 12 + iMonth - 1
        let flag = gLunarHolDay[array_index]
        var day = 0
        if iDay < 15 {
            day = 15 - ((flag >> 4)&0x0f)
        }else {
            day = ((flag)&0x0f) + 15
        }
        var index = -1
        if iDay == day {
            index = (iMonth-1) * 2 + (iDay > 15 ? 1: 0);
        }
        
        if index >= 0 && index < chineseDays.count {
            return chineseDays[index]
        }
        return nil
    }
    
    
    public static let START_YEAR = 1901
    public static let END_YEAR = 2050
    
//24节气暂时只有(1901 - 2050)之间为准确的节气
    public static let  gLunarHolDay = [
    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x79,0x69, 0x78,0x77,  //1901

    0x96,0xA4, 0x96,0x96, 0x97,0x87, 0x79,0x79, 0x79,0x69, 0x78,0x78,  //1902

    0x96,0xA5, 0x87,0x96, 0x87,0x87, 0x79,0x69, 0x69,0x69, 0x78,0x78,  //1903

    0x86,0xA5, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x79, 0x78,0x87,  //1904

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x79,0x69, 0x78,0x77,  //1905

    0x96,0xA4, 0x96,0x96, 0x97,0x97, 0x79,0x79, 0x79,0x69, 0x78,0x78,  //1906

    0x96,0xA5, 0x87,0x96, 0x87,0x87, 0x79,0x69, 0x69,0x69, 0x78,0x78,  //1907

    0x86,0xA5, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x69, 0x78,0x87,  //1908

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x79,0x69, 0x78,0x77,  //1909

    0x96,0xA4, 0x96,0x96, 0x97,0x97, 0x79,0x79, 0x79,0x69, 0x78,0x78,  //1910

    0x96,0xA5, 0x87,0x96, 0x87,0x87, 0x79,0x69, 0x69,0x69, 0x78,0x78,  //1911

    0x86,0xA5, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x69, 0x78,0x87,  //1912

    0x95,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x79,0x69, 0x78,0x77,  //1913

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x79,0x79, 0x79,0x69, 0x78,0x78,  //1914

    0x96,0xA5, 0x97,0x96, 0x97,0x87, 0x79,0x79, 0x69,0x69, 0x78,0x78,  //1915

    0x96,0xA5, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x79, 0x77,0x87,  //1916

    0x95,0xB4, 0x96,0xA6, 0x96,0x97, 0x78,0x79, 0x78,0x69, 0x78,0x87,  //1917

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x79,0x79, 0x79,0x69, 0x78,0x77,  //1918

    0x96,0xA5, 0x97,0x96, 0x97,0x87, 0x79,0x79, 0x69,0x69, 0x78,0x78,  //1919

    0x96,0xA5, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x79, 0x77,0x87,  //1920

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x78,0x79, 0x78,0x69, 0x78,0x87,  //1921

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x79,0x79, 0x79,0x69, 0x78,0x77,  //1922

    0x96,0xA4, 0x96,0x96, 0x97,0x87, 0x79,0x79, 0x69,0x69, 0x78,0x78,  //1923

    0x96,0xA5, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x79, 0x77,0x87,  //1924

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x78,0x79, 0x78,0x69, 0x78,0x87,  //1925

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x79,0x69, 0x78,0x77,  //1926

    0x96,0xA4, 0x96,0x96, 0x97,0x87, 0x79,0x79, 0x79,0x69, 0x78,0x78,  //1927

    0x96,0xA5, 0x96,0xA5, 0x96,0x96, 0x88,0x78, 0x78,0x78, 0x87,0x87,  //1928

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x79, 0x77,0x87,  //1929

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x79,0x69, 0x78,0x77,  //1930

    0x96,0xA4, 0x96,0x96, 0x97,0x87, 0x79,0x79, 0x79,0x69, 0x78,0x78,  //1931

    0x96,0xA5, 0x96,0xA5, 0x96,0x96, 0x88,0x78, 0x78,0x78, 0x87,0x87,  //1932

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x69, 0x78,0x87,  //1933

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x79,0x69, 0x78,0x77,  //1934

    0x96,0xA4, 0x96,0x96, 0x97,0x97, 0x79,0x79, 0x79,0x69, 0x78,0x78,  //1935

    0x96,0xA5, 0x96,0xA5, 0x96,0x96, 0x88,0x78, 0x78,0x78, 0x87,0x87,  //1936

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x69, 0x78,0x87,  //1937

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x79,0x69, 0x78,0x77,  //1938

    0x96,0xA4, 0x96,0x96, 0x97,0x97, 0x79,0x79, 0x79,0x69, 0x78,0x78,  //1939

    0x96,0xA5, 0x96,0xA5, 0x96,0x96, 0x88,0x78, 0x78,0x78, 0x87,0x87,  //1940

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x69, 0x78,0x87,  //1941

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x79,0x69, 0x78,0x77,  //1942

    0x96,0xA4, 0x96,0x96, 0x97,0x97, 0x79,0x79, 0x79,0x69, 0x78,0x78,  //1943

    0x96,0xA5, 0x96,0xA5, 0xA6,0x96, 0x88,0x78, 0x78,0x78, 0x87,0x87,  //1944

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x79, 0x77,0x87,  //1945

    0x95,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x78,0x69, 0x78,0x77,  //1946

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x79,0x79, 0x79,0x69, 0x78,0x78,  //1947

    0x96,0xA5, 0xA6,0xA5, 0xA6,0x96, 0x88,0x88, 0x78,0x78, 0x87,0x87,  //1948

    0xA5,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x79, 0x78,0x79, 0x77,0x87,  //1949

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x78,0x79, 0x78,0x69, 0x78,0x77,  //1950

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x79,0x79, 0x79,0x69, 0x78,0x78,  //1951

    0x96,0xA5, 0xA6,0xA5, 0xA6,0x96, 0x88,0x88, 0x78,0x78, 0x87,0x87,  //1952

    0xA5,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x79, 0x77,0x87,  //1953

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x78,0x79, 0x78,0x68, 0x78,0x87,  //1954

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x79,0x69, 0x78,0x77,  //1955

    0x96,0xA5, 0xA5,0xA5, 0xA6,0x96, 0x88,0x88, 0x78,0x78, 0x87,0x87,  //1956

    0xA5,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x79, 0x77,0x87,  //1957

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x69, 0x78,0x87,  //1958

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x79,0x69, 0x78,0x77,  //1959

    0x96,0xA4, 0xA5,0xA5, 0xA6,0x96, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //1960

    0xA5,0xB4, 0x96,0xA5, 0x96,0x96, 0x88,0x78, 0x78,0x78, 0x87,0x87,  //1961

    0x96,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x69, 0x78,0x87,  //1962

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x79,0x69, 0x78,0x77,  //1963

    0x96,0xA4, 0xA5,0xA5, 0xA6,0x96, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //1964

    0xA5,0xB4, 0x96,0xA5, 0x96,0x96, 0x88,0x78, 0x78,0x78, 0x87,0x87,  //1965

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x69, 0x78,0x87,  //1966

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x79,0x69, 0x78,0x77,  //1967

    0x96,0xA4, 0xA5,0xA5, 0xA6,0xA6, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //1968

    0xA5,0xB4, 0x96,0xA5, 0x96,0x96, 0x88,0x78, 0x78,0x78, 0x87,0x87,  //1969

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x69, 0x78,0x87,  //1970

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x79,0x69, 0x78,0x77,  //1971

    0x96,0xA4, 0xA5,0xA5, 0xA6,0xA6, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //1972

    0xA5,0xB5, 0x96,0xA5, 0xA6,0x96, 0x88,0x78, 0x78,0x78, 0x87,0x87,  //1973

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x69, 0x78,0x87,  //1974

    0x96,0xB4, 0x96,0xA6, 0x97,0x97, 0x78,0x79, 0x78,0x69, 0x78,0x77,  //1975

    0x96,0xA4, 0xA5,0xB5, 0xA6,0xA6, 0x88,0x89, 0x88,0x78, 0x87,0x87,  //1976

    0xA5,0xB4, 0x96,0xA5, 0x96,0x96, 0x88,0x88, 0x78,0x78, 0x87,0x87,  //1977

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x79, 0x78,0x87,  //1978

    0x96,0xB4, 0x96,0xA6, 0x96,0x97, 0x78,0x79, 0x78,0x69, 0x78,0x77,  //1979

    0x96,0xA4, 0xA5,0xB5, 0xA6,0xA6, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //1980

    0xA5,0xB4, 0x96,0xA5, 0xA6,0x96, 0x88,0x88, 0x78,0x78, 0x77,0x87,  //1981

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x79, 0x77,0x87,  //1982

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x78,0x79, 0x78,0x69, 0x78,0x77,  //1983

    0x96,0xB4, 0xA5,0xB5, 0xA6,0xA6, 0x87,0x88, 0x88,0x78, 0x87,0x87,  //1984

    0xA5,0xB4, 0xA6,0xA5, 0xA6,0x96, 0x88,0x88, 0x78,0x78, 0x87,0x87,  //1985

    0xA5,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x79, 0x77,0x87,  //1986

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x79, 0x78,0x69, 0x78,0x87,  //1987

    0x96,0xB4, 0xA5,0xB5, 0xA6,0xA6, 0x87,0x88, 0x88,0x78, 0x87,0x86,  //1988

    0xA5,0xB4, 0xA5,0xA5, 0xA6,0x96, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //1989

    0xA5,0xB4, 0x96,0xA5, 0x96,0x96, 0x88,0x78, 0x78,0x79, 0x77,0x87,  //1990

    0x95,0xB4, 0x96,0xA5, 0x86,0x97, 0x88,0x78, 0x78,0x69, 0x78,0x87,  //1991

    0x96,0xB4, 0xA5,0xB5, 0xA6,0xA6, 0x87,0x88, 0x88,0x78, 0x87,0x86,  //1992

    0xA5,0xB3, 0xA5,0xA5, 0xA6,0x96, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //1993

    0xA5,0xB4, 0x96,0xA5, 0x96,0x96, 0x88,0x78, 0x78,0x78, 0x87,0x87,  //1994

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x76, 0x78,0x69, 0x78,0x87,  //1995

    0x96,0xB4, 0xA5,0xB5, 0xA6,0xA6, 0x87,0x88, 0x88,0x78, 0x87,0x86,  //1996

    0xA5,0xB3, 0xA5,0xA5, 0xA6,0xA6, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //1997

    0xA5,0xB4, 0x96,0xA5, 0x96,0x96, 0x88,0x78, 0x78,0x78, 0x87,0x87,  //1998

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x69, 0x78,0x87,  //1999

    0x96,0xB4, 0xA5,0xB5, 0xA6,0xA6, 0x87,0x88, 0x88,0x78, 0x87,0x86,  //2000

    0xA5,0xB3, 0xA5,0xA5, 0xA6,0xA6, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //2001

    0xA5,0xB4, 0x96,0xA5, 0x96,0x96, 0x88,0x78, 0x78,0x78, 0x87,0x87,  //2002

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x69, 0x78,0x87,  //2003

    0x96,0xB4, 0xA5,0xB5, 0xA6,0xA6, 0x87,0x88, 0x88,0x78, 0x87,0x86,  //2004

    0xA5,0xB3, 0xA5,0xA5, 0xA6,0xA6, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //2005

    0xA5,0xB4, 0x96,0xA5, 0xA6,0x96, 0x88,0x88, 0x78,0x78, 0x87,0x87,  //2006

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x69, 0x78,0x87,  //2007

    0x96,0xB4, 0xA5,0xB5, 0xA6,0xA6, 0x87,0x88, 0x87,0x78, 0x87,0x86,  //2008

    0xA5,0xB3, 0xA5,0xB5, 0xA6,0xA6, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //2009

    0xA5,0xB4, 0x96,0xA5, 0xA6,0x96, 0x88,0x88, 0x78,0x78, 0x87,0x87,  //2010

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x79, 0x78,0x87,  //2011

    0x96,0xB4, 0xA5,0xB5, 0xA5,0xA6, 0x87,0x88, 0x87,0x78, 0x87,0x86,  //2012

    0xA5,0xB3, 0xA5,0xB5, 0xA6,0xA6, 0x87,0x88, 0x88,0x78, 0x87,0x87,  //2013

    0xA5,0xB4, 0x96,0xA5, 0xA6,0x96, 0x88,0x88, 0x78,0x78, 0x87,0x87,  //2014

    0x95,0xB4, 0x96,0xA5, 0x96,0x97, 0x88,0x78, 0x78,0x79, 0x77,0x87,  //2015

    0x95,0xB4, 0xA5,0xB4, 0xA5,0xA6, 0x87,0x88, 0x87,0x78, 0x87,0x86,  //2016

    0xA5,0xC3, 0xA5,0xB5, 0xA6,0xA6, 0x87,0x88, 0x88,0x78, 0x87,0x87,  //2017

    0xA5,0xB4, 0xA6,0xA5, 0xA6,0x96, 0x88,0x88, 0x78,0x78, 0x87,0x87,  //2018

    0xA5,0xB4, 0x96,0xA5, 0x96,0x96, 0x88,0x78, 0x78,0x79, 0x77,0x87,  //2019

    0x95,0xB4, 0xA5,0xB4, 0xA5,0xA6, 0x97,0x87, 0x87,0x78, 0x87,0x86,  //2020

    0xA5,0xC3, 0xA5,0xB5, 0xA6,0xA6, 0x87,0x88, 0x88,0x78, 0x87,0x86,  //2021

    0xA5,0xB4, 0xA5,0xA5, 0xA6,0x96, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //2022

    0xA5,0xB4, 0x96,0xA5, 0x96,0x96, 0x88,0x78, 0x78,0x79, 0x77,0x87,  //2023

    0x95,0xB4, 0xA5,0xB4, 0xA5,0xA6, 0x97,0x87, 0x87,0x78, 0x87,0x96,  //2024

    0xA5,0xC3, 0xA5,0xB5, 0xA6,0xA6, 0x87,0x88, 0x88,0x78, 0x87,0x86,  //2025

    0xA5,0xB3, 0xA5,0xA5, 0xA6,0xA6, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //2026

    0xA5,0xB4, 0x96,0xA5, 0x96,0x96, 0x88,0x78, 0x78,0x78, 0x87,0x87,  //2027

    0x95,0xB4, 0xA5,0xB4, 0xA5,0xA6, 0x97,0x87, 0x87,0x78, 0x87,0x96,  //2028

    0xA5,0xC3, 0xA5,0xB5, 0xA6,0xA6, 0x87,0x88, 0x88,0x78, 0x87,0x86,  //2029

    0xA5,0xB3, 0xA5,0xA5, 0xA6,0xA6, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //2030

    0xA5,0xB4, 0x96,0xA5, 0x96,0x96, 0x88,0x78, 0x78,0x78, 0x87,0x87,  //2031

    0x95,0xB4, 0xA5,0xB4, 0xA5,0xA6, 0x97,0x87, 0x87,0x78, 0x87,0x96,  //2032

    0xA5,0xC3, 0xA5,0xB5, 0xA6,0xA6, 0x88,0x88, 0x88,0x78, 0x87,0x86,  //2033

    0xA5,0xB3, 0xA5,0xA5, 0xA6,0xA6, 0x88,0x78, 0x88,0x78, 0x87,0x87,  //2034

    0xA5,0xB4, 0x96,0xA5, 0xA6,0x96, 0x88,0x88, 0x78,0x78, 0x87,0x87,  //2035

    0x95,0xB4, 0xA5,0xB4, 0xA5,0xA6, 0x97,0x87, 0x87,0x78, 0x87,0x96,  //2036

    0xA5,0xC3, 0xA5,0xB5, 0xA6,0xA6, 0x87,0x88, 0x88,0x78, 0x87,0x86,  //2037

    0xA5,0xB3, 0xA5,0xA5, 0xA6,0xA6, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //2038

    0xA5,0xB4, 0x96,0xA5, 0xA6,0x96, 0x88,0x88, 0x78,0x78, 0x87,0x87,  //2039

    0x95,0xB4, 0xA5,0xB4, 0xA5,0xA6, 0x97,0x87, 0x87,0x78, 0x87,0x96,  //2040

    0xA5,0xC3, 0xA5,0xB5, 0xA5,0xA6, 0x87,0x88, 0x87,0x78, 0x87,0x86,  //2041

    0xA5,0xB3, 0xA5,0xB5, 0xA6,0xA6, 0x88,0x88, 0x88,0x78, 0x87,0x87,  //2042

    0xA5,0xB4, 0x96,0xA5, 0xA6,0x96, 0x88,0x88, 0x78,0x78, 0x87,0x87,  //2043

    0x95,0xB4, 0xA5,0xB4, 0xA5,0xA6, 0x97,0x87, 0x87,0x88, 0x87,0x96,  //2044

    0xA5,0xC3, 0xA5,0xB4, 0xA5,0xA6, 0x87,0x88, 0x87,0x78, 0x87,0x86,  //2045

    0xA5,0xB3, 0xA5,0xB5, 0xA6,0xA6, 0x87,0x88, 0x88,0x78, 0x87,0x87,  //2046

    0xA5,0xB4, 0x96,0xA5, 0xA6,0x96, 0x88,0x88, 0x78,0x78, 0x87,0x87,  //2047

    0x95,0xB4, 0xA5,0xB4, 0xA5,0xA5, 0x97,0x87, 0x87,0x88, 0x86,0x96,  //2048

    0xA4,0xC3, 0xA5,0xA5, 0xA5,0xA6, 0x97,0x87, 0x87,0x78, 0x87,0x86,  //2049

    0xA5,0xC3, 0xA5,0xB5, 0xA6,0xA6, 0x87,0x88, 0x78,0x78, 0x87,0x87    //2050
    ]

你可能感兴趣的:(看网上没有swift的24节气,对比着翻译了一下)