Script to Tell Tell Time then Limit by it?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike A

    Script to Tell Tell Time then Limit by it?

    Hi,
    I'm hoping someone can help me with this.

    I have a URL for which I'd like to limit access to by time. For
    example,say I have a URL that I don't want accessable on Monday mornings
    between 10am-noon and Fri. afternoons between 2-4pm. So when someone clicks
    on the URL during those times a message pops up saying somthing like "sorry we're
    closed now etc"

    Is this possible? if yes, I'm guessing I'll need somesort of "onclick" for the
    href and a script to check the sys time/date ?

    TIA,
    Mike
  • Michael Winter

    #2
    Re: Script to Tell Tell Time then Limit by it?

    "Mike A" wrote on 15/11/2003:
    [color=blue]
    > Hi,
    > I'm hoping someone can help me with this.
    >
    > I have a URL for which I'd like to limit access to by time. For
    > example,say I have a URL that I don't want accessable on Monday
    > mornings between 10am-noon and Fri. afternoons between 2-4pm. So
    > when someone clicks on the URL during those times a message pops up
    > saying somthing like "sorry we're closed now etc"
    >
    > Is this possible? if yes, I'm guessing I'll need somesort of
    > "onclick" for the href and a script to check the sys time/date ?[/color]

    Be aware that it is much better to do this server-side. Many users
    routinely disable JavaScript, so your restrictions will be ignored.
    However, if your host doesn't allow server-side processing, you might
    do something like:

    // Returns boolean false if the website
    // is closed, true otherwise
    // All comparisons are done using UTC (GMT).
    function isAccessable()
    {
    var now = new Date(); // Get current time and date

    select( now.getUTCDay() )
    {
    case 1: // Monday
    // Time between 10:00:00 and 11:59:59 UTC
    if(( 10 <= now.getUTCHours () ) && ( 12 > now.getUTCHours () ))
    return false;
    break;
    case 5: // Friday
    // Time between 14:00:00 and 15:59:59 UTC
    if(( 14 <= now.getUTCHours () ) && ( 16 > now.getUTCHours () ))
    return false;
    break;
    }
    window.alert(
    'Sorry, this site is closed between the following times (GMT):\n'
    + '\n10:00 and 12:00 on Mondays'
    + '\n14:00 and 16:00 on Fridays' );
    return true;
    }

    ....and use a link like:

    <A href="my-time-restricted-page.html"
    onclick="return !isClosed();">E nter</A>

    One last point: as I've learnt recently, operations involving dates
    can be very tricky. Although you shouldn't have any trouble here (the
    comparisons are quite simple in the example above), you might want to
    take a look at the 'Date and Time' section of Dr J R Stockton's
    JavaScript Index (http://www.merlyn.demon.co.uk/js-index.htm).

    Hope that helps,

    Mike

    --
    Michael Winter
    M.Winter@[no-spam]blueyonder.co.u k (remove [no-spam] to reply)


    Comment

    • Fabian

      #3
      Re: Script to Tell Tell Time then Limit by it?

      Mike A hu kiteb:
      [color=blue]
      > Hi,
      > I'm hoping someone can help me with this.
      >
      > I have a URL for which I'd like to limit access to by time. For
      > example,say I have a URL that I don't want accessable on Monday
      > mornings
      > between 10am-noon and Fri. afternoons between 2-4pm. So when someone
      > clicks
      > on the URL during those times a message pops up saying somthing like
      > "sorry we're closed now etc"
      >
      > Is this possible? if yes, I'm guessing I'll need somesort of
      > "onclick" for the href and a script to check the sys time/date ?[/color]

      How do you plan to account for different time zones? How do you plan to
      account for computers whose clocks are set incorectly?


      --
      --
      Fabian
      Visit my website often and for long periods!


      Comment

      • Dr John Stockton

        #4
        Re: Script to Tell Tell Time then Limit by it?

        JRS: In article <15deaa82.03111 50608.3dfdea5a@ posting.google. com>, seen
        in news:comp.lang. javascript, Mike A <mikea@capital. net> posted at Sat,
        15 Nov 2003 06:08:49 :-
        [color=blue]
        >I have a URL for which I'd like to limit access to by time. For
        >example,say I have a URL that I don't want accessable on Monday mornings
        >between 10am-noon and Fri. afternoons between 2-4pm. So when someone clicks
        >on the URL during those times a message pops up saying somthing like "sorry
        >we're
        >closed now etc"
        >
        >Is this possible? if yes, I'm guessing I'll need somesort of "onclick" for the
        >href and a script to check the sys time/date ?[/color]


        Firstly, what do you mean by "Monday"? On the WWW, a day lasts for
        about 48 hours, starting at 0000h in or to the Eastward of NZ and
        finishing at 2400h somewhere South of the Aleutians.

        Probably you mean Monday GMT; or Monday your local time; or Monday in
        server's local time; or Monday in some other location; or Monday in your
        user's time - and, with all but the first, there is the Summer/Winter
        question.

        What you ask is, of course, impossible. If I know that URL, I can put
        it on a page of my own, and I can click on it at any time I like; even
        when I am not connected to the Net. You can, in principle, arrange for
        that URL to give a modified 404 response at those times (GMT, server
        local, or your local; the user's time is AFAIK unknowable at that
        stage). That will need some sort of server-side code.


        You can put script in the page itself (which will only work if the user
        executes script) to do a pop-up instead of showing the page (unless the
        user has a pop-up killer), based on time read from the user's clock and
        interpreted as local, or GMT, or elsewhere. The user can defeat this by
        setting his clock differently.

        You can put the URL on a page of your own, with code such that the click
        only works in allowable hours; that's easily defeated

        Using user's local time, to determine whether the page should be shown:

        T = new Date() // Now
        D = T.getDay() // Sun=0..Sat=6
        H = T.getHours() // 0..23
        Not = D==1 ? H>10 && H<12 : D==5 ? H>14 && H<16 : false
        or
        HoW = D*24+H
        Not = (HoW>34 && HoW<36) || (HoW>134 && HoW<136)

        then maybe

        if (Not) { DoPoP() ; location.href = ... }

        For GMT, use the getUTC functions instead. For remote time, adjust the
        UTC to that, see via below.

        --
        © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
        <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
        <URL:http://www.merlyn.demo n.co.uk/js-index.htm> JS maths, dates, sources.
        <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

        Comment

        • Dr John Stockton

          #5
          Re: Script to Tell Tell Time then Limit by it?

          JRS: In article <JMrtb.767$tX3. 6270159@news-text.cableinet. net>, seen
          in news:comp.lang. javascript, Michael Winter <M.Winter@[no-spam]> posted
          at Sat, 15 Nov 2003 15:39:21 :-[color=blue]
          >"Mike A" wrote on 15/11/2003:[/color]
          [color=blue][color=green]
          >> I have a URL for which I'd like to limit access to by time.[/color][/color]
          [color=blue]
          >Be aware that it is much better to do this server-side. Many users
          >routinely disable JavaScript, so your restrictions will be ignored.[/color]

          It is possible to have a lead-in page which uses javascript to call the
          real page provided that the time is right. If the lead-in page appends
          the time_t of call to the URL, and the real page checks early in loading
          that the present time is no earlier than that and not much later
          aborting otherwise, modest security is obtained. The time can be
          encoded in Base 36 and shuffled, to make the situation obscure. Non-JS
          users then do not see the real page, and cheating is non-trivial.


          [color=blue]
          > select( now.getUTCDay() )[/color]

          I'm not familiar with that use of "select"; I'd use "switch".
          [color=blue]
          > // Time between 10:00:00 and 11:59:59 UTC[/color]

          Not really. Time >=10h & <12h.
          [color=blue]
          > if(( 10 <= now.getUTCHours () ) && ( 12 > now.getUTCHours () ))[/color]
          [color=blue]
          > window.alert(
          > 'Sorry, this site is closed between the following times (GMT):\n'
          > + '\n10:00 and 12:00 on Mondays'
          > + '\n14:00 and 16:00 on Fridays' );
          > return true;
          >}[/color]

          AFAICS, that alert is given when the site is accessible.

          On the whole, only tested code is worth posting.

          --
          © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
          <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
          <URL:http://www.merlyn.demo n.co.uk/js-index.htm> JS maths, dates, sources.
          <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

          Comment

          • Michael Winter

            #6
            Re: Script to Tell Tell Time then Limit by it?

            Dr John Stockton wrote on 16 Nov 2003:
            [color=blue]
            > JRS: In article
            > <JMrtb.767$tX3. 6270159@news-text.cableinet. net>, seen in
            > news:comp.lang. javascript, Michael Winter <M.Winter@[no-spam]>
            > posted at Sat, 15 Nov 2003 15:39:21 :-[color=green]
            >>"Mike A" wrote on 15/11/2003:[/color]
            >[color=green][color=darkred]
            >>> I have a URL for which I'd like to limit access to by time.[/color][/color]
            >[color=green]
            >>Be aware that it is much better to do this server-side. Many
            >>users routinely disable JavaScript, so your restrictions will be
            >>ignored.[/color]
            >
            > It is possible to have a lead-in page which uses javascript to
            > call the real page provided that the time is right. If the
            > lead-in page appends the time_t of call to the URL, and the real
            > page checks early in loading that the present time is no earlier
            > than that and not much later aborting otherwise, modest security
            > is obtained. The time can be encoded in Base 36 and shuffled,
            > to make the situation obscure. Non-JS users then do not see the
            > real page, and cheating is non-trivial.
            >
            >
            >[color=green]
            >> select( now.getUTCDay() )[/color]
            >
            > I'm not familiar with that use of "select"; I'd use "switch".[/color]

            Simple confusion between languages.
            [color=blue][color=green]
            >> // Time between 10:00:00 and 11:59:59 UTC[/color]
            >
            > Not really. Time >=10h & <12h.[/color]

            That is, for all intents and purposes, the same thing. If the hour
            is, or is after 10, and at any time during the 11th hour, it is as I
            described (though more correctly 11:59:59.999) and evaluated below.
            [color=blue][color=green]
            >> if(( 10 <= now.getUTCHours () ) && ( 12 > now.getUTCHours ()
            >> ))[/color]
            >[color=green]
            >> window.alert(
            >> 'Sorry, this site is closed between the following times
            >> (GMT):\n' + '\n10:00 and 12:00 on Mondays'
            >> + '\n14:00 and 16:00 on Fridays' );
            >> return true;
            >>}[/color]
            >
            > AFAICS, that alert is given when the site is accessible.[/color]

            You would be correct. If you check the HTML snippet I included, the
            function name is 'isClosed()'. I thought that I'd reverse the logic
            to make it easier to use, but I obviously forgot to negate the
            comparisons. Each if statement should be corrected to:

            if( !( <original expression )) { statements }

            Thank you for bringing attention to my lapse in concentration: I've
            informed the original poster by e-mail (he contacted me after I made
            my post).

            Mike

            --
            Michael Winter
            M.Winter@[no-spam]blueyonder.co.u k (remove [no-spam] to reply)

            Comment

            • Michael Winter

              #7
              Re: Script to Tell Tell Time then Limit by it?

              I really did make a pigs ear of my original code: all returns need to
              have their values inverted too.

              I truly am sorry about this. I will make sure that I review and test
              any code in my responses thoroughly. I will refrain from posting
              further unless I am as certain as I can be about the validity of the
              advice or suggestions I give.

              Sincerly,
              Michael Winter

              Comment

              • Mike A

                #8
                Re: Script to Tell Tell Time then Limit by it?

                Ok, As a newbie, I'll have to ask as I'm now totally confused.
                I'm trying to edit Michael Winter's original code with the edits
                he suggested (in a previous post) with no luck, would someone
                be kind and assist?

                TIA,
                Mike

                Comment

                • Michael Winter

                  #9
                  Re: Script to Tell Tell Time then Limit by it?

                  Mike A wrote on 17 Nov 2003:
                  [color=blue]
                  > Ok, As a newbie, I'll have to ask as I'm now totally confused.
                  > I'm trying to edit Michael Winter's original code with the edits
                  > he suggested (in a previous post) with no luck, would someone
                  > be kind and assist?
                  >
                  > TIA,
                  > Mike[/color]


                  Unless someone can find any more errors (I did boundary test it) or I
                  overlooked something, this should be fine (under Opera 7.22 and IE 6,
                  at least). Any comments relating to date operations are also welcome.


                  The script:

                  function isAccessable()
                  {
                  var now = new Date(); // Get current time and date

                  switch( now.getUTCDay() )
                  {
                  case 1: // Monday
                  // Time between 10:00:00 and 11:59:59.999 UTC
                  if( !(( 10 <= now.getUTCHours () ) && ( now.getUTCHours () < 12 )))
                  return true;
                  break;
                  case 5: // Friday
                  // Time between 14:00:00 and 15:59:59.999 UTC
                  if( !(( 14 <= now.getUTCHours () ) && ( now.getUTCHours () < 16 )))
                  return true;
                  break;
                  }
                  window.alert(
                  'Sorry, this site is closed between the following times (GMT):\n'
                  + '\n10:00 and 12:00 on Mondays'
                  + '\n14:00 and 16:00 on Fridays' );
                  return false;
                  }


                  The HTML:

                  <A href="my-time-dependant-page.html"
                  onclick="return isAccessable(); ">Enter</A>

                  I really am sorry about the mix up. Be warned: when entering a month,
                  remember that they're zero based (0 - January, 1 - February, etc).

                  Also remember to convert all times to UTC (GMT) so the comparisons
                  are applicable all over the world.

                  Mike

                  --
                  Michael Winter
                  M.Winter@[no-spam]blueyonder.co.u k (remove [no-spam] to reply)

                  Comment

                  • Dr John Stockton

                    #10
                    Re: Script to Tell Tell Time then Limit by it?

                    JRS: In article <15deaa82.03111 70949.6f715305@ posting.google. com>, seen
                    in news:comp.lang. javascript, Mike A <mikea@capital. net> posted at Mon,
                    17 Nov 2003 09:49:58 :-[color=blue]
                    >Ok, As a newbie, I'll have to ask as I'm now totally confused.
                    >I'm trying to edit Michael Winter's original code with the edits
                    >he suggested (in a previous post) with no luck, would someone
                    >be kind and assist?[/color]

                    That may be sub-optimal.

                    To the article to which the above is a response, add :

                    or
                    HoW = D*100 + H
                    Not = (HoW>110 && HoW<112) || (HoW>514 && HoW<516)

                    or
                    HoW = D + H/100
                    Not = (HoW>1.10 && HoW<1.12) || (HoW>5.14 && HoW<5.16)

                    Note that the numbers are of the form <Day-of-JS-Week><Hours>; cf.
                    <URL:http://www.merlyn.demo n.co.uk/js-date1.htm#DC> and
                    <URL:http://www.merlyn.demo n.co.uk/js-date1.htm#TCp>.

                    --
                    © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
                    <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
                    <URL:http://www.merlyn.demo n.co.uk/js-index.htm> JS maths, dates, sources.
                    <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

                    Comment

                    • Mike A

                      #11
                      Re: Script to Tell Tell Time then Limit by it?

                      Thank you all for assisting me with this script. I'm in the process of
                      testing
                      it (Michael's last updated Usenet post) and Have a few followup
                      questions/uncertainties:

                      1. The href in question should only be avail on mondays 10-noon and
                      fridays 2-4pm, any other times the window.alert should appear. I think
                      this is working correctly, based on the code, is this correct?

                      2. I'm testing the various days/time periods by manually changing the
                      clock on my PC (windoze xp)I'm having problems when I change the time
                      on any given day. i.e. say I change the day to fri, and the time to
                      1pm, I should get the window.alert but I don't Is this normal?

                      Thank you for your patience.
                      Mike

                      Dr John Stockton <spam@merlyn.de mon.co.uk> wrote in message news:<e6qby0B5z Tu$EwlQ@merlyn. demon.co.uk>...[color=blue]
                      > JRS: In article <15deaa82.03111 70949.6f715305@ posting.google. com>, seen
                      > in news:comp.lang. javascript, Mike A <mikea@capital. net> posted at Mon,
                      > 17 Nov 2003 09:49:58 :-[color=green]
                      > >Ok, As a newbie, I'll have to ask as I'm now totally confused.
                      > >I'm trying to edit Michael Winter's original code with the edits
                      > >he suggested (in a previous post) with no luck, would someone
                      > >be kind and assist?[/color]
                      >
                      > That may be sub-optimal.
                      >
                      > To the article to which the above is a response, add :
                      >
                      > or
                      > HoW = D*100 + H
                      > Not = (HoW>110 && HoW<112) || (HoW>514 && HoW<516)
                      >
                      > or
                      > HoW = D + H/100
                      > Not = (HoW>1.10 && HoW<1.12) || (HoW>5.14 && HoW<5.16)
                      >
                      > Note that the numbers are of the form <Day-of-JS-Week><Hours>; cf.
                      > <URL:http://www.merlyn.demo n.co.uk/js-date1.htm#DC> and
                      > <URL:http://www.merlyn.demo n.co.uk/js-date1.htm#TCp>.[/color]

                      Comment

                      • Dr John Stockton

                        #12
                        Re: Script to Tell Tell Time then Limit by it?

                        JRS: In article <Xns9436E3DE9D8 C6MWinterBlueyo nder@193.38.113 .46>, seen
                        in news:comp.lang. javascript, Michael Winter <M.Winter@[no-spam]> posted
                        at Mon, 17 Nov 2003 22:24:01 :-
                        [color=blue]
                        >Unless someone can find any more errors (I did boundary test it) or I
                        >overlooked something, this should be fine (under Opera 7.22 and IE 6,
                        >at least). Any comments relating to date operations are also welcome.[/color]

                        I think you overlooked the possibility that it might be Tuesday, for
                        example; also Wed Thu Sat Sun.

                        Every switch statement should have a default: at the end, unless it is
                        absolutely certain that all possible cases are covered, and will remain
                        covered, above. If it is intended that all cases be covered above, use
                        default: alert('Blunder' ) // or suchlike.

                        You probably need :
                        default: return true


                        [color=blue]
                        ><A href="my-time-dependant-page.html"
                        > onclick="return isAccessable(); ">Enter</A>[/color]

                        isAccessable should be isAccessible
                        dependant should be dependent

                        --
                        © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
                        <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
                        <URL:http://www.merlyn.demo n.co.uk/js-index.htm> JS maths, dates, sources.
                        <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

                        Comment

                        • Grant Wagner

                          #13
                          Re: Script to Tell Tell Time then Limit by it?

                          Mike A wrote:
                          [color=blue]
                          > Ok, As a newbie, I'll have to ask as I'm now totally confused.
                          > I'm trying to edit Michael Winter's original code with the edits
                          > he suggested (in a previous post) with no luck, would someone
                          > be kind and assist?
                          >
                          > TIA,
                          > Mike[/color]

                          The code is pointless, since you're telling me when the page is
                          unavailable, I can simply adjust the clock on my PC to avoid your
                          "security".

                          Also, even if the target audience is in North America, NA consists
                          of at least 3 time zones, making "10am to noon on Monday"
                          meaningless, except to users in your local time zone, and even then,
                          meaningful only if the clock on their local PC is set accurately.

                          The only way to disable a page for a specific period of time (to
                          perform maintenance, updating or backups) is to disable the page on
                          the server, using some sort of server-side processing. If you have
                          no access to server-side processing (Perl, PHP, ASP, etc), then the
                          simplest solution is to simply swap a "This page not available" page
                          in over the page you want to disable while you are performing
                          whatever updates are necessary.

                          --
                          | Grant Wagner <gwagner@agrico reunited.com>

                          * Client-side Javascript and Netscape 4 DOM Reference available at:
                          *


                          * Internet Explorer DOM Reference available at:
                          *
                          Gain technical skills through documentation and training, earn certifications and connect with the community


                          * Netscape 6/7 DOM Reference available at:
                          * http://www.mozilla.org/docs/dom/domref/
                          * Tips for upgrading JavaScript for Netscape 7 / Mozilla
                          * http://www.mozilla.org/docs/web-deve...upgrade_2.html


                          Comment

                          • Michael Winter

                            #14
                            Re: Script to Tell Tell Time then Limit by it?

                            Dr John Stockton wrote on 18 Nov 2003:
                            [color=blue]
                            > JRS: In article
                            > <Xns9436E3DE9D8 C6MWinterBlueyo nder@193.38.113 .46>, seen in
                            > news:comp.lang. javascript, Michael Winter <M.Winter@[no-spam]>
                            > posted at Mon, 17 Nov 2003 22:24:01 :-
                            >[color=green]
                            >>Unless someone can find any more errors (I did boundary test it)
                            >>or I overlooked something, this should be fine (under Opera 7.22
                            >>and IE 6, at least). Any comments relating to date operations
                            >>are also welcome.[/color]
                            >
                            > I think you overlooked the possibility that it might be Tuesday,
                            > for example; also Wed Thu Sat Sun.[/color]

                            They were omitted on purpose. This was only an example - in fact, an
                            implementation of the example given by the original poster. I
                            expected additional cases to be added as necessary.

                            I should have also commented the if statements better:

                            // If time is not between 10:00:00 and 11:59:59.999 UTC, the site
                            // is accessible (returns true).
                            if( !(( 10 <= now.getUTCHours () ) && ( now.getUTCHours () < 12 )))
                            return true;

                            It's a minor change, but it explains the logic a little better.
                            [color=blue]
                            > Every switch statement should have a default: at the end, unless
                            > it is absolutely certain that all possible cases are covered,
                            > and will remain covered, above. If it is intended that all
                            > cases be covered above, use
                            > default: alert('Blunder' ) // or suchlike.
                            >
                            > You probably need :
                            > default: return true;
                            >[/color]

                            You are absolutely correct: a default case is required for the script
                            to work as desired. The default case should return boolean true (as
                            quoted above).

                            I didn't discover this because I only tested the days that had
                            conditions (serves me right for not preparing proper test cases).
                            [color=blue][color=green]
                            >><A href="my-time-dependant-page.html"
                            >> onclick="return isAccessable(); ">Enter</A>[/color]
                            >
                            > isAccessable should be
                            > isAccessible
                            > dependant should be dependent[/color]

                            I didn't think I had spelt either correctly, but I was more concerned
                            about replying then ensuring correct spelling.

                            Mike

                            --
                            Michael Winter
                            M.Winter@blueyo nder.co.uk.invalid (remove ".invalid" to reply)

                            Comment

                            • Michael Winter

                              #15
                              Re: Script to Tell Tell Time then Limit by it?

                              Mike A wrote on 18 Nov 2003:
                              [color=blue]
                              > Thank you all for assisting me with this script. I'm in the
                              > process of testing
                              > it (Michael's last updated Usenet post) and Have a few followup
                              > questions/uncertainties:
                              >
                              > 1. The href in question should only be avail on mondays 10-noon
                              > and fridays 2-4pm, any other times the window.alert should
                              > appear. I think this is working correctly, based on the code, is
                              > this correct?[/color]

                              As Dr Stockton pointed out in his reply to the new code, I missed the
                              default case. The switch should read:

                              switch ( now.getUTCDay() )
                              {
                              case 1: // Monday
                              // If time is not between 10:00:00 and 11:59:59.999 UTC
                              // (inclusive), the site is accessible (returns true)

                              if ( !(( 10 <= now.getUTCHours ()) && ( now.getUTCHours () < 12 )))
                              return true;
                              break;
                              case 5: // Friday
                              // If time is not between 14:00:00 and 15:59:59.999 UTC
                              // (inclusive), the site is accessible (returns true)

                              if ( !(( 14 <= now.getUTCHours ()) && ( now.getUTCHours () < 16 )))
                              return true;
                              break;
                              default: // Other days have no restrictions
                              return true;
                              }

                              Now the script should only return false on Mondays, between 10:00 and
                              12:00, and Fridays between 14:00 and 16:00 (closed times). It will
                              return true at all other times.
                              [color=blue]
                              > 2. I'm testing the various days/time periods by manually
                              > changing the clock on my PC (windoze xp)I'm having problems when
                              > I change the time on any given day. i.e. say I change the day to
                              > fri, and the time to 1pm, I should get the window.alert but I
                              > don't Is this normal?[/color]

                              The times the script checks are in the GMT time zone. You could
                              adjust your clock to cope with the difference in time zones, but
                              there is an easier way. It also means you don't have to play with
                              your system's clock.

                              Comment out the line beginning: var now = .... Add a new line after
                              it like this:

                              var now = new Date(
                              Date.UTC(year, month (zero-based), day, hour, min, sec, millisec));

                              If you entered: Date.UTC( 2003, 10, 21, 13, 0, 0, 0 ) [Friday, 21
                              November 2003 @ 1pm], you will get the alert. Just remember to change
                              back to "var now = new Date();" when you've finished testing.

                              Remember that using the UTC methods is the only way to ensure that
                              the date and times will be evaluted consistently across the world.
                              When you set the disallowed dates and times, change them from your
                              local time zone to GMT.

                              Mike

                              --
                              Michael Winter
                              M.Winter@blueyo nder.co.uk.invalid (remove ".invalid" to reply)

                              Comment

                              Working...