def test_invalid_year(self, test_input, expected): with pytest.raises(OverflowError) as e: convert.Hijri(*test_input, validate=False)._check_date() assert str(e.value) == expected
def test_invalid_day_or_month(self, test_input, expected): with pytest.raises(ValueError) as e: convert.Hijri(*test_input, validate=False)._check_date() assert str(e.value) == expected
def test_valid_date(self, test_input): year, month, day = test_input try: convert.Hijri(year, month, day, validate=False)._check_date() except (ValueError, OverflowError): pytest.fail()
def to_gregorian(cls, year=None, month=None, day=None): g = convert.Hijri(year=year, month=month, day=day, validate=False).to_gregorian() return g.datetuple()
def month_length(cls, year, month): h = convert.Hijri(year=year, month=month, day=1) return h.month_length()
def get_gregorian(hijri_date): gregorian = convert.Hijri(hijri_date.year, hijri_date.month, hijri_date.day).to_gregorian() return f'{hijri_date.strftime("%d-%m-%Y")} AH is **{gregorian.strftime("%d %B %Y")}**'
sg.Button('Georg to Arabic'), sg.Button('Cancel') ]] # Window window = sg.Window('Date Converter', layout) # Event Loop to process the inputs while True: event, values = window.read() if event in (None, 'Cancel'): break if event == 'Arabic to Georg': arabicDay = int(values['arabic']) arabicMonth = int(values['arabic2']) arabicYear = int(values['arabic3']) g = convert.Hijri(arabicYear, arabicMonth, arabicDay).to_gregorian() n = g.day_name() print('The result in Georg. Calender: ', g) print('Day: ', n) if event == 'Georg to Arabic': georgDay = int(values['georg']) georgMonth = int(values['georg2']) georgYear = int(values['georg3']) h = convert.Gregorian(georgYear, georgMonth, georgDay).to_hijri() m = h.day_name() print('The result in Arabic Calender: ', h) print('Day: ', m) window.close()