Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is DATE BST or GMT. DST Daylight Saving Time Check

Status
Not open for further replies.

axLW

Programmer
Feb 6, 2015
110
0
0
GB
Hello I'm trying to check whether a given date is within the UK classifcation of Daylight Saving Time.

I have a function that was written in VBA and I need to convert it to VBScipt to use on my .asp page.

I basically have a date/time value in the following format: YYYY-MM-DDTHH:MM:SS

I need to break this down and establish whether or not that date/time falls within UK British Summer Time.

I would really appreciate somebody helping me convert this into a working asp file.

Code:
Function isBST(PickupDate As Date) As Boolean

Dim PickUpWeekDay As Byte     ' ---- The index number of the day of the week
Dim PickUpDay As Integer      ' ---- The day of the month
Dim PickUpMonth As Integer    ' ---- The number of the month

isBST = False  ' ---- Start by assuming we're not in BST

'--- As we we're comparing against an 01:00 cutoff, we will subtract an hour from the pickup time...
'--- ... it is easier to drop an hour and compare against an 00:00 cutoff as we can ignore any time element.

PickupDate = 2015-11-08T14:45:00

PickupDate = DateAdd("h", -1, PickupDate)

PickUpWeekDay = Weekday(PickupDate, vbSunday)  ' --- get the index of the weekday (1 for Sunday etc...)
PickUpDay = Day(PickupDate)                    ' --- get the day of the month of the pickup
PickUpMonth = Month(PickupDate)                ' --- get the number of the month of the pickup

'If between April and September then BST is true
If PickUpMonth > 3 And PickUpMonth < 10 Then
    isBST = True

'If after last Sunday in March then BST is true
ElseIf PickUpMonth = 3 And PickUpDay + (7 - PickUpWeekDay) > 30 Then
    isBST = True

'If before last Sunday of October then BST is true
ElseIf PickUpMonth = 10 And PickUpDay + (7 - PickUpWeekDay) < 30 Then
    isBST = True

Else
    isBST = False

End If
End Function

If isBST = True Then
Response.Write PickupDate & "is BST"
End If

If isBST = False Then
Response.Write PickupDate & "is NOT BST"
End If


SOMEBODY PLEASE HELP ME!
 
Do you have access to a SQL Server? If you have a newer version you can use functions like GETUTCDATE, SYSUTCDATETIME, SYSDATETIMEOFFSET to do the work for you. Use a DB query in ASP to get your "isBST" binary result.

BTW: Kudos to you for saying "Daylight Saving Time" and not "Savings Time."

Dave [idea]
[]
 
Hi El, thank you for the reply.

Unfortunately I'm quite limited here as to how much access I have and how able I am do delve deeper. I'm hoping to achieve this client side using the variable provided in the code itself...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top