473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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.getMonthDays, 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("Jul 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
Oct 9 '08 #1
11 2683
Hi Chris
You will find tutorials and blog articles on what you need at
http://developer.yahoo.com/yui/theater/
Peter
"Chris" <ch********************@googlemail.comwrote in message
news:2a**********************************@d1g2000h sg.googlegroups.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.getMonthDays, 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("Jul 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
Oct 9 '08 #2
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" <ch********************@googlemail.comwrote in message
news:2a**********************************@d1g2000h sg.googlegroups.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.getMonthDays, 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("Jul 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
Oct 9 '08 #3
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).
Oct 9 '08 #4
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
Oct 9 '08 #5
In comp.lang.javascript message <2aad5f4d-8f31-4f8f-b4a6-22f9ab07379c@d1
g2000hsg.googlegroups.com>, Wed, 8 Oct 2008 21:34:18, Chris <christopher
..jo********@googlemail.composted:
>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.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Oct 9 '08 #6
Hi,

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

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

but I still get the same error of "ZDate.parse 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
Oct 10 '08 #7
Chris wrote on 10 okt 2008 in comp.lang.javascript:
I tried the implementation described above for inheritence,
Above what?

[please always quote on usenet]
followed
by:

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

but I still get the same error of "ZDate.parse is not a function"
You should use Date, not ZDate.

Date.parse(dateVal)
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)
Oct 11 '08 #8
In comp.lang.javascript message <Xn********************@194.109.133.242>
, Sat, 11 Oct 2008 13:23:31, Evertjan. <ex**************@interxnl.net>
posted:
>You should use Date, not ZDate.

Date.parse(dateVal)
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.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Oct 11 '08 #9
Dr J R Stockton wrote on 11 okt 2008 in comp.lang.javascript:
In comp.lang.javascript message
<Xn********************@194.109.133.242, Sat, 11 Oct 2008 13:23:31,
Evertjan. <ex**************@interxnl.netposted:
>>You should use Date, not ZDate.

Date.parse(dateVal)
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.
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)
Oct 12 '08 #10
In comp.lang.javascript message <Xn********************@194.109.133.242>
, Sun, 12 Oct 2008 21:20:49, Evertjan. <ex**************@interxnl.net>
posted:
>Dr J R Stockton wrote on 11 okt 2008 in comp.lang.javascript:
>In comp.lang.javascript message
<Xn********************@194.109.133.242, Sat, 11 Oct 2008 13:23:31,
Evertjan. <ex**************@interxnl.netposted:
>>>You should use Date, not ZDate.

Date.parse(dateVal)
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.

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("2008/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.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Oct 13 '08 #11
Dr J R Stockton wrote on 13 okt 2008 in comp.lang.javascript:
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)
Oct 13 '08 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: nikolai.onken | last post by:
Hello, I got following problem trying to inherit a variable from another class class Core { public $obj; function initialize($obj) {
7
by: bobsled | last post by:
For class A to reuse functionality of a class B, A could either contains B or inherits from B. When should pick which? In a book the author says that "Don't inherit from a concrete class." Does...
4
by: Slavyan | last post by:
(I just started to learn C#.NET) What's the syntax in c# for a class to inherit more than one class. I know following syntax: public class MyClass : MyOtherClass { } but I need to inherit...
3
by: Boaz Ben-Porat | last post by:
I Know, ... a struct can not be inherited. ** Is there any tricky way to extend a struct ? ** I have to implement a component that represent a date (without time) that has a small number of...
9
by: Razzie | last post by:
Hey all, When should or should you not inherit from the IDisposable interface for your custom classes? Say I have a custom class SomeClass that does... some stuff. If I create a new instance...
44
by: Frank Rizzo | last post by:
Any ideas?
7
by: Frank | last post by:
Hi, a question probably asked before, but I can't find the answers. Base class X, classes A, B and C inherit class X. In class A I do not want to inherit property (or function or method) P1....
3
by: J | last post by:
I tried to inherit 'Shot' class from 'Image' class, only to fail. It gives me the CS0122 error, which says that it can't access 'System.Drawing.Image.Image()'. What am I missing? using...
2
by: Joe | last post by:
Is it possible to inherit from a UserControl? If I try my user control class is not recognized. Thanks, Joe
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.