Can Java Script allow me to calculate a future date?

R

rohayre

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?
 
G

Georgi Naumov

(e-mail address 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>
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
 
D

Dr John Stockton

JRS: In article <[email protected]>
, dated Sun, 13 Aug 2006 01:00:36 remote, seen in
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.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated
Sun, 13 Aug 2006 12:55:45 remote, seen in Jim
Davis said:
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.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated
Mon, 14 Aug 2006 01:20:53 remote, seen in Jim
Davis said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top