Skip to content

HeyPouya/PersianLinearDatePicker

Repository files navigation

Persian Date Picker

An easy to use Android library to pick a date.

API Codacy Badge ktlint

You can set the minimum and maximum dates to be shown to the user. After user selects the desired date, you can get the year, month and day separated, or joined together by any separator character you like.

Also the numbers are shown in Persian characters by default to users.

Description

Library

This project is made in Kotlin and AndroidX.

Current Functions

Functions that are available in this library are:

  • setMaxYear
  • setMinYear
  • setDate
  • getSelectedYear
  • getSelectedMonth
  • getSelectedDay
  • getSelectedGregorianYear
  • getSelectedGregorianMonth
  • getSelectedGregorianDay
  • getFormattedDate
  • getPersianFormattedDate
  • setOnDateChangedListener

Usage

First add maven repository to your project level gradle file:

   allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

Then add the dependency:

  dependencies {
   implementation ("com.github.SirLordPouya:PersianLinearDatePicker:latest_version")
}

Add PersianLinearDatePicker view to your xml:

<com.pouyaheydari.lineardatepicker.PersianLinearDatePicker
    android:id="@+id/datePicker"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:defaultDay="20"
    app:defaultMonth="6"
    app:defaultYear="1400"
    app:maxYear="1420"
    app:minYear="1320" />

Note that maxYear and minYear are optional. If you don't set any values for minYear or maxYear, 1320..1420 will be used as default values.

License

PersianLinearDatePicker is released under the Apache License 2.0. See LICENSE for details.

Copyright (c) 2020 Pouya Heydari

This App icon and style is designed by Amir Gerdakane