472,371 Members | 1,482 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

change month/date

I have a script for my church that we use for the weekly events. I
currently have it as week of Feb 1, 2003 at the top, then list Sun -
Sat below the date. I have been asked to put the date next to each
day of the week.

I want to have the Month and Day after the day of the week. My
problem is during transition weeks, from one month to the next, that I
cannot figure out how to have it know to start over with day 1 on the
next month.
my files/scripts are -

caltext.html
---------------------------
<table bgcolor="eeeeff" width="200" border="0">
<tr><td colspan="2">
<script language="JavaScript" src="weekchoose.js">
</script></td></tr>
<script language="JavaScript" src="week.js"></script>
<tr><td colspan="2"><a href="cal.html">
Next week &gt;&gt;</a></td></tr>
</table>
weekchoose.js
---------------------------

var kw=new Array();
kw[2]=new Array("2004/2/1","2004/2/7","1");
kw[1]=new Array("2004/2/8","2004/2/14","2");
kw[0]=new Array("2004/2/15","2004/2/21","3");

var today = new Date();
var ct = 0;
var dayarray=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
var montharray=new
Array("Jan","Feb","Mar","Apr","May","Jun","Jul","A ug","Sep","Oct","Nov
","Dec")
for (var i=kw.length-1;i>=0;i--)
{
var date = new Date(kw[i][1])
var date2 = new Date(kw[i][0])

var year = 1900 + date.getYear()%1900 // < AD 3800
var year2 = 1900 + date2.getYear()%1900 // < AD 3800

if (ct < 1) {
if (today.getTime() <= date.getTime()) {
ct = ct + 1
document.write('<center>Church Events for the Week of<br>'+
'<b>' + dayarray[date2.getDay()]+', '+
montharray[date2.getMonth()]+' '+date2.getDate()+',
'+year+'</b></center>');

document.write('<script language=JavaScript src=week/'
+ kw[i][2] + '.js></script>');

}
var ds = date2
}
}


week.js
---------------------------

document.write('<tr><td colspan="2"><b>Sunday</b></td></tr>'+
'<tr><td>&nbsp;</td><td>'+sun+'</td></tr>');

document.write('<tr><td colspan="2"><b>Monday</b></td></tr>'+
'<tr><td>&nbsp;</td><td>'+mon+'</td></tr>');

document.write('<tr><td colspan="2"><b>Tuesday</b></td></tr>'+
'<tr><td>&nbsp;</td><td>'+tue+'</td></tr>');

document.write('<tr><td colspan="2"><b>Wednesday</b></td></tr>'+
'<tr><td>&nbsp;</td><td>'+wed+'</td></tr>');

document.write('<tr><td colspan="2"><b>Thursday</b></td></tr>'+
'<tr><td>&nbsp;</td><td>'+thu+'</td></tr>');

document.write('<tr><td colspan="2"><b>Friday</b></td></tr>'+
'<tr><td>&nbsp;</td><td>'+fri+'</td></tr>');

document.write('<tr><td colspan="2"><b>Saturday</b></td></tr>'+
'<tr><td>&nbsp;</td><td>'+sat+'</td></tr>');

Jul 20 '05 #1
4 1892
I forgot the number js files
1.js (or 2,3,4, or 5)
---------------------------

var sun = "8:30 am Worship Service<br>"+
"11:00 am Worship Service";

var mon = "";

var tue = "6:00 am Elder Meeting";

var wed = "6:55 pm AWANA";

var thu = "8:00 pm College Bible Study";

var fri = "9:00 pm College 939";

var sat = "";
Jul 20 '05 #2
JRS: In article <bv*************@ID-221536.news.uni-berlin.de>, seen in
news:comp.lang.javascript, Treetop <tr*****@netfront.net> posted at Thu,
5 Feb 2004 16:20:24 :-

I want to have the Month and Day after the day of the week. My
problem is during transition weeks, from one month to the next, that I
cannot figure out how to have it know to start over with day 1 on the
next month.


ISTM that you did not read the FAQ carefully enough; see below.

See <URL:http://www.merlyn.demon.co.uk/js-date4.htm#MaYL> for
determining month length; then at the end of each day something like

if (++DayNo > MonLen) { DayNo = 1
if (++MonNo > 12) { MonNo = 1 ; ++YearNo }
MonLen = MonthLength(YearNo, MonNo) )

Alternatively, just increment a Date Object
<URL:http://www.merlyn.demon.co.uk/js-date2.htm#incr>
and output the desired fields
<URL:http://www.merlyn.demon.co.uk/js-date9.htm>.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for 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.
Jul 20 '05 #3

"Dr John Stockton" <sp**@merlyn.demon.co.uk> wrote in message
news:3l**************@merlyn.demon.co.uk...
JRS: In article <bv*************@ID-221536.news.uni-berlin.de>, seen in news:comp.lang.javascript, Treetop <tr*****@netfront.net> posted at Thu, 5 Feb 2004 16:20:24 :-

I want to have the Month and Day after the day of the week. My
problem is during transition weeks, from one month to the next, that Icannot figure out how to have it know to start over with day 1 on thenext month.


ISTM that you did not read the FAQ carefully enough; see below.

See <URL:http://www.merlyn.demon.co.uk/js-date4.htm#MaYL> for
determining month length; then at the end of each day something like

if (++DayNo > MonLen) { DayNo = 1
if (++MonNo > 12) { MonNo = 1 ; ++YearNo }
MonLen = MonthLength(YearNo, MonNo) )

Alternatively, just increment a Date Object
<URL:http://www.merlyn.demon.co.uk/js-date2.htm#incr>
and output the desired fields
<URL:http://www.merlyn.demon.co.uk/js-date9.htm>.


I did look at the FAQ, but I was not able to figure it out, I am
affraid. What I did, and it works, is the following:

// ds is the date for a Sunday, which I already had

var dm = new Date(ds.getTime() + (1 * 86400000));
var dt = new Date(ds.getTime() + (2 * 86400000));
var dw = new Date(ds.getTime() + (3 * 86400000));
var dh = new Date(ds.getTime() + (4 * 86400000));
var df = new Date(ds.getTime() + (5 * 86400000));
var da = new Date(ds.getTime() + (6 * 86400000));

document.write('<tr><td colspan="2"><b>Sunday, '+
montharray[ds.getMonth()]+' '+ds.getDate()+'</b></td></tr>'+
'<tr><td>&nbsp;</td><td>'+sun+'</td></tr>');

document.write('<tr><td colspan="2"><b>Monday, '+
montharray[dm.getMonth()]+' '+dm.getDate()+'</b></td></tr>'+
<tr><td>&nbsp;</td><td>'+mon+'</td></tr>');

and so on for the rest of the week

Jul 20 '05 #4
JRS: In article <43******************************@news.teranews.co m>,
seen in news:comp.lang.javascript, Treetop <tr*****@netfront.net> posted
at Fri, 6 Feb 2004 17:40:14 :-

I did look at the FAQ, but I was not able to figure it out, I am
affraid. What I did, and it works, is the following:

// ds is the date for a Sunday, which I already had

var dm = new Date(ds.getTime() + (1 * 86400000));


That means that you have not understood the advice given, and have not
tested for users in NA or EU for a week starting with the last Sunday in
October.

Actually, that could be another reason for preferring ISO-8601 week
numbering, with a week being Mon=1..Sun=7, in the same way that it would
be better to start year numbering in March (which also makes October the
8th month, as it should be etymologically).

AISB, <URL:http://www.merlyn.demon.co.uk/js-date2.htm#incr>;
and <URL:http://www.merlyn.demon.co.uk/uksumtim.htm>.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
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.
Jul 20 '05 #5

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

Similar topics

2
by: Tjerk | last post by:
Hello all, I have the script below to change an image depending on the date upto january it worked fine but then it just stopped working does anybody have an idea how I can make it work again or...
6
by: Hasanain F. Esmail | last post by:
Hi all, I sincerly thank you all in advance for your help to solve this problem. I have been trying to find a solution to this problem for sometime now but have failed. I am working on a...
6
by: Ante Perkovic | last post by:
Hi, How to declare datetime object and set it to my birthday, first or last day of this month or any other date. I can't find any examples in VS.NET help! BTW, what is the difference...
0
by: larry | last post by:
I am in the process of rewriting one of my first PHP scripts, an event calendar, and wanted to share the code that is the core of the new calendar. My current/previous calendar processed data...
7
by: ajaydesai | last post by:
I have JavaScript code to dispaly two month calendar days at a time, but i have a problem both month that disaplay at a time have same days (for example May and June has same days, June and July have...
11
by: Randy | last post by:
I have a MonthCalendar on one of my forms. I have disovered that the DateChanged event is triggered not only when the user clicks on a new date, but also if they click on the Previous or Next...
0
by: marlberg | last post by:
Platform: Windows2000, WindowsXP, Windows Vista, etc Language: C#, ASP.NET Pre-compiled Libraries: Enterprise Library 3.0 full I have a requirement to implement in and display in C# and...
2
by: nspader | last post by:
Hello All, I have a DB that shows information generated on a form setup to look like a calendar. I am working with Windows 2000 and Access 2000. Public Sub PutInData() On Error GoTo...
2
by: sreemati | last post by:
Hi One of the web form has 3 dates fields: Date of form entry, date of diagnosis and date of death. Date of form entry has future date validation done which I thought of extending to the...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

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.