@(Html.EJ().Schedule("Schedule1")
.Width("100%")
.Height("525px")
.TimeZone("UTC -05:00") // Here you can give your time zone value
.CurrentDate(new DateTime(2015, 8, 24))
.ShowCurrentTimeIndicator()
.ShowQuickWindow(true)
.AppointmentSettings(fields => fields.Datasource(ds => ds.URL("/Home/GetData").CrudURL("/Home/Batch").Adaptor("UrlAdaptor"))
.Id("Id")
.Subject("Subject")
.StartTime("StartTime")
.StartTimeZone("StartTimeZone") // Kindly mention the StartTimeZone and EndTimeZone fields
.EndTimeZone("EndTimeZone")
.EndTime("EndTime")
.Description("Description")
.AllDay("AllDay")
.Recurrence("Recurrence")
.RecurrenceRule("RecurrenceRule"))
)
HomeContorller.cs
if (param.action == "insert" || (param.action == "batch" && param.added != null)) // this block of code will execute while inserting the appointments
{
var value = param.action == "insert" ? param.value : param.added[0];
int intMax = db.Appointments.ToList().Count > 0 ? db.Appointments.ToList().Max(p => p.Id) : 1;
DateTime startTime = Convert.ToDateTime(value.StartTime);
DateTime endTime = Convert.ToDateTime(value.EndTime);
var currentTimeZone = TimeZone.CurrentTimeZone;
Appointment appoint = new Appointment()
{
Id = value.Id,
StartTime = startTime, // Kindly ignore ToUniversalTime() for both Start and EndTime as we have internally processed the appointment to render in the same time as created(even after appointments are reloaded) by using StartTimeZone and EndTimeZone fields
EndTime = endTime,
StartTimeZone=value.StartTimeZone,
EndTimeZone=value.EndTimeZone,
Subject = value.Subject,
Description = value.Description,
Recurrence = value.Recurrence,
RoomId = value.RoomId,
OwnerId = value.OwnerId,
CategoryId = value.CategoryId,
AllDay = value.AllDay,
RecurrenceRule = value.RecurrenceRule,
};
db.Appointments.InsertOnSubmit(appoint);
db.SubmitChanges();
}
<code>
By default in schedule, appointments will render with the TimeZone “UTC +05:30”. If the system TimeZone differs from the “UTC +05:30” or if different TimeZone is given on the sample side, it is mandatory to mention the “StartTimeZone and EndTimeZone” fields within the AppointmentSettings in order to save the appointments in the same time as created (even after appointments are reloaded). If the TimeZone value is given on sample side then the system TimeZone value will be neglected. For example “system TimeZone value/ sample side TimeZone value” is UTC +05:30 and if the “StarttimeZone and EndTimeZone value” is UTC +05:00 then the appointment will be rendered 30mins later from the time of appointment creation. The appointment will be rendered at 10.30 AM (say) if we create appointment at 10.00 AM.
Regards,
Karthigeyan.