Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
android-app
java-lib
resources
web-app
LICENSE
README.md
android-app-backup.7z

README.md

Persian Calendar Project

This is my own algorithm of Persian Calendar. This project contains:

  1. Java class library for use in Java/Android projects.
  2. Persian Calendar Android application.
  3. Javascript library and a simple web application.

Usage:

  1. Java
  2. Javascript

Java

PersianCalendar pc = new PersianCalendar();

Subclasses and functions:




toPersian() Converting gregorian date to persian date.

Arguments:
Integer values for Year, Month and Day
     int Year, int Month, int Day
or String format as follow
     "YYYY-MM-DD"
     "YYYY/MM/DD"
     "MM-DD-YYYY"
     "MM/DD/YYYY"

Return value: String

Eg:

PersianCalendar pc = new PersianCalendar();

String date = pc.Convert.toPersian(1987, 1, 19);
String date = pc.Convert.toPersian("1-19-1987");        




toGregorian() Converting persian date to gregorian date.

Arguments:
Integer values for Year, Month and Day
     int Year, int Month, int Day
or String format as follow
     "YYYY-MM-DD"
     "YYYY/MM/DD"

Return value: String

Eg:

PersianCalendar pc = new PersianCalendar();

String date = pc.Convert.toGregorian(1365, 10, 29);
String date = pc.Convert.toGregorian("1365/10/29");        




Today() Current system date in persian.

Return value: String

Eg:

PersianCalendar pc = new PersianCalendar();

String date = pc.Now.Today();       




Year()Return the current persian Year.

Return value: Integer

Eg:

PersianCalendar pc = new PersianCalendar();

int year = pc.Now.Year();       




Month()Return the current persian Month.

Return value: Integer

Eg:

PersianCalendar pc = new PersianCalendar();

int month = pc.Now.Month();       




Day()Return the current persian Day.

Return value: Integer

Eg:

PersianCalendar pc = new PersianCalendar();

int day = pc.Now.Day();       




getYearOf()Returns Year for the specified date in persian.

Arguments:
Integer values for Year, Month and Day
     int Year, int Month, int Day

Return value: Integer

Eg:

PersianCalendar pc = new PersianCalendar();

int year = pc.Utility.getYearOf(int Year, int Month, int Day);       




getMonthOf()Returns Month for the specified date in persian.

Arguments:
Integer values for Year, Month and Day
     int Year, int Month, int Day

Return value: Integer

Eg:

PersianCalendar pc = new PersianCalendar();

int month = pc.Utility.getMonthOf(int Year, int Month, int Day);       




getDayOf()Returns Day for the specified date in persian.

Arguments:
Integer values for Year, Month and Day
     int Year, int Month, int Day

Return value: Integer

Eg:

PersianCalendar pc = new PersianCalendar();

int day = pc.Utility.getDayOf(int Year, int Month, int Day);       




extractYear()Extracts the Year from the given date.

Arguments:
String format as follow
     "YYYY-MM-DD"
     "YYYY/MM/DD"

Return value: Integer

Eg:

PersianCalendar pc = new PersianCalendar();

int year = pc.Utility.extractYear("1365/10/29");       




extractMonth()Extracts the Month from the date.

Arguments:
String format as follow
     "YYYY-MM-DD"
     "YYYY/MM/DD"

Return value: Integer

Eg:

PersianCalendar pc = new PersianCalendar();

int month = pc.Utility.extractMonth("1365/10/29");       




extractDay()Extracts the Day from the date.

Arguments:
String format as follow
     "YYYY-MM-DD"
     "YYYY/MM/DD"

Return value: Integer

Eg:

PersianCalendar pc = new PersianCalendar();

int day = pc.Utility.extractDay("1365/10/29");       




getMaxDay()Number of days in specified Month.

Arguments:
Integer values for Year and Month
     int Year, int Month

Return value: Integer

Eg:

PersianCalendar pc = new PersianCalendar();

int maxDay = pc.Utility.getMaxDay(int Year, int Month);       




getDayOfWeek()Return the Day of week for specified date in persian.

Arguments:
String format as follow
     "YYYY-MM-DD"
     "YYYY/MM/DD"

Return value: Integer

Eg:

PersianCalendar pc = new PersianCalendar();

int weekDay = pc.Utility.getDayOfWeek("1365-10-29");       




GregorianLeapYear()Return the leap year status for gregorian year.

Arguments:
Integer values for Year
     int Year
Return value: Boolean

Eg:

PersianCalendar pc = new PersianCalendar();

boolean leap = pc.Utility.GregorianLeapYear(2017);       




PersianLeapYear()Return the leap year status for persian year.

Arguments:
Integer values for Year
     int Year
Return value: Boolean

Eg:

PersianCalendar pc = new PersianCalendar();

boolean leap = pc.Utility.PersianLeapYear(1396);       

Javascript

<script language="javascript" type="text/javascript" src="js/calendar.js"></script>

We have 3 categories of functions:




toPersian() Converting gregorian date to persian date.

Arguments:
Integer values for Year, Month and Day
     int Year, int Month, int Day

for String format we have separate function. Because functions in Javascript are nonpolymorphic.
toPersianByStr()
     "YYYY-MM-DD"
     "YYYY/MM/DD"
     "MM-DD-YYYY"
     "MM/DD/YYYY"

Return value: String

Eg:

var date = toPersian(1987, 1, 19);
var date = toPersianByStr("1-19-1987");        




toGregorian() Converting persian date to gregorian date.

Arguments:
Integer values for Year, Month and Day
     int Year, int Month, int Day
for String format:
toGregorianByStr()
     "YYYY-MM-DD"
     "YYYY/MM/DD"

Return value: String

Eg:

var date = toGregorian(1365, 10, 29);
var date = toGregorian("1365/10/29");        




Now() Current system date in persian.

Return value: String

Eg:

let now = new Now();

alert(now.Today());     //Returns Current persian date as string.
alert(now.Year());      //Returns the Year of current persian date as int.
alert(now.Month());     //Returns the Month of current persian date as int.
alert(now.Day());       //Returns the Day of current persian date as int.




getDateAt()Return Year, Month, Day for the specified date in persian.

Arguments:
Integer values for Year, Month and Day
     int Year, int Month, int Day

Return value: Integer

Eg:

let getDate = new getDateAt(int Year, int Month, int Day);

var year, month, day;
year = getDate.Year();
month = getDate.Month();
day = getDate.Day();




Extract()Extracts the Year, Month, Day from given date.

Arguments:
String format as follow
     "YYYY-MM-DD"
     "YYYY/MM/DD"

Return value: Integer

Eg:

let extract = new Extract("1365/10/29");

var year, month, dat;
year = extract.Year();
month = extract.Month();
day = extract.Day();




getMaxDay()Number of days in specified Month.

Arguments:
Integer values for Year and Month
     int Year, int Month

Return value: Integer

Eg:

var maxDay = getMaxDay(int Year, int Month);       




getDayOfWeek()Return the Day of week for specified date.

Arguments:
String format as follow
     "YYYY-MM-DD"
     "YYYY/MM/DD"

Return value: Integer

Eg:

var weekDay = getDayOfWeek("1365-10-29");       




GregorianLeapYear()Return the leap year status for gregorian year.

Arguments:
Integer values for Year
     int Year
Return value: Boolean

Eg:

if(GregorianLeapYear(2017)){
    //Do something!
}




PersianLeapYear()Return the leap year status for persian year.

Arguments:
Integer values for Year
     int Year
Return value: Boolean

Eg:

if(PersianLeapYear(1396)){
    //Do something!
}
You can’t perform that action at this time.