You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Galbreath <ma...@qat.com> on 2003/01/24 16:16:23 UTC
[OT] Programming Challenge
Anybody know the algorithm for randomly calculating the day of the week,
given a particular date? E.g., July 4, 2006 = Wednesday. I need to do this
in JavaScript and for some reason (too much wine last night?) I can't get
brain engaged.
Mark
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [OT] Programming Challenge
Posted by Gemes Tibor <ti...@i-trade.hu>.
2003. január 24. 16:16 dátummal Mark Galbreath ezt írtad:
> Anybody know the algorithm for randomly calculating the day of the week,
> given a particular date? E.g., July 4, 2006 = Wednesday. I need to do
> this in JavaScript and for some reason (too much wine last night?) I can't
> get brain engaged.
d = new Date('October 02, 2003');
var weekday=new
Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
alert(d.getDay()+ ': ' + weekday(d.getDay() );
Hth,
Tib
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [OT] Programming Challenge
Posted by Andrew Hill <an...@gridnode.com>.
And if you want an underlying algorithm you could check out the source to
Rhino - which probably just uses the java classes - so you could go check
their source, but Im thinking you just want a quick solution....
...what with it being Friday morning and a long tedious day ahead before you
can relax ;-)
-----Original Message-----
From: Andrew Hill [mailto:andrew.david.hill@gridnode.com]
Sent: Friday, 24 January 2003 23:20
To: Struts Users Mailing List
Subject: RE: [OT] Programming Challenge
var bob = new Date(...
var dayOfWeek = bob.getDay(); //what day is it here
var utcDayOfWeek = bob.getUTCDay(); //what day it is in merry old England
right now
returns 0 for Sunday , etc...
-----Original Message-----
From: Mark Galbreath [mailto:mark_galbreath@qat.com]
Sent: Friday, 24 January 2003 23:16
To: struts
Subject: [OT] Programming Challenge
Anybody know the algorithm for randomly calculating the day of the week,
given a particular date? E.g., July 4, 2006 = Wednesday. I need to do this
in JavaScript and for some reason (too much wine last night?) I can't get
brain engaged.
Mark
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [OT] Programming Challenge
Posted by Andrew Hill <an...@gridnode.com>.
var bob = new Date(...
var dayOfWeek = bob.getDay(); //what day is it here
var utcDayOfWeek = bob.getUTCDay(); //what day it is in merry old England
right now
returns 0 for Sunday , etc...
-----Original Message-----
From: Mark Galbreath [mailto:mark_galbreath@qat.com]
Sent: Friday, 24 January 2003 23:16
To: struts
Subject: [OT] Programming Challenge
Anybody know the algorithm for randomly calculating the day of the week,
given a particular date? E.g., July 4, 2006 = Wednesday. I need to do this
in JavaScript and for some reason (too much wine last night?) I can't get
brain engaged.
Mark
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [OT] Programming Challenge
Posted by Mark Galbreath <ma...@qat.com>.
Yeah, I was using http://javascript.internet.com/calendars/ but got tired of
reading source. I deserve this.
-----Original Message-----
From: James Turner [mailto:turner@blackbear.com]
Sent: Friday, January 24, 2003 10:24 AM
Search engines: Know them, use them.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [OT] Programming Challenge
Posted by Andrew Hill <an...@gridnode.com>.
umm....
<snip>
var dayOfWeek = c.getDay();
</snip>
Nope.
Posting it here got him the answer quicker - and without the 50 tons of
nonsense around the one line of interest :-)
...search engines can never compete with struts users who are easily
distracted by [OT] challenges...
-----Original Message-----
From: James Turner [mailto:turner@blackbear.com]
Sent: Friday, 24 January 2003 23:24
To: 'Struts Users Mailing List'
Subject: RE: [OT] Programming Challenge
> From: Mark Galbreath [mailto:mark_galbreath@qat.com]
> Sent: Friday, January 24, 2003 10:16 AM
> To: struts
> Subject: [OT] Programming Challenge
>
>
> Anybody know the algorithm for randomly calculating the day
> of the week, given a particular date? E.g., July 4, 2006 =
> Wednesday. I need to do this in JavaScript and for some
> reason (too much wine last night?) I can't get brain engaged.
>
> Mark
Well, if you want to randomly calculate the day of the week, rand(7)
sounds like a good start :-)
If you'd like to *deterministically* determine the day of the week, try:
http://javascript.internet.com/calculators/day-of-week.html
Search engines: Know them, use them.
James Turner
Owner & Manager, Black Bear Software, LLC
turner@blackbear.com
Author:
MySQL & JSP Web Applications:
Data Driven Programming Using Tomcat and MySQL
ISBN 0672323095; Sams, 2002
Co-Author:
Struts Kick Start
ISBN 0672324725; Sams, 2002
Forthcoming:
JavaServer Faces Kick Start
Sams, Fall 2003
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: [OT] Programming Challenge
Posted by James Turner <tu...@blackbear.com>.
> From: Mark Galbreath [mailto:mark_galbreath@qat.com]
> Sent: Friday, January 24, 2003 10:16 AM
> To: struts
> Subject: [OT] Programming Challenge
>
>
> Anybody know the algorithm for randomly calculating the day
> of the week, given a particular date? E.g., July 4, 2006 =
> Wednesday. I need to do this in JavaScript and for some
> reason (too much wine last night?) I can't get brain engaged.
>
> Mark
Well, if you want to randomly calculate the day of the week, rand(7)
sounds like a good start :-)
If you'd like to *deterministically* determine the day of the week, try:
http://javascript.internet.com/calculators/day-of-week.html
Search engines: Know them, use them.
James Turner
Owner & Manager, Black Bear Software, LLC
turner@blackbear.com
Author:
MySQL & JSP Web Applications:
Data Driven Programming Using Tomcat and MySQL
ISBN 0672323095; Sams, 2002
Co-Author:
Struts Kick Start
ISBN 0672324725; Sams, 2002
Forthcoming:
JavaServer Faces Kick Start
Sams, Fall 2003
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>