我们一直在研究类似的应用程序。我们将 TimeZoneOffset 和 Scheduled Time 存储在数据库表中。在客户端,TimeZOneOffset(以分钟为单位)考虑了夏令时。计算如下:
Dim localZone As TimeZone = TimeZone.CurrentTimeZone
Dim StartTime As DateTime = UserEnteredStartDateTime 'from your web app
Dim TimeZoneOffset As Integer = localZone.GetUtcOffset(StartTime).TotalMinutes
服务器上的存储过程包括一个 where 子句,它选择在预定开始时间加上 30 秒窗口内的行,如下所示:
SELECT Invitations.ID, Invitations.OrganizerName, Invitations.OrganizerEmail, Invitations.EMailBody, Invitations.[Subject]
FROM Invitations
WHERE (Invitations.MailSent=0)
And (Invitations.SendTime Between DateAdd(mi,Invitations.TimeZOneOffset,GETUTCDATE())
And DateAdd(s,(Invitations.TimeZoneOffset*60)+30,GETUTCDATE()))