Inherit Date Class?

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

    Inherit Date Class?

    Hi,

    I'm kind of new to the more involved workings of javascript, and am
    having a few problems.

    My problem is this: I am working with a CMS which is including various
    javascrip files in the pages, including files for a calendar
    (Dynarch).

    I would like to add some new functionality to the CMS and add some
    extra javascript files from a different calendar (Zapatech). The
    Zapatech calendar is veeeeeeery closely based on the Dynarch calendar.

    Both calendars extend the Date object, and in many places use the same
    prototype function names e.g. Date.prototype. getMonthDays

    The problem is that calling Date.getMonthDa ys, for example, calls the
    definition from the Dynarch files (these files are included in the
    page first), whereas I want it to call the definition in the Zapatech
    files.

    I have been looking for a way to apply appropriate namespacing, via
    inheriting the Date class into a new class e.g. ZDate, but have not
    figured out how to successfully achieve this.

    For example, my attempts at the new ZDate class will return an error
    when you try ZDate.parse("Ju l 8, 2008"); stating that ZDate.parse is
    not a function

    So my question is how do I succesfully seperate my new javascript from
    the already present definitions.

    (or alternatively, is there a way to remove all the additions made to
    the Date class, and start with a fresh Date version for my new
    javascript?)

    Any help in this is greatly appreciated!

    Chris
  • Peter McMurray

    #2
    Re: Inherit Date Class?

    Hi Chris
    You will find tutorials and blog articles on what you need at
    Measure, monetize, advertise and improve your apps with Yahoo tools. Join the 200,000 developers using Yahoo tools to build their app businesses.

    Peter
    "Chris" <christopher.jo hn.allan@google mail.comwrote in message
    news:2aad5f4d-8f31-4f8f-b4a6-22f9ab07379c@d1 g2000hsg.google groups.com...
    Hi,
    >
    I'm kind of new to the more involved workings of javascript, and am
    having a few problems.
    >
    My problem is this: I am working with a CMS which is including various
    javascrip files in the pages, including files for a calendar
    (Dynarch).
    >
    I would like to add some new functionality to the CMS and add some
    extra javascript files from a different calendar (Zapatech). The
    Zapatech calendar is veeeeeeery closely based on the Dynarch calendar.
    >
    Both calendars extend the Date object, and in many places use the same
    prototype function names e.g. Date.prototype. getMonthDays
    >
    The problem is that calling Date.getMonthDa ys, for example, calls the
    definition from the Dynarch files (these files are included in the
    page first), whereas I want it to call the definition in the Zapatech
    files.
    >
    I have been looking for a way to apply appropriate namespacing, via
    inheriting the Date class into a new class e.g. ZDate, but have not
    figured out how to successfully achieve this.
    >
    For example, my attempts at the new ZDate class will return an error
    when you try ZDate.parse("Ju l 8, 2008"); stating that ZDate.parse is
    not a function
    >
    So my question is how do I succesfully seperate my new javascript from
    the already present definitions.
    >
    (or alternatively, is there a way to remove all the additions made to
    the Date class, and start with a fresh Date version for my new
    javascript?)
    >
    Any help in this is greatly appreciated!
    >
    Chris

    Comment

    • dhtml

      #3
      Re: Inherit Date Class?

      Peter McMurray wrote:
      Hi Chris
      You will find tutorials and blog articles on what you need at
      http://developer.yahoo.com/yui/theater/
      The Grady Booch video is good.

      Some good quotes:

      "Microsoft Office will one day consume all the bits in the universe."

      And this one:
      | The wrong architectural setup that I see in some places is where you
      | have an architectural group over here (waves hand) not associated with
      | any one project and you end up with people who are generally the
      | people who are... they're there because they aren't good enough to be
      | on a real project, I'll politely say.
      |
      | And furthermore, they are so disjointed from the real problem, that
      | they're building things that nobody will care about anymore.
      |

      That sounds a lot like the role of the YUI team, the Yahoo Exceptional
      Performance Team, and Douglas Crockford.

      Points taken:
      The major factor that impacts the performance of a project (its
      success) is complexity
      A bad process increases complexity, a good one reduces it.

      But the yahoo video controls have a lot of problems (kept popping up
      favorites)

      Then when I try and fast forward it takes me to a login page.
      Peter
      "Chris" <christopher.jo hn.allan@google mail.comwrote in message
      news:2aad5f4d-8f31-4f8f-b4a6-22f9ab07379c@d1 g2000hsg.google groups.com...
      >Hi,
      >>
      >I'm kind of new to the more involved workings of javascript, and am
      >having a few problems.
      >>
      >My problem is this: I am working with a CMS which is including various
      >javascrip files in the pages, including files for a calendar
      >(Dynarch).
      >>
      >I would like to add some new functionality to the CMS and add some
      >extra javascript files from a different calendar (Zapatech). The
      >Zapatech calendar is veeeeeeery closely based on the Dynarch calendar.
      >>
      >Both calendars extend the Date object, and in many places use the same
      >prototype function names e.g. Date.prototype. getMonthDays
      >>
      >The problem is that calling Date.getMonthDa ys, for example, calls the
      >definition from the Dynarch files (these files are included in the
      >page first), whereas I want it to call the definition in the Zapatech
      >files.
      >>
      >I have been looking for a way to apply appropriate namespacing, via
      >inheriting the Date class into a new class e.g. ZDate, but have not
      >figured out how to successfully achieve this.
      >>
      >For example, my attempts at the new ZDate class will return an error
      >when you try ZDate.parse("Ju l 8, 2008"); stating that ZDate.parse is
      >not a function
      >>
      Did you call it before it was available? Before the script containing
      |ZDate.parse| was loaded?
      >So my question is how do I succesfully seperate my new javascript from
      >the already present definitions.
      >>
      >(or alternatively, is there a way to remove all the additions made to
      >the Date class, and start with a fresh Date version for my new
      >javascript?)
      >>
      >Any help in this is greatly appreciated!
      >>
      >Chris
      >

      Comment

      • dhtml

        #4
        Re: Inherit Date Class?

        dhtml wrote:
        Peter McMurray wrote:
        And this one:
        | The wrong architectural setup that I see in some places is where you
        | have an architectural group over here (waves hand) not associated with
        | any one project and you end up with people who are generally the
        | people who are... they're there because they aren't good enough to be
        | on a real project, I'll politely say.
        |
        | And furthermore, they are so disjointed from the real problem, that
        | they're building things that nobody will care about anymore.
        |
        >
        That sounds a lot like the role of the YUI team, the Yahoo Exceptional
        Performance Team, and Douglas Crockford.
        >
        (not to discredit any of them, more to what I see as that organizational
        role at Yahoo).

        Comment

        • Chris

          #5
          Re: Inherit Date Class?

          Hi,

          Thanks for the link. Just to be clear, you were referring to the
          videos by Douglas Crockford — "The JavaScript Programming Language",
          right?

          I will try and get through the 2hours of video tonight, but in the
          meantime, I would appreciate it if anyone could make a comment on what
          I'm trying to achieve - whether it's incredibly easy to do, whether
          it's just not possible etc.

          Thanks

          Comment

          • Dr J R Stockton

            #6
            Re: Inherit Date Class?

            In comp.lang.javas cript message <2aad5f4d-8f31-4f8f-b4a6-22f9ab07379c@d1
            g2000hsg.google groups.com>, Wed, 8 Oct 2008 21:34:18, Chris <christopher
            ..john.allan@go oglemail.compos ted:
            >My problem is this: I am working with a CMS which is including various
            >javascrip files in the pages, including files for a calendar
            >(Dynarch).
            >
            >I would like to add some new functionality to the CMS and add some
            >extra javascript files from a different calendar (Zapatech). The
            >Zapatech calendar is veeeeeeery closely based on the Dynarch calendar.
            >
            >Both calendars extend the Date object, and in many places use the same
            >prototype function names e.g. Date.prototype. getMonthDays
            Is there anything that might reasonably be added to Date Objects, by
            such systems, that one cannot readily add oneself, guided by freely-
            available code and other resources?

            I suppose I am assuming that you are using only Gregorian or Julian
            dates, AD/BC/astro - not AM, AH, AUC, etc., dates?

            If you do use imported libraries, make careful full-range checks. If MS
            cannot get things right, should one expect that others will? Perhaps
            that had better not be answered.

            --
            (c) John Stockton, nr London, UK. ?@merlyn.demon. co.uk Turnpike v6.05.
            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

            • Chris

              #7
              Re: Inherit Date Class?

              Hi,

              I tried the implementation described above for inheritence, followed
              by:

              var d = ZDate.parse("Ju l 8, 2005");

              but I still get the same error of "ZDate.pars e is not a function"

              I'm sure I'm not understanding things properly (I am going to go and
              watch several hours of video now to try and catch up), but in the
              meantime, can I inherit from the Date prototype (or whatever) such
              that ZDate.parse is actually a function (without explicitly defining
              it)? Is this possible?

              Thanks

              Comment

              • Evertjan.

                #8
                Re: Inherit Date Class?

                Chris wrote on 10 okt 2008 in comp.lang.javas cript:
                I tried the implementation described above for inheritence,
                Above what?

                [please always quote on usenet]
                followed
                by:
                >
                var d = ZDate.parse("Ju l 8, 2005");
                >
                but I still get the same error of "ZDate.pars e is not a function"
                You should use Date, not ZDate.

                Date.parse(date Val)
                Parses a string containing a date, and returns the number of milliseconds
                between that date and midnight, January 1, 1970.

                Try:

                <script type='text/javascript'>

                alert( Date.parse('Jul 8, 2005') )

                </script>



                I'm sure I'm not understanding things properly (I am going to go and
                watch several hours of video now to try and catch up), but in the
                meantime, can I inherit from the Date prototype (or whatever) such
                that ZDate.parse is actually a function (without explicitly defining
                it)? Is this possible?

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

                Comment

                • Dr J R Stockton

                  #9
                  Re: Inherit Date Class?

                  In comp.lang.javas cript message <Xns9B349C91FAF 28eejj99@194.10 9.133.242>
                  , Sat, 11 Oct 2008 13:23:31, Evertjan. <exjxw.hannivoo rt@interxnl.net >
                  posted:
                  >You should use Date, not ZDate.
                  >
                  >Date.parse(dat eVal)
                  >Parses a string containing a date, and returns the number of milliseconds
                  >between that date and midnight, January 1, 1970.
                  >
                  Accurate citation of inaccurate material.

                  (A) Midnight is generally, or at least often, considered as being at the
                  end of the day. Granted, anyone intelligent enough to become a
                  successful programmer will realise that; but many others visit here.

                  (B) Needs GMT, UTC, or ideally UT.

                  Epoch is 1970-01-01T00:00:00Z. I'd have transposed the "arguments" of
                  'between', too.

                  --
                  (c) John Stockton, nr London, UK. ?@merlyn.demon. co.uk Turnpike v6.05.
                  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.

                    #10
                    Re: Inherit Date Class?

                    Dr J R Stockton wrote on 11 okt 2008 in comp.lang.javas cript:
                    In comp.lang.javas cript message
                    <Xns9B349C91FAF 28eejj99@194.10 9.133.242, Sat, 11 Oct 2008 13:23:31,
                    Evertjan. <exjxw.hannivoo rt@interxnl.net posted:
                    >>You should use Date, not ZDate.
                    >>
                    >>Date.parse(da teVal)
                    >>Parses a string containing a date, and returns the number of
                    >>millisecond s between that date and midnight, January 1, 1970.
                    >>
                    >
                    Accurate citation of inaccurate material.
                    It is from the Jscript 5.6 specs by MS.
                    >
                    (A) Midnight is generally, or at least often, considered as being at
                    the end of the day. Granted, anyone intelligent enough to become a
                    successful programmer will realise that; but many others visit here.
                    I would never specify "midnight" of a given date in the first place
                    (B) Needs GMT, UTC, or ideally UT.

                    I would think it gives the miliseconds difference between zero hours
                    local time and 1970-01-01T00:00:00Z

                    However as local time overhere is UTC+2 [CET summertime/DST],

                    The result of:

                    document.write( Date.parse('Jan 1, 1970')+1*60*60* 1000 )

                    being zero amazes me,

                    as I would have expected zero to be the result of

                    document.write( Date.parse('Jan 1, 1970')+2*60*60* 1000+'<br>' )


                    Epoch is 1970-01-01T00:00:00Z. I'd have transposed the "arguments" of
                    'between', too.




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

                    Comment

                    • Dr J R Stockton

                      #11
                      Re: Inherit Date Class?

                      In comp.lang.javas cript message <Xns9B35ED7E51A DBeejj99@194.10 9.133.242>
                      , Sun, 12 Oct 2008 21:20:49, Evertjan. <exjxw.hannivoo rt@interxnl.net >
                      posted:
                      >Dr J R Stockton wrote on 11 okt 2008 in comp.lang.javas cript:
                      >In comp.lang.javas cript message
                      ><Xns9B349C91FA F28eejj99@194.1 09.133.242, Sat, 11 Oct 2008 13:23:31,
                      >Evertjan. <exjxw.hannivoo rt@interxnl.net posted:
                      >>>You should use Date, not ZDate.
                      >>>
                      >>>Date.parse(d ateVal)
                      >>>Parses a string containing a date, and returns the number of
                      >>>millisecon ds between that date and midnight, January 1, 1970.
                      >>>
                      >>
                      >Accurate citation of inaccurate material.
                      >
                      >It is from the Jscript 5.6 specs by MS.
                      A notoriously chronologically-unreliable organisation. Additionally,
                      the string can contain a time and an optional offset.

                      >(A) Midnight is generally, or at least often, considered as being at
                      >the end of the day. Granted, anyone intelligent enough to become a
                      >successful programmer will realise that; but many others visit here.
                      >
                      >I would never specify "midnight" of a given date in the first place
                      The Dutch are wise.

                      >(B) Needs GMT, UTC, or ideally UT.
                      >
                      >
                      >I would think it gives the miliseconds difference between zero hours
                      >local time and 1970-01-01T00:00:00Z
                      Yes.

                      >However as local time overhere is UTC+2 [CET summertime/DST],
                      >
                      >The result of:
                      >
                      >document.write ( Date.parse('Jan 1, 1970')+1*60*60* 1000 )
                      >
                      >being zero amazes me,
                      It may be Summer in the Netherlands at present, but it was Winter on
                      1970/01/01.

                      >as I would have expected zero to be the result of
                      >
                      >document.write ( Date.parse('Jan 1, 1970')+2*60*60* 1000+'<br>' )
                      Ditto.


                      Note that the parsing of date/time strings is ill-defined in ECMA &
                      ISO/IEC : accepting "Zondag 12 oktober 2008" is permissible.

                      Test, with different months, something like
                      Date.parse("200 8/07/15 12:00 ") % 864e5 / 36e5
                      with/without UTC in the string.

                      +new Date(Date.parse (S)) == +new Date(S) // IIRC.

                      --
                      (c) John Stockton, nr London, UK. ?@merlyn.demon. co.uk Turnpike v6.05.
                      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.

                        #12
                        Re: Inherit Date Class?

                        Dr J R Stockton wrote on 13 okt 2008 in comp.lang.javas cript:
                        It may be Summer in the Netherlands at present, but it was Winter on
                        1970/01/01.
                        Thanks, I didn't remember ;-)

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

                        Comment

                        Working...