Link to "Change Lock Times on 3.0"

Message board links from 2010 as taken from the Internet Wayback Machine pages.
Post Reply
User avatar
admin
Site Admin
Posts: 159
Joined: Mon Aug 26, 2013 3:47 pm

Re: Link to "Change Lock Times on 3.0"

Post by admin »

08-26-2009 5:16 PM
kamokid
Top 10 Contributor
Joined on 08-27-2009
Posts 56

Change Lock Times on 3.0
Reply Contact

I need to know how to change the lock times to Friday @ 5 pm CST for Sunday games. Thursday games will lock at the same time. I could change the times on the last version how do I do it on 3.0???



Any help would be great!
08-26-2009 7:11 PM In reply to
mikehall
Top 10 Contributor
Joined on 08-09-2009
Chandler, AZ
Posts 456

Re: Change Lock Times on 3.0
Reply Contact

In the includes/common.asp file is a function named IsWeekLocked(), you want to replace that and add an additional function:

'--------------------------------------------------------------------------
' Returns true if all games for the specified week are locked.
'--------------------------------------------------------------------------
function IsWeekLocked(week)

IsWeekLocked = false
if GetCurrentDateTime() >= GetAllLockDateTime(week) then
IsWeekLocked = true
end if

end function

'--------------------------------------------------------------------------
' Returns a date object representing the lock time for the specified week.
'--------------------------------------------------------------------------
function GetAllLockDateTime(week)

dim sql, rs
dim dateTime

GetAllLockDateTime = ""

'Get the last game of the specified week.
sql = "SELECT * FROM SCHEDULE WHERE Week = " & week & " ORDER BY [Date] DESC, [Time] DESC"
set rs = DbConn.Execute(sql)
if not (rs.EOF and rs.BOF) then

'Get the date and time of that game.
dateTime = CDate(rs.Fields("Date").Value & " " & rs.Fields("Time").Value)

'Find the date of the previous Friday.
do while true

'Is the date on a Friday?
if Weekday(dateTime) = vbFriday then
'Yes, use the date and set the time to 3pm ET (5pm CT).
GetAllLockDateTime = CDate(FormatDateTime(dateTime, vbShortDate) & " 15:00:00")
exit function
end if

'No, go to the previous day.
dateTime = DateAdd("d", -1, dateTime)
loop
end if

Filed under: customize, lock
08-26-2009 7:26 PM In reply to
kamokid
Top 10 Contributor
Joined on 08-27-2009
Posts 56

Re: Change Lock Times on 3.0
Reply Contact

Thank you very much this will help make sure everyone pays and picks before they leave work!
09-09-2009 12:42 AM In reply to
livead
Top 25 Contributor
Joined on 08-13-2009
Posts 22

delete
Reply Contact
delete
Filed under: delete
09-09-2009 9:41 AM In reply to
mikehall
Top 10 Contributor
Joined on 08-09-2009
Chandler, AZ
Posts 456

Re: Change Lock Times on 3.0
Reply Contact

You can do that by modifying the IsWeekLocked() function in includes/common.asp to look like this:

'--------------------------------------------------------------------------
' Returns true if all games for the specified week are locked.
'--------------------------------------------------------------------------
function IsWeekLocked(week)

dim dateTime, rs, gameDateTime

IsWeekLocked = false
dateTime = GetCurrentDateTime()
set rs = GetGamesRecordset(week)
if not (rs.EOF and rs.BOF) then
gameDateTime = CDate(rs.Fields("Date").Value & " " & rs.Fields("Time").Value)
if gameDateTime <= dateTime then
IsWeekLocked = true
end if
end if

end function

Filed under: customize, lock time
09-10-2009 6:12 PM In reply to
kamokid
Top 10 Contributor
Joined on 08-27-2009
Posts 56

Re: Change Lock Times on 3.0
Reply Contact

For some reason tonights game did not lock with the above code. I'm going to see if it locks at 830 if not i need to figure it out within the next 10 weeks. lol
09-10-2009 6:20 PM In reply to
mikehall
Top 10 Contributor
Joined on 08-09-2009
Chandler, AZ
Posts 456

Re: Change Lock Times on 3.0
Reply Contact

Do you have the TIME_ZONE_DIFF set right for your site? If so, you should see the current Eastern time in the upper-right hand corner of each page.
09-10-2009 6:27 PM In reply to
kamokid
Top 10 Contributor
Joined on 08-27-2009
Posts 56

Re: Change Lock Times on 3.0
Reply Contact

thats the reason why i had it set to central time. but forgot to change the game times to match central time.
09-10-2009 6:45 PM In reply to
kamokid
Top 10 Contributor
Joined on 08-27-2009
Posts 56

Re: Change Lock Times on 3.0
Reply Contact

I just ran the scrip to change all times in the data base for central time. This forum is amazing and lots of help. here is the script I used if anyone needs it.



<%@ LANGUAGE="VBScript" %>
<!-- #include file="includes/config.asp" --><!-- #include file="includes/common.asp" --><% PageSubTitle = "Pool Rules" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title><% = PAGE_TITLE & ": " & PageSubTitle %></title>
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet" type="text/css" href="styles/common.css" />
<link rel="stylesheet" type="text/css" href="styles/print.css" media="print" />
<script type="text/javascript" src="scripts/scriptLib.js"></script>
<script type="text/javascript" src="scripts/common.js"></script>
</head>
<body>
<!-- #include file="includes/header.asp" -->
<!-- #include file="includes/siteMenu.asp" -->
<div id="contentSection">
<table id="mainWrapper" border="0" cellpadding="0" cellspacing="0"><tr><td>
<%
call OpenDB()

dim sql, rs

sql = "SELECT * From Schedule"
set rs = DbConn.Execute(sql)
do while not rs.EOF
call ChangeGameDateTime("Schedule", rs)
rs.MoveNext
loop

sql = "SELECT * From PlayoffsSchedule"
set rs = DbConn.Execute(sql)
do while not rs.EOF
call ChangeGameDateTime("PlayoffsSchedule", rs)
rs.MoveNext
loop
%>
</td></tr></table>
</div>
<!-- #include file="includes/footer.asp" -->
</body>
</html>
<% '**************************************************************************
'* Local subroutines. *
'**************************************************************************
sub ChangeGameDateTime(tableName, rs)

dim dt, gameDate, gameTime, sql

dt = CDate(rs.Fields("Date").Value & " " & rs.Fields("Time").Value)
dt = DateAdd("h", -3, dt)
gameDate = Month(dt) & "/" & Day(dt) & "/" & Year(dt)
gameTime = Hour(dt) & ":" & Minute(dt) & ":00"
sql = "UPDATE " & tableName & " SET" _
& " [Date] = #" & gameDate & "#," _
& " [Time] = #" & gameTime & "#" _
& " WHERE GameID = " & rs.Fields("GameID").Value
DbConn.Execute(sql)

end sub %>


09-24-2009 9:50 AM In reply to
Jondoe
Top 25 Contributor
Joined on 09-12-2009
Posts 24

Re: Change Lock Times on 3.0
Reply Contact

anyone see any trouble with this code to Lock all games on wed



function AllGamesLocked(week)

dim dateTimeNow, rs, gameDatetime

AllGamesLocked = false

dateTimeNow = CurrentDateTime()
set rs = WeeklySchedule(week)
do while not rs.EOF
gameDatetime = CDate(rs.Fields("Date").Value & " " & rs.Fields("Time").Value)
if Weekday(gameDatetime) = vbSunday and gameDatetime <= dateTimeNow then
AllGamesLocked = true
if Weekday(gameDatetime) = vbSunday and dateTimeNow >= vbThursday then
AllGamesLocked = true

exit function
end if
end if
rs.MoveNext
loop

end function

09-24-2009 6:26 PM In reply to
mikehall
Top 10 Contributor
Joined on 08-09-2009
Chandler, AZ
Posts 456

Re: Change Lock Times on 3.0
Reply Contact

The problem is that vbSunday is just a constant integer (vbSunday = 1, vbMonday = 2, etc.) so it won't compare properly to a Date object like dateTimeNow. Instead, you want to compare day of the week to day of the week:

Weekday(dateTimeNow) >= vbThursday

But you're still just checking the day of the week. Since vbSunday = 1, it that would give you a weird situation where it would lock games between Thursday and Saturday, but then unlock them on Sunday and Monday.

What you need to do is find the date that a day of the week falls on for a given week in the Schedule. If you modify the code posted previously, you can do this to lock them at 12am (eastern time) each Thursday morning:

'--------------------------------------------------------------------------
' Returns true if all games for the specified week are locked.
'--------------------------------------------------------------------------
function IsWeekLocked(week)

IsWeekLocked = false
if GetCurrentDateTime() >= GetAllLockDateTime(week) then
IsWeekLocked = true
end if

end function

'--------------------------------------------------------------------------
' Returns a date object representing the lock time for the specified week.
'--------------------------------------------------------------------------
function GetAllLockDateTime(week)

dim sql, rs
dim dateTime

GetAllLockDateTime = ""

'Get the last game of the specified week.
sql = "SELECT * FROM SCHEDULE WHERE Week = " & week & " ORDER BY [Date] DESC, [Time] DESC"
set rs = DbConn.Execute(sql)
if not (rs.EOF and rs.BOF) then

'Get the date and time of that game.
dateTime = CDate(rs.Fields("Date").Value & " " & rs.Fields("Time").Value)

'Find the date of the previous Thursday.
do while true

'Is the date on a Thursday?
if Weekday(dateTime) = vbThursday then
'Yes, use the date and set the time to midnight.
GetAllLockDateTime = CDate(FormatDateTime(dateTime, vbShortDate) & " 00:00:00")
exit function
end if

'No, go to the previous day.
dateTime = DateAdd("d", -1, dateTime)
loop
end if

Basically, it takes the date of the last game of the week (which will be a Monday or Sunday), then goes back day by day until it finds date that the previous Thursday would fall on. Given that date, you can compare it to the current date and time to determine if the week should be locked.

Hope that all makes sense.
10-23-2009 3:17 PM In reply to
sportstalk
Top 10 Contributor
Joined on 09-15-2009
Georgia
Posts 98

Re: Change Lock Times on 3.0
Reply Contact

how can i edit this code to change it to where the lock times are done on a daily basis? what do i need to add or take away and how lol

Page 1 of 1 (12 items)
Post Reply