# -*- coding: utf-8 -*-
__author__ = 'isee15'

import LunarSolarConverter

converter = LunarSolarConverter.LunarSolarConverter()

def LunarToSolar(year, month, day, isleap = False):
    lunar = LunarSolarConverter.Lunar(year, month, day, isleap)
    solar = converter.LunarToSolar(lunar)
    return (solar.solarYear, solar.solarMonth, solar.solarDay)


def SolarToLunar(year, month, day):
    solar = LunarSolarConverter.Solar(year, month, day)
    lunar = converter.SolarToLunar(solar)
    return (lunar.lunarYear, lunar.lunarMonth, lunar.lunarDay)




def LunarMonthDays(year, month, isleap = False):
    converter = LunarSolarConverter.LunarSolarConverter
    days = converter.lunar_month_days[year - converter.lunar_month_days[0]]
    leap = LunarSolarConverter.GetBitInt(days, 4, 13)
    offset = 0
    loopend = leap
    if not isleap:

        if month <= leap or leap == 0:
            loopend = month - 1
        else:
            loopend = month

    days = LunarSolarConverter.GetBitInt(days, 1, 12 - loopend) == 1 and 30 or 29
    return days

[((6, 12, 6, 53), 'LunarSolarConverter.LunarSolarConverter', 'LunarSolarConverter.LunarSolarConverter', ({}, {}), '()', False, 'import LunarSolarConverter\n'), ((9, 12, 9, 63), 'LunarSolarConverter.Lunar', 'LunarSolarConverter.Lunar', ({(9, 38, 9, 42): 'year', (9, 44, 9, 49): 'month', (9, 51, 9, 54): 'day', (9, 56, 9, 62): 'isleap'}, {}), '(year, month, day, isleap)', False, 'import LunarSolarConverter\n'), ((15, 12, 15, 55), 'LunarSolarConverter.Solar', 'LunarSolarConverter.Solar', ({(15, 38, 15, 42): 'year', (15, 44, 15, 49): 'month', (15, 51, 15, 54): 'day'}, {}), '(year, month, day)', False, 'import LunarSolarConverter\n'), ((25, 11, 25, 53), 'LunarSolarConverter.GetBitInt', 'LunarSolarConverter.GetBitInt', ({(25, 41, 25, 45): 'days', (25, 47, 25, 48): '4', (25, 50, 25, 52): '13'}, {}), '(days, 4, 13)', False, 'import LunarSolarConverter\n'), ((35, 11, 35, 63), 'LunarSolarConverter.GetBitInt', 'LunarSolarConverter.GetBitInt', ({(35, 41, 35, 45): 'days', (35, 47, 35, 48): '(1)', (35, 50, 35, 62): '(12 - loopend)'}, {}), '(days, 1, 12 - loopend)', False, 'import LunarSolarConverter\n')]