This is a migrated thread and some comments may be shown as answers.

AM/PM Appointment Times

5 Answers 273 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Marcus
Top achievements
Rank 1
Marcus asked on 16 Jun 2009, 03:47 PM
Is there any way to get the appointment times to appear in 12-hour format? I saw the AppointmentTitleFormat property, but it looks like there is only the availability to rearrange or add formatting to the 24-hour format.

Is this possible?

Thanks,
Marcus

5 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 17 Jun 2009, 10:28 AM
Hi Marcus,

The only way to make an appointment appear in 24hour or 12hour format is to modify the Culture property of RadScheduler. This is because we format Appointment ‘s Start and End time using the ShortTimePattern and the culture settings used in RadScheduler. We do the string formatting using a code like this:
DateTimeFormatInfo info = new DateTimeFormatInfo();  
string str = info.ShortTimePattern + " tt";  
CultureInfo culture = base.Scheduler.Culture;  
string startString = this.Appointment.Start.ToString(str, culture);  
string EndString = this.Appointment.End.ToString(str, culture); 

As you can see, the result string value depends on the culture and ShortTimePattern only.

All the best,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Marcus
Top achievements
Rank 1
answered on 17 Jun 2009, 06:48 PM
Thanks for the response, I am having some trouble understanding what you mean by this. It seems that since you are explicitly giving a format string to the ToString() method, it would not be possible for me to alter this by simply changing the culture. The line that you have provided:
string
 str = info.ShortTimePattern + " tt";
pulls the ShortTimePattern from "CultureInfo.InvariantCulture" which is strictly readonly.

Can you give an example of how I should go about changing the culture in order to change the times to 12-hr?

Thanks for your help,
Marcus
0
Nikolay
Telerik team
answered on 22 Jun 2009, 12:49 PM

Hi Marcus,

We pass RadScheduler's culture parameter when we do datetime formatting. This will format the time string according to specific culture settings.

To change appointment's start and end time formatting you should use RadScheduler's Culture property. 

To change the culture you can use a code snippet like this:

this.radScheduler1.Culture = new System.Globalization.CultureInfo("en-US"); 

I hope this helps. If you have additional questions, feel free to contact me.

Kind regards,

Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Marcus
Top achievements
Rank 1
answered on 22 Jun 2009, 03:07 PM

In your code you show the following:

 

DateTimeFormatInfo info = new DateTimeFormatInfo();  

string str = info.ShortTimePattern + " tt";  

 

When you get the ShortTimePattern it is returning HH:mm (HH = 24 hour format, we need it to be hh which is 12 hour format) and then you append ‘tt’ to it to get the am/pm.  Then you get the culture from the scheduler.  The culture is then applied in the ToString using the datetime format that was created in the code above.  In doing so the only effect the culture has on the formatted output is setting the correct am/pm for that culture, not the 12 hour time format since that is what we are trying to change. 

 

I am sure you have good reason for the code above, but I don’t understand why you couldn’t have used the ShortTimePattern from the culture instead of the new DateTimeFormatInfo.  If you did we could easily modify the culture and pass it into the scheduler and everything would work great, but the way you are currently doing this I don’t see any way of changing the ShortTimePattern.  Is there any way of doing this?  Could you please show us an example that works?

0
Nikolay
Telerik team
answered on 26 Jun 2009, 01:37 PM

Hello Marcus,

We will consider changing the current behavior in the next version. We will add a property for a custom format string which will help you to easily modify the appointment's text. As soon as we change the current logic I will write you back and will describe you how the new behavior works. It is true that the only option at the moment which will affect the appointment's start and end datetime strings is changing the Culture property, but I agree that this is not enough.

Please contact me again if you have more questions. We will do our best to improve the logic for the upcoming releases.

Kind regards,

Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Scheduler and Reminder
Asked by
Marcus
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Marcus
Top achievements
Rank 1
Share this question
or