Date and time

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

    #16
    Re: Date and time

    Samir wrote on 19 aug 2004 in comp.lang.javas cript:[color=blue]
    > How would the function work if I were to test for pre 1900-1999 years????[/color]

    Slip of the keyboard:

    My sentence was first .. pre 2000 .. , than I changed it to 1900-1999 and
    left the pre in ;-)

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

    Comment

    • Randy Webb

      #17
      Re: Date and time

      Thomas 'PointedEars' Lahn wrote:
      [color=blue]
      > Lee <REM0VElbspamtr ap@cox.net> wrote:
      >
      > Your From address does not specify a mailbox which is a violation of
      > Internet/Usenet standards and disregarding the Netiquette as well
      > as most certainly a violation of the Acceptable Use Policy of your
      > service provider. You have been warned.[/color]

      Will you please explain the difference between a "munged" address and an
      "un-mailable" address? Since you seem to have a problem with munging,
      and you want to "warn" everyone, please explain. And since you can *not*
      send email to the From: address in my post, you will have to answer it here.
      [color=blue]
      > <http://www.interhack.n et/pubs/munging-harmful/>[/color]

      Reads like it was written by a spam-harvesting-programmer. Utter Junk to
      anyone with half a sense of intelligence.

      --
      Randy
      comp.lang.javas cript FAQ - http://jibbering.com/faq

      Comment

      • MA

        #18
        Re: Date and time


        "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message
        news:opsczv7706 x13kvk@atlantis ...[color=blue]
        > On 19 Aug 2004 19:39:10 GMT, Evertjan. <exjxw.hannivoo rt@interxnl.net >
        > wrote:
        >
        > [snip]
        >[color=green]
        > > function dateToString(d) {
        > > return [d.getYear(),d.g etMonth()+1,d.g etDate()].join('/')
        > > }
        > >
        > > function plus90(x){
        > > d = new Date(x.form.dat e1.value)
        > > d = new Date(d.getYear( ),d.getMonth(), d.getDate()+90)[/color]
        >
        > Wouldn't
        >
        > d = new Date(...);
        > d.setDate(d.get Date() + 90);
        >
        > be simpler?
        >
        > Also, getFullYear() is preferable to getYear().
        >
        > Mike
        >
        > --
        > Michael Winter
        > Replace ".invalid" with ".uk" to reply by e-mail.[/color]
        Hi!

        I used your code like this:
        <!--
        function onclickHandler( oGridCell, date)
        {
        var objDate = new Date();
        //split date in year, month, day
        dateSplitter = date.split("-");
        //set date for date object.
        objDate.setFull Year(dateSplitt er[0], dateSplitter[1], dateSplitter[2]);
        //date argument only contains the first date of the week since I get the
        value from the first cell in my table.
        //Thats the cause of cellIndex. -4 is because there is four columns
        before the actual date.
        returnDate = objDate.getFull Year()+objDate. getMonth()+objD ate.getDay();
        alert(oGridCell .cellIndex-4);
        alert(dateToStr ing(objDate, (oGridCell.cell Index-4)));
        }

        function dateToString(d, addDays)
        {
        d.setDate(d.get Date()+addDays) ;
        return [d.getYear(),d.g etMonth(),d.get Date()].join('/');
        }

        -->
        It really works fine if I don´t add a value that results in a new month.
        When I used todays date (20040820) and the value of addDays where 11, I got
        the value 2004/09/01. This should be 2004/08/31. Doés any of you know whats
        wrong with this?

        /Marre


        Comment

        • Michael Winter

          #19
          Re: Date and time

          On Fri, 20 Aug 2004 15:48:38 +0200, MA <news@supremeli nk.se> wrote:
          [color=blue]
          > function dateToString(d, addDays)
          > {
          > d.setDate(d.get Date()+addDays) ;
          > return [d.getYear(),d.g etMonth(),d.get Date()].join('/');
          > }
          >
          > It really works fine if I don´t add a value that results in a new month.
          > When I used todays date (20040820) and the value of addDays where 11, I
          > got the value 2004/09/01. This should be 2004/08/31. Doés any of you
          > know whats wrong with this?[/color]

          The getMonth() method returns a value between zero (0) and eleven (11),
          not one (1) and twelve (12). Add one to the returned value and you be part
          of the way there.

          Similarly, the setFullYear() method expects the months to be numbered from
          one to eleven. When you pass eight (8), instead of specifying August,
          you're actually setting September (which only has 30 days, hence the
          rollover). You'll want to subtract one from the value you use.

          Mike

          --
          Michael Winter
          Replace ".invalid" with ".uk" to reply by e-mail.

          Comment

          • MA

            #20
            Re: Date and time


            "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message
            news:opsc1aq1vj x13kvk@atlantis ...[color=blue]
            > On Fri, 20 Aug 2004 15:48:38 +0200, MA <news@supremeli nk.se> wrote:
            >[color=green]
            > > function dateToString(d, addDays)
            > > {
            > > d.setDate(d.get Date()+addDays) ;
            > > return [d.getYear(),d.g etMonth(),d.get Date()].join('/');
            > > }
            > >
            > > It really works fine if I don´t add a value that results in a new month.
            > > When I used todays date (20040820) and the value of addDays where 11, I
            > > got the value 2004/09/01. This should be 2004/08/31. Doés any of you
            > > know whats wrong with this?[/color]
            >
            > The getMonth() method returns a value between zero (0) and eleven (11),
            > not one (1) and twelve (12). Add one to the returned value and you be part
            > of the way there.
            >
            > Similarly, the setFullYear() method expects the months to be numbered from
            > one to eleven. When you pass eight (8), instead of specifying August,
            > you're actually setting September (which only has 30 days, hence the
            > rollover). You'll want to subtract one from the value you use.
            >
            > Mike
            >
            > --
            > Michael Winter
            > Replace ".invalid" with ".uk" to reply by e-mail.[/color]
            Aha!
            Should have thougt of that :)

            Thanx!!

            /Marre


            Comment

            • Dr John Stockton

              #21
              Re: Date and time

              JRS: In article <Xns954ADF96995 BBeejj99@194.10 9.133.29>, dated Thu, 19
              Aug 2004 19:58:27, seen in news:comp.lang. javascript, Evertjan.
              <exjxw.hannivoo rt@interxnl.net > posted :[color=blue]
              >Michael Winter wrote on 19 aug 2004 in comp.lang.javas cript:[color=green]
              >> Wouldn't
              >>
              >> d = new Date(...);
              >> d.setDate(d.get Date() + 90);
              >>
              >> be simpler?[/color]
              >
              >Yes, more concise, but perhaps not as clear to the OP.[/color]

              It preserves the civil time (if possible) which was a requirement stated
              in the original posting. It uses only one Date Object, which seems
              nicer.
              [color=blue][color=green]
              >> Also, getFullYear() is preferable to getYear().[/color]
              >
              >Why, in this case?[/color]

              Showing a four-digit year, if permissible, should always be preferred.
              Likewise following ISO 8601, at least in spirit.

              Note that getYear (according to information received, can only be relied
              on to give a result of 0..99 for years 1900-99. To get a two-digit year
              as a number, one needs to use %100. To get a two-digit string, %100 &
              LZ, or add a sufficient multiple of 100, convert to string, and use the
              last two characters. There may be other ways.


              If getFullYear may be unavailable : I have code for determining the Full
              Year Number using getYear and either valueOf or getTime; the only
              assumption AFAICS is that getYear is correct modulo 100.

              --
              © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
              <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.htm> jscr maths, dates, sources.
              <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

              Comment

              • Dennis M. Marks

                #22
                Re: Date and time

                In article <PV6Vc.54880$8s 1.52932@fe08.us enetserver.com> , Samir
                <Samir@hotmail. com> wrote:
                [color=blue]
                > Okay here is my redited code
                >
                > <form>
                > <p><input type="text" name="date1" size="20"><br>
                > date</p>
                > <p><input type="text" name="date2" size="20"><br>
                > 90 days from date</p>
                > <p><input type="button" value="Submit" name="B1"
                > onclick="this.f orm.date2.value =plus90(this.fo rm.date1.value) "></p>
                > </form>
                >
                > I can't seem to know how to do this, I couldn't find the function in the
                > page you have said. Can anyone else help me?
                > <script language="javas cript">
                > function plus90(){[/color]
                <snip>

                You did not read the response correctly. It stated that you would have
                to write a function called "plus90" (or anything else). It is up to you
                to look up how to use date functions and decide how to add 90 days.
                This forum can not teach you everything you need to know about dates
                and functions.

                There is a date calculator at my site that can manipulate dates. You
                may get some ideas there. I would not recommend a single date input
                field. You should have separate fields for month, day, and year in
                order to validate them. Why include the time when it does not change?

                --
                Dennis Marks

                Mail to the return email address is bounced.
                Go to web site for active email address.


                -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
                http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
                -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

                Comment

                Working...