Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fancy code to work with timeout without weekends
Message
From
12/01/2007 23:12:37
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Fancy code to work with timeout without weekends
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01185319
Message ID:
01185319
Views:
70
I am looking for some fancy code to allow me to verify if a timeout has expired in consideration to the weekends.

I have presently this function:
    ' See if a timeout has expired
    ' expD1 The starting date
    ' expN1 The number of minutes
    Public Function TimeoutHasExpired(ByVal tdDate As Date, ByVal tnMinute As Integer) As Boolean
        Dim llExpired As Boolean = False
        Dim lnMinute As Integer = tnMinute

        ' Adjust the timeout to remove the weekends


        ' If it has expired
        If tdDate.AddMinutes(lnMinute) < Date.Now Then
            llExpired = True
        End If

        Return True
    End Function
It receives a starting date. Lets assume tdDate is 01/01/2007 12:00:00 and the timeout is 1440. In this case, the timeout is one day. When I call this function, I need to see if the timeout has expired. As is now, it will return True.

I need to add the relevent code after the first comment to adjust lnMinute to take in consideration that the timeout is not effective on Saturday and on Sunday. Thus, if I would have a tdDate equal to 01/01/2007 12:00:00 and a timeout of 10080, which is one week, based on the actual code, assuming Date.Now would be 01/08/2007 00:00:00, the method would return True. But, considering that we should not count the Saturday and Sunday, the method should then return False. Because, in reality, working in that mode, it means the we should be good until 01/10/2007 11:59:59.

Anyone would have a logic for handling this?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform