+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Altering timezone description to remove UTC and (US) from calendar events

Altering timezone description to remove UTC and (US) from calendar events

2 posts, 0 answered
  1. Adam
    Adam avatar
    3 posts
    Registered:
    31 Mar 2014
    13 May 2015
    Link to this post
    The default calendar event popup shows (UTC-08:00) Pacific Time (US & Canada) after the time. Is there any way to alter that timezone description so it only says (PST)?
  2. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    08 Dec 2016
    19 May 2015
    Link to this post
    Hi Adam,

    Please note that we get the information which we display after the event time from the system by using the id of the time zone. For example:

    var timeZone = TimeZoneInfo.FindSystemTimeZoneById("FLE Standard Time");

    The above will return for example the following:

    "(UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius"

    What I can suggest is that you use javascript in order to manage the value returned by the TimeZoneInfo system class.

    Here ia a sample javascript which you can use and further modify to fit your exact scenario:

    $(document).ready(function () {
        debugger;
        var utcPatern = /\(UTC.*?\)\s/;
        var calendar = $find("C001_eventsFrontendCalendar_ctl00_ctl00_viewEventDialog");
        var baseRebind = calendar._rebind;
        calendar._baseRebind = baseRebind;
        calendar._rebind = newRebind;
     
        function newRebind () {
            this._baseRebind();
            if (this._appointment.get_attributes().getAttribute("AllDay") != "True") {
     
                var userTimeZone = GetUserPreferences().get_timeZoneDisplayName();
     
                //Replace the UTC part of the time zone
                var userTimeZoneModified = userTimeZone.replace(utcPatern, "(PST) ");
     
                jQuery(this.get_timeZoneDisplayNameLabel()).html(userTimeZoneModified);
            }
        }
    });

    You can modify the utcPatern and use your own regular expression.

    In order to apply this javascript, please open the page where you display the Events and drop the Javascript widget where you can place the javascript code above. Under Where to include in HTML?, select Where the widget is dropped.

    In addition to this, here is also how you can get the time zone id and the time zone display name using javascript:

    // e.g. "FLE Standard Time"
    var timezoneId = GetUserPreferences().get_timeZoneId();
     
    // e.g. "(UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius"
    var zone displayName = GetUserPreferences().get_timeZoneDisplayName();


    Regards,
    Sabrie Nedzhip
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
2 posts, 0 answered