All Projects β†’ afollestad β†’ Date Picker

afollestad / Date Picker

Licence: apache-2.0
πŸ“… Custom responsive date picker widget for Android, written in Kotlin.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Date Picker

Angular Moment Picker
Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
Stars: ✭ 536 (+267.12%)
Mutual labels:  time, date, datetime, picker
vue-timeselector
πŸ•’ Simply customizable powerful time picker for Vue.js
Stars: ✭ 41 (-71.92%)
Mutual labels:  time, datetime, date, picker
Delorean
Delorean: Time Travel Made Easy
Stars: ✭ 1,793 (+1128.08%)
Mutual labels:  time, date, datetime
Pickadate.js
The mobile-friendly, responsive, and lightweight jQuery date & time input picker.
Stars: ✭ 7,753 (+5210.27%)
Mutual labels:  time, date, picker
Horizontalpicker
DatePicker horizontal con selecciΓ³n smooth por dΓ­a para Android.
Stars: ✭ 116 (-20.55%)
Mutual labels:  date, datetime, picker
Dateparse
GoLang Parse many date strings without knowing format in advance.
Stars: ✭ 1,365 (+834.93%)
Mutual labels:  time, date, datetime
Tinydate
A tiny (349B) reusable date formatter. Extremely fast!
Stars: ✭ 990 (+578.08%)
Mutual labels:  time, date, datetime
Time Stamp
Get a formatted timestamp. Used in gulp, assemble, generate, and many others.
Stars: ✭ 104 (-28.77%)
Mutual labels:  time, date, datetime
Vue Datetime
Mobile friendly datetime picker for Vue. Supports date and datetime modes, i18n and more.
Stars: ✭ 928 (+535.62%)
Mutual labels:  time, date, datetime
Tail.datetime
A lightweight, translat- and configurable Open Source DateTime Picker, written in pure vanilla JavaScript!
Stars: ✭ 139 (-4.79%)
Mutual labels:  time, date, datetime
When
A natural language date/time parser with pluggable rules
Stars: ✭ 1,113 (+662.33%)
Mutual labels:  time, date, datetime
Iso8601
Ruby parser to work with ISO8601 dateTimes and durations β€” http://en.wikipedia.org/wiki/ISO_8601
Stars: ✭ 70 (-52.05%)
Mutual labels:  time, date, datetime
Luatz
Time, Date and Timezone library for lua
Stars: ✭ 92 (-36.99%)
Mutual labels:  time, date, datetime
React Picky Date Time
A react component for date time picker. Online demo examples
Stars: ✭ 31 (-78.77%)
Mutual labels:  time, date, picker
Calendar
πŸ“… PHP Date & Time library that solves common problems in object oriented, immutable way.
Stars: ✭ 113 (-22.6%)
Mutual labels:  time, date, datetime
Dayjs
⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API
Stars: ✭ 37,373 (+25497.95%)
Mutual labels:  time, date, datetime
Zulu
A drop-in replacement for native Python datetimes that embraces UTC.
Stars: ✭ 52 (-64.38%)
Mutual labels:  time, date, datetime
Rc Datetime Picker
React component for datetime picker by Moment.js
Stars: ✭ 85 (-41.78%)
Mutual labels:  date, datetime, picker
Vue Ctk Date Time Picker
VueJS component to select dates & time, including a range mode
Stars: ✭ 707 (+384.25%)
Mutual labels:  time, date, picker
Singledateandtimepicker
You can now select a date and a time with only one widget !
Stars: ✭ 921 (+530.82%)
Mutual labels:  time, date, picker

Date Picker

Maven Central Android CI Codacy Badge License


Gradle Dependency

dependencies {
  ...
  implementation 'com.afollestad:date-picker:0.6.1'
}

Why?

Android includes a stock DatePicker in its framework, however this widget is very stubborn. It does not adapt to different view widths, making it difficult to use in modern UI. This library solves for that by creating a custom implementation, written completely in Kotlin.


Basics

It's simple, just add a DatePicker to your layout (with the fully qualified package name):

<com.afollestad.date.DatePicker
    android:id="@+id/datePicker"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    />

There are a few basic getters and setters:

val datePicker: DatePicker = // ...

val selectedDate: Calendar? = datePicker.getDate()

datePicker.setDate(
    year = 2019,
    month = Calendar.JUNE,
    selectedDate = 17
)
datePicker.setDate(Calendar.getInstance())

Styling

You can configure basic theme properties from your layout:

<com.afollestad.date.DatePicker
    xmlns:app="http://schemas.android.com/apk/res-auto"
    ...
    app:date_picker_selection_color="?colorAccent"
    app:date_picker_header_background_color="?colorAccent"
    app:date_picker_medium_font="@font/some_medium_font"
    app:date_picker_normal_font="@font/some_normal_font"
    app:date_picker_disabled_background_color="@color/disabled_color"
    app:date_picker_selection_vibrates="true"
    app:date_picker_calendar_horizontal_padding="4dp"
    />

(Note that in order for date_picker_selection_vibrates=true to have an effect, your app needs to declare the VIBRATE permission in its manifest.)


Callback

val datePicker: DatePicker = // ...

datePicker.addOnDateChanged { previousDate, newDate->
  // this library provides convenience extensions to Calendar like month, year, and dayOfMonth too.
}

// Removes all callbacks you've added previously with addOnDateChanged(...) 
datePicker.clearOnDateChanged()

Min and Max Dates

val datePicker: DatePicker = // ...

val minDate = datePicker.getMinDate()
datePicker.setMinDate(
  year = 2019,
  month = Calendar.JUNE,
  date = 17
)
datePicker.setMinDate(Calendar.getInstance())

val maxDate = datePicker.getMaxDate()
datePicker.setMaxDate(
  year = 2019,
  month = Calendar.JUNE,
  date = 20
)
datePicker.setMaxDate(Calendar.getInstance())
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].