开发者

iphone UIDatePicker showing wrong date in Central Timezone

I am at a loss. I have an NSDate that gets passed to a UIDatePicker. When I am set to the Eastern time zone, all is fine.

When I am set to Central, the date picker shows the time as being off by 1 h开发者_JAVA技巧our.

So, if I turn my NSLogs on, this is what I show:

2010-08-25 18:15:19.317[59299:207] ---- into the picker --->2010-08-25 17:37:51 -0500
2010-08-25 18:15:19.318[59299:207] Local Time Zone America/Chicago
2010-08-25 18:15:19.318[59299:207] 2010-08-25 17:37:51 -0500
2010-08-25 18:15:19.319[59299:207] current locale: en_US

But the UIDatePicker displays "Today 6:37 PM".

If I reset my timezone to Eastern, I get this:

2010-08-25 19:26:11.551[59521:207] ---- into the picker --->2010-08-25 18:37:51 -0400
2010-08-25 19:26:11.552[59521:207] Local Time Zone America/New_York
2010-08-25 19:26:11.552[59521:207] 2010-08-25 18:37:51 -0400
2010-08-25 19:26:11.553[59521:207] current locale: en_US

And the UIDatePicker displays "Today 6:37 PM".

Just wondering if anyone out there has seen this before. It looks like a timezone or daylight savings problem, but I can't seem to track it down.

Any help would be appreciated.

edit: I did some more testing with this and it seems like any timezone causes problems. It is almost like the UIDatePicker only wants to display in Eastern. I don't think I have anything set that would do that.


I did some more searching. It sure helps if you use the correct search terms.

Anyhow, I found the answer on the iPhoneDevSDK - http://www.iphonedevsdk.com/forum/iphone-sdk-development/52533-uidatepicker-bug-ios-4-a.html - UIDatePicker bug.

It looks like there might be a UIDatePicker bug.

I added this to my code before I set the picker and it fixed the problem.

datePicker.timeZone = [NSTimeZone localTimeZone];

No more problem (for now).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜