Weird timezone issue with Tapku library - iphone

I have a strange issue with Tapku Calendar control library.
It was showing me wrong date information, so I replaced all timezones from
[NSTimeZone timeZoneForSecondsFromGMT:0]
to
[NSTimeZone systemTimeZone]];
All works well till here.
However, when I changed timezone in the file called
NSDate + CalendarGrid.m,
at that point my calendar selection of dates was disabled.
No touches are being detected on calendar.
I have done all this step by step and found this issue in NSDate+CalendarGrid.m file.
I have already spent lot of hours finding this.
Please help in how to fix this weird issue.
Thanks in advance.

I don't know about the touches Disabled Problem, But for fixing the wrong date information problem, what you can do is change the following line in viewDidLoad
[self.monthView selectDate:[NSDate date] month];
to
[self.monthView selectDate:[NSDate date]];
Hope it helps

Related

Strange Timezone issue with Tapku Library Calendar

I have a weird problem with the Tapku Library Calendar.
I am showing events in Tapku Library Calendar. I am getting date from my server in America/Toronto Time zone. ie. -500.
My system and calendar time zone set to Toronto,Canada in Setting app.
So, the problem is when Calendar show one event in wrong day view (day tiles). Event is on 16th November 2011 and it is showing on 17th on to the Calendar.
11/16/2011 17:00 -0500
So I found solution to make time zone as GMT.
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:#"GMT"]];
And above working fine with Toronto time zone. Now, I set my timezone to Rome,Italy and It suppose to show that event on 16th too but it is showing on 17th.
so, the problem is if I keep above line it works fine with the Toronto, Canada Timezone and problem with the Rome,Italy Timezone and If I remove this line then it works fine for Rome,Italy and problem with Toronto,Italy.
For this I tried to set systemTimeZone and localTimeZone as well but still no luck.
So, what should I do to keep event on correct day view for all the timezones ?
Please let me know if you require any further details.
Here is an answer to a similar problem:
https://stackoverflow.com/a/9405625/220154
I think the tapku calendar sets GMT:0 as the date it uses to compare against your dates, so it mess a lot with timezones. probably you would need to reduct the date to GMT midnight when you are checking what dates to include in the calendar.
hope it helps.
All [NSTimeZone timeZoneForSecondsFromGMT:0]; should be replaced with [NSTimeZone systemTimeZone];
When it is not systemTimeZone you have to edit your dates coming out of the UIDatePicker to reflect time zone hour change, and all dates would be displayed a day later if you don't.
Here is the issue : https://github.com/devinross/tapkulibrary/issues/40

iphone uidatepicker localization

I facing a problem with localization in iphone date picker.I want the date picker to show dates only in English, but now it takes the language which is set to the region in iphone settings.I tried various things which was not useful like the below.
setting the locale setting in the nib file of the uidatepicker.
setting the locale through code
NSLocale* locale = [[NSLocale alloc] initWithLocaleIdentifier:#"en_GB"];
[datePicker setLocale:locale];
[datePicker setCalendar:[locale objectForKey:NSLocaleCalendar]];
This did not work.If any one has good ideas to resolve the issue please help
I think this is a known issue. The date picker seems to rely on the current user's country settings which you cannot change from code. In fact, I don't know what the locale property is there for. It simply does nothing.

UIDatePicker for a Non-Gregorian calendar

I am using UIDatePicker in my App, which works fine for a Gregorian calendar.
But I want to use a Non-Gregorian calendar with the DatePicker, which I didn't succeed to do it!
I need it to do some conversion from Non-Gregorian to Gregorian dates, so it must work the same whatever the iPhone 'Locales' are.
Please can you answer this!
Your help is really appreciated,
Did you try setting the UIDatePicker's calendar property to a non-Gregorian calendar?

init] returning date an hour in the past?

When I call
NSDate *now = [[NSDate alloc] init];
in order to get the current date and time, I check it with:
NSLog(#"Date now: %#", now);
the date outputted is one hour in the past.
2010-10-08 12:04:38.227
MiniBf[1326:207] Now: 2010-10-08
11:04:38 GMT
Is my time zone set incorrectly somewhere perhaps?
Thanks!
Michael
I've seen that behavior on the DatePicker running on iOS 4.1 devices while on iOS 4.0 and previous it does not happen. I can't confirm it is actually the same bug.
But I suggest you check whether is related with the acknowledged by Apple bug regarding dates/summer time/4.1 by running that code on < 4.1. Then you will need to decide whether to hack a fix for that particular version/dates or wait for the next release of the SDK to fix it and not support 4.1 devices...
The bug I'm talking about I believe only happens while passing dates within the summer time period (2010: 28th March - 31st October)
Use NSDateFormatter to localize the date:
NSLog(#"%#",[NSDateFormatter localizedStringFromDate:[NSDate date] dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterShortStyle]);
Use NSDate *now = [NSDate date];
I am using it and giving me perfect result.
Maybe your timezone is wrong in your iPhone simulator. Press the home button, go to settings.app and correct it ;)

How To Call/Create iPhone Calendar In A User Application

I would like to know whether we can create a calendar using NSCalender and show it in our dedicated application. We can create a NSCalender object by
****NSCalendar *japaneseCalendar = [[NSCalendar alloc] initWithCalendarIdentifier : NSJapaneseCalendar];****
But how can we show this calender in out application. Is there any way to show the default calander in our application when a user click a button.
Please please guide me, i am hanging here for last few days.
Thank You
Rahul
NSCalendar has nothing to with the Calendar app on the iPhone, it's simply a class used to represent a calendar for whatever reason you need one.
I'm not sure that this can be done on the iPhone from within an app.
-
After re-reading your question, I think I misunderstood what you were asking.
If you want to display some kind of calendar view within the app using that particular calendar, you'll have to create you own view and draw the calendar into it.
You may be able to find some code on the internet to accomplish this already.