Awesome
PersianDatePicker
An Android DatePicker for Persian Calendar
Usage:
- Add as an Android Library Project:
- Add this line to root layout element:
- Add PersianDatePicker view:
- Add Source and other required things to your Project:
- Copy all sources to your source tree.
- Copy /res/layout/sl_persian_date_picker.xml to your /res/layout folder.
- Add this to your /res/values/attrs.xml:
Params:
- minYear: Min value for year in the picker. Default is current Hijri Shamsi (Jalali) year - yearRange(default is 10).
- maxYear: Max value for year in the picker. Default is current Hijri Shamsi (Jalali) year + yearRange(default is 10).
- yearRange: If you set a selected year, available years in picker will be from (selectedYear - yearRange) to (selectedYear + yearRange). Default value is 10.
- selectedYear: Selected year that PersianDatePicker starts with. Default is the current Hijri Shamsi (Jalali) year.
- selectedMonth: Selected month that PersianDatePicker starts with. Default is the current Hijri Shamsi (Jalali) year's month.
- selectedDay: Selected day of month that PersianDatePicker starts with. Default is the current Hijri Shamsi (Jalali) month's day.
- displayMonthNames: If set to true, months names are displayed, otherwise their number will be shown.
- displayDescription: If set to true, a TextView below datepicker will show the selected date with more details.
Examples:
- Display a PersianDatePicker with current Hijri Shamsi (Jalali) values:
- Display a PersianDatePicker with selected Hijri Shamsi (Jalali) date: <pre><code><ir.smartlab.persindatepicker.PersianDatePicker android:layout_width="wrap_content" android:layout_height="wrap_content" app:selectedYear="1390" app:selectedMonth="5" app:selectedDay="15" /></code></pre>
- Display a PersianDatePicker that shows month names:
- Display a PersianDatePicker that shows years between 1350 and 1450:
Java Examples:
- You can set a java.util.Date object to PersianDatePpicker in java code:
- you can also set a ir.smartlab.persindatepicker.util.PersianCalendar object:
- You can get displayed date in java.util.Date or ir.smartlab.persindatepicker.util.PersianCalendar:
Leap Year:
In Hijri Shamsi some years are leap year, so the last month of year is 30 days (not 29 days). PersianDatePicker take cares of leap years. This means that users will never pick a wrong date.
To Do:
- Support Persian digits as an option
- Support typeface settings
Credits:
PersianDatepicker is heavily based on AOSP (https://source.android.com) and persian-calendar (https://github.com/mortezaadi/persian-calendar).
Version
1.0
License
Apache License Version 2.0