Strange Timezone issue with Tapku Library Calendar - iphone

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

Related

iOS16 bug in SwiftUI.Text(_: Date, style: Text.DateStyle)

I made some widget that used to as a digital clock formatted HH:mm:ss
below is code, or ref: SwiftUI iOS 14 Widget CountDown
let todayMidnight: Date // this property means today's midnight date&time Ex) 2022-08-30 0:0:0, yyyy-MM-dd HH:mm:ss
Text(todayMidnight, style: .timer)
before iOS16 beta, it works well but, not now
I know other way that insert Entry per second to timeline
but first time, I thk it doing well, but after some time, stopped
App WidgetSmith have problem same like me
is someone know about this?
This is a bug in iOS 16.0.
I have submitted feedback.
The good news is that this problem has been fixed in the latest version of iOS16.1

Weird timezone issue with Tapku library

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

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 ;)