Giter Club home page Giter Club logo

persiandatepicker's Introduction

PersianDatePicker

An Android DatePicker for Persian Calendar

ScreenShot ScreenShot

Usage:

  • Add as an Android Library Project:
  • Add this line to root layout element:
xmlns:persianDatePicker="http://schemas.android.com/apk/res-auto"
  • Add PersianDatePicker view:
<ir.smartlab.persindatepicker.PersianDatePicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
  • 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:
<declare-styleable name="PersianDatePicker">
        <attr name="minYear" format="integer" />
        <attr name="maxYear" format="integer" />
        <attr name="selectedYear" format="integer" />
        <attr name="selectedMonth" format="integer" />
        <attr name="selectedDay" format="integer" />
        <attr name="displayMonthNames" format="boolean" />
        <attr name="yearRange" format="integer" />
    </declare-styleable>

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:
<ir.smartlab.persindatepicker.PersianDatePicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
  • Display a PersianDatePicker with selected Hijri Shamsi (Jalali) date:
    <ir.smartlab.persindatepicker.PersianDatePicker
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:selectedYear="1390"
    app:selectedMonth="5"
    app:selectedDay="15" />
  • Display a PersianDatePicker that shows month names:
<ir.smartlab.persindatepicker.PersianDatePicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:displayMonthNames="true" />
  • Display a PersianDatePicker that shows years between 1350 and 1450:
<ir.smartlab.persindatepicker.PersianDatePicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:maxYear="1450"
        app:minYear="1350" />

Java Examples:

  • You can set a java.util.Date object to PersianDatePpicker in java code:
persianDatePicker.setDisplayDate(new Date());
  • you can also set a ir.smartlab.persindatepicker.util.PersianCalendar object:
PersianCalendar persianCalendar = new PersianCalendar();
persianCalendar.setPersianDate(1393, 6, 28);
persianDatePicker.setDisplayPersianDate(persianCalendar);
  • You can get displayed date in java.util.Date or ir.smartlab.persindatepicker.util.PersianCalendar:
Date d = persianDatePicker.getDisplayDate();
// OR
PersianCalendar pCal = persianDatePicker.getDisplayPersianDate();

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

persiandatepicker's People

Contributors

abbas-oveissi avatar alibehzadian avatar masoudfallahpour avatar mderis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

persiandatepicker's Issues

Problem in import

با سلام
من پروژه مورد نظر رو دانلود و به پروژه خودم اضافه کردم ولی متاسفانه موقع سینک کردن گریدل Error:Configuration with name 'default' not found.
این خطا رو می دهد
از روش دوم هم استقاده کردم و تمامی کدها رو به پروژه اضافه کردم ولی این سری با خود کلاس هایی که شما نوشته بودید مشکل داره
می تونید راهنمایی کنید؟
ممنون می شم

why I cannot download ?

hello
I cannot download this persiandatepicker by Download Zip button and ...
can you help me ?
or send the library to my gmail I added below
[email protected]
thank you very much
m.sh from north khorasan

library name

سلام . من نمیتونم اسم کتابخونه رو پیدا کنم . ممکنه راهنمایی بفرمایید

getDisplayeDate method

سلام
متدهای تعریف شده برای گرفتن تاریخ انتخاب شده به درستی کار نمیکند.لطفا در صورت اشتباه از طرف بنده نحوه استفاده درست از این متد را توضیح دهید و یا در صورت اشتباه بودن متد و عدم جوابگویی آن را اصلاح نمایید.با تشکر

Screen Shots

Hi, is there any screen shot for this library? could you attach on readme?

how to convert to miladi date?

hi mr behzadian
very good library 2 use!
but i didnt find any functions to return miladi date, guid me if there is any way!
TnX ;)

Listener for date change

I've had a quick look at PersianDatePicker.java and have found that there is no way for a class to be notified when the date of PersianDatePicker changes. If that is the case I can send you a pull request that adds that feature.

Rendering pronlem

Hello
Thanks for your library.
when I open the project in android studio(not import in my own project) and when open the acrivity_main in design view i get this error:
rendering problems
the following class could not be found:
ir.smartlab.persiandatepicker.PersianDatePicker

When I import the module in my own project I also got that error.what is the problem, please help.

problem with getDisplayPersianDate()

The output of the function "getDisplayPersianDate()" is as written below. I would be thankful if you modify it:

at.andreasrohner.spartantimelapserec.persindatepicker.util.PersianCalendar[time=1312653074599,areFieldsSet=true,lenient=true,zone=GMT,firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2011,MONTH=7,WEEK_OF_YEAR=32,WEEK_OF_MONTH=1,DAY_OF_MONTH=6,DAY_OF_YEAR=218,DAY_OF_WEEK=7,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=5,HOUR_OF_DAY=17,MINUTE=51,SECOND=14,MILLISECOND=599,ZONE_OFFSET=0,DST_OFFSET=0,PersianDate=1390/05/15]

Problem with timezone

I went the following methods:

pCal.setTimeZone (TimeZone.getTimeZone ( "Iran"));
&
pCal.setTimeZone (TimeZone.getTimeZone ( "Asia / Tehran"));
&
pCal.setTimeZone (TimeZone.getTimeZone ( "GMT + 03: 30"));

change font

hi
thank for this it was really usefull but how can i change the font of the number picker

نمایش تاریخ جاری سیستم در هر صورت

مشکلم اینجاست که همواره مقدار تاریخ جاری رو بهم برمیگردونه ! ینی هر چقدر من عوض میکنم هیچ اتفاقی نمیوفته.
اما متد شما میگه getDisplayPersianDate !!
ینی تاریخی که داری نمایش میدی رو برگردون. !!! نه تاریخ جاری رو !!
ممنون میشم راهنمایی کنید.

Error parsing XML: unbound prefix

Hi
I have imported the project as a Library
I face to this problem when I want to add attributes like app:maxYear="1450" to my layout file.
without any attributes the simple following tag will work
<ir.smartlab.persindatepicker.PersianDatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

Invalid month and day value

There's an issue for month and day when enter values by keyboard. fields value filled valid but when get values, result isn't valid.

Thanks.

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.