Blazor wasm scheduler seems to ignore Timezone

Hi,

In my project I have a sfSchedule like below:

<SfSchedule @ref="scheduler" TValue="Activity" Height="650px" @bind-SelectedDate="@CurrentDate" Timezone="@GetCurrentTimezone()" Readonly="true">

<ScheduleEvents TValue="Activity" ActionCompleted="OnActionCompleted" DataBound="OnDataBound" EventRendered="OnEventRendered"></ScheduleEvents>

        <ScheduleViews>

        <ScheduleView Option="View.WorkWeek"></ScheduleView>

        <ScheduleView Option="View.Month"></ScheduleView>

    </ScheduleViews>

    <ScheduleEventSettings TValue="Activity">

        <SfDataManager Url=@GetAddress() Adaptor="Adaptors.WebApiAdaptor"></SfDataManager>

        <ScheduleField Id="ID">

            <FieldSubject Name="Subject"></FieldSubject>

            <FieldLocation Name="Location"></FieldLocation>

            <FieldDescription Name="Description"></FieldDescription>

            <FieldStartTime Name="Start"></FieldStartTime>

            <FieldEndTime Name="Finish"></FieldEndTime>

        </ScheduleField>

    </ScheduleEventSettings>

</SfSchedule>

No matter what Timezone I assign to the Scheduler it displays events in UTC.

Info: 

Start and End are stored as DateTime UTC on server.

Using  Syncfusion.Blazor19.2.0.44 and Blazor 5.0.5

Have tried:

ODatav4Adaptor and WebApiAdaptor

Assignment of StartTimezone and EndTimezone

Changing Start and End to LocalTime() in the DataBound, ActionCompleted and EventRendered events.

But no luck so far.

Any hints on how to get the schedulers Timezone to show the events in local time?

Best regards

Jens





4 Replies

SK Satheesh Kumar Balasubramanian Syncfusion Team July 9, 2021 04:55 PM UTC

Hi Jens,

Thanks for using Syncfusion Products.

We have validated your reported query "Blazor wasm scheduler seems to ignore Timezone" and let you know that if you use different timezone in server and database in your application you need to use the below timezone conversion to render the appointments in local timezone to resolve this issue. For the same we have prepared a sample for your reference which can be downloaded from the following link.


ODataV4Controller.cs:   
        public List<EventData> GetODataV4(string StartDate, string EndDate)
        {
            DateTime start = DateTime.Parse(StartDate);
            DateTime end = DateTime.Parse(EndDate);
            var data = db.EventData.Where(evt => evt.StartTime >= start && evt.EndTime <= end).ToList();
            TimeZone curTimeZone = TimeZone.CurrentTimeZone;
            var timezone = TimeZoneInfo.FindSystemTimeZoneById(curTimeZone.StandardName);
            for (var i = 0; i < data.Count; i++)
            {
                if (timezone != null)
                {
                    DateTime startTime = Convert.ToDateTime(data[i].StartTime);
                    DateTime endTime = Convert.ToDateTime(data[i].EndTime);
                    startTime = DateTime.SpecifyKind(startTime, DateTimeKind.Utc);
                    endTime = DateTime.SpecifyKind(endTime, DateTimeKind.Utc);
                    data[i].StartTime = TimeZoneInfo.ConvertTime(startTime, timezone);
                    data[i].EndTime = TimeZoneInfo.ConvertTime(endTime, timezone);
                }
            }
            return data;
        }

Note: You need to change the path for accessing the database in ScheduleDataContext.cs of Restful_Services\Models in the above sample.

ScheduleDataContext.cs:   
optionsBuilder.UseSqlServer("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\EJ2\\July8th\\Incident\\F166967\\ScheduleCRUD\\blazor-scheduler-crud\\Restful_Services\\App_Data\\ScheduleData.mdf;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework;Integrated Security=True");

Please let us know if you need any further assistance on this.

Regards,
Satheesh Kumar B



JB Jens Bo Frederiksen July 12, 2021 08:10 AM UTC

Hi Satheesh,


Thanks for the sample and explanation. I have got it running.


As I understand your solution, the basic steps are:

  1. In the request for data use a header or a parameter to indicate the timezone of the client.
  2. In the controller you make use of a new entity "EventData" in which you convert the utc start and end to the timezone of the client

If that is correct I can see it is doable, but quite som work and error handling remains:


  • Creation of a new event entity (with Start and End converted to local) solely for the purpose of the scheduler.
  • Making sure that the server function "TimeZoneInfo.FindSystemTimeZoneById" recognizes the timezone string sent from the client. (In Denmark the value I get from the function scheduler.Timezone is "Europe/Copenhagen" and this string is not recognized by FindSystemTimeZoneById.)
  • Additional handling of Start- and EndTimezone values.


If I have missed the point, please let me know.

Otherwise it would be a nice addition to the sfSchedule if the TimeZone handling was included (given that the stored datetime values always are in UTC).


Best regards,

Jens



VD Vinitha Devi Murugan Syncfusion Team July 16, 2021 06:17 AM UTC

Hi Jens, 
 
Sorry for the delay. 
 
Yes, your understating is correct. 
 
Q1 & Q3 & Q4: 
 
We have planned to fix the issue “Timezone ignores in blazor wasm application” at our end which can be tracked from the following link and the fix will be included in our Volume 3, 2021 release expected to be rolled out by the end of October 2021. 
 
Q2: FindSystemTimeZoneById returns the corresponding time zone in windows appears with an English display name. For Denmark the value we get from the function is {(UTC+01:00) Brussels, Copenhagen, Madrid, Paris}. Please refer the below screen shot. 
 
 
 
Please refer below links and image to know more about FindSystemTimeZoneById method: 
 
 
 
 
 
 
 
We would appreciate your patience until the fix got included. 
 
Regards, 
Vinitha 



NR Nevitha Ravi Syncfusion Team October 1, 2021 12:31 PM UTC

Hi Jens, 
 
Thanks for being patience. 
 
We are glad to announce that our Essential Studio 2021 Volume 3 release v19.3.0.43 is rolled out successfully. In this release, we have resolved the reported issue with timezone. 
 
 
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
Regards,            
Nevitha 


Loader.
Up arrow icon