473,378 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

calender starts on sundays instead of mondays

Hello,

I am using a calender which begins with a sunday, but I would like it
to begin with monday.

The author's mail address isn't working (mail got bounced) so I'm
really hoping anyone here can help me out on this..

This is the code in the HEAD of the HTML document (quite long):

========================

<SCRIPT LANGUAGE="JavaScript">

<!-- Original: Nick Korosi (nf*****@hotmail.com) -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin

var dDate = new Date();
var dCurMonth = dDate.getMonth();
var dCurDayOfMonth = dDate.getDate();
var dCurYear = dDate.getFullYear();
var objPrevElement = new Object();

function fToggleColor(myElement) {
var toggleColor = "#ff0000";
if (myElement.id == "calDateText") {
if (myElement.color == toggleColor) {
myElement.color = "";
} else {
myElement.color = toggleColor;
}
} else if (myElement.id == "calCell") {
for (var i in myElement.children) {
if (myElement.children[i].id == "calDateText") {
if (myElement.children[i].color == toggleColor) {
myElement.children[i].color = "";
} else {
myElement.children[i].color = toggleColor;
}
}
}
}
}

function fSetSelectedDay(myElement){
if (myElement.id == "calCell") {
if (!isNaN(parseInt(myElement.children["calDateText"].innerText))) {
myElement.bgColor = "#c0c0c0";
objPrevElement.bgColor = "";
document.all.calSelectedDate.value =
parseInt(myElement.children["calDateText"].innerText);
objPrevElement = myElement;
parent.content.location.href='comp/' +
document.all.calSelectedDate.value + '-' +
document.all.tbSelMonth.value + '-' +
document.all.tbSelYear.value.substr(2,2) + '.html';
}
}
}
function fGetDaysInMonth(iMonth, iYear) {
var dPrevDate = new Date(iYear, iMonth, 0);
return dPrevDate.getDate();
}
function fBuildCal(iYear, iMonth, iDayStyle) {
var aMonth = new Array();
aMonth[0] = new Array(7);
aMonth[1] = new Array(7);
aMonth[2] = new Array(7);
aMonth[3] = new Array(7);
aMonth[4] = new Array(7);
aMonth[5] = new Array(7);
aMonth[6] = new Array(7);
var dCalDate = new Date(iYear, iMonth-1, 1);
var iDayOfFirst = dCalDate.getDay();
var iDaysInMonth = fGetDaysInMonth(iMonth, iYear);
var iVarDate = 1;
var i, d, w;
if (iDayStyle == 2) {
aMonth[0][0] = "zondag";
aMonth[0][1] = "maandag";
aMonth[0][2] = "dinsdag";
aMonth[0][3] = "woensdag";
aMonth[0][4] = "donderdag";
aMonth[0][5] = "vrijdag";
aMonth[0][6] = "zaterdag";
} else if (iDayStyle == 1) {
aMonth[0][0] = "zon";
aMonth[0][1] = "maa";
aMonth[0][2] = "din";
aMonth[0][3] = "woe";
aMonth[0][4] = "don";
aMonth[0][5] = "vry";
aMonth[0][6] = "zat";
} else {
aMonth[0][0] = "zo";
aMonth[0][1] = "ma";
aMonth[0][2] = "di";
aMonth[0][3] = "wo";
aMonth[0][4] = "do";
aMonth[0][5] = "vr";
aMonth[0][6] = "za";
}
for (d = iDayOfFirst; d < 7; d++) {
aMonth[1][d] = iVarDate;
iVarDate++;
}
for (w = 2; w < 7; w++) {
for (d = 0; d < 7; d++) {
if (iVarDate <= iDaysInMonth) {
aMonth[w][d] = iVarDate;
iVarDate++;
}
}
}
return aMonth;
}
function fDrawCal(iYear, iMonth, iCellWidth, iCellHeight,
sDateTextSize, sDateTextWeight, iDayStyle) {

var myMonth;
myMonth = fBuildCal(iYear, iMonth, iDayStyle);
document.write("<table border='0' cellpadding='1' cellspacing='1'>")
document.write("<tr>");
document.write("<td align='center'><b>" + myMonth[0][0] +
"</b></td>");
document.write("<td align='center'><b>" + myMonth[0][1] +
"</b></td>");
document.write("<td align='center'><b>" + myMonth[0][2] +
"</b></td>");
document.write("<td align='center'><b>" + myMonth[0][3] +
"</b></td>");
document.write("<td align='center'><b>" + myMonth[0][4] +
"</b></td>");
document.write("<td align='center'><b>" + myMonth[0][5] +
"</b></td>");
document.write("<td align='center'><b>" + myMonth[0][6] +
"</b></td>");
document.write("</tr>");
for (w = 1; w < 7; w++) {
document.write("<tr>")
for (d = 0; d < 7; d++) {
document.write("<td align='center' bgcolor='#FFFFFF' valign='top'
id=calCell style='CURSOR:Hand' onMouseOver='fToggleColor(this)'
onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this)>");
if (!isNaN(myMonth[w][d])) {
document.write("<font id=calDateText
onMouseOver='fToggleColor(this)' onMouseOut='fToggleColor(this)'
onclick=fSetSelectedDay(this)>" + myMonth[w][d] + "</font>");
} else {
document.write("<font id=calDateText
onMouseOver='fToggleColor(this)' onMouseOut='fToggleColor(this)'
onclick=fSetSelectedDay(this)> </font>");
}
document.write("</td>")
}
document.write("</tr>");
}
document.write("</table>")
}
function fUpdateCal(iYear, iMonth) {
myMonth = fBuildCal(iYear, iMonth);
objPrevElement.bgColor = "";
document.all.calSelectedDate.value = "";
for (w = 1; w < 7; w++) {
for (d = 0; d < 7; d++) {
if (!isNaN(myMonth[w][d])) {
calDateText[((7*w)+d)-7].innerText = myMonth[w][d];
} else {
calDateText[((7*w)+d)-7].innerText = " ";
}
}
}
}
// End -->

</SCRIPT>

========================

And this is the code used in the BODY of the HTML document :

========================

<script language="JavaScript" for=window event=onload>
<!-- Begin
var dCurDate = new Date();
frmCalendarSample.tbSelMonth.options[dCurDate.getMonth()].selected =
true;
for (i = 0; i < frmCalendarSample.tbSelYear.length; i++)
if (frmCalendarSample.tbSelYear.options[i].value ==
dCurDate.getFullYear())
frmCalendarSample.tbSelYear.options[i].selected = true;
// End -->
</script>

<form name="frmCalendarSample" method="post" action="">
<input type="hidden" name="calSelectedDate" value="">
<table border="1" cellpadding="2" cellspacing="2" width="100%">
<tr bgcolor="#EEEEEE">
<td align="center">
<select style="font-size:9px" name="tbSelMonth"
onchange='fUpdateCal(frmCalendarSample.tbSelYear.v alue,
frmCalendarSample.tbSelMonth.value)'>
<option value="1">januari</option>
<option value="2">februari</option>
<option value="3">maart</option>
<option value="4">april</option>
<option value="5">mei</option>
<option value="6">juni</option>
<option value="7">juli</option>
<option value="8">augustus</option>
<option value="9">september</option>
<option value="10">oktober</option>
<option value="11">november</option>
<option value="12">december</option>
</select>
<select style="font-size:9px" name="tbSelYear"
onchange='fUpdateCal(frmCalendarSample.tbSelYear.v alue,
frmCalendarSample.tbSelMonth.value)'>
<option value="2003">2003</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
</select>
</td>
</tr>
<tr>
<td align="center">
<script language="JavaScript">
var dCurDate = new Date();
fDrawCal(dCurDate.getFullYear(), dCurDate.getMonth()+1, 30, 30,
"10px", "bold", 0);
</script>
</td>
</tr>
</table>
</form>

========================
Thanks!

Best regards,

Tom van den Broek
Jul 23 '05 #1
3 1509
"Tom Meerstad" <tv******@hotmail.com> wrote in message
news:25**************************@posting.google.c om...
Hello,

I am using a calender which begins with a sunday, but I would like it
to begin with monday.

The author's mail address isn't working (mail got bounced) so I'm
really hoping anyone here can help me out on this..


[snip]

Change
var iDayOfFirst = dCalDate.getDay();
to
var iDayOfFirst = dCalDate.getDay()-1;
if (iDayOfFirst < 0) iDayOfFirst = 6;

Change
if (iDayStyle == 2) {
aMonth[0][0] = "zondag";
aMonth[0][1] = "maandag";
aMonth[0][2] = "dinsdag";
aMonth[0][3] = "woensdag";
aMonth[0][4] = "donderdag";
aMonth[0][5] = "vrijdag";
aMonth[0][6] = "zaterdag";
} else if (iDayStyle == 1) {
aMonth[0][0] = "zon";
aMonth[0][1] = "maa";
aMonth[0][2] = "din";
aMonth[0][3] = "woe";
aMonth[0][4] = "don";
aMonth[0][5] = "vry";
aMonth[0][6] = "zat";
} else {
aMonth[0][0] = "zo";
aMonth[0][1] = "ma";
aMonth[0][2] = "di";
aMonth[0][3] = "wo";
aMonth[0][4] = "do";
aMonth[0][5] = "vr";
aMonth[0][6] = "za";
}
to
if (iDayStyle == 2) {
aMonth[0][0] = "maandag";
aMonth[0][1] = "dinsdag";
aMonth[0][2] = "woensdag";
aMonth[0][3] = "donderdag";
aMonth[0][4] = "vrijdag";
aMonth[0][5] = "zaterdag";
aMonth[0][6] = "zondag";
} else if (iDayStyle == 1) {
aMonth[0][0] = "maa";
aMonth[0][1] = "din";
aMonth[0][2] = "woe";
aMonth[0][3] = "don";
aMonth[0][4] = "vry";
aMonth[0][5] = "zat";
aMonth[0][6] = "zon";
} else {
aMonth[0][0] = "ma";
aMonth[0][1] = "di";
aMonth[0][2] = "wo";
aMonth[0][3] = "do";
aMonth[0][4] = "vr";
aMonth[0][5] = "za";
aMonth[0][6] = "zo";
}
Jul 23 '05 #2
On 8 Oct 2004 03:26:46 -0700, in comp.lang.javascript
tv******@hotmail.com (Tom Meerstad) wrote:
| Hello,
|
| I am using a calender which begins with a sunday, but I would like it
| to begin with monday.
|
| The author's mail address isn't working (mail got bounced) so I'm
| really hoping anyone here can help me out on this..


[snip code]

all of the 'magic' happens in the fBuildCal function. You need to make
to following changes:

insert: var pos = new Array(6,0,1,2,3,4,5);
change aMonth array to (notice the ordering):
aMonth[0][6] = "zo";
aMonth[0][0] = "ma";
aMonth[0][1] = "di";
aMonth[0][2] = "wo";
aMonth[0][3] = "do";
aMonth[0][4] = "vr";
aMonth[0][5] = "za";
Change: for (d = iDayOfFirst; d < 7; d++)
to : for (d = pos[iDayOfFirst]; d < 7; d++)

---------------------------------------------------------------
jn****@yourpantsbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
Jul 23 '05 #3
"McKirahan" <Ne**@McKirahan.com> wrote in message news:<71v9d.223253$3l3.35404@attbi_s03>...
"Tom Meerstad" <tv******@hotmail.com> wrote in message
news:25**************************@posting.google.c om...
Hello,

I am using a calender which begins with a sunday, but I would like it
to begin with monday.

The author's mail address isn't working (mail got bounced) so I'm
really hoping anyone here can help me out on this..


[snip]

Change
var iDayOfFirst = dCalDate.getDay();
to
var iDayOfFirst = dCalDate.getDay()-1;
if (iDayOfFirst < 0) iDayOfFirst = 6;


[snip]

This seems to work out! Thanks a million!

Best regards,

Tom
Jul 23 '05 #4

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

Similar topics

9
by: Chris | last post by:
Is there a way to make python create a list of Mondays for a given year? For example, mondays =
1
by: Alicia | last post by:
I basically wanted something that would do a count of the dates, then group them by their week name.. BEFORE: Resource Date Total number of times that date Appeared (Count) 4/3/03 ...
4
by: Chris | last post by:
Hi, I am trying to create a popup calender so a user can click on a button on the main form, a calender will then popup, the user will select a date and then click ok on the popup. The date will...
2
by: David | last post by:
I am trying to get an image to appear on all Mondays within the calendar control. I also want that image to be a link. How can I do this?
5
by: MasterChief | last post by:
I have a imagebutton that when you click on it, it will open up a page containing a calender. When the pages starts up it gives the error Object reference not set to an instance of an object. and...
0
by: Steven Blair | last post by:
Hi, I would like to create a Calender effect like this website: http://www.expedia.co.uk/default.aspx This site uses ASP.NET, so I guess we should be able to use VS 2005 to recreate this. ...
0
by: kalichakradhar | last post by:
hi all, hi, I am developing a application which would open the shared calender of outlook and read the meeting notices and also modifies the meeting notice from Vb.I am successful in opening the...
7
by: gubbachchi | last post by:
Hi all, In my application I need to display the data fetched from mysql database after the user selects date from javascript calender. I have written the code in which after the user selects the...
21
Vkas
by: Vkas | last post by:
i had created my own web calender control!!!! it consist 1} text box (it display's the selected date) 2} button (it hide and show the calender control) 3} calender control (use for the selection...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.