gzazJim
06-30-2000, 08:39 PM
Greetings fellow code-monkeys (or is that junkies...?),
I am trying to come up with a way to determine what "Shift" today is. Apparently I am completely muddled in my thinking, because I cannot figure out HOW to do this!
This is the full skinny - Here at the Fire Department most people work in "shifts" - A-Shift, B-Shift and C-Shift; each of these shifts have an indicator that displays on our home page on the appropriate day. The shift-change is at 8:00 am. For example: today is A-Shift, so the "A.gif" is displayed; at 8 am on Saturday, the shift changes to B-Shift, so the image changes to the "B.gif" image.
Right now I have a REALLY UGLY solution that involves a "shiftscript.js" which steps through an if/then/else set-up which I have hard-coded with the month/day/year. Needless to say, the file is HUGE and pretty ridiculous to update.
Here's a snippet of the code *embarrassed look* :
if (now.getMonth() == 7)
{
if (now.getDate() == 1)
{
if (now.getHours() >= 8)
{
document.shiftInd.src= shiftName[2]
}
if (now.getHours() < 8)
{
document.shiftInd.src= shiftName[1]
}
}
if (now.getDate() == 2)
{
if (now.getHours() >= 8)
{
document.shiftInd.src= shiftName[0]
}
if (now.getHours() < 8)
{
document.shiftInd.src= shiftName[2]
}
}
if (now.getDate() ==... (and so on)
(I wasn't kidding when I said it was ugly...)
Does anyone have some thoughts on how to code this in such a way that it will not require much (or any) maintenance? Again, I am rather muddled when it comes to time/date-related issues (just ask any of my ex-girlfriends...).
Thanks in advance!
Jim
I am trying to come up with a way to determine what "Shift" today is. Apparently I am completely muddled in my thinking, because I cannot figure out HOW to do this!
This is the full skinny - Here at the Fire Department most people work in "shifts" - A-Shift, B-Shift and C-Shift; each of these shifts have an indicator that displays on our home page on the appropriate day. The shift-change is at 8:00 am. For example: today is A-Shift, so the "A.gif" is displayed; at 8 am on Saturday, the shift changes to B-Shift, so the image changes to the "B.gif" image.
Right now I have a REALLY UGLY solution that involves a "shiftscript.js" which steps through an if/then/else set-up which I have hard-coded with the month/day/year. Needless to say, the file is HUGE and pretty ridiculous to update.
Here's a snippet of the code *embarrassed look* :
if (now.getMonth() == 7)
{
if (now.getDate() == 1)
{
if (now.getHours() >= 8)
{
document.shiftInd.src= shiftName[2]
}
if (now.getHours() < 8)
{
document.shiftInd.src= shiftName[1]
}
}
if (now.getDate() == 2)
{
if (now.getHours() >= 8)
{
document.shiftInd.src= shiftName[0]
}
if (now.getHours() < 8)
{
document.shiftInd.src= shiftName[2]
}
}
if (now.getDate() ==... (and so on)
(I wasn't kidding when I said it was ugly...)
Does anyone have some thoughts on how to code this in such a way that it will not require much (or any) maintenance? Again, I am rather muddled when it comes to time/date-related issues (just ask any of my ex-girlfriends...).
Thanks in advance!
Jim