date validation scrip

Discussion in 'Javascript' started by Abby Lee, Sep 1, 2004.

  1. Abby Lee

    Abby Lee Guest

    http://www.apriori-it.co.uk/FormatDate.asp

    I found the above date format script while doing a search.
    it works fine except with the format mm/dd/yyyy.
    Type in 01/02/03 and hit the "format date" link...the month and day
    will switch back and forth. This does not happen if you use the
    dd/mm/yyyy format. I want to use the mm/dd/yyyy part of this...can
    someone tell me where the problem is?
     
    Abby Lee, Sep 1, 2004
    #1
    1. Advertising

  2. JRS: In article <>,
    dated Wed, 1 Sep 2004 12:40:27, seen in news:comp.lang.javascript, Abby
    Lee <> posted :
    >http://www.apriori-it.co.uk/FormatDate.asp
    >
    >I found the above date format script while doing a search.
    >it works fine except with the format mm/dd/yyyy.
    >Type in 01/02/03 and hit the "format date" link...the month and day
    >will switch back and forth. This does not happen if you use the
    >dd/mm/yyyy format. I want to use the mm/dd/yyyy part of this...can
    >someone tell me where the problem is?



    Having an off-line news reader, I rarely follow Web references while
    answering incomplete News questions. Your "switch back and forth" is
    most unclear.

    Date format mm/dd/yyyy is really stupid; 99% of countries, and parts of
    Canada, laugh sneer or weep at seeing it. You should follow the
    International standard, ISO 8601, which is AIUI also a US Federal
    standard; yyyy-mm-dd is correct and unambiguous; and yyyy-mm-dd is
    reliable.

    Evidence suggests that even Americans can understand a yyyy/mm/dd date
    when they see it.

    Read the newsgroup FAQ; see below.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
     
    Dr John Stockton, Sep 2, 2004
    #2
    1. Advertising

  3. JRS: In article <>,
    dated Wed, 1 Sep 2004 12:40:27, seen in news:comp.lang.javascript, Abby
    Lee <> posted :
    >http://www.apriori-it.co.uk/FormatDate.asp
    >
    >I found the above date format script while doing a search.
    >it works fine except with the format mm/dd/yyyy.
    >Type in 01/02/03 and hit the "format date" link...the month and day
    >will switch back and forth. This does not happen if you use the
    >dd/mm/yyyy format. I want to use the mm/dd/yyyy part of this...can
    >someone tell me where the problem is?



    I've looked at the script. It is of low quality, and the HTML is not
    good either. The author clearly knows little of the subject, or is paid
    by the yard. If you want bloatware that gives US formats, properly
    tested, there are other sources.

    It accepts days & months with many leading zeroes, and keeps them. It
    does not extend years to 4 digits. Year 33 becomes 2033, but year 033
    remains. Year 0000 is not Leap.

    Each month can have the appropriate number of days 1..n , or 365/366 +
    1..n, or 730/731 + 1..n (roughly stated).

    It windows 2-digit years, but not 1-digit ones, into 1941..2040. It
    accepts "Janitor" and "Octopus" as month-names.

    It does toggle as described; while it can output UK & US forms, it reads
    as UK if possible. Of course, most of us expect the reverse fault <G>.

    To generate mm/dd/yyyy efficiently from a date object, if you must, see
    below and adapt, say,

    function LZ(x) { return (x<0||x>=10?"":"0") + x }

    Date.prototype.ISOlocaldateStr =
    new Function(" /* Date.ISOlocaldateStr */ with (this)\n return " +
    "getFullYear()+'-'+LZ(getMonth()+1)+'-'+LZ(getDate())")


    If you have a numeric date string in another format, rearrange it with a
    RegExp .replace .

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
     
    Dr John Stockton, Sep 2, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TmFocmlu?=
    Replies:
    3
    Views:
    1,143
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jan 27, 2006
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,372
    Michael Borgwardt
    May 30, 2004
  3. Alexander Terekhov

    Re: How to Super Scrip?

    Alexander Terekhov, Jul 2, 2003, in forum: C++
    Replies:
    0
    Views:
    398
    Alexander Terekhov
    Jul 2, 2003
  4. Replies:
    1
    Views:
    348
    Andreas Kraemer
    Oct 19, 2007
  5. Bal Sidhu
    Replies:
    3
    Views:
    251
    Robert Klemme
    Nov 13, 2010
Loading...

Share This Page