Giter VIP home page Giter VIP logo

ummalqura's Introduction

Python Umm Al-Qura Calender

Python Umalqurra Calender is an API that will give you the ability to convert Gregorian to Hijri and hijri to Gregorian it will give you the day name in arabic and english , and the month name in Hijri arabic and Gregorian.

Thanks for Khalid Al-hussayen : https://pypi.python.org/pypi/umalqurra/0.2

Install

sudo pip3 install ummalqura

or

sudo pip3 install git+https://github.com/borni-dhifi/ummalqura.git

Features:

  • Convert Gregorian to Hijri

  • Convert Hijri to Gregorian

  • give the arabic name of the hijri month

  • give the english name of the gregorian month

  • give the day name in Arabic and English

  • give the current day both in Hijri and Gregorian

Usage

#!/usr/bin/env python3

from ummalqura.hijri_date import HijriDate
from datetime import date

# create the object with Gregorian date
um = HijriDate(2017, 12, 26, gr=True)

# hijri month
print('hijri month: ', um.month)  # 4
# Hijri year
print('hijri year: ', um.year)  # 1439
# arabic day name
print('arabic day name: ', um.day_name)  # الثلاثاء
# english day name
print('english day name: ', um.day_name_en)  # Tuesday
# arabic hijri month name
print('arabic hijri month name: ', um.month_name)  # ربيع الثاني
# english gregorian month name
print('english gregorian month name: ', um.month_name_gr)  # December
# gregorian year
print('gregorian year: ', um.year_gr)  # 2017
# gregorian month
print('gregorian month: ', um.month_gr)  # 12
# gregorian day
print('gregorian day: ', um.day_gr)  # 26

# current hijri month
print('current_month: ', HijriDate.current_month())  # 4
# the gregorian date corresponding to the first day of the given hijri month/year
print('first day: ', HijriDate.month_start_date(4))  # 2017-12-19
print('first day: ', HijriDate.month_start_date(4, 1439))  # 2017-12-19
# the gregorian date corresponding to the last day of the given hijri month/year
print('last day: ', HijriDate.month_end_date(4))   # 2018-01-17
print('last day: ', HijriDate.month_end_date(4, 1439))   # 2018-01-17
# the hijri month for the given gregorian date
print('hijri month: ', HijriDate.hijri_month_from_date(date.today()))  # 4
# the hijri year for the given gregorian date
print('hijri year: ', HijriDate.hijri_year_from_date(date.today()))  # 1439
# convert the given gregorian date to hijri date
print('hijri date: ', HijriDate.get_hijri_date(date.today()))  # 1439-04-08
# convert the given hijri date to gregorian date
print('georing date: ', HijriDate.get_georing_date('1439-04-08'))  # 2017-12-26

ummalqura's People

Contributors

adel-slnee avatar borni-dhifi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ummalqura's Issues

Incorrect conversion for dates 1937-03-13 and earlier

Passing a date of 1937-03-13 or earlier gives a negative number for the result day.

Bad:

>>> h=HijriDate(1937, 3, 13, gr=True)
>>> h.__dict__
{'day_gr': 13, 'month_gr': 3, 'year_gr': 1937, 'year': 1355, 'month': 12, 'day':
 -51383, 'month_len': -51383, 'month_name': '?? ?????', 'day_name_en': 'Saturday',
'day_name': '?????', 'month_name_gr': 'March'}

Good:

>>> h=HijriDate(1937, 3, 14, gr=True)
>>> h.__dict__
{'day_gr': 14, 'month_gr': 3, 'year_gr': 1937, 'year': 1356, 'month': 1, 'day':
1, 'month_len': 29, 'month_name': '????', 'day_name_en': 'Sunday', 'day_name': 
'?????', 'month_name_gr': 'March'}
>>>

converting whole columns

I have a column with the Gregorian year (2019, 2018...) and Gregorian month (1,2,3...).
I cant seem to convert the whole column to hijri.

i_year=HijriDate(year="year", gr=True)

df["islamic yr"]=i_year
df.head (5)

Below is the column that gets created.
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.