[MonoTouch] UIDatePicker - AM/PM : Getting it exactly the wrong way around.
I'm using a *UIDatePicker *control in a pretty standard way (I think). That is, I'm not setting much configuration at all at initialization: Control = new UIDatePicker(RectangleF.Empty){ AutoresizingMask = UIViewAutoresizing.FlexibleWidth }; The problem is, when I read the selected *Date* value out of it, the AM/PM values are exactly the wrong way around. Eg. 1PM is being returned as 1AM and vice versa. Here's a GIST of the entire code I've got (for context): https://gist.github.com/3082372 Is this some kind of time-zone wierdness. I'm in NZ. Doesn't seem like it's time-zones though, because it's an exact reversal of the AM/PM values, not a shift in the time. Thanks! -- *Phil *Cockfield ___ MonoTouch mailing list MonoTouch@lists.ximian.com http://lists.ximian.com/mailman/listinfo/monotouch
Re: [MonoTouch] UIDatePicker - AM/PM : Getting it exactly the wrong way around.
Hi, I think the date picker handles date/time internally in some way, so I use my date picker this way: picker.Date = date.ToLocalTime(); date = DateTime.SpecifyKind(picker.Date, DateTimeKind.Local).ToLocalTime(); Does that help? Mikkel On Tue, Jul 10, 2012 at 11:55 AM, Phil Cockfield p...@cockfield.net wrote: I'm using a *UIDatePicker *control in a pretty standard way (I think). That is, I'm not setting much configuration at all at initialization: Control = new UIDatePicker(RectangleF.Empty){ AutoresizingMask = UIViewAutoresizing.FlexibleWidth }; The problem is, when I read the selected *Date* value out of it, the AM/PM values are exactly the wrong way around. Eg. 1PM is being returned as 1AM and vice versa. Here's a GIST of the entire code I've got (for context): https://gist.github.com/3082372 Is this some kind of time-zone wierdness. I'm in NZ. Doesn't seem like it's time-zones though, because it's an exact reversal of the AM/PM values, not a shift in the time. Thanks! -- *Phil *Cockfield ___ MonoTouch mailing list MonoTouch@lists.ximian.com http://lists.ximian.com/mailman/listinfo/monotouch ___ MonoTouch mailing list MonoTouch@lists.ximian.com http://lists.ximian.com/mailman/listinfo/monotouch
Re: [MonoTouch] UIDatePicker - AM/PM : Getting it exactly the wrong way around.
The dates that come out of pickers are GMT. You are GMT+12 :) (I had the same problem developing TripWallet - I was in NZ then, too) On Tue, Jul 10, 2012 at 10:55 AM, Phil Cockfield p...@cockfield.net wrote: I'm using a UIDatePicker control in a pretty standard way (I think). That is, I'm not setting much configuration at all at initialization: Control = new UIDatePicker(RectangleF.Empty){ AutoresizingMask = UIViewAutoresizing.FlexibleWidth }; The problem is, when I read the selected Date value out of it, the AM/PM values are exactly the wrong way around. Eg. 1PM is being returned as 1AM and vice versa. Here's a GIST of the entire code I've got (for context): https://gist.github.com/3082372 Is this some kind of time-zone wierdness. I'm in NZ. Doesn't seem like it's time-zones though, because it's an exact reversal of the AM/PM values, not a shift in the time. Thanks! -- Phil Cockfield ___ MonoTouch mailing list MonoTouch@lists.ximian.com http://lists.ximian.com/mailman/listinfo/monotouch -- Nic Wise t. +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise b. http://www.fastchicken.co.nz/ Earnest: Self-employed? Track your business expenses and income. http://earnestapp.com Nearest Bus: find when the next bus is coming to your stop. http://goo.gl/Vcz1p mobileAgent (for FreeAgent): get your accounts in your pocket. http://goo.gl/IuBU Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2 ___ MonoTouch mailing list MonoTouch@lists.ximian.com http://lists.ximian.com/mailman/listinfo/monotouch
Re: [MonoTouch] UIDatePicker - AM/PM : Getting it exactly the wrong way around.
Thanks Nic - good to know it actually is a TimeZone issue. Being exactly 12 hours off made it look suspicious :) There must be some other trick, beyond what Mikkel was showing with the * ToLocalTime*() methods to have it convert correctly. Mikkel suggested this: picker.Date = date.ToLocalTime(); date = DateTime.SpecifyKind(picker.Date, DateTimeKind.Local).ToLocalTime(); Were there other time localization calls you were making for TripWallet? On Wed, Jul 11, 2012 at 12:44 AM, Nic Wise n...@fastchicken.co.nz wrote: The dates that come out of pickers are GMT. You are GMT+12 :) (I had the same problem developing TripWallet - I was in NZ then, too) On Tue, Jul 10, 2012 at 10:55 AM, Phil Cockfield p...@cockfield.net wrote: I'm using a UIDatePicker control in a pretty standard way (I think). That is, I'm not setting much configuration at all at initialization: Control = new UIDatePicker(RectangleF.Empty){ AutoresizingMask = UIViewAutoresizing.FlexibleWidth }; The problem is, when I read the selected Date value out of it, the AM/PM values are exactly the wrong way around. Eg. 1PM is being returned as 1AM and vice versa. Here's a GIST of the entire code I've got (for context): https://gist.github.com/3082372 Is this some kind of time-zone wierdness. I'm in NZ. Doesn't seem like it's time-zones though, because it's an exact reversal of the AM/PM values, not a shift in the time. Thanks! -- Phil Cockfield ___ MonoTouch mailing list MonoTouch@lists.ximian.com http://lists.ximian.com/mailman/listinfo/monotouch -- Nic Wise t. +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise b. http://www.fastchicken.co.nz/ Earnest: Self-employed? Track your business expenses and income. http://earnestapp.com Nearest Bus: find when the next bus is coming to your stop. http://goo.gl/Vcz1p mobileAgent (for FreeAgent): get your accounts in your pocket. http://goo.gl/IuBU Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2 -- *Phil *Cockfield ___ MonoTouch mailing list MonoTouch@lists.ximian.com http://lists.ximian.com/mailman/listinfo/monotouch
Re: [MonoTouch] UIDatePicker - AM/PM : Getting it exactly the wrong way around.
I was trying to use NSTimeZone, but I think what he has will work a lot better. Mine is MESSY On Tue, Jul 10, 2012 at 8:30 PM, Phil Cockfield p...@cockfield.net wrote: Thanks Nic - good to know it actually is a TimeZone issue. Being exactly 12 hours off made it look suspicious :) There must be some other trick, beyond what Mikkel was showing with the * ToLocalTime*() methods to have it convert correctly. Mikkel suggested this: picker.Date = date.ToLocalTime(); date = DateTime.SpecifyKind(picker.Date, DateTimeKind.Local).ToLocalTime(); Were there other time localization calls you were making for TripWallet? On Wed, Jul 11, 2012 at 12:44 AM, Nic Wise n...@fastchicken.co.nz wrote: The dates that come out of pickers are GMT. You are GMT+12 :) (I had the same problem developing TripWallet - I was in NZ then, too) On Tue, Jul 10, 2012 at 10:55 AM, Phil Cockfield p...@cockfield.net wrote: I'm using a UIDatePicker control in a pretty standard way (I think). That is, I'm not setting much configuration at all at initialization: Control = new UIDatePicker(RectangleF.Empty){ AutoresizingMask = UIViewAutoresizing.FlexibleWidth }; The problem is, when I read the selected Date value out of it, the AM/PM values are exactly the wrong way around. Eg. 1PM is being returned as 1AM and vice versa. Here's a GIST of the entire code I've got (for context): https://gist.github.com/3082372 Is this some kind of time-zone wierdness. I'm in NZ. Doesn't seem like it's time-zones though, because it's an exact reversal of the AM/PM values, not a shift in the time. Thanks! -- Phil Cockfield ___ MonoTouch mailing list MonoTouch@lists.ximian.com http://lists.ximian.com/mailman/listinfo/monotouch -- Nic Wise t. +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise b. http://www.fastchicken.co.nz/ Earnest: Self-employed? Track your business expenses and income. http://earnestapp.com Nearest Bus: find when the next bus is coming to your stop. http://goo.gl/Vcz1p mobileAgent (for FreeAgent): get your accounts in your pocket. http://goo.gl/IuBU Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2 -- *Phil *Cockfield -- Nic Wise t. +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise b. http://www.fastchicken.co.nz/ Earnest: Self-employed? Track your business expenses and income. http://earnestapp.com Nearest Bus: find when the next bus is coming to your stop. http://goo.gl/Vcz1p mobileAgent (for FreeAgent): get your accounts in your pocket. http://goo.gl/IuBU Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2 ___ MonoTouch mailing list MonoTouch@lists.ximian.com http://lists.ximian.com/mailman/listinfo/monotouch