Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Can Java Script allow me to calculate a future date?

Reply
Thread Tools

Can Java Script allow me to calculate a future date?

 
 
rohayre@gmail.com
Guest
Posts: n/a
 
      08-13-2006
Im a long time java developer and actually have never done anything
with java scripting. I'd like to write a short simple script for
calculating a date in the future based on today's date and a letter.
Can I use javascripting to create a webpage to allow a user to enter a
letter and then click a button to find a future calendar date? I'm just
not sure how much user interaction scripting allows. Does java
scripting allow buttons, textfields and the ability to put enough
smarts in to calculate a future date?

 
Reply With Quote
 
 
 
 
Georgi Naumov
Guest
Posts: n/a
 
      08-13-2006

http://www.velocityreviews.com/forums/(E-Mail Removed) написа:
> Im a long time java developer and actually have never done anything
> with java scripting. I'd like to write a short simple script for
> calculating a date in the future based on today's date and a letter.

You can make this easily. See the reference for JavaScript Date object.
http://www.w3schools.com/jsref/jsref_obj_date.asp
This is smal example how to add one day to current date:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title></title>
<script type="text/javascript">
var today=new Date();
today.setDate(today.getDate()+1);
document.write("Tomorrow is:"+ today.toLocaleString());
</script>
</head>
<body>
</body>
</html>

> Can I use javascripting to create a webpage to allow a user to enter a
> letter and then click a button to find a future calendar date? I'm just
> not sure how much user interaction scripting allows. Does java
> scripting allow buttons, textfields and the ability to put enough
> smarts in to calculate a future date?

Yes JavaScript is very usefull for this tasks. Tell me your idea and I
will help you with a
pleasure.
Best Regardss

 
Reply With Quote
 
 
 
 
Dr John Stockton
Guest
Posts: n/a
 
      08-13-2006
JRS: In article <(E-Mail Removed) .com>
, dated Sun, 13 Aug 2006 01:00:36 remote, seen in
news:comp.lang.javascript, (E-Mail Removed) posted :
>Im a long time java developer and actually have never done anything
>with java scripting.


There is no space in "Javascript".

> I'd like to write a short simple script for
>calculating a date in the future based on today's date and a letter.
>Can I use javascripting to create a webpage to allow a user to enter a
>letter and then click a button to find a future calendar date?


Yes, and if you had read the newsgroup FAQ ... See sig.

> I'm just
>not sure how much user interaction scripting allows. Does java
>scripting allow buttons, textfields and the ability to put enough
>smarts in to calculate a future date?


See for example <URL:http://www.merlyn.demon.co.uk/js-clndr.htm>.

Javascript goes only up to AD 275760-09-13 with the built-in capability;
but can do up to about AD 3E12 if you code your own.

--
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.
 
Reply With Quote
 
Dr John Stockton
Guest
Posts: n/a
 
      08-13-2006
JRS: In article <(E-Mail Removed)>, dated
Sun, 13 Aug 2006 12:55:45 remote, seen in news:comp.lang.javascript, Jim
Davis <(E-Mail Removed)> posted :
>
>As far as adding to the current date (getting the future date) JavaScript's
>Date object is very rich. There are "set" and "get" methods for all data
>parts and several abstractions.



Actually, there is only one data part, an IEEE Double of milliseconds
from 1970.0 GMT. There are "get" methods for most derivable components
of conventional forms of the UTC/local date/time (but not Week Number,
although ISO 8601 defines it). For most of those, but not all, there is
a "set" method.

--
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.
 
Reply With Quote
 
Dr John Stockton
Guest
Posts: n/a
 
      08-14-2006
JRS: In article <(E-Mail Removed)>, dated
Mon, 14 Aug 2006 01:20:53 remote, seen in news:comp.lang.javascript, Jim
Davis <(E-Mail Removed)> posted :
>"Dr John Stockton" <(E-Mail Removed)> wrote in message
>news(E-Mail Removed)...
>> JRS: In article <(E-Mail Removed)>, dated
>> Sun, 13 Aug 2006 12:55:45 remote, seen in news:comp.lang.javascript, Jim
>> Davis <(E-Mail Removed)> posted :
>>>
>>>As far as adding to the current date (getting the future date)
>>>JavaScript's
>>>Date object is very rich. There are "set" and "get" methods for all data
>>>parts and several abstractions.

>>
>>
>> Actually, there is only one data part, an IEEE Double of milliseconds
>> from 1970.0 GMT. There are "get" methods for most derivable components
>> of conventional forms of the UTC/local date/time (but not Week Number,
>> although ISO 8601 defines it). For most of those, but not all, there is
>> a "set" method.

>
>Sorry - typo. I meant "date part".
>
>Although (since you got me thinking) "data part" is, I think, applicable -
>not physically as in the memory storage of the implementation but rather (as
>you imply) as information derivable from that implementation. It's
>applicable since I was talking about the interface to the Date object rather
>than the implementation.


> ...


There is a test, ISTM : The Date Object is required to behave as if it
stores just an IEEE Double of milliseconds from 1970.0 GMT, limit 10^8
days-worth; but it is neither required to store only that, not to store
exactly that.

Using only UTC functions, set a date from year, month, day and then read
out year, month, day in that order. We know that converting YMD to
milliseconds and milliseconds to YMD are tasks of similar complexity.
If setting YMD and reading Y take similar times but then reading M & D
is much faster, then there must be some sort of cache for M & D and
presumably Y; if each of the four take a similar time, then probably
only milliseconds are stored. That could be browser-dependent.


I've now put the code for function setDay in my js-date8.htm; also a
proposed method for setting the Week. Corresponding setUTC... functions
are then obvious. But function setTimezoneOffset is probably
impossible.

--
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie: allow deny vs deny allow Jeff ASP .Net 2 09-19-2006 02:12 AM
Location element in the Web.config file. Allow System Admin whole directory, allow others specific page Ryan Taylor ASP .Net Security 1 09-09-2004 06:52 PM
Script to calculate remaining minutes hupjack Perl 4 05-05-2004 03:42 PM
Re: How do I calculate the free disk space from within a java program? Miguel De Anda Java 1 04-21-2004 02:13 PM
Calculate Running sum of 4 text boxes on client side script? Davisro ASP .Net 2 04-20-2004 08:18 PM



Advertisments