We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Timezone in Scheduler; slight confusion

Thread ID:

Created:

Updated:

Platform:

Replies:

143725 Apr 2,2019 07:57 PM UTC Apr 9,2019 12:26 PM UTC ASP.NET Core - EJ 2 5
loading
Tags: Scheduler
Stefan
Asked On April 2, 2019 07:57 PM UTC

Hi, I'm afraid that I've got difficulties understanding timezones in the Scheduler.

My scheduler is set up with a fixed timezone (Europe/Berlin). As such, there is an offset of +2 from UTC in Daylight Saving time (active now). I refer to this as CEST (Central European Summer time).
The server's timezone (not that it really matters, I guess), is UTC.

A client that connects with the client timezone in CEST creates an appointment from 22:00 to 23:00. When the Batch method of the Crud module is hit on the server, StartTime and EndTime are converted to UTC - 22:00 will become 20:00 in the POST, and 23:00 will become 21:00. This is also how the values are stored in the database.

What I find confusing is that upon GET, that appointment is now displayed in the scheduler as 20:00 to 21:00. Is the correction for TimeZone one-way?
The StartTime in the appointment after submit is
  1. StartTimeTue Apr 02 2019 20:00:00 GMT+0200 (Central European Summer Time)

Nevitha Ravi [Syncfusion]
Replied On April 3, 2019 12:21 PM UTC

Hi Stefan, 

Greetings from Syncfusion Support. 

By default, the startTime and endTime of the appointments are calculated and processed in UTC time at server side. We can achieve your requirement of having same start and end time for appointments in both client and server side by adding the following code snippet in startup.cs file of the application. 
        public void ConfigureServices(IServiceCollection services) 
        { 
            services.AddDbContext<ScheduleDataContext>(options => options.UseSqlServer(Configuration.GetConnectionString("ScheduleDataConnection"))); 
            services.AddMvc(); 
            services.AddMvc() 
                .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver()) 
                .AddJsonOptions(opt => opt.SerializerSettings.DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat) 
                .AddJsonOptions(opt => opt.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Local); 
        } 

And we have prepared sample for your reference which can be downloaded from the following location. 

Please check the sample and let us know if you need any further assistance on this. 

Regards, 
Nevitha 


Stefan
Replied On April 3, 2019 06:55 PM UTC

Thank you Nevitha
the Serializer Options appear to do the trick. Might be an idea to add this to the manual?

Whilst discussing serializer options, I've also had to change the loop handling in order to get the Scheduler to work properly; maybe something to make a note of in the manual as well? Although I can't remember exactly where and what went wrong. So in total it now looks like this:

         services.AddMvc()
                .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
                .AddJsonOptions(options =>
                {
                    options.SerializerSettings.ContractResolver = new DefaultContractResolver();
                    options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                    options.SerializerSettings.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat;
                    options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local;
                });



Nevitha Ravi [Syncfusion]
Replied On April 4, 2019 12:57 PM UTC

Hi Stefan, 

Thanks for you update. 

Yes we have the plan to add this in our UG documentation which will be refreshed in live by April end. We have checked with our previous code and it works fine at all cases at our end. Could you please revert us the following details to check further on this. 

  • Purpose of adding the below line in your application.
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; 
  • Whether you have faced any issue without adding this line, if yes please share the issue details.
 
Regards, 
Nevitha 


Stefan
Replied On April 5, 2019 07:54 AM UTC

Hi Nevitha
re:
  • Purpose of adding the below line in your application.
    options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; 
  • Whether you have faced any issue without adding this line, if yes please share the issue details.
It is possible to set up resources and groups which are self-referencing - so a resource can contain a list of other resources, which in turn have a reference to it's parent or similar.
One may find themselves confronted with a JsonSerializationException: Self referencing loop detected with type '..type..'

In my particular software, I'm also serializing claims in order to decide which user may book particular resources. Without the loop handling set to ignore, it will throw an exception:
JsonSerializationException: Self referencing loop detected with type 'System.Security.Claims.Claim'
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CheckForCircularReference(JsonWriter writer, object value, JsonProperty property, JsonContract contract, JsonContainerContract containerContract, JsonProperty containerProperty)

So this is probably not required for everyone, but it can be an obstacle with multi-level groups.

Vinitha Devi Murugan [Syncfusion]
Replied On April 9, 2019 12:26 PM UTC

Hi Stefan, 
 
We have checked the below code with multiple level resource grouping it works fine at our end. We have modified previously provided sample with multiple resource for your reference which can be downloaded from the following location. 
 
 
        public void ConfigureServices(IServiceCollection services)  
        {  
            services.AddDbContext<ScheduleDataContext>(options => options.UseSqlServer(Configuration.GetConnectionString("ScheduleDataConnection")));  
            services.AddMvc();  
            services.AddMvc()  
                .AddJsonOptions(options => options.SerializerSettings.ContractResolver = newDefaultContractResolver())  
                .AddJsonOptions(opt => opt.SerializerSettings.DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat)  
                .AddJsonOptions(opt => opt.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Local);  
        }  
 
 
So we will add this details in our UG as mentioned earlier, which will be refreshed at April end. 
 
Regards, 
M.Vinitha devi. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon