Please help me on this script

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

    #16
    Re: Please help me on this script

    Dr J R Stockton wrote on 26 okt 2006 in comp.lang.javas cript:
    In message <Xns9868B29AF26 92eejj99@194.10 9.133.242>, Thu, 26 Oct 2006
    15:33:26, Evertjan. <exjxw.hannivoo rt@interxnl.net writes
    >>
    > // below formula from John Stockton at
    > // <http://www.merlyn.demo n.co.uk/js-date1.htm#DDf>
    > // no account is taken of summer/winter and other time differences.
    >>
    var diffDate = Math.round( ( d2-d1 ) / 864e5 );
    >
    Being named Vishnu, he may be in India where IIRC they need no Summer
    Time.
    Vishnu is the Ultimate Reality and is responsible for the maintainance and
    preservation of the universe, so he is surely would not be interested in
    futilities like local time differences of one hour?
    But, contrary to what your comment suggests, that method deals
    with changes in season between d1 & d2.
    Ah, yes,
    because the rounding takes care of time zone differences
    that are less than half a day.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Dr J R Stockton

      #17
      Re: Please help me on this script

      In message <Xns98695E8B5F8 6Aeejj99@194.10 9.133.242>, Fri, 27 Oct 2006
      07:17:38, Evertjan. <exjxw.hannivoo rt@interxnl.net writes
      >Dr J R Stockton wrote on 26 okt 2006 in comp.lang.javas cript:
      >But, contrary to what your comment suggests, that method deals
      >with changes in season between d1 & d2.
      >
      >Ah, yes,
      >because the rounding takes care of time zone differences
      >that are less than half a day.
      No; the coding expects both dates to be in the same time zone. The
      rounding allows for the summer/winter change of offset from UTC by
      thirty minutes or by one hour (and, merely adventitiously, for larger
      differences).

      Time zones are geographically stable, changing only by specific
      political action. Offsets from UTC often change twice a year.

      Around 1970, the UK remained in the GMT zone but had Summer Time all
      year round. In principle, that's quite different from moving to your
      (NL) time zone and having Winter Time all year round. But they have the
      same effect on the clocks.
      --
      (c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 IE 6.
      Web <URL:http://www.merlyn.demo n.co.uk/- w. FAQish topics, links, acronyms
      PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/- see 00index.htm
      Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.

      Comment

      • Evertjan.

        #18
        Re: Please help me on this script

        Dr J R Stockton wrote on 27 okt 2006 in comp.lang.javas cript:
        Around 1970, the UK remained in the GMT zone but had Summer Time all
        year round. In principle, that's quite different from moving to your
        (NL) time zone and having Winter Time all year round. But they have the
        same effect on the clocks.
        And 25 years earlier Britain toggled between British Summer Time (BST) in
        winter and British Double Summer Time (BDST) in summer for 4 years, as I
        faguely remember.

        At present the Netherlands, using CET, linked to the meridian of Berlin,
        enjoys a winter time advance of about 20 minutes and a summer time advance
        of 80 minutes, depending on location.

        A same effect is enjoyed in Wales etc with WET.

        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress)

        Comment

        • Dr J R Stockton

          #19
          Re: Please help me on this script

          In message <Xns986A76C406B 30eejj99@194.10 9.133.242>, Sat, 28 Oct 2006
          09:40:30, Evertjan. <exjxw.hannivoo rt@interxnl.net writes
          >
          >And 25 years earlier Britain toggled between British
          >Summer Time (BST) in winter and British Double Summer Time
          >(BDST) in summer for 4 years, as I faguely remember.
          Double Summer Time (BDST/DBST) has been used in the UK, during 1941-45
          and 1947; and between Summer 1940 and Summer 1945, civil time in the
          Winter was an hour ahead of GMT. BDST is no longer allowed. See Myers
          and NPL's archive, via
          <URL:http://www.merlyn.demo n.co.uk/uksumtim.htm#Li nx>.


          Returning towards topic a little : there was a pleasant discussion here
          a while back about the fastest way to determine Leap Year - the result
          did not use a Date Object. But what's the best way *with* a Date Object
          ?
          --
          (c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 IE 6.
          Web <URL:http://www.merlyn.demo n.co.uk/- w. FAQish topics, links, acronyms
          PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/- see 00index.htm
          Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.

          Comment

          • Evertjan.

            #20
            Re: Please help me on this script

            Dr J R Stockton wrote on 28 okt 2006 in comp.lang.javas cript:
            Returning towards topic a little : there was a pleasant discussion here
            a while back about the fastest way to determine Leap Year - the result
            did not use a Date Object. But what's the best way *with* a Date Object
            ?
            >
            function isLeapyear(yr) {
            return new Date(yr,1,29).g etMonth()==1
            }

            --
            Evertjan.
            The Netherlands.
            (Please change the x'es to dots in my emailaddress)

            Comment

            • Dr J R Stockton

              #21
              Re: Please help me on this script

              In message <Xns986B66E678B DEeejj99@194.10 9.133.242>, Sun, 29 Oct 2006
              09:06:55, Evertjan. <exjxw.hannivoo rt@interxnl.net writes
              >Dr J R Stockton wrote on 28 okt 2006 in comp.lang.javas cript:
              >
              >Returning towards topic a little : there was a pleasant discussion here
              >a while back about the fastest way to determine Leap Year - the result
              >did not use a Date Object. But what's the best way *with* a Date Object
              >?
              >>
              >
              >function isLeapyear(yr) {
              return new Date(yr,1,29).g etMonth()==1
              >}
              >
              function isLeapyear(yr) { return new Date(yr, 2, -28).getMonth() }

              returns 0 or 1, which can be used directly in a context demanding
              Boolean, can be converted to true Boolean with ! or !!, and can be used
              to index an array. No comparison operation required. Speed is about
              doubled (for me) by using UTC.

              --
              (c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 IE 6
              <URL:http://www.jibbering.c om/faq/>? JL/RC: FAQ of news:comp.lang. javascript
              <URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
              <URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.

              Comment

              • Evertjan.

                #22
                Re: Please help me on this script

                Dr J R Stockton wrote on 29 okt 2006 in comp.lang.javas cript:
                In message <Xns986B66E678B DEeejj99@194.10 9.133.242>, Sun, 29 Oct 2006
                09:06:55, Evertjan. <exjxw.hannivoo rt@interxnl.net writes
                >>Dr J R Stockton wrote on 28 okt 2006 in comp.lang.javas cript:
                >>
                >>Returning towards topic a little : there was a pleasant discussion
                >>here a while back about the fastest way to determine Leap Year - the
                >>result did not use a Date Object. But what's the best way *with* a
                >>Date Object ?
                >>>
                >>
                >>function isLeapyear(yr) {
                > return new Date(yr,1,29).g etMonth()==1
                >>}
                >>
                >
                function isLeapyear(yr) { return new Date(yr, 2, -28).getMonth() }
                >
                returns 0 or 1, which can be used directly in a context demanding
                Boolean, can be converted to true Boolean with ! or !!, and can be
                used to index an array. No comparison operation required.
                function isLeapyear(yr) { return !new Date(yr, 2, -59).getMonth() }

                will give return true boolean value.

                As will:

                function isLeapyear(yr) { return !new Date(yr, 0, 397).getMonth() }

                Or if you wish:

                function isLeapyear(yr) { return !!new Date(yr, 0, 366).getMonth() }
                Speed is about doubled (for me) by using UTC.
                How many leapyear tests would you like to do in a real life script?

                ;-}

                =============== ======

                new Date(yr, 0, d) is a quick way
                to get the Date Object date from the year day number.

                Is there a similar quick way
                to get the year day number from a Date Object date?



                --
                Evertjan.
                The Netherlands.
                (Please change the x'es to dots in my emailaddress)

                Comment

                • Dr J R Stockton

                  #23
                  Re: Please help me on this script

                  In message <Xns986CAFE92F7 2Aeejj99@194.10 9.133.242>, Mon, 30 Oct 2006
                  16:17:34, Evertjan. <exjxw.hannivoo rt@interxnl.net writes
                  >new Date(yr, 0, d) is a quick way
                  >to get the Date Object date from the year day number.
                  >
                  >Is there a similar quick way
                  >to get the year day number from a Date Object date?

                  function DoY(X) { var D
                  return Math.round((+(D = new Date(+X)) - D.setMonth(0, 0))/864e5) }

                  That can be simplified if the object's value need not be preserved ...

                  return Math.round((+X - X.setMonth(0, 0))/864e5) }

                  Those functions should give Local Day of Year; for UTC Day of Year, use
                  UTC setMonth. South of the Equator, one can use |0 instead of
                  Math.round.

                  I wrote those while answering; see also
                  <URL:http://www.merlyn.demo n.co.uk/js-date0.htm#DoY which includes
                  much the same but less compactly.

                  --
                  (c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 IE 6
                  <URL:http://www.jibbering.c om/faq/>? JL/RC: FAQ of news:comp.lang. javascript
                  <URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
                  <URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.

                  Comment

                  Working...