The local time is EEST — Eastern European Summer Time (Current Offset: UTC/GMT +3 hours). Add an additional time zone IST — India Standard Time (Current Offset: UTC/GMT +5:30 hours). It is expected to show 2 hours and 30 minutes difference between the two times zones. However, it is 1 hour and 30 minutes:
Public Sub New()
InitializeComponent()
allTimeZones = SchedulerTimeZone.GetSchedulerTimeZones()
Dim mumbai As SchedulerTimeZone = GetSpecificTimeZone("India Standard Time")
If Not mumbai.Equals(Me.RadScheduler1.GetDayView().DefaultTimeZone) Then
RadScheduler1.GetDayView().TimeZones.Insert(0, mumbai)
End If
Dim utc As SchedulerTimeZone = GetSpecificTimeZone("UTC")
If Not utc.Equals(Me.RadScheduler1.GetDayView().DefaultTimeZone) Then
RadScheduler1.GetDayView().TimeZones.Insert(0, utc)
End If
End Sub
Private Function GetSpecificTimeZone(_TimeZoneInformationID As String) As SchedulerTimeZone
Try
Dim tempZone As New SchedulerTimeZone((From t In allTimeZones.Where(Function(x) x.TimeZoneInformation.Id Like _TimeZoneInformationID) Select t.TimeZoneInformation).First)
tempZone.Label = tempZone.TimeZoneInformation.BaseUtcOffset.ToString()
Return tempZone
Catch ex As Exception
Return Nothing
End Try
End Function
Actual: 1 hour behind the expected
Expected:
Workaround:
Public Class Form1
Private allTimeZones As List(Of SchedulerTimeZone)
Public Sub New()
InitializeComponent()
Me.RadScheduler1.ElementProvider = New CustomSchedulerElementProvider(Me.RadScheduler1)
allTimeZones = SchedulerTimeZone.GetSchedulerTimeZones()
Dim mumbai As SchedulerTimeZone = GetSpecificTimeZone("India Standard Time")
If Not mumbai.Equals(Me.RadScheduler1.GetDayView().DefaultTimeZone) Then
RadScheduler1.GetDayView().TimeZones.Insert(0, mumbai)
End If
Dim utc As SchedulerTimeZone = GetSpecificTimeZone("UTC")
If Not utc.Equals(Me.RadScheduler1.GetDayView().DefaultTimeZone) Then
RadScheduler1.GetDayView().TimeZones.Insert(0, utc)
End If
End Sub
Private Function GetSpecificTimeZone(_TimeZoneInformationID As String) As SchedulerTimeZone
Try
Dim tempZone As New SchedulerTimeZone((From t In allTimeZones.Where(Function(x) x.TimeZoneInformation.Id Like _TimeZoneInformationID) Select t.TimeZoneInformation).First)
tempZone.Label = tempZone.TimeZoneInformation.BaseUtcOffset.ToString()
Return tempZone
Catch ex As Exception
Return Nothing
End Try
End Function
End Class
Public Class CustomSchedulerElementProvider
Inherits SchedulerElementProvider
Public Sub New(scheduler As RadScheduler)
MyBase.New(scheduler)
End Sub
Public Overrides Function CreateRulerPrimitive(area As DayViewAppointmentsArea, timeZone As SchedulerTimeZone) As RulerPrimitive
Dim ruler As RulerPrimitive = MyBase.CreateRulerPrimitive(area, timeZone)
ruler.RulerRenderer = New CustomRulerRenderer(ruler)
Return ruler
End Function
End Class
Public Class CustomRulerRenderer
Inherits RulerRenderer
Public Sub New(ruler As RulerPrimitive)
MyBase.New(ruler)
End Sub
Public Overrides Sub RenderHour(g As IGraphics, hour As Integer, bounds As RectangleF)
hour += Me.ruler.StartScale + CInt(Math.Ceiling(Me.ruler.DefaultOffset))
Dim currentTime As DateTime = DateTime.Now.Date.AddHours(hour)
Dim percent As Single = Me.ruler.DefaultOffset - CSng(Math.Floor(CDbl(Me.ruler.DefaultOffset)))
Dim x As Integer = Me.ruler.HourLineStartPosition
Dim y As Single = CSng(Math.Ceiling(bounds.Top + (GetSpecificRange() * bounds.Height) * percent))
Dim hourText As String = ""
If Me.ruler.FormatStrings.HoursFormatString IsNot Nothing Then
hourText = currentTime.ToString(Me.ruler.FormatStrings.HoursFormatString)
End If
'Dim args As RulerTextFormattingEventArgs = New RulerTextFormattingEventArgs(hourText, RulerTextFormattingContext.Hour, currentTime)
'Me.ruler.Scheduler.OnRulerTextFormatting(args)
'hourText = args.Text
Dim minutesText As String = ""
If Me.ruler.FormatStrings.MinutesFormatString IsNot Nothing Then
minutesText = currentTime.ToString(Me.ruler.FormatStrings.MinutesFormatString)
End If
'args = New RulerTextFormattingEventArgs(minutesText, RulerTextFormattingContext.Minute, currentTime)
'Me.ruler.scheduler.OnRulerTextFormatting(args)
'minutesText = args.Text
Dim measuredSize As Size = TextRenderer.MeasureText(hourText, Me.ruler.Font)
measuredSize = DrawTimeText(g, y, hourText, minutesText, measuredSize)
If ruler.RightToLeft Then
g.DrawLine(Me.ruler.HourLineColor, Me.ruler.Bounds.Left, y, Me.ruler.Bounds.Width - x, y, Me.ruler.DpiScaleFactor.Height)
g.DrawLine(Me.ruler.HourLineShadowColor, Me.ruler.Bounds.Left, y + Me.ruler.DpiScaleFactor.Height, Me.ruler.Bounds.Width - x, y + Me.ruler.DpiScaleFactor.Height, Me.ruler.DpiScaleFactor.Height)
Else
g.DrawLine(Me.ruler.HourLineColor, x, y, Me.ruler.Bounds.Width, y, Me.ruler.DpiScaleFactor.Height)
g.DrawLine(Me.ruler.HourLineShadowColor, x, y + Me.ruler.DpiScaleFactor.Height, Me.ruler.Bounds.Width, y + Me.ruler.DpiScaleFactor.Height, Me.ruler.DpiScaleFactor.Height)
End If
End Sub
Friend Function GetSpecificRange() As Integer
Return 60 / CInt(Me.ruler.RangeFactor)
End Function
End Class