#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2008
    Location
    Brewster, NY
    Posts
    29
    Rep Power
    0

    Question 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.

    Since we have visitors across multiple time-zones and our hosting may or may not be in the same time zone as our office, I would need a JavaScript .js file that I can customize to have it use the time zone of our office, regardless of what time zone the web server is at (or do a comparison of our time zone with the time zone of the surfer visiting the page), then allow me to set it to show us as open during our Monday-Friday, 9am-5pm hours, all other times as closed.

    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?
  2. #2
  3. Forgotten Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,053
    Rep Power
    9616
    Why does it have to be Javascript? It's not like people are going to stay on the same page for hours on end.

    Can't you simply have your .asp output whether you're open? Surely it would be easier and just as effective...
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2008
    Location
    Brewster, NY
    Posts
    29
    Rep Power
    0
    Originally Posted by requinix
    Why does it have to be Javascript? It's not like people are going to stay on the same page for hours on end.

    Can't you simply have your .asp output whether you're open? Surely it would be easier and just as effective...
    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.

    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.

    I'm looking at JavaScript because I know I can put a <script> tag and insert JavaScript inline where I want something to show on the page (call up a .js file and add a little code to make it display). But if there's an independently-running .asp code that will do the same as an inline JavaScript, then I'm game.
  6. #4
  7. Forgotten Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,053
    Rep Power
    9616
    Originally Posted by MGatESS
    Okay, first off I am NOT a programmer, I BARELY understand all the stuff that makes the .asp pages operate.
    And you expect Javascript to be easier?

    I don't know what you need to do with ASP, but I do know it will be better and easier than doing it with Javascript, so I'm moving your thread to the ASP forum. It's been years since I've worked with Classic ASP but I'll try to scrounge up some code...

    In the meantime there are a couple things we need to know - regardless of whether this was done with ASP or Javascript:
    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 09:53 AM.
  8. #5
  9. Forgotten Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,053
    Rep Power
    9616
    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?
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2008
    Location
    Brewster, NY
    Posts
    29
    Rep Power
    0
    Originally Posted by requinix
    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?
    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.

    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.
  12. #7
  13. Forgotten Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,053
    Rep Power
    9616
    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
    asp Code:
    <%
     
    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"
    Else
    	Response.Write "Office Is Closed"
    End If
     
    %>

    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.
  14. #8
  15. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,529
    Rep Power
    4541
    You can use javascript server-side, even if your server is configured with vbscript as the default. Found one example here: utc - Current Universal time in classic asp - Stack Overflow
    ======
    Doug G
    ======
    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

IMN logo majestic logo threadwatch logo seochat tools logo