AM/PM Appointment Times

6 posts, 0 answers
  1. Marcus
    Marcus avatar
    5 posts
    Member since:
    Jun 2009

    Posted 16 Jun 2009 Link to this post

    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
  2. Nikolay
    Admin
    Nikolay avatar
    1805 posts

    Posted 17 Jun 2009 Link to this post

    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.
  3. Marcus
    Marcus avatar
    5 posts
    Member since:
    Jun 2009

    Posted 17 Jun 2009 Link to this post

    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
  4. Nikolay
    Admin
    Nikolay avatar
    1805 posts

    Posted 22 Jun 2009 Link to this post

    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.
  5. Marcus
    Marcus avatar
    5 posts
    Member since:
    Jun 2009

    Posted 22 Jun 2009 Link to this post

    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?

  6. Nikolay
    Admin
    Nikolay avatar
    1805 posts

    Posted 26 Jun 2009 Link to this post

    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.
Back to Top