I'm developing a calendar app using ionic and I want to show only the current days in the month in the view. I'm using ionic2-calendar and now it shows the previous month's last days, current month's days, and next month's first days in one calendar view. Please help me with this.
Thanks to #Indraraj26 's comment, I finally managed to solve the issue by adding visibility: hidden to the related class in global.scss file . (as below)
td.text-muted{
visibility: hidden;
}
The best option I can find is to begin the month on the 1st, hiding the greyed out days before the 1st day of the month. Do this by adding the option [startingDayMonth]=1 to the calendar directive, e.g.
<calendar
...
[startingDayMonth]=1
...
></calendar>
As #Indraraj26 pointed out, you could hide td.text-muted globally but this could well have side-effects.
I would certainly create an issue to add a similar option for hiding next month's dates.
Related
I have a button which disables after it is pressed. I need To work out how to get the button re-enable after midnight, or the next day.
So I think I need the button to set the date in a variable after it is pressed. Then an if statement which enables the button if the variable does not match today's date.
Would that be the best way to handle it? Can anyone offer any rough code advice, or possibly advice of an easier way to handle enabling a button after midnight?
Thanks
Then an if statement which enables the button if the variable does not match today's date.
But the question is, an if statement where? Your code can only run if something makes it run. If your app is just sitting there, midnight can come and go and your button won't be enabled because the code that looks to see if it's a different day from the day you saved is not running.
The solution:
Register to be notified by the system when the day changes.
Woow finally some nice question... it's definitely possible... you can check this beautiful documentation by apple:
https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
Basically you have 2 or more solutions, just 2 comes to my mind right now:
1.) Use UserDefaults or CoreData (Userdefaults for one property is more acceptable I guess
2.) Run backgroundTask as mentioned above..
The first one is very basic solution... you get the date when the button was tapped and if the day is equal to the day you entered the screen later, you keep the button disabled, else you unlock the button and store again the date into the user defaults, this seems to me a little piggy if you ask me..
The second one is much more elegant, in a nutshell... You setup button with some actions and the last thing is disabling it. Then, you setup background Task that every next day the button becomes enabled again...
I am pretty sure you will find the codes somewhere else here, maybe you will find the first algorithm more useful for you..
Anyway wish you best luck and happy coding! :)
I want to have a time range on a UIDatePicker, so I can display what times users can book a meeting. Say on May 25th, they can book between 12pm and 8 pm, if they scroll to May 26th they can book between 4pm and 8pm.
So I'm wondering how I can display this in a UIDatePicker? Users can't choose time outside of a preset I have for each day.
Any help is appreciated!
I found this one, hope this will help you out..
Can UIDatePicker's minimumDate and maximumDate include time?
Enjoy Coding :)
Sorry, but no. UIDatePicker can only set ranges for dates. If you want to restrict the range of the hours, you will have to subclass uidatepicker and create your own custom class.
Here's a link: UIDatePicker hours interval (NSCalendarUnit?)
Hope this helped!
I would suggest using UIPickerView to make your own date picker. Every time a date is selected, you can change what times are available inside pickerView:didSelectRow:inComponent:.
What I ended up doing was to add a target to the date picker, and check if the time of the date chosen matched the hours I preset and display an alert view if they didn't match.
I'm after a open source Calendar List View, Tapku has Day and Month, but I need a listView, if it hasn't been done, I have to do it myself, and if so I'll just create a fork of Tapku and add it.
ya i know one such calendar Kal. you can try Kal. I have given its link below. it has a day view, a month view and a list view of a calendar. try using it. it is the best one.
https://github.com/klazuka/Kal
Hope this helps you.
I want to show only day and month and not year in my date picker. Not sure how to achieve this. Please suggest.
you'll find the answer by Googling this and clicking on the first entry which happens to be from Stackoverflow also: UIDatePicker show only month and day
Hope it helps!
I solved this by setting the maximumDate property to current date. This disabled the dates from current date.
I'm trying to make a UIDatePicker which allows the selection of hours only between 6.00 and 17.00. The other hours shall be inactive but still visible.
I think it can be done with setting up the picker calendar and then use this:
- (NSRange)maximumRangeOfUnit:(NSCalendarUnit)unit
but I'm not sure how.
Maybe someone can help me.
Thank you!
Sorry, but UIDatePicker doesn't support setting valid time ranges like you describe. The only options are minimum and maximum dates.
You'll either need to build a custom control from scratch or try to subclass UIDatePicker, but that's not a path I'd recommend.