abhi-dave / addatepicker Goto Github PK
View Code? Open in Web Editor NEWA fully customizable iOS Horizontal PickerView library, written in pure swift
License: MIT License
A fully customizable iOS Horizontal PickerView library, written in pure swift
License: MIT License
I can set the initialDate but after view is loaded i am unable to change the selected date programmatically
datePicker.currentDate = Date().addingTimeInterval(3600*24))
From debugging..it seems days model does't contain 31
so
let d = days.index { (modelObj) -> Bool in return Int(modelObj.type) == Int(dd) }
gives nil and crashes on days[d!].isSelected = true
The issue happens in devices in timezones other that GMT. The returned day is the previous day of the day picked by the user. That happens because when converting the date string to Date the timezone is not taken into account (DateFormatter assumes 00:00 for GMT). And if your timezone is not GMT when using or visualising the Date it is converted to YOUR timezone and if it is for example GMT-1, you date has been changed to the previous day at 23:00.
How to fix? The following change fixed the issue for me.
In CalendarHelper.swift change:
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "MM/dd/yyyy"
if currentDay == "" {
currentDay = (days.last?.type)!
}
let date = dateFormatter.date(from: "\(currentMonth)/\(currentDay)/\(currentYear)")
to
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "MM/dd/yyyy"
if currentDay == "" {
currentDay = (days.last?.type)!
}
dateFormatter.locale = Locale.current // Added line
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0) // Added line
let date = dateFormatter.date(from: "\(currentMonth)/\(currentDay)/\(currentYear)")
ADDatePicker(frame: .zero)
method is not available as public
class func getYears(startYear: Int = 1980, endYear: Int = 2018) ;
I recommend changing the default value of endYear of the method func getYears(startYear:Int = 1980,endYear:Int = 2018) to the current year, otherwise it will crash if there is no age range set.
Hi,
I want to update the date label text, while scrolling the date, month , row. Could you please update me regarding this?
Kindly let me know if you need more clarifications.
Thanks.
Error if iOS device preferred device language other than English.
Easy t test, just switch language from device Settings > General > Language & Region > Make any other language first on Preferred Language order.
Date picker will report error "Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value!" in CalendarHelper.swift "return date!" line 89
I'd like to be able to limit the number of days we can scroll.
For example +/- 3 days from today (August 25th)
func limitScrollingOfDays(daysBefore before: Int, daysAfter after: Int, from selectedDate) {
//TODO: Logic here
}
And be used like:
datePicker.limitScrollingOfDays(daysBefore: 3, daysAfter: 10, from: Date())
It should limit the number of scrolling days from August 22nd to September 4th
i have found an issue on leap year. after launching it current date. i am trying to move the year section (2016) and then month section (feb). after that i have found that 29th is selected but not moved to the selected area of the picker. this happen when our first launching current date is like 31-03-20
datePicker.bgColor = .clear
datePicker.deselectedBgColor = .clear
datePicker.selectedBgColor = COLORS.Blue
datePicker.selectedTextColor = .white
datePicker.deselectTextColor = UIColor(hex: 0x1B9AFF).alpha(alpha: 0.7)
https://i.ibb.co/N6Q2drx/image.png
blacks seems to work fine
Hi i set Custom Class of UIView to ADDatePicker and run the app.
then app crashes on .
https://i.ibb.co/CPRPHRf/image.png
hoping for a reply ASAP please
I'd like to be able to display weekdays inside the scrolls and decide if I want to display for example year or maybe number of days
Something like:
MON | TUE | WED | THUR | FRI | SAT | SUN
1 | 2 | 3 | 4 5 | 6 | 7
JAN | ....
And a method like:
func displayElements(_ elements: [ElementType]) {
//Logic here
}
That would be called like:
datePicker.displayElements([.weekday, .day, .month])
The code above would display weekdays, days and months
While this one below would display only months and years:
datePicker.displayElements([.month, .year])
I love the design of this horizontal picker. Can we replace the text with images? I am interested in the carousel itself. Not the data picker. Thanks!
I Need a just month and year picker...i was thinking to give some -ve top dates section get hidden :D but not working...so can i have it as feature like a fixed height from user and then he can control what to show or option to make picker just for month and year
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.