Summary:
How can I customize the interval formatter for hours to display 24-hour time?
Background:
I've found the default interval formatters detailed here:
http://www.telerik.com/help/wpf/radtimebar-intervals-formatters.html
I have my Windows regional settings set to 24-hour time (without any suffix) and what I'm finding is that the hour interval for the RadTimeBar is displaying in 12-hour time, however without any suffix, presumably because Windows regional settings do not specify a suffix when set to displaying 24-hour time. This makes it a little more ambiguous for the user who is expecting 24-hour time, however gets 12-hour time instead.
How can I customize the interval formatter for hours to display 24-hour time?
Kind regards,
Dave.
11 Answers, 1 is accepted
As mentioned in our online documentation, the HourInterval supports the following datetime formats:
- hh tt
- ht
All the best,
Tsvetie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
You stated:
"the only way to change these, is to change the formats collection in the code of RadTimeBar."
Can you show me how to do that with a working example?
Kind regards,
Dave.
What I meant by that, is that RadTimeBar does not support changing the formats of the intervals and that the only way to do it, is to modify the source code. Thit means that you have to download the source code, make the modifications that you need to the interval classes (e.g. the HourInterval class), build a custom DLL and use it in your solution. Unfortunately, only licensed customers can download the source code of our controls.
Please note that we do not offer custom solutions to clients and we do not support custom modifications of the code.
Tsvetie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Can you please forward a request to the development team to include public access to the interval formatters collection so that can be modified without requiring modifying Telerik's source code? From my personal perspective, I believe the ability to choose between 12-hour or 24-hour formatting for hours would be a useful addition to many developers as 24-hour formatting is not an uncommon setting.
Kind regards,
Dave.
This request is already logged in our database. Here is a link to out PITS system, where you can vote and track the progress on the feature.
Greetings,Tsvetie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I am testing timebar to fit my scenario where I need relative time in the timebar rather than absolute time with the lowest time interval used will be seconds and next will be minutes. This is going to be relative time so I donot want timeofday or date to be displayed, just seconds and minutes. The link of PITS that you mentioned, shows the issue as resolved but I am not able to find any documentation of how to achieve this. I have also tried to create my own interval using the abstract class "Interval Base", but I am having no luck on that as well because of missing documentation. Is it possible in Q2 2012 sp2 release. I need some pointers please.
The feature will be available with Q1 2013, scheduled for later this week. In terms of API, there will be a new property for the predefined intervals - FormatterProvider of type IIntervalFormatterProvider. In order to specify custom formatters for an interval, you need to create your custom class that implements IIntervalFormatterProvider. For example:
public
class
MonthFormatterProvider : IIntervalFormatterProvider
{
public
Func<DateTime,
string
>[] GetFormatters(IntervalBase interval)
{
return
new
Func<DateTime,
string
>[]
{
date => date.ToString(
"MMM"
)
};
}
public
Func<DateTime,
string
>[] GetIntervalSpanFormatters(IntervalBase interval)
{
return
new
Func<DateTime,
string
>[]
{
date => String.Format(
"{0} ... {1}"
, date.ToString(
"MMM"
).Substring(0, 1), interval.IncrementByCurrentInterval(date).ToString(
"MMM"
).Substring(0, 1))
};
}
}
Greetings,
Tsvetie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Thank you for the reply. Waiting for the release.
I am trying to set up IIntervalFormatterProvider like your example.
But I have a problem with AM/PM format.
My format is like 'd MMM, hh tt', but it will be shown only 'd MMM, hh'.
We are using Silverlight Q1 2013 and the rest of formula is exactly same as the example.
Could you please advise me if it is a bug or I did something wrong?
Thanks.
The "tt" custom format specifier depends on the current culture. You can get this result in case you are using a culture, in which the localized designator is an empty string. You can read more about this in MSDN.
Regards,Tsvetie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Working fine now.
Thank you for your help.