February 15th, 2017, 12:21 PM
ASP to Show "Office Is Open" or "Closed"
Not a programmer, but need to know if there is an inline script I can put in an .asp page in an eCommerce package that will display to a customer whether or not our office is open.
Also, script would have to track the date and allow me to build a "database" within it to mark certain holidays as closed, even if it would fall on a normally open time.
So, would need a .js file that I can call inline within the .asp page. Cannot fill a <head> tag due to the eCommerce package design, but I can place a .js file in a subdirectory and have the inline code on the page call it from its direct URL.
Anyone know if there's a script floating around out there that's "open-source" that would fit the bill?
February 15th, 2017, 12:29 PM
Can't you simply have your .asp output whether you're open? Surely it would be easier and just as effective...
February 16th, 2017, 09:29 AM
Okay, first off I am NOT a programmer, I BARELY understand all the stuff that makes the .asp pages operate. Second, it's a VERY large canned eCommerce package, and I haven't the foggiest idea of where to go to do what I want where I want it.
Originally Posted by requinix
Unless this .asp solution you're suggesting can be put within the <body> tags of a document, and be placed inline where I want it to show like any other HTML tags, it won't work for me.
February 16th, 2017, 10:47 AM
Originally Posted by MGatESS
1. The message will show up somewhere on the page. Do you have a mockup of where you want it to appear, and how? In other words, is everything ready to go except for placing the actual message itself and/or are you able to put a static "Office Is Open/Closed" message (that doesn't change with the time) and have it appear the way you want?
2. What is the HTML for that part of the page, and what is the ASP that outputs/generates it?
Know you will have to get your hands dirty here. We don't know your system any better than you do, so we need you to some legwork and then we can help with the message part itself.
Last edited by requinix; February 16th, 2017 at 10:53 AM.
February 16th, 2017, 11:10 AM
Wow, ASP does not make this nice.
3a. What timezone do you want to use and what timezone is your server using?
3b. What is the chance of either of those changing?
February 17th, 2017, 09:55 AM
I have sent an e-mail to the hosting company to get a definitive answer to those very questions. Waiting to hear back from them.
Originally Posted by requinix
Time zone for OUR office (that I would want the script/app/whatever to display) would be based on Eastern Time zone. As long as the servers hosting our site are in the same time zone, then grabbing the server date/time would be one step closer to finding a solution.
February 17th, 2017, 12:24 PM
So the problem with ASP is that it doesn't know about timezones. All you really have to work with is the current server time, but if you know the server timezone then you can just do a bit of math to get the time you want - if the server isn't in the same timezone to begin with. Working with the hour of day isn't so bad, but you also need to deal with the weekday.
First you have to figure out when you're open and closed according to the server's timezone. If it's in the same timezone then the work is straightforward: put
Dim CurrentDay, CurrentHour
CurrentDay = Weekday(Date(), 1) ' -> 1=Sunday, 7=Saturday
CurrentHour = Hour(Now())
If CurrentDay >= 2 And CurrentDay <= 6 And CurrentHour >= 9 And CurrentHour <= 17 Then
Response.Write "Office Is Open"
Response.Write "Office Is Closed"
at the appropriate location. It not then you need to figure out what numbers to use; for example, if the server is +3h ahead of you then the hours are 12-20 (9+3 to 17+3) and the weekday is unchanged. However if the server is +12h ahead then that affects the weekday and you need more complicated logic...
Worse is dealing with holidays. What you do with them depends on what you're thinking with this "database" you mentioned.
February 17th, 2017, 01:18 PM
I've never been able to appreciate the sublime arrogance of folks who feel they were put on earth just to save other folks from themselves .." - Donald Hamilton