Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
I think i may have discovered a bug relating to the ToShortTimeString() method on the DateTime Object in iOS where the string returned is not correctly formatted.
If the culture settings for the device are set to United Kingdom and the 24hr setting in DateTime is set to Yes, the string returned is in 24hr format (for example 23:00). However if the 24hr setting under DateTime is set to no/off then this method still returns 23:00, surely it should be 11:00 p.m.
Upon analysis if you use the NSDateFormatter class to format the string to ShortTime it will obey all the settings and return 11:00 pm if the 24hr setting is switched off and 23:00 if its switched on.
Below is the sample piece of coding that i have used to illustrate this:
DateTime date = DateTime.Now;
toShortTimeStringLabel.Text = date.ToShortTimeString ();
NSDateFormatter formatter = new NSDateFormatter();
formatter.Locale = NSLocale.CurrentLocale;
formatter.DateStyle = NSDateFormatterStyle.None;
formatter.TimeStyle = NSDateFormatterStyle.Short;
NSDate nsDate = DateTimeToNSDate (date);
NSDateFormatLabel.Text = formatter.ToString(nsDate);
Any help on this would be greatly appreciated.
Version 5.9.7 (build 9)
Version: 184.108.40.206 (Business Edition)
Apple Developer Tools
Xcode 6.4 (7720)
DateTime::ToShortTimeString uses current culture formatting as recognized by .net. Whole culture properties are readonly by XI so any user changes won't affect ToShortTimeString output.
You need to use iOS specific formatter to have device specific behaviour.
If possible, could you please check the suggestion given in comment 1?
Yeah I should be able to test it for at the latest Monday. Is that ok?
We have not received further information and will assume this is not an issue anymore. If you can still affected by this please re-open the bug and include the requested information. Thanks.