ZWDS foundation course by Master aoefengshui. One-on-one teaching.

Author Topic: Gmuli Solar Calendar Class  (Read 2325 times)

0 Members and 1 Guest are viewing this topic.

Offline annutara

  • G51-G100
  • **
  • Posts: 99
  • Karma: +20/-0
  • Last Login:January 25, 2020, 12:02:14 AM
    • View Profile
Re: Gmuli Solar Calendar Class
« Reply #15 on: June 03, 2018, 11:12:01 PM »
I took a while to get the code ported to C#.net, and I'm releasing my version here for more pair of eyes to screen it.

If anybody find improvements or bugs, please shout out. I'm not sure I handle all transitions seamlessly.

    class ChineseSolarDateTime
    {
        // Acknowledgements: To Gumuli who provided his visual basic version for reference. I've made some modifications of my own in C#.
        // Releasing source code in the spirit of sharing and leveraging the community, according to GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
        // If you use this code, please release your code to the public domain as well.

        static readonly string 天干 = "甲乙丙丁戊己庚辛壬癸";
        static readonly string 地支 = "子丑寅卯辰巳午未申酉戌亥";
        static readonly string[] monthTransitions = new string[] { "09/08/1912", "10/09/1912", "11/08/1912", "12/07/1912", "01/06/1913", "02/04/1913", "03/06/1913", "04/05/1913", "05/06/1913", "06/06/1913", "07/08/1913", "08/08/1913", "09/08/1913", "10/09/1913", "11/08/1913", "12/08/1913", "01/06/1914", "02/04/1914", "03/06/1914", "04/05/1914", "05/06/1914", "06/06/1914", "07/08/1914", "08/08/1914", "09/08/1914", "10/09/1914", "11/08/1914", "12/08/1914", "01/06/1915", "02/04/1915", "03/06/1915", "04/05/1915", "05/06/1915", "06/07/1915", "07/08/1915", "08/08/1915", "09/09/1915", "10/09/1915", "11/08/1915", "12/07/1915", "01/06/1916", "02/05/1916", "03/06/1916", "04/05/1916", "05/06/1916", "06/06/1916", "07/07/1916", "08/08/1916", "09/08/1916", "10/08/1916", "11/08/1916", "12/06/1916", "01/06/1917", "02/04/1917", "03/06/1917", "04/05/1917", "05/06/1917", "06/06/1917", "07/08/1917", "08/08/1917", "09/08/1917", "10/09/1917", "11/08/1917", "12/08/1917", "01/06/1918", "02/04/1918", "03/06/1918", "04/05/1918", "05/06/1918", "06/06/1918", "07/08/1918", "08/08/1918", "09/08/1918", "10/09/1918", "11/08/1918", "12/08/1918", "01/06/1919", "02/05/1919", "03/06/1919", "04/06/1919", "05/06/1919", "06/07/1919", "07/08/1919", "08/08/1919", "09/09/1919", "10/09/1919", "11/08/1919", "12/08/1919", "01/06/1920", "02/05/1920", "03/06/1920", "04/05/1920", "05/06/1920", "06/06/1920", "07/07/1920", "08/08/1920", "09/08/1920", "10/08/1920", "11/08/1920", "12/07/1920", "01/06/1921", "02/04/1921", "03/06/1921", "04/05/1921", "05/06/1921", "06/06/1921", "07/08/1921", "08/08/1921", "09/08/1921", "10/09/1921", "11/08/1921", "12/07/1921", "01/06/1922", "02/04/1922", "03/06/1922", "04/05/1922", "05/06/1922", "06/06/1922", "07/08/1922", "08/08/1922", "09/08/1922", "10/09/1922", "11/08/1922", "12/08/1922", "01/06/1923", "02/05/1923", "03/06/1923", "04/06/1923", "05/06/1923", "06/07/1923", "07/08/1923", "08/08/1923", "09/09/1923", "10/09/1923", "11/08/1923", "12/08/1923", "01/06/1924", "02/05/1924", "03/06/1924", "04/05/1924", "05/06/1924", "06/06/1924", "07/07/1924", "08/08/1924", "09/08/1924", "10/08/1924", "11/08/1924", "12/07/1924", "01/06/1925", "02/04/1925", "03/06/1925", "04/05/1925", "05/06/1925", "06/06/1925", "07/08/1925", "08/08/1925", "09/08/1925", "10/09/1925", "11/08/1925", "12/07/1925", "01/06/1926", "02/04/1926", "03/06/1926", "04/05/1926", "05/06/1926", "06/06/1926", "07/08/1926", "08/07/1926", "09/08/1926", "10/09/1926", "11/08/1926", "12/08/1926", "01/06/1927", "02/05/1927", "03/06/1927", "04/06/1927", "05/06/1927", "06/07/1927", "07/08/1927", "08/08/1927", "09/09/1927", "10/09/1927", "11/08/1927", "12/08/1927", "01/06/1928", "02/05/1928", "03/06/1928", "04/05/1928", "05/06/1928", "06/06/1928", "07/07/1928", "08/08/1928", "09/08/1928", "10/08/1928", "11/07/1928", "12/07/1928", "01/06/1929", "02/04/1929", "03/06/1929", "04/05/1929", "05/06/1929", "06/06/1929", "07/07/1929", "08/08/1929", "09/08/1929", "10/09/1929", "11/08/1929", "12/07/1929", "01/06/1930", "02/04/1930", "03/06/1930", "04/05/1930", "05/06/1930", "06/06/1930", "07/08/1930", "08/08/1930", "09/08/1930", "10/09/1930", "11/08/1930", "12/08/1930", "01/06/1931", "02/05/1931", "03/06/1931", "04/06/1931", "05/06/1931", "06/07/1931", "07/08/1931", "08/08/1931", "09/08/1931", "10/09/1931", "11/08/1931", "12/08/1931", "01/06/1932", "02/05/1932", "03/06/1932", "04/05/1932", "05/06/1932", "06/06/1932", "07/07/1932", "08/08/1932", "09/08/1932", "10/08/1932", "11/07/1932", "12/07/1932", "01/06/1933", "02/04/1933", "03/06/1933", "04/05/1933", "05/06/1933", "06/06/1933", "07/07/1933", "08/08/1933", "09/08/1933", "10/09/1933", "11/08/1933", "12/07/1933", "01/06/1934", "02/04/1934", "03/06/1934", "04/05/1934", "05/06/1934", "06/06/1934", "07/08/1934", "08/08/1934", "09/08/1934", "10/09/1934", "11/08/1934", "12/08/1934", "01/06/1935", "02/05/1935", "03/06/1935", "04/06/1935", "05/06/1935", "06/06/1935", "07/08/1935", "08/08/1935", "09/08/1935", "10/09/1935", "11/08/1935", "12/08/1935", "01/06/1936", "02/05/1936", "03/06/1936", "04/05/1936", "05/06/1936", "06/06/1936", "07/07/1936", "08/08/1936", "09/08/1936", "10/08/1936", "11/07/1936", "12/07/1936", "01/06/1937", "02/04/1937", "03/06/1937", "04/05/1937", "05/06/1937", "06/06/1937", "07/07/1937", "08/08/1937", "09/08/1937", "10/09/1937", "11/08/1937", "12/07/1937", "01/06/1938", "02/04/1938", "03/06/1938", "04/05/1938", "05/06/1938", "06/06/1938", "07/08/1938", "08/08/1938", "09/08/1938", "10/09/1938", "11/08/1938", "12/08/1938", "01/06/1939", "02/05/1939", "03/06/1939", "04/06/1939", "05/06/1939", "06/06/1939", "07/08/1939", "08/08/1939", "09/08/1939", "10/09/1939", "11/08/1939", "12/08/1939", "01/06/1940", "02/04/1940", "03/06/1940", "04/05/1940", "05/06/1940", "06/06/1940", "07/07/1940", "08/08/1940", "09/08/1940", "10/08/1940", "11/07/1940", "12/07/1940", "01/06/1941", "02/04/1941", "03/06/1941", "04/05/1941", "05/06/1941", "06/06/1941", "07/07/1941", "08/08/1941", "09/08/1941", "10/09/1941", "11/08/1941", "12/07/1941", "01/06/1942", "02/04/1942", "03/06/1942", "04/05/1942", "05/06/1942", "06/06/1942", "07/08/1942", "08/08/1942", "09/08/1942", "10/09/1942", "11/08/1942", "12/08/1942", "01/06/1943", "02/05/1943", "03/06/1943", "04/06/1943", "05/06/1943", "06/06/1943", "07/08/1943", "08/08/1943", "09/08/1943", "10/09/1943", "11/08/1943", "12/08/1943", "01/06/1944", "02/05/1944", "03/06/1944", "04/05/1944", "05/05/1944", "06/06/1944", "07/07/1944", "08/08/1944", "09/08/1944", "10/08/1944", "11/07/1944", "12/07/1944", "01/06/1945", "02/04/1945", "03/06/1945", "04/05/1945", "05/06/1945", "06/06/1945", "07/07/1945", "08/08/1945", "09/05/1945", "10/08/1945", "11/08/1945", "12/07/1945", "01/06/1946", "02/04/1946", "03/06/1946", "04/05/1946", "05/06/1946", "06/06/1946", "07/08/1946", "08/08/1946", "09/08/1946", "10/09/1946", "11/08/1946", "12/08/1946", "01/06/1947", "02/04/1947", "03/06/1947", "04/05/1947", "05/06/1947", "06/06/1947", "07/08/1947", "08/08/1947", "09/08/1947", "10/09/1947", "11/08/1947", "12/08/1947", "01/06/1948", "02/04/1948", "03/05/1948", "04/05/1948", "05/05/1948", "06/06/1948", "07/07/1948", "08/07/1948", "09/08/1948", "10/08/1948", "11/07/1948", "12/07/1948", "01/05/1949", "02/04/1949", "03/06/1949", "04/05/1949", "05/06/1949", "06/06/1949", "07/07/1949", "08/08/1949", "09/08/1949", "10/08/1949", "11/08/1949", "12/07/1949", "01/06/1950", "02/04/1950", "03/06/1950", "04/05/1950", "05/06/1950", "06/06/1950", "07/08/1950", "08/08/1950", "09/08/1950", "10/09/1950", "11/08/1950", "12/08/1950", "01/06/1951", "02/04/1951", "03/06/1951", "04/05/1951", "05/06/1951", "06/06/1951", "07/08/1951", "08/08/1951", "09/08/1951", "10/09/1951", "11/08/1951", "12/08/1951", "01/06/1952", "02/05/1952", "03/05/1952", "04/05/1952", "05/05/1952", "06/06/1952", "07/07/1952", "08/07/1952", "09/08/1952", "10/08/1952", "11/07/1952", "12/07/1952", "01/05/1953", "02/04/1953", "03/06/1953", "04/05/1953", "05/06/1953", "06/06/1953", "07/07/1953", "08/08/1953", "09/08/1953", "10/08/1953", "11/08/1953", "12/07/1953", "01/06/1954", "02/04/1954", "03/06/1954", "04/05/1954", "05/06/1954", "06/06/1954", "07/08/1954", "08/08/1954", "09/08/1954", "10/09/1954", "11/08/1954", "12/07/1954", "01/06/1955", "02/04/1955", "03/06/1955", "04/05/1955", "05/06/1955", "06/06/1955", "07/08/1955", "08/08/1955", "09/08/1955", "10/09/1955", "11/08/1955", "12/08/1955", "01/06/1956", "02/05/1956", "03/05/1956", "04/05/1956", "05/05/1956", "06/06/1956", "07/07/1956", "08/07/1956", "09/08/1956", "10/08/1956", "11/07/1956", "12/07/1956", "01/05/1957", "02/04/1957", "03/07/1957", "04/05/1957", "05/06/1957", "06/06/1957", "07/07/1957", "08/08/1957", "09/08/1957", "10/08/1957", "11/08/1957", "12/07/1957", "01/06/1958", "02/04/1958", "03/06/1958", "04/05/1958", "05/06/1958", "06/06/1958", "07/07/1958", "08/08/1958", "09/08/1958", "10/09/1958", "11/08/1958", "12/07/1958", "01/06/1959", "02/04/1959", "03/06/1959", "04/05/1959", "05/06/1959", "06/06/1959", "07/08/1959", "08/08/1959", "09/08/1959", "10/09/1959", "11/08/1959", "12/08/1959", "01/06/1960", "02/05/1960", "03/05/1960", "04/05/1960", "05/05/1960", "06/06/1960", "07/07/1960", "08/07/1960", "09/07/1960", "10/08/1960", "11/07/1960", "12/07/1960", "01/05/1961", "02/04/1961", "03/06/1961", "04/05/1961", "05/06/1961", "06/06/1961", "07/07/1961", "08/08/1961", "09/08/1961", "10/08/1961", "11/07/1961", "12/07/1961", "01/06/1962", "02/04/1962", "03/06/1962", "04/05/1962", "05/06/1962", "06/06/1962", "07/07/1962", "08/08/1962", "09/08/1962", "10/09/1962", "11/08/1962", "12/07/1962", "01/06/1963", "02/04/1963", "03/06/1963", "04/05/1963", "05/06/1963", "06/06/1963", "07/08/1963", "08/08/1963", "09/08/1963", "10/09/1963", "11/08/1963", "12/08/1963", "01/06/1964", "02/05/1964", "03/05/1964", "04/05/1964", "05/05/1964", "06/06/1964", "07/07/1964", "08/07/1964", "09/07/1964", "10/08/1964", "11/07/1964", "12/07/1964", "01/05/1965", "02/04/1965", "03/06/1965", "04/05/1965", "05/06/1965", "06/06/1965", "07/07/1965", "08/08/1965", "09/08/1965", "10/08/1965", "11/07/1965", "12/07/1965", "01/06/1966", "02/04/1966", "03/06/1966", "04/05/1966", "05/06/1966", "06/06/1966", "07/07/1966", "08/08/1966", "09/08/1966", "10/09/1966", "11/08/1966", "12/07/1966", "01/06/1967", "02/04/1967", "03/06/1967", "04/05/1967", "05/06/1967", "06/06/1967", "07/08/1967", "08/08/1967", "09/08/1967", "10/09/1967", "11/08/1967", "12/08/1967", "01/06/1968", "02/04/1968", "03/05/1968", "04/05/1968", "05/05/1968", "06/05/1968", "07/07/1968", "08/07/1968", "09/07/1968", "10/08/1968", "11/07/1968", "12/07/1968", "01/05/1969", "02/04/1969", "03/06/1969", "04/05/1969", "05/06/1969", "06/06/1969", "07/07/1969", "08/08/1969", "09/08/1969", "10/08/1969", "11/07/1969", "12/07/1969", "01/06/1970", "02/04/1970", "03/06/1970", "04/05/1970", "05/05/1970", "06/06/1970", "07/07/1970", "08/08/1970", "09/08/1970", "10/09/1970", "11/08/1970", "12/07/1970", "01/06/1971", "02/04/1971", "03/06/1971", "04/05/1971", "05/06/1971", "06/06/1971", "07/08/1971", "08/08/1971", "09/08/1971", "10/09/1971", "11/08/1971", "12/08/1971", "01/06/1972", "02/05/1972", "03/05/1972", "04/05/1972", "05/05/1972", "06/05/1972", "07/07/1972", "08/07/1972", "09/07/1972", "10/08/1972", "11/07/1972", "12/07/1972", "01/05/1973", "02/04/1973", "03/06/1973", "04/05/1973", "05/05/1973", "06/06/1973", "07/07/1973", "08/08/1973", "09/08/1973", "10/08/1973", "11/07/1973", "12/07/1973", "01/06/1974", "02/04/1974", "03/06/1974", "04/05/1974", "05/06/1974", "06/06/1974", "07/07/1974", "08/08/1974", "09/08/1974", "10/09/1974", "11/08/1974", "12/07/1974", "01/06/1975", "02/04/1975", "03/06/1975", "04/05/1975", "05/06/1975", "06/06/1975", "07/08/1975", "08/08/1975", "09/08/1975", "10/09/1975", "11/08/1975", "12/08/1975", "01/06/1976", "02/05/1976", "03/05/1976", "04/04/1976", "05/05/1976", "06/05/1976", "07/07/1976", "08/07/1976", "09/07/1976", "10/08/1976", "11/07/1976", "12/07/1976", "01/05/1977", "02/04/1977", "03/06/1977", "04/05/1977", "05/05/1977", "06/06/1977", "07/07/1977", "08/07/1977", "09/08/1977", "10/08/1977", "11/07/1977", "12/07/1977", "01/06/1978", "02/04/1978", "03/06/1978", "04/05/1978", "05/06/1978", "06/06/1978", "07/07/1978", "08/08/1978", "09/08/1978", "10/08/1978", "11/08/1978", "12/07/1978", "01/06/1979", "02/04/1979", "03/06/1979", "04/05/1979", "05/06/1979", "06/06/1979", "07/08/1979", "08/08/1979", "09/08/1979", "10/09/1979", "11/08/1979", "12/08/1979", "01/06/1980", "02/05/1980", "03/05/1980", "04/04/1980", "05/05/1980", "06/05/1980", "07/07/1980", "08/07/1980", "09/07/1980", "10/08/1980", "11/07/1980", "12/07/1980", "01/05/1981", "02/04/1981", "03/06/1981", "04/05/1981", "05/05/1981", "06/06/1981", "07/07/1981", "08/07/1981", "09/08/1981", "10/08/1981", "11/07/1981", "12/07/1981", "01/06/1982", "02/04/1982", "03/06/1982", "04/05/1982", "05/06/1982", "06/06/1982", "07/07/1982", "08/08/1982", "09/08/1982", "10/08/1982", "11/08/1982", "12/07/1982", "01/06/1983", "02/04/1983", "03/06/1983", "04/05/1983", "05/06/1983", "06/06/1983", "07/08/1983", "08/08/1983", "09/07/1983", "10/09/1983", "11/08/1983", "12/08/1983", "01/06/1984", "02/04/1984", "03/05/1984", "04/04/1984", "05/05/1984", "06/05/1984", "07/07/1984", "08/07/1984", "09/07/1984", "10/08/1984", "11/07/1984", "12/07/1984", "01/05/1985", "02/04/1985", "03/05/1985", "04/05/1985", "05/05/1985", "06/06/1985", "07/07/1985", "08/07/1985", "09/08/1985", "10/08/1985", "11/07/1985", "12/07/1985", "01/04/1986", "02/04/1986", "03/06/1986", "04/05/1986", "05/06/1986", "06/06/1986", "07/07/1986", "08/08/1986", "09/08/1986", "10/08/1986", "11/08/1986", "12/07/1986", "01/06/1987", "02/04/1987", "03/06/1987", "04/04/1987", "05/06/1987", "06/06/1987", "07/07/1987", "08/08/1987", "09/08/1987", "10/09/1987", "11/08/1987", "12/07/1987", "01/06/1988", "02/04/1988", "03/05/1988", "04/04/1988", "05/05/1988", "06/05/1988", "07/07/1988", "08/07/1988", "09/07/1988", "10/08/1988", "11/07/1988", "12/07/1988", "01/05/1989", "02/04/1989", "03/05/1989", "04/05/1989", "05/05/1989", "06/06/1989", "07/07/1989", "08/07/1989", "09/07/1989", "10/08/1989", "11/07/1989", "12/07/1989", "01/05/1990", "02/04/1990", "03/06/1990", "04/05/1990", "05/06/1990", "06/06/1990", "07/07/1990", "08/08/1990", "09/08/1990", "10/08/1990", "11/08/1990", "12/07/1990", "01/06/1991", "02/04/1991", "03/06/1991", "04/04/1991", "05/06/1991", "06/06/1991", "07/07/1991", "08/08/1991", "09/08/1991", "10/09/1991", "11/08/1991", "12/07/1991", "01/08/1992", "02/04/1992", "03/05/1992", "04/04/1992", "05/05/1992", "06/05/1992", "07/07/1992", "08/07/1992", "09/07/1992", "10/08/1992", "11/07/1992", "12/07/1992", "01/05/1993", "02/04/1993", "03/05/1993", "04/05/1993", "05/05/1993", "06/06/1993", "07/07/1993", "08/07/1993", "09/07/1993", "10/08/1993", "11/07/1993", "12/07/1993", "01/05/1994", "02/04/1994", "03/06/1994", "04/05/1994", "05/06/1994", "06/06/1994", "07/07/1994", "08/08/1994", "09/08/1994", "10/08/1994", "11/07/1994", "12/07/1994", "01/06/1995", "02/04/1995", "03/06/1995", "04/05/1995", "05/06/1995", "06/06/1995", "07/07/1995", "08/08/1995", "09/08/1995", "10/09/1995", "11/08/1995", "12/07/1995", "01/06/1996", "02/04/1996", "03/05/1996", "04/04/1996", "05/05/1996", "06/05/1996", "07/07/1996", "08/07/1996", "09/07/1996", "09/07/1996", "10/08/1996", "11/07/1996", "12/06/1996", "02/04/1997", "03/05/1997", "04/05/1997", "05/05/1997", "06/05/1997", "07/07/1997", "08/07/1997", "09/07/1997", "10/08/1997", "11/07/1997", "12/07/1997", "01/05/1998", "02/04/1998", "03/06/1998", "04/05/1998", "05/06/1998", "06/06/1998", "07/07/1998", "08/08/1998", "09/08/1998", "10/08/1998", "11/07/1998", "12/07/1998", "01/06/1999", "02/04/1999", "03/06/1999", "04/05/1999", "05/06/1999", "06/06/1999", "07/07/1999", "08/08/1999", "09/08/1999", "10/09/1999", "11/08/1999", "12/07/1999", "01/06/2000", "02/04/2000", "03/05/2000", "04/04/2000", "05/05/2000", "06/05/2000", "07/07/2000", "08/07/2000", "09/07/2000", "10/08/2000", "11/07/2000", "12/07/2000", "01/05/2001", "02/04/2001", "03/05/2001", "04/05/2001", "05/05/2001", "06/05/2001", "07/07/2001", "08/07/2001", "09/07/2001", "10/08/2001", "11/07/2001", "12/07/2001", "01/05/2002", "02/04/2002", "03/06/2002", "04/05/2002", "05/06/2002", "06/06/2002", "07/07/2002", "08/08/2002", "09/08/2002", "10/08/2002", "11/07/2002", "12/07/2002", "01/06/2003", "02/04/2003", "03/06/2003", "04/05/2003", "05/06/2003", "06/06/2003", "07/07/2003", "08/08/2003", "09/08/2003", "10/09/2003", "11/08/2003", "12/07/2003", "01/06/2004", "02/04/2004", "03/05/2004", "04/04/2004", "05/05/2004", "06/05/2004", "07/07/2004", "08/07/2004", "09/07/2004", "10/08/2004", "11/07/2004", "12/07/2004", "01/05/2005", "02/04/2005", "03/05/2005", "04/05/2005", "05/05/2005", "06/06/2005", "07/07/2005", "08/07/2005", "09/07/2005", "10/08/2005", "11/07/2005", "12/07/2005", "01/05/2006", "02/04/2006", "03/06/2006", "04/05/2006", "05/05/2006", "06/06/2006", "07/07/2006", "08/07/2006", "09/08/2006", "10/07/2006", "11/07/2006", "12/07/2006", "01/06/2007", "02/04/2007", "03/06/2007", "04/05/2007", "05/06/2007", "06/06/2007", "07/07/2007", "08/08/2007", "09/08/2007", "10/09/2007", "11/08/2007", "12/07/2007", "01/06/2008", "02/04/2008", "03/05/2008", "04/04/2008", "05/04/2008", "06/05/2008", "07/07/2008", "08/07/2008", "09/07/2008", "10/08/2008", "11/07/2008", "12/07/2008", "01/05/2009", "02/04/2009", "03/05/2009", "04/04/2009", "05/05/2009", "06/05/2009", "07/07/2009", "08/07/2009", "09/07/2009", "10/08/2009", "11/07/2009", "12/07/2009", "01/07/2010", "02/04/2010", "03/06/2010", "04/05/2010", "05/05/2010", "06/06/2010", "07/07/2010", "08/07/2010", "09/07/2010", "10/08/2010", "11/07/2010", "12/07/2010", "01/06/2011", "02/04/2011", "03/06/2011", "04/05/2011", "05/06/2011", "06/06/2011", "07/07/2011", "08/08/2011", "09/08/2011", "10/08/2011", "11/08/2011", "12/07/2011", "01/06/2012", "02/04/2012", "03/05/2012", "04/04/2012", "05/06/2012", "06/05/2012", "07/07/2012", "08/07/2012", "09/07/2012", "10/08/2012", "11/07/2012", "12/07/2012", "01/05/2013", "02/04/2013", "03/05/2013", "04/04/2013", "05/05/2013", "06/05/2013", "07/07/2013", "08/07/2013", "09/07/2013", "10/08/2013", "11/07/2013", "12/07/2013", "01/05/2014", "02/04/2014", "03/06/2014", "04/05/2014", "05/05/2014", "06/06/2014", "07/07/2014", "08/07/2014", "09/08/2014", "10/08/2014", "11/07/2014", "12/07/2014", "01/06/2015", "02/04/2015", "03/06/2015", "04/05/2015", "05/06/2015", "06/06/2015", "07/07/2015", "08/08/2015", "09/08/2015", "10/08/2015", "11/08/2015", "12/07/2015", "01/06/2016", "02/04/2016", "03/05/2016", "04/04/2016", "05/05/2016", "06/05/2016", "07/07/2016", "08/07/2016", "09/07/2016", "10/08/2016", "11/07/2016", "12/07/2016", "01/05/2017", "02/03/2017", "03/05/2017", "04/04/2017", "05/05/2017", "06/05/2017", "07/07/2017", "08/07/2017", "09/07/2017", "10/08/2017", "11/07/2017", "12/07/2017", "01/05/2018", "02/04/2018", "03/05/2018", "04/05/2018", "05/05/2018", "06/06/2018", "07/07/2018", "08/07/2018", "09/08/2018", "10/08/2018", "11/07/2018", "12/07/2018", "01/05/2019", "02/04/2019", "03/06/2019", "04/05/2019", "05/06/2019", "06/06/2019", "07/07/2019", "08/08/2019", "09/08/2019", "10/08/2019", "11/08/2019", "12/07/2019", "01/06/2020", "02/04/2020", "03/05/2020", "04/04/2020", "05/05/2020", "06/05/2020", "07/06/2020", "08/07/2020", "09/07/2020", "10/08/2020", "11/07/2020", "12/07/2020", "01/05/2021", "02/03/2021", "03/05/2021", "04/04/2021", "05/05/2021", "06/05/2021", "07/07/2021", "08/07/2021", "09/07/2021", "10/08/2021", "11/07/2021", "12/07/2021", "01/05/2022", "02/04/2022", "03/05/2022", "04/05/2022", "05/05/2022", "06/06/2022", "07/07/2022", "08/07/2022", "09/07/2022", "10/08/2022", "11/07/2022", "12/07/2022", "01/05/2023", "02/04/2023", "03/06/2023", "04/05/2023", "05/06/2023", "06/06/2023", "07/07/2023", "08/08/2023", "09/08/2023", "10/08/2023", "11/08/2023", "12/07/2023", "01/06/2024", "02/04/2024", "03/05/2024", "04/04/2024", "05/05/2024", "06/05/2024", "07/06/2024", "08/07/2024", "09/07/2024", "10/08/2024", "11/07/2024", "12/06/2024", "01/05/2025", "02/03/2025", "03/05/2025", "04/04/2025", "05/05/2025", "06/05/2025", "07/07/2025", "08/07/2025", "09/07/2025", "10/08/2025", "11/07/2025", "12/07/2025", "01/05/2026", "02/04/2026", "03/05/2026", "04/05/2026", "05/05/2026", "06/05/2026", "07/07/2026", "08/07/2026", "09/07/2026", "10/08/2026", "11/07/2026", "12/07/2026", "01/05/2027", "02/04/2027", "03/06/2027", "04/05/2027", "05/06/2027", "06/06/2027", "07/07/2027", "08/08/2027", "09/08/2027", "10/08/2027", "11/07/2027", "12/07/2027", "01/06/2028", "02/04/2028", "03/05/2028", "04/04/2028", "05/05/2028", "06/05/2028", "07/06/2028", "08/07/2028", "09/07/2028", "10/08/2028", "11/07/2028", "12/06/2028", "01/05/2029", "02/03/2029", "03/05/2029", "04/04/2029", "05/05/2029", "06/05/2029", "07/07/2029", "08/07/2029", "09/07/2029", "10/07/2029", "11/07/2029", "12/07/2029", "01/05/2030", "02/04/2030", "03/05/2030", "04/05/2030", "05/05/2030", "06/05/2030", "07/07/2030", "08/07/2030", "09/07/2030", "10/08/2030", "11/07/2030", "12/07/2030", "01/05/2031", "02/04/2031", "03/06/2031", "04/05/2031", "05/06/2031", "06/06/2031", "07/07/2031", "08/08/2031", "09/08/2031", "10/08/2031", "11/07/2031", "12/07/2031", "01/06/2032", "02/04/2032", "03/05/2032", "04/04/2032", "05/05/2032", "06/06/2032", "07/06/2032", "08/07/2032", "09/07/2032", "10/08/2032", "11/07/2032", "12/06/2032", "01/05/2033", "02/03/2033", "03/05/2033", "04/04/2033", "05/05/2033", "06/05/2033", "07/07/2033", "08/07/2033", "09/07/2033", "10/08/2033", "11/07/2033", "12/07/2033", "01/06/2034", "02/04/2034", "03/05/2034", "04/05/2034", "05/05/2034", "06/05/2034", "07/07/2034", "08/07/2034", "09/07/2034", "10/08/2034", "11/07/2034", "12/07/2034", "01/05/2035", "02/04/2035", "03/06/2035", "04/05/2035", "05/04/2035", "06/06/2035", "07/07/2035", "08/07/2035", "09/08/2035", "10/08/2035", "11/07/2035", "12/07/2035", "01/06/2036", "02/04/2036", "03/05/2036", "04/04/2036", "05/05/2036", "06/05/2036", "07/06/2036", "08/07/2036", "09/07/2036", "10/08/2036", "11/07/2036", "12/06/2036", "01/05/2037", "02/03/2037", "03/05/2037", "04/04/2037", "05/05/2037", "06/05/2037", "07/07/2037", "08/07/2037", "09/07/2037", "10/07/2037", "11/07/2037", "12/07/2037", "01/05/2038", "02/04/2038", "03/05/2038", "04/05/2038", "05/05/2038", "06/05/2038", "07/07/2038", "08/07/2038", "09/07/2038", "10/08/2038", "11/07/2038", "12/07/2038", "01/05/2039", "02/04/2039", "03/06/2039", "04/05/2039", "05/05/2039", "06/06/2039", "07/07/2039", "08/07/2039", "09/08/2039", "10/08/2039", "11/07/2039", "12/07/2039", "01/06/2040", "02/04/2040", "03/05/2040", "04/04/2040", "05/05/2040", "06/05/2040", "07/06/2040", "08/07/2040", "09/07/2040", "10/08/2040", "11/07/2040", "12/06/2040", "01/05/2041", "02/03/2041", "03/05/2041", "04/04/2041", "05/05/2041", "06/05/2041", "07/07/2041", "08/07/2041", "09/07/2041", "10/08/2041", "11/07/2041", "12/07/2041", "01/05/2042", "02/04/2042", "03/05/2042", "04/04/2042", "05/05/2042", "06/05/2042", "07/07/2042", "08/07/2042", "09/07/2042", "10/08/2042", "11/07/2042", "12/07/2042", "01/05/2043", "02/04/2043", "03/06/2043", "04/05/2043", "05/05/2043", "06/06/2043", "07/07/2043", "08/07/2043", "09/08/2043", "10/08/2043", "11/07/2043", "12/07/2043", "01/06/2044", "02/04/2044", "03/05/2044", "04/04/2044", "05/05/2044", "06/05/2044", "07/06/2044", "08/07/2044", "09/07/2044", "10/07/2044", "11/07/2044", "12/06/2044", "01/05/2045", "02/03/2045", "03/05/2045", "04/04/2045", "05/05/2045", "06/05/2045", "07/07/2045", "08/07/2045", "09/07/2045", "10/08/2045", "11/07/2045", "12/07/2045", "01/05/2046", "02/04/2046", "03/05/2046", "04/04/2046", "05/05/2046", "06/05/2046", "07/07/2046", "08/07/2046", "09/07/2046", "10/08/2046", "11/07/2046", "12/07/2046", "01/05/2047", "02/04/2047", "03/06/2047", "04/05/2047", "05/05/2047", "06/06/2047", "07/07/2047", "08/07/2047", "09/08/2047", "10/08/2047", "11/07/2047", "12/07/2047", "01/06/2048", "02/04/2048", "03/05/2048", "04/04/2048", "05/05/2048", "06/05/2048", "07/06/2048", "08/07/2048", "09/07/2048", "10/07/2048", "11/07/2048", "12/06/2048", "01/05/2049", "02/03/2049", "03/05/2049", "04/04/2049", "05/05/2049", "06/05/2049", "07/06/2049", "08/07/2049", "09/07/2049", "10/08/2049", "11/07/2049", "12/07/2049", "01/05/2050", "02/03/2050", "03/05/2050", "04/04/2050", "05/05/2050", "06/05/2050", "07/07/2050", "08/07/2050", "09/07/2050", "10/08/2050", "11/07/2050", "12/07/2050", "01/05/2051" };
        static DateTime[] dtmonthTransitions = new DateTime[monthTransitions.Length];

        private int hourStem, hourBranch, dayStem, dayBranch, monthStem, monthBranch, yearStem, yearBranch;
        private DateTime gregorianDate, nextMonthTransitionDate, previousMonthTransitionDate;
        private int daysToEndofMonth, daysfromStartofMonth;

        public ChineseSolarDateTime(DateTime gregorianDate)
        {
            this.gregorianDate = gregorianDate;

            for (int i = 0; i < monthTransitions.Length; i++)
            {
                dtmonthTransitions = DateTime.Parse(monthTransitions);
            }

            List<DateTime> list = new List<DateTime>();
            list.AddRange(dtmonthTransitions);
            list.Add(gregorianDate);
            list.Sort();
            int datePosition = list.IndexOf(gregorianDate);

            try
            {
                NextMonthTransitionDate = list[datePosition + 1];
                PreviousMonthTransitionDate = list[datePosition - 1];
            }
            catch (Exception e)
            {
                Console.WriteLine("Date entered is outside of the range of my calendar: " + e);
                Environment.Exit(-1);
            }

            AssignDatewithStemsandBranches();
            AssignTimewithStemsandBranches();

            Console.WriteLine("Date Entered                     : " + gregorianDate.ToString());
            Console.WriteLine("Previous Transition Month Date   : " + previousMonthTransitionDate.ToString());
            Console.WriteLine("Next Month Transition Date       : " + nextMonthTransitionDate.ToString());
        }

        public int HourStem
        {
            get => hourStem;
            set => hourStem = value;
        }

        public int HourBranch
        {
            get => hourBranch;
            set => hourBranch = value;
        }

        public int DayStem
        {
            get => dayStem;
            set => dayStem = value;
        }

        public int DayBranch
        {
            get => dayBranch;
            set => dayBranch = value;
        }

        public int MonthStem
        {
            get => monthStem;
            set => monthStem = value;
        }

        public int MonthBranch
        {
            get => monthBranch;
            set => monthBranch = value;
        }

        public int YearStem
        {
            get => yearStem;
            set => yearStem = value;
        }

        public int YearBranch
        {
            get => yearBranch;
            set => yearBranch = value;
        }

        public void DisplayDate()
        {
            Console.WriteLine("Hour\tDay\tMonth\tYear");
            Console.WriteLine(HourStem + "\t" + DayStem + "\t" + MonthStem + "\t" + YearStem);
            Console.WriteLine(HourBranch + "\t" + DayBranch + "\t" + MonthBranch + "\t" + YearBranch);
            //Console.WriteLine("Hour Stem: " + this.HourStem + "\tHour Branch: " + this.HourBranch);
            //Console.WriteLine("Day Stem: " + this.DayStem + "\tDay Branch: " + this.DayBranch);
            //Console.WriteLine("Month Stem: " + this.MonthStem + "\tMonth Branch: " + this.MonthBranch);
            //Console.WriteLine("Year Stem: " + this.YearStem + "\tYear Branch: " + this.YearBranch);
        }

        private int GetDifferenceInYears(DateTime startDate, DateTime endDate)
        {
            int years = endDate.Year - startDate.Year;

            if (startDate.Month == endDate.Month &&     // if the start month and the end month are the same
                endDate.Day < startDate.Day             // AND the end day is less than the start day
                || endDate.Month < startDate.Month)     // OR if the end month is less than the start month
            {
                years--;
            }

            return years;
        }

        public DateTime NextMonthTransitionDate
        {
            //Date when the next month starts(variable type Date)
            get => nextMonthTransitionDate;
            set => nextMonthTransitionDate = value;
        }

        public DateTime PreviousMonthTransitionDate
        {
            //Date when the previous month ended(variable type Date)
            get => previousMonthTransitionDate;
            set => previousMonthTransitionDate = value;
        }

        public int DaystoEndofMonth            //Integer number of Days until the end of Month
        {
            get => daysToEndofMonth;
            set => daysToEndofMonth = value;
        }

        public int DaysfromStartofMonth //Integer number of Days from start of Month
        {
            get => daysfromStartofMonth;
            set => daysfromStartofMonth = value;
        }

        private void AssignTimewithStemsandBranches()
        {
            int thishour    = gregorianDate.Hour;

            int[] oddCycle  = { 1, 3, 5, 7, 9 };
            int[] evenCycle = { 2, 4, 6, 8, 10};

            int remainder = DayStem % 5;
            int multiplier;

            if (remainder == 0) multiplier = 5;
            else multiplier = remainder;

            if (thishour >= 0 && thishour < 1)
            {
                HourBranch = 1;
                HourStem = oddCycle[multiplier - 1];
            }

            if (thishour >= 1 || thishour < 2)
            {
                HourBranch = 2;
                HourStem = evenCycle[multiplier - 1];
            }

            if (thishour >= 3 && thishour < 5)
            {
                HourBranch = 3;
                HourStem = oddCycle[multiplier % 5];
            }

            if (thishour >= 5 && thishour < 7)
            {
                HourBranch = 4;
                HourStem = evenCycle[multiplier % 5];
            }

            if (thishour >= 7 && thishour < 9)
            {
                HourBranch = 5;
                HourStem = oddCycle[(multiplier + 1) % 5];
            }

            if (thishour >= 9 && thishour < 11)
            {
                HourBranch = 6;
                HourStem = evenCycle[(multiplier + 1) % 5];
            }

            if (thishour >= 11 && thishour < 13)
            {
                HourBranch = 7;
                HourStem = oddCycle[(multiplier + 2) % 5];
            }

            if (thishour >= 13 && thishour < 15)
            {
                HourBranch = 8;
                HourStem = evenCycle[(multiplier + 2) % 5];
            }

            if (thishour >= 15 && thishour < 17)
            {
                HourBranch = 9;
                HourStem = oddCycle[(multiplier + 3) % 5];
            }

            if (thishour >= 17 && thishour < 19)
            {
                HourBranch = 10;
                HourStem = evenCycle[(multiplier + 3) % 5];
            }

            if (thishour >= 19 && thishour < 21)
            {
                HourBranch = 11;
                HourStem = oddCycle[multiplier - 1];
            }

            if (thishour >= 21 && thishour < 23)
            {
                HourBranch = 12;
                HourStem = evenCycle[multiplier - 1];
            }

            if (thishour >= 23)
            {
                HourBranch = 1;
                HourStem = oddCycle[multiplier % 5];
            }
        }

        private void AssignDatewithStemsandBranches()
        {
            DateTime refDate = DateTime.Parse("1/1/0001"); //assigning 1 January 0001 year to compare all other years to; that was day Ding Chou, Month was Wu Zi, Year was Geng Shen
            TimeSpan span = gregorianDate - refDate;
            long DaysBetween = (long)span.TotalDays;
            int YearsBetween = GetDifferenceInYears(refDate, gregorianDate);

            this.DayStem = (int)((DaysBetween) % 10 + 6);

            if (DayStem > 10) DayStem -= 10;
            if (DayStem == 0) DayStem = 10;

            this.DayBranch = (int)((DaysBetween) % 12 + 4);
            if (DayBranch > 12) DayBranch -= 12;

            YearStem = (YearsBetween % 10) + 8;
            YearBranch = (YearsBetween % 12) + 10;

            if (YearStem > 10) YearStem -= 10;
            if (YearBranch > 12) YearBranch -= 12;

            //Console.WriteLine("Number of days since 1/1/0001:" + DaysBetween);
            //Console.WriteLine("Number of years since 1/1/0001:" + YearsBetween);

             //////////////////////////////////////// Compute Month Stem and Branch //////////////////////////////////////
            DateTime LastMonthTransition = NextMonthTransitionDate;         // = list[datePosition + 1];
            DateTime PreviousMonthTransition = PreviousMonthTransitionDate; // = list[datePosition - 1];

            YearStem = (YearsBetween % 10) + 8;
            YearBranch = (YearsBetween % 12) + 10;

            if (YearStem > 10) YearStem -= 10;
            if (YearBranch > 12) YearBranch -= 12;

            int PreviousMonthNumber = PreviousMonthTransition.Month;
            int LastMonthNumber = LastMonthTransition.Month;

            //Here is code to rewrite for the months and all is ready

            if ((PreviousMonthNumber == 2) && (LastMonthNumber == 3))
            {
                if (YearStem == 1 || YearStem == 6) MonthStem = 3;
                if (YearStem == 2 || YearStem == 7) MonthStem = 5;
                if (YearStem == 3 || YearStem == 8) MonthStem = 7;
                if (YearStem == 4 || YearStem == 9) MonthStem = 9;
                if (YearStem == 5 || YearStem == 10) MonthStem = 1;
                MonthBranch = 3;
            }

            if ((PreviousMonthNumber == 3) && (LastMonthNumber == 4))
            {
                if (YearStem == 1 || YearStem == 6) MonthStem = 4;
                if (YearStem == 2 || YearStem == 7) MonthStem = 6;
                if (YearStem == 3 || YearStem == 8) MonthStem = 8;
                if (YearStem == 4 || YearStem == 9) MonthStem = 10;
                if (YearStem == 5 || YearStem == 10) MonthStem = 2;
                MonthBranch = 4;
            }

            if ((PreviousMonthNumber == 4) && (LastMonthNumber == 5))
            {
                if (YearStem == 1 || YearStem == 6) MonthStem = 5;
                if (YearStem == 2 || YearStem == 7) MonthStem = 7;
                if (YearStem == 3 || YearStem == 8) MonthStem = 9;
                if (YearStem == 4 || YearStem == 9) MonthStem = 1;
                if (YearStem == 5 || YearStem == 10) MonthStem = 3;
                MonthBranch = 5;
            }

            if ((PreviousMonthNumber == 5) && (LastMonthNumber == 6))
            {
                if (YearStem == 1 || YearStem == 6) MonthStem = 6;
                if (YearStem == 2 || YearStem == 7) MonthStem = 8;
                if (YearStem == 3 || YearStem == 8) MonthStem = 10;
                if (YearStem == 4 || YearStem == 9) MonthStem = 2;
                if (YearStem == 5 || YearStem == 10) MonthStem = 4;
                MonthBranch = 6;
            }

            if ((PreviousMonthNumber == 6) && (LastMonthNumber == 7))
            {
                if (YearStem == 1 || YearStem == 6) MonthStem = 7;
                if (YearStem == 2 || YearStem == 7) MonthStem = 9;
                if (YearStem == 3 || YearStem == 8) MonthStem = 1;
                if (YearStem == 4 || YearStem == 9) MonthStem = 3;
                if (YearStem == 5 || YearStem == 10) MonthStem = 5;
                MonthBranch = 7;
            }

            if ((PreviousMonthNumber == 7) && (LastMonthNumber == 8))
            {
                if (YearStem == 1 || YearStem == 6) MonthStem = 8;
                if (YearStem == 2 || YearStem == 7) MonthStem = 10;
                if (YearStem == 3 || YearStem == 8) MonthStem = 2;
                if (YearStem == 4 || YearStem == 9) MonthStem = 4;
                if (YearStem == 5 || YearStem == 10) MonthStem = 6;
                MonthBranch = 8;
            }

            if ((PreviousMonthNumber == 8) && (LastMonthNumber == 9))
            {
                if (YearStem == 1 || YearStem == 6) MonthStem = 9;
                if (YearStem == 2 || YearStem == 7) MonthStem = 1;
                if (YearStem == 3 || YearStem == 8) MonthStem = 3;
                if (YearStem == 4 || YearStem == 9) MonthStem = 5;
                if (YearStem == 5 || YearStem == 10) MonthStem = 7;
                MonthBranch = 9;
            }

            if ((PreviousMonthNumber == 9) && (LastMonthNumber == 10))
            {
                if (YearStem == 1 || YearStem == 6) MonthStem = 10;
                if (YearStem == 2 || YearStem == 7) MonthStem = 2;
                if (YearStem == 3 || YearStem == 8) MonthStem = 4;
                if (YearStem == 4 || YearStem == 9) MonthStem = 6;
                if (YearStem == 5 || YearStem == 10) MonthStem = 8;
                MonthBranch = 10;
            }

            if ((PreviousMonthNumber == 10) && (LastMonthNumber == 11))
            {
                if (YearStem == 1 || YearStem == 6) MonthStem = 1;
    &
« Last Edit: June 03, 2018, 11:20:32 PM by annutara »

Offline annutara

  • G51-G100
  • **
  • Posts: 99
  • Karma: +20/-0
  • Last Login:January 25, 2020, 12:02:14 AM
    • View Profile
Re: Gmuli Solar Calendar Class
« Reply #16 on: June 05, 2018, 01:14:35 AM »
Gumulis, I think there are some inaccuracies with the transitions.

Checked it against my ten thousand year calendar, and I would get the eight characters given by:
http://bazi.kevinfoongcg.com/free?gender=F&dob_year=2018&dob_month=2&dob_day=4&dob_hour=4&dob_minute=59&fullname=&submit=Plot


Offline annutara

  • G51-G100
  • **
  • Posts: 99
  • Karma: +20/-0
  • Last Login:January 25, 2020, 12:02:14 AM
    • View Profile
Re: Gmuli Solar Calendar Class
« Reply #17 on: June 05, 2018, 01:33:40 AM »
Some how the previous post dropped my screen capture.

Online Gmuli

  • Deian
  • G501++
  • *****
  • Posts: 1220
  • Karma: +263/-0
  • Last Login:Today at 09:00:49 PM
  • https://bright-hall.net
    • View Profile
    • Bright Hall. net
  • Re: Gmuli Solar Calendar Class
    « Reply #18 on: June 05, 2018, 01:50:04 AM »
    Gumulis, I think there are some inaccuracies with the transitions.

    Checked it against my ten thousand year calendar, and I would get the eight characters given by:
    http://bazi.kevinfoongcg.com/free?gender=F&dob_year=2018&dob_month=2&dob_day=4&dob_hour=4&dob_minute=59&fullname=&submit=Plot

    Error in input, was adding a lot of stuff and couldn't copy/paste so there are some errors.

    Its interesting to mention that Mean Longitude would give 21:16 GMT on 3Th February, while Apparent will give around 6-7AM in the morning on 4th February.

    So if the calculator app/website doesn't use time of transition someone will be left out. Either people before 6-7 AM would be counted as Yin, or people after it will be counted as Chou.


    One interesting solution is just to go 60, 120 or 180 years back. In this case 180 years back we have a lot clearer date if someone wants to use Chou pillar and that could be:
    January 19 1838.

    Not perfect, but all solutions will have some problem, unless we have hours of change and than people using paper calendar will have discrepancies.

    In any case, this time it is just error in input, if you want change it to 5th and should be same as paper calendar. And there is good chance there are more errors like this, as it was a lot of data that I had to input manually. : )

    Online Gmuli

    • Deian
    • G501++
    • *****
    • Posts: 1220
    • Karma: +263/-0
    • Last Login:Today at 09:00:49 PM
    • https://bright-hall.net
    • View Profile
    • Bright Hall. net
  • Re: Gmuli Solar Calendar Class
    « Reply #19 on: March 19, 2019, 10:18:48 PM »
    I took a while to get the code ported to C#.net, and I'm releasing my version here for more pair of eyes to screen it.

    If anybody find improvements or bugs, please shout out. I'm not sure I handle all transitions seamlessly.


    Some more optimizations.
    I'm rewriting the code a little for another language and in my view some parts can be done in more cleaner way now.

    Get in range function that I use all around the place is this(all is Javascript code from now on):
    Quote
    function getinrange(number,range){
          while (number > range){number = number - range}
          while (number <= 0.0){number = number+range}           
            return number;
    }

    So if we have the 2 digits from the hour and the day stem and we can find the whole pillar in just a few lines :


    Quote
       HourBranch = getinrange(parseInt(hoursvar),23);
       if (HourBranch % 2 == 0){   
       HourBranch = getinrange((HourBranch - 1),23)}   
       if (HourBranch  == 0) {HourBranch = 1} else {   
       HourBranch = getinrange(((HourBranch+3) / 2),12)
       }

       HourStem = getinrange(HourBranch + (((DayStem % 5) *2) -2 ),10);
       if (hoursvar >=23){HourStem = getinrange(13 + (((DayStem % 5) *2) -2 ),10)};

    hoursvar - the 2 digits from the hour(23:35 would be 23).
    Solar Month - we get from the Suns longitude.

    Quote
    SolarTerm = getinrange( (Math.floor(longitude_of_the_sun / 15) + 4,24) );
    SolarMonth = getinrange( Math.floor( ((longitude_of_the_sun+15)/30 )+2 ,12) );
    This part I haven't tested a lot, but seems to be fine.

    Once we have it for the Month Pillar we can do this:

    Quote
       MonthBranch = getinrange(SolarMonth+2,12);   
       MonthStem = getinrange((((YearStem % 5) * 2 )+ SolarMonth),10)

    If we play with the longitude a lot opens up for easier way to implement it.
    For example the days to end of month can be done using the longitude of the Sun:
    Quote
    function days_to_end_of_month(longitude_of_the_sun)
    {
    return getinrange(30-(longitude_of_the_sun % 30 + 14),30);
    }

    As the Solar Terms will always start in 15 degrees, so months will be on 30.If we need higher accuracy its around 1,0138 degrees for a day. This may have some variations, for example days when DTS changes will be longer or shorter, by an hour, but for 30 days periods should be close enough approximation.

    Another thing that can be optimized is adjustment to the year for January and part of the February that is before start of the new year.

    Can be done like this:
    Quote
       if ((longitude_of_the_sun<=315) && (date_for_longitude.getMonth()<=2))   {
       YearBranch = getinrange(YearBranch-1,12);
       YearStem = getinrange(YearStem-1,10);
    }

    All values that are months January and February(javascript starts months with value of 0), but also fall below longitude of 315 would be part of the previous year.

    Just making it cleaner, of course all this assumes we are switching from calendar to longitude. But that is inevitable at some point. Not just coz of accuracy, but also because its much easier to calculate everything else.Then if we want we can still round it to a day for month transitions, but at least the internal engine would be working in a much smoother and accurate way.

    Online Gmuli

    • Deian
    • G501++
    • *****
    • Posts: 1220
    • Karma: +263/-0
    • Last Login:Today at 09:00:49 PM
    • https://bright-hall.net
    • View Profile
    • Bright Hall. net
  • Re: Gmuli Solar Calendar Class
    « Reply #20 on: July 20, 2019, 11:10:01 PM »
    @annutara

    I haven't forgot about the open source request and its a good idea in our view.

    Currently all the code of the WWG and Bazi calculators we are making on the website are visible in the Javascript. I did what I could to leave it readable, so they aren't minified or anything.

    Only part that is hidden by the ajax in the php is for the Solar Calendar, but that is using only the longitude as explained in here, so shouldn't be needed. Also for manual selection much of it is also in the javascript as well.

    If you have questions feel free to ask. : )



    five arts forum

    Re: Gmuli Solar Calendar Class
    « Reply #20 on: July 20, 2019, 11:10:01 PM »
    Fortune-telling / birth chart reading / predict your future services by Master Tony (aka aoefengshui). Area of interest:
    Category 1: Relationship/Peach Blossom/Marriage/Spouse/Divorce.
    Category 2: Wealth/Business/Investment/Legal Problem.
    Category 3: Career Plan/Career Move/Job Promotion/Study.
    Category 4: Health/Pregnancy/Children/Accident/Disaster.
    Category 5: The Luck of next 10 years: (Master Tony will work out your luck for next 10 years in general and point out the happening years for the important events).
    Category 6: The Luck of next 12 months: (Master Tony will work out your luck for next 12 months in general and point out the happening months for the important events.)
    Category 7: Your own Category which didn’t mention above.

    Note: Master Tony will provide you the reading report in writing and also one private Q&A session afterwards. Everything to be conducted conveniently and anonymously via this forum online.

    More detail | About Master Tony (aka aoefengshui) | Ask question privately | Post question in Pre-sales forum | Testimonials | View sample Fortune-telling report
    Tired of advertisement on the forum? Remove advertisement on the forum now. For detail, please click here.
    Learn fortune-telling skills from Master Tony (Purple Star Astrology / 紫微斗数 / ZWDS)

    Features: Online private learning | one-on-one teaching | Everything starts from zero | 24/7 access to constantly updated learning materials | Medium of instruction: English
    Bazi reading service:
    Click here to view detail | Real Bazi reading reports (coming soon)

    Tags:
     

    how to define Jia Zi - beginning of 60 years cycle without paper calendar?

    Started by padmaBoard Miscellaneous

    Replies: 6
    Views: 125
    Last post March 28, 2020, 09:16:40 PM
    by Gmuli
    chinese zodiac lunar vs solar

    Started by Johnson92Board Request for birth chart reading [FREE]

    Replies: 10
    Views: 407
    Last post January 27, 2020, 05:38:14 PM
    by Gmuli
    Looking at the Solar Eclipse of December 26, 2019

    Started by CyanCatBoard Indian Astrology

    Replies: 4
    Views: 563
    Last post December 22, 2019, 10:14:59 PM
    by tureno
    Calendar hexagram Nyarzir

    Started by dakini456Board Liu Yao Yi Gua (LYYG)

    Replies: 0
    Views: 195
    Last post October 29, 2019, 11:01:35 PM
    by dakini456
    Jing Fang's remarks about the calendar are referring to the solar calendar

    Started by hmeskerBoard Liu Yao Yi Gua (LYYG)

    Replies: 21
    Views: 870
    Last post August 15, 2019, 11:17:07 PM
    by ArtofFugue
    DGDS calendar for 2020 (+ 28 constellations)

    Started by ArtofFugueBoard Date Selection

    Replies: 9
    Views: 4366
    Last post March 13, 2020, 10:31:38 PM
    by Achtzeichen
    Gmuli XKFX(Flying Star) App

    Started by GmuliBoard Xuan Kong Fei Xing

    Replies: 4
    Views: 986
    Last post October 19, 2018, 12:05:02 AM
    by j27945
    DGDS calendar for 2019 (+ 28 constellations)

    Started by ArtofFugueBoard Date Selection

    Replies: 18
    Views: 5494
    Last post September 14, 2019, 07:11:44 AM
    by fengshuiplus168
    OMG! 2 days before Ghost Month, Taiwan approves solar panels in cemeteries

    Started by AdministratorBoard Dreams, Omens, Symbols and Taboos

    Replies: 0
    Views: 451
    Last post August 11, 2018, 02:41:13 AM
    by Administrator
    Chinese Solar Calendar month transition

    Started by annutaraBoard Miscellaneous

    Replies: 7
    Views: 1026
    Last post June 04, 2018, 01:46:47 AM
    by annutara
    Xuan Kong Da Gua Calendar 2018

    Started by HanShengBoard Date Selection

    Replies: 10
    Views: 2610
    Last post January 31, 2019, 09:44:51 PM
    by chary
    solar eclipse on 21 August 2017..

    Started by RaoBoard Miscellaneous casual talks

    Replies: 16
    Views: 2362
    Last post September 08, 2017, 08:26:56 PM
    by Remoteviewer
    DGDS calendar for 2018 (+ 28 constellations)

    Started by ArtofFugueBoard Date Selection

    Replies: 13
    Views: 4334
    Last post January 30, 2020, 10:33:00 PM
    by socrates
    Gmuli Wen Wang Gua Calculator

    Started by GmuliBoard Books, Software, Tools, and Resources

    Replies: 74
    Views: 8710
    Last post December 05, 2019, 05:17:03 PM
    by Gmuli
    software for xkdg calendar

    Started by fengshuiartistBoard Date Selection

    Replies: 8
    Views: 1989
    Last post March 31, 2017, 11:51:19 PM
    by fengshuiartist
    Re: Online Jia Zi Calendar calculator for Year, Month and Day HS EB

    Started by JeremyBoard Books, Software, Tools, and Resources

    Replies: 3
    Views: 1284
    Last post March 15, 2017, 12:56:23 AM
    by Jeremy
    The Chinese Calendar

    Started by TEESEEPEEJAYBoard Date Selection

    Replies: 0
    Views: 1403
    Last post February 08, 2017, 10:16:26 AM
    by TEESEEPEEJAY
    2017 Solar and Lunar Eclipses

    Started by CyanCatBoard Western Astrology

    Replies: 4
    Views: 1381
    Last post March 24, 2017, 12:34:08 AM
    by Gui
    Bazi Q & A * Where do we find free Hsia calendar? *

    Started by sosweetBoard Books, Software, Tools, and Resources

    Replies: 1
    Views: 1330
    Last post January 14, 2017, 06:21:19 PM
    by IceLemonTea
    Plot bazi chart - solar vs lunar date

    Started by sosweetBoard Si Zhu Ba Zi (SZBZ) 四柱八字

    Replies: 0
    Views: 919
    Last post December 26, 2016, 10:58:59 AM
    by sosweet
    How to find QMDJ calendar

    Started by TarnBoard Qi Men Dun Jia

    Replies: 13
    Views: 2891
    Last post November 24, 2019, 11:42:36 AM
    by j27945
    Real Solar Time or True local time?

    Started by fongwee768Board Request for birth chart reading [FREE]

    Replies: 10
    Views: 1741
    Last post November 07, 2016, 02:42:08 PM
    by Han
    World class, local class...?

    Started by johnyqiBoard Blindman School (Mangpai Bazi)

    Replies: 2
    Views: 1222
    Last post November 01, 2016, 05:50:44 PM
    by johnyqi
    Is it required to change to solar time for ziwei dou shou?

    Started by MacyBoard Request for birth chart reading [FREE]

    Replies: 8
    Views: 1629
    Last post November 11, 2017, 09:20:25 AM
    by ArtofFugue
    Calculating True/Apparent Solar Time by the position of the Sun

    Started by OwlbearBoard Books, Software, Tools, and Resources

    Replies: 11
    Views: 3249
    Last post December 30, 2016, 04:21:31 PM
    by sosweet
    DGDS calendar for 2017 (+ 28 constellations)

    Started by ArtofFugueBoard Date Selection

    Replies: 42
    Views: 9034
    Last post June 30, 2017, 05:26:18 PM
    by ArtofFugue
    Xuan Kong Da Gua Calendar 2017

    Started by HanShengBoard Date Selection

    Replies: 61
    Views: 8058
    Last post January 16, 2018, 09:30:15 AM
    by chary
    Xuan Kong Da Gua Calendar 2016

    Started by HanShengBoard Date Selection

    Replies: 0
    Views: 1121
    Last post August 22, 2016, 08:07:45 PM
    by HanSheng
    Solar Time VS Local Time

    Started by MachiBoard Request for birth chart reading [FREE]

    Replies: 46
    Views: 6689
    Last post July 30, 2016, 03:33:36 PM
    by ArtofFugue
    24 Solar Terms Tutorial

    Started by OwlbearBoard Books, Software, Tools, and Resources

    Replies: 0
    Views: 793
    Last post April 27, 2016, 06:22:09 PM
    by Owlbear

    Disclaimer:

    Your use of FiveArts.Info is at your sole risk. FiveArts.Info cannot be held responsible for the inaccuracy of the readings and information provided by its members.  FiveArts.Info owners, administrators, moderators, masters, members, partners expressly disclaim all warranties of any kind whether express or implied including but not limited to the implied warranties of merchantability or fitness for a particular purpose.




    Total visits since 2014: