Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #18965 > unrolled thread

how to use MakeTime()?

Started byJim Michaels <jmichae3@yahoo.com>
First post2013-03-21 18:36 -0700
Last post2013-03-24 18:36 +0000
Articles 7 — 4 participants

Back to article view | Back to comp.lang.javascript


Contents

  how to use MakeTime()? Jim Michaels <jmichae3@yahoo.com> - 2013-03-21 18:36 -0700
    Re: how to use MakeTime()? Scott Sauyet <scott.sauyet@gmail.com> - 2013-03-21 21:04 -0700
      Re: how to use MakeTime()? Jim Michaels <jmichae3@yahoo.com> - 2013-03-22 00:21 -0700
      Re: how to use MakeTime()? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-22 16:44 +0100
        Re: how to use MakeTime()? Scott Sauyet <scott.sauyet@gmail.com> - 2013-03-22 18:58 -0700
    Re: how to use MakeTime()? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-22 16:30 +0100
    Re: how to use MakeTime()? Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-03-24 18:36 +0000

#18965 — how to use MakeTime()?

FromJim Michaels <jmichae3@yahoo.com>
Date2013-03-21 18:36 -0700
Subjecthow to use MakeTime()?
Message-ID<35b1cc53-fb63-46e9-8f4d-b9880c86fdc3@googlegroups.com>
I am trying to use MakeTIme(), MakeDay(), and MakeDate().
for a time zone offset, I am using 
	var tztc = MakeTime(parseInt(tza[0]), parseInt(tza[1]), 0, 0);//GMT-8 or UTC-8
	var day = MakeDay(time.getUTCFullYear(), time.getUTCMonth() + 1, time.getUTCDate());
	var timeWithTZ = MakeTime(time.getUTCHours(), time.getUTCMinutes(), time.getUTCSeconds(), time.getUTCMilliseconds())  + tztc;
	var tc = TimeClip( MakeDate(day, timeWithTZ) );
	var dt = new Date(tc);

but this is causing the debugger error "MakeTime is not defined". I see this operator in older books. so it's very probable (?) that the browser supports it, but if so, how? it's related to the Date object.
I tried 

var tztc = Date.MakeTime(parseInt(tza[0]), parseInt(tza[1]), 0, 0);//GMT-8 or UTC-8

and I tried 
var d=new Date();
var tztc = d.MakeTime(parseInt(tza[0]), parseInt(tza[1]), 0, 0);//GMT-8 or UTC-8

[toc] | [next] | [standalone]


#18967

FromScott Sauyet <scott.sauyet@gmail.com>
Date2013-03-21 21:04 -0700
Message-ID<ca7b99dc-1ef7-442f-9332-f298c6c4d22e@5g2000yqz.googlegroups.com>
In reply to#18965
Jim Michaels wrote:
> I am trying to use MakeTIme(), MakeDay(), and MakeDate().
> for a time zone offset, I am using
>     var tztc = MakeTime(parseInt(tza[0]), parseInt(tza[1]), 0, 0);//GMT-8 or UTC-8
>     var day = MakeDay(time.getUTCFullYear(), time.getUTCMonth() + 1, time.getUTCDate());
>     [ ... ]
> but this is causing the debugger error "MakeTime is not defined".
> I see  this operator in older books. so it's very probable (?)
> that the browser supports it, but if so, how? it's related to the
> Date object. [ ... ]

First off, the quality of Javascript books is notoriously poor,
especially that of older books.

But the error message is pretty clear:  That function is not defined.
It's also not a property of the Date constructor function.  In fact,
it's not built into any Javascript environment I know of.

Perhaps your book defines this function earlier?

In any case, if you want to use a function such as this, you'll have
to include it in the environment yourself.

Best of luck,

  -- Scott

[toc] | [prev] | [next] | [standalone]


#18968

FromJim Michaels <jmichae3@yahoo.com>
Date2013-03-22 00:21 -0700
Message-ID<b99e7eeb-faea-4314-a05e-cc108618b481@googlegroups.com>
In reply to#18967
On Thursday, March 21, 2013 9:04:31 PM UTC-7, Scott Sauyet wrote:
> Jim Michaels wrote:
> 
> > I am trying to use MakeTIme(), MakeDay(), and MakeDate().
> 
> > for a time zone offset, I am using
> 
> >     var tztc = MakeTime(parseInt(tza[0]), parseInt(tza[1]), 0, 0);//GMT-8 or UTC-8
> 
> >     var day = MakeDay(time.getUTCFullYear(), time.getUTCMonth() + 1, time.getUTCDate());
> 
> >     [ ... ]
> 
> > but this is causing the debugger error "MakeTime is not defined".
> 
> > I see  this operator in older books. so it's very probable (?)
> 
> > that the browser supports it, but if so, how? it's related to the
> 
> > Date object. [ ... ]
> 
> 
> 
> First off, the quality of Javascript books is notoriously poor,
> 
> especially that of older books.
> 
> 
> 
> But the error message is pretty clear:  That function is not defined.
> 
> It's also not a property of the Date constructor function.  In fact,
> 
> it's not built into any Javascript environment I know of.
> 
> 
> 
> Perhaps your book defines this function earlier?
> 
> 
> 
> In any case, if you want to use a function such as this, you'll have
> 
> to include it in the environment yourself.
> 
> 
> 
> Best of luck,
> 
> 
> 
>   -- Scott

I was looking both at the ecmascript 262 5.1 language reference (latest edition) and I tried also looking at some older books I had. there are a few places on the google groups which show some code which lists similar usage to what I have, but the function doesn't seem towork in chrome,opera,ie8,ff.references to these functions are very few and far between: TimeClip(), MakeTime(), MakeDay() MakeDate() operators. (odd thatthey are operators, but I read that they are supposed to operate like functions).
maybe they just aren't implemented yet?
or,I just plain don't know how to access these ops, which very well could be the case, I am just guessing as to how to use them.

[toc] | [prev] | [next] | [standalone]


#18973

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-03-22 16:44 +0100
Message-ID<1768477.VDQZ9sSgU4@PointedEars.de>
In reply to#18967
Scott Sauyet wrote:

> Jim Michaels wrote:
>> I am trying to use MakeTIme(), MakeDay(), and MakeDate().
>> for a time zone offset, I am using
>> var tztc = MakeTime(parseInt(tza[0]), parseInt(tza[1]), 0, 0);//GMT-8 or
>> UTC-8 var day = MakeDay(time.getUTCFullYear(), time.getUTCMonth() + 1,
>> time.getUTCDate());
>>     [ ... ]
>> but this is causing the debugger error "MakeTime is not defined".
>> I see  this operator in older books. so it's very probable (?)
>> that the browser supports it, but if so, how? it's related to the
>> Date object. [ ... ]
> 
> First off, the quality of Javascript books is notoriously poor,
> especially that of older books.

A considerable part of that poor quality is due to the fact that the author 
is describing a programming language that simply does not exist.  In my 
experience any text that contains the word “Javascript” or even “javascript” 
(sic!) can only be of substandard quality, as its (original) author 
evidently has (had) no clue what they are talking about.  Texts containing 
the “JavaScript” string, but in wrong context, such as “JavaScript 
standard”, are only a little bit better.

<http://PointedEars.de/es-matrix>

> But the error message is pretty clear:  That function is not defined.
> It's also not a property of the Date constructor function.

There is no good reason to believe that the latter would be relevant.  If it 
were the case, the code above could only work if “Date” was in the scope 
chain, meaning “with”.

> In fact, it's not built into any Javascript environment I know of.
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
QED.

> Perhaps your book defines this function earlier?

Unlikely, unless it is a rip of the Specification.

> In any case, if you want to use a function such as this, you'll have
> to include it in the environment yourself.

Probably he does not want to, though.

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#18975

FromScott Sauyet <scott.sauyet@gmail.com>
Date2013-03-22 18:58 -0700
Message-ID<5e834e01-810c-4aec-8045-da7b290b7190@f5g2000yqp.googlegroups.com>
In reply to#18973
Thomas 'PointedEars' Lahn wrote:
> Scott Sauyet wrote:
>> Jim Michaels wrote:
>>> I am trying to use MakeTIme(), MakeDay(), and MakeDate().
>>> for a time zone offset, I am using
>>> var tztc = MakeTime(parseInt(tza[0]), parseInt(tza[1]), 0, 0);//GMT-8 or
>>> UTC-8 var day = MakeDay(time.getUTCFullYear(), time.getUTCMonth() + 1,
>>> time.getUTCDate());
>>>     [ ... ]
>>> but this is causing the debugger error "MakeTime is not defined".
>>> I see  this operator in older books. so it's very probable (?)
>>> that the browser supports it, but if so, how? it's related to the
>>> Date object. [ ... ]
>
>> First off, the quality of Javascript books is notoriously poor,
>> especially that of older books.
>
> A considerable part of that poor quality is due to the fact that the author
> is describing a programming language that simply does not exist.  In my
> experience any text that contains the word “Javascript” or even “javascript”
> (sic!) can only be of substandard quality, as its (original) author
> evidently has (had) no clue what they are talking about.  Texts containing
> the “JavaScript” string, but in wrong context, such as “JavaScript
> standard”, are only a little bit better.

NAK.  Herman's _Effective Javascript_ is the best book I've read on
this language (or, if you insist, on this collection of closely
related languages) at least since Flanagan's most recent _Definitive
Guide_, and maybe ever.  Both are IMHO excellent books, and while both
recognize the distinction you draw, both also find the common usage
clear and unambiguous enough to use almost everywhere.  I certainly
know that you disagree, but I'm not convinced, and I plan on
continuing to use "Javascript" rather than some awkward circumlocution
to describe the language in which I spend most of my work time coding.



>> But the error message is pretty clear:  That function is not defined.
>> It's also not a property of the Date constructor function.
>
> There is no good reason to believe that the latter would be relevant.  If it
> were the case, the code above could only work if “Date” was in the scope
> chain, meaning “with”.

Sorry, I obviously trimmed too much.  I often err in that direction,
trying to ensure I don't quote more than the relevant minimum.  The OP
went on to say (slightly reformatted and trimmed):

| I tried
|     var tztc = Date.MakeTime(parseInt(tza[0]), parseInt(tza[1]), 0,
0);
| and I tried
|     var d=new Date();
|     var tztc = d.MakeTime(parseInt(tza[0]), parseInt(tza[1]), 0, 0);

... which explains the relevance.

>
>> In fact, it's not built into any Javascript environment I know of.
>                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> QED.

I'm not sure if you really believe it would have been clearer had I
instead said:

| In fact, it's not built into any implementation of any version of
| the ECMAScript standard I know of.

or if you just enjoy pedantry, but I believe the original communicates
my meaning quite clearly to other readers of comp.lang.javascript.  I
feel absolutely no need to use anything like the latter.  Do you have
a suggested phrasing that would still easily communicate with others
but would offend you less?


>> Perhaps your book defines this function earlier?
>
> Unlikely, unless it is a rip of the Specification.

Possibly it's a simple misunderstanding on the OP's part about what
these operators are, but the samples look to me more as though they
were copied from someone's implementation of a date/time library.  I
haven't personally run across books describing these operators, but I
have seen libraries that try to follow the specs to whatever degree
they can.  If one of those libraries were included in a book, the OP's
post would make a fair bit of sense.

>> In any case, if you want to use a function such as this, you'll have
>> to include it in the environment yourself.
>
> Probably he does not want to, though.

ACK.

  -- Scott

[toc] | [prev] | [next] | [standalone]


#18972

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-03-22 16:30 +0100
Message-ID<14217435.zA5glZemQV@PointedEars.de>
In reply to#18965
Jim Michaels wrote:

> I am trying to use MakeTIme(), MakeDay(), and MakeDate().
> for a time zone offset, I am using
> var tztc = MakeTime(parseInt(tza[0]), parseInt(tza[1]), 0, 0);//GMT-8 or
> UTC-8 var day = MakeDay(time.getUTCFullYear(), time.getUTCMonth() + 1,
> time.getUTCDate());
> var timeWithTZ = MakeTime(time.getUTCHours(), time.getUTCMinutes(),
> time.getUTCSeconds(), time.getUTCMilliseconds())  + tztc; var tc =
> TimeClip( MakeDate(day, timeWithTZ) ); var dt = new Date(tc);
> 
> but this is causing the debugger error "MakeTime is not defined". I see
> this operator in older books.

Most books on this topic are bad, however you might have misunderstood.  
MakeTime() is an *Abstract* Operator.  It is the name of a *Specification 
algorithm* used for computing the time value of Date instances, which in 
turn is used by other date-related algorithms.

> so it's very probable (?) that the browser supports it,

No, it is entirely impossible that “the browser” (which one) supports it, 
unless someone has implemented the Specification algorithm as a public 
method, and either made it part of their ECMAScript implementation or loaded 
it from a file.

> but if so, how? it's related to the Date object.

Read the ECMAScript Language Specification (again, more carefully this 
time).  The current Edition is 5.1, and MakeTime() is specified in its 
subsection 15.9.1.11.  The corresponding section starts with:

| 15.9.1 Overview of Date Objects and Definitions of Abstract Operators
| 
| The following functions are abstract operations that operate on time
                              ^^^^^^^^^^^^^^^^^^^
| values (defined in 15.9.1.1). Note that, in every case, if any argument to
| one of these functions is NaN, the result will be NaN.

So, what are you really up to?

And please do not post to Usenet using Google Groups.  See also my 
signature.

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#18989

FromDr J R Stockton <reply1300@merlyn.demon.co.uk.invalid>
Date2013-03-24 18:36 +0000
Message-ID<C0SmmiE3e0TRFwlm@invalid.uk.co.demon.merlyn.invalid>
In reply to#18965
In comp.lang.javascript message <35b1cc53-fb63-46e9-8f4d-b9880c86fdc3@go
oglegroups.com>, Thu, 21 Mar 2013 18:36:42, Jim Michaels
<jmichae3@yahoo.com> posted:

>I am trying to use MakeTIme(), MakeDay(), and MakeDate().
>for a time zone offset, I am using
>       var tztc = MakeTime(parseInt(tza[0]), parseInt(tza[1]), 0, 0);//GMT-8 or UTC-8
>       var day = MakeDay(time.getUTCFullYear(), time.getUTCMonth() + 1, time.getUTCDate());
>       var timeWithTZ = MakeTime(time.getUTCHours(), time.getUTCMinutes(), time.getUTCSeconds(), time.getUTCMilliseconds())  + tztc;
>       var tc = TimeClip( MakeDate(day, timeWithTZ) );
>       var dt = new Date(tc);
>
>but this is causing the debugger error "MakeTime is not defined". I see this operator in older books. so it's very probable (?) that the
>browser supports it, but if so, how? it's related to the Date object.
>I tried
>
>var tztc = Date.MakeTime(parseInt(tza[0]), parseInt(tza[1]), 0, 0);//GMT-8 or UTC-8
>
>and I tried
>var d=new Date();
>var tztc = d.MakeTime(parseInt(tza[0]), parseInt(tza[1]), 0, 0);//GMT-8 or UTC-8


Those routines are specified by ECMA 262 for use "within" a Date Object,
and are not specified to be exposed by an Object; therefore, they should
not be exposed.  AIUI, a Date Object is not actually required to use
them, but is required to give the effect of using them internally.

Once one realises that, it is easy to see in ECMA 262 which routines are
to be "visible" Properties and which are for internal and/or explanatory
use only.

But the description of the internal routines should be sufficient to let
you write your own versions; I suggest the use of similar but different
names, such as JMmaketime for MakeTime.

-- 
 (c) John Stockton, nr London, UK.   E-mail, see Home Page.    Turnpike v6.05.
 Website  <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
 PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
 Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web