Nepali Date Picker library in Jetpack compose for android with Date conversion from BS to AD and vice-versa

Overview

Nepali Date picker Converter - Re in Compose

This is a re-work of Nepali Date Picker Converter in jetpack compose and kotlin.

English Locale Nepali Locale

Setup

Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:

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

Add the dependency

 dependencies {
     implementation 'com.github.keyrunHORNET:composeNepaliDatePicker:$version'
}

Using Date Picker

var showDialog by remember { mutableStateOf(false) }

if (showDialog) {
    NepaliDatePicker(
        onDateSelected = { date ->
            // selected date 
        },
        onDismiss = {
            showDialog = false
        }
    ) 
}

NepaliDate is a data class used to hold value of year, month, day and weekday in date converters and in callbacks of date picker.

onDismiss is mandatory for callback on dismiss of picker dialog.

onDateSelected is mandatory for callback on date selected. Returns selectedNepaliDate

Picker Options

NepaliDatePicker can take additional arguments to customise picker to your needs

  • startDate of type NepaliDate for the date you want to start with, in picker. It's default value is current instance.

  • showYearPickerFirst of type Boolean to show year picker first when picker is displayed. Its true by default and set it to false if you want month view as default view. Especially if you have limited date for selection in picker.

  • minDate of type NepaliDate to set the lower limit of date in picker.

  • maxDate of type NepaliDate to set upper limit of date in picker.

  • highlightDays of type List<NepaliDate>. This will highlight the given list of dates in picker.

  • disableDays of type List<NepaliDate>. This will disable selection of the given dates in picker.

Using Date Converter

value when passed beyond the conversion range throws an IllegalArgumentException. Make sure you catch them.

  • Converting english Date to Nepali date (i.e A.D to B.S):
NepaliDateUtils.adToBs(engYY,engMM,engDD)

you can also pass the calendar instance as an argument

  • Converting Nepali Date to English date (i.e B.S to A.D):
NepaliDateUtils.bsToAd(nepYY,nepMM,nepDD)

you can also pass NepaliDate as an argument

Additional Options

Accessible from NepaliDateUtils

  • NepaliDateUtils.isEngDateInRange(int yy,int mm,int dd) returns true if english date is within the range of conversion.

  • NepaliDateUtils.isNepDateInRange(int yy,int mm,int dd) returns true if nepali date is within the range of conversion.

  • NepaliDateUtils.getInstance() returns current instance of Nepali date

  • NepaliDateUtils.fillMissingWeekDayValue(nepaliDate: NepaliDate) will add missing dayOfWeek for a given NepaliDate.

License

MIT License

Copyright (c) 2022 Kiran Gyawali

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You might also like...
A customizable, easy-to-use, and functional circular time range picker library for Android
A customizable, easy-to-use, and functional circular time range picker library for Android

A customizable, easy-to-use, and functional circular time range picker library for Android. Use this library to mimic Apple's iOS or Samsung's bedtime picker.

[NO LONGER MAINTAINED] Android library for better Picker DialogFragments
[NO LONGER MAINTAINED] Android library for better Picker DialogFragments

/!\ This Project is no longer maintained /!\ DialogFragments modeled after the AOSP Clock and Calendar apps to improve UX for picking time, date, numb

[NO LONGER MAINTAINED] Android library for better Picker DialogFragments
[NO LONGER MAINTAINED] Android library for better Picker DialogFragments

/!\ This Project is no longer maintained /!\ DialogFragments modeled after the AOSP Clock and Calendar apps to improve UX for picking time, date, numb

Android time range picker

TimeRangePicker TimeRangePicker is a library which can be used to select a time range. WARNING Requires android-support-v4 Description This library pr

Simplge ImageGallery Picker
Simplge ImageGallery Picker

SimpleImagePicker add camera and files permissions to manifest file uses-permission android:name="android.permission.CAMERA" / uses-permiss

Standalone Android widget for picking a single date from a calendar view.
Standalone Android widget for picking a single date from a calendar view.

TimesSquare for Android Standalone Android widget for picking a single date from a calendar view. Usage Include CalendarPickerView in your layout XML.

Pick a date or time on Android in style
Pick a date or time on Android in style

Material DateTime Picker - Select a time/date in style Material DateTime Picker tries to offer you the date and time pickers as shown in the Material

A material-styled android view that provisions picking of a date, time & recurrence option, all from a single user-interface.
A material-styled android view that provisions picking of a date, time & recurrence option, all from a single user-interface.

SublimePicker A customizable view that provisions picking of a date, time & recurrence option, all from a single user-interface. You can also view 'Su

An android app that can calculate the minutes from the date the user entered, till today.
An android app that can calculate the minutes from the date the user entered, till today.

AgeInMinutesApp An android app that can calculate the minutes from the date the user entered, till today. If user tap Select Date button, Calender dia

Comments
  • Date Display Issue and doesnot support below minSDK 26

    Date Display Issue and doesnot support below minSDK 26

    Hello, In this lib, there is issue while displaying date of every month of date 12. Instead of 12 there is 22 date is displayed. 1659938684786 Also, why doesn't it support below minSDK 26. I need to support my app from 23 so.

    Thank you!!

    opened by shresthaRam 1
  • Max Date Issue.

    Max Date Issue.

    Thank for this great lib.

    I have got a issue while using max date only. Here is sample code: maxDate.value = NepaliDateUtils.getInstance()

    Log: max NepaliDate(year=2079, month=4, day=30, dayOfWeek=2)

    NepaliDatePicker( showYearPickerFirst=false, // minDate = minDate.value, maxDate = maxDate.value,)

    pic

    Changing month and displaying month it's a issue while using max date.

    opened by shresthaRam 2
Releases(v1.1)
Owner
Kiran Gyawali
Relax, chill, contribute!
Kiran Gyawali
Appleader707 1 Aug 9, 2022
A date time range picker for android written in Kotlin

DateTimeRangePicker A date time range picker for android Usage Firstly, grab latest release of the library via JitPack. And note that, it utilizes Jod

SkedGo 501 Dec 31, 2022
A material Date Range Picker based on wdullaers MaterialDateTimePicker

Material Date and Time Picker with Range Selection Credits to the original amazing material date picker library by wdullaer - https://github.com/wdull

Supratim 1.3k Dec 14, 2022
A material Date Range Picker based on wdullaers MaterialDateTimePicker

Material Date and Time Picker with Range Selection Credits to the original amazing material date picker library by wdullaer - https://github.com/wdull

Supratim 1.3k Dec 14, 2022
Time-DatePicker - A Simple Time Date Picker With Kotlin

Time-DatePicker Time.DatePicker.mp4

Faysal Hossain 0 Jan 19, 2022
Alwan 🎨 is an Android Jetpack Compose color picker library.

Alwan Alwan is an Android Jetpack Compose color picker library. Preview Recording.mp4 Download Gradle: dependencies { implementation 'com.raedapps:a

Raed Mughaus 6 Sep 16, 2022
JetCountrypicker - Country code bottomsheet picker in Jetpack Compose

JetCountryPicker Country code bottomsheet picker in Jetpack Compose How to add i

Canopas Software 30 Nov 17, 2022
Android Compose wheel picker library based on LazyColumn in vertical and LazyRow in horizontal.

About Android Compose wheel picker library based on LazyColumn in vertical and LazyRow in horizontal. Gradle Sample Default Item size Unfocused count

null 6 Dec 22, 2022
Material3 themed Jetpack Compose date & time pickers.

Compose material3 Date1 and Time pickers Highly customizable Jetpack Compose components with material3 support for date & time picking. Contents Lates

Maroš Šeleng 35 Jan 31, 2023
A simple compose weight picker drawn with canvas.

CanvasWeightPicker A simple compose weight picker drawn with canvas. Features Drag scale to select weight Haptic feedback on weight selected Video of

Timothy Serem 5 Dec 2, 2022