主题:  看看这个日历

雅痞公子

职务:普通成员
等级:3
金币:-3.0
发贴:732
注册:2003/3/27 23:16:34
#12003/11/17 23:30:39
出了个大错误,改一下:
<cfparam name="URL.year" default="#DatePart('YYYY',Now())#" type="date">
<cfparam name="URL.month" default="#DatePart('M',Now())#" type="date">
<cfparam name="startYear" default="#DatePart('YYYY',Now())#">
<cfparam name="startMonth" default="#DatePart('M',Now())#">
<cfparam name="day" default="#DatePart('D',Now())#">
<cfset thisDate=CreateDate(URL.year,URL.month,1)>
<cfset thisMonthDays=DaysInMonth(thisDate)>
<cfset nextYearMonth=DateAdd('M',1,thisDate)>
<cfset nextYear=DatePart('YYYY',nextYearMonth)>
<cfset nextMonth=DatePart('M',nextYearMonth)>
<cfset backYearMonth=DateAdd('M',-1,thisDate)>
<cfset backYear=DatePart('YYYY',backYearMonth)>
<cfset backMonth=DatePart('M',backYearMonth)>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Calendar</title>
<style>
A{color:#999999;}
A:hover{color:#000000;}
</style>
</head>

<body>
<table width="150" border="0" cellpadding="0" cellspacing="1">
<tr bgcolor="#FFFFFF" style="text-align:center;font-size:10.5pt;">
<cfoutput>
<td>
<a href="#CGI.SCRIPT_NAME#?year=#backYear#&month=#backMonth#">&lt;&lt;</a>
&nbsp;&nbsp;#URL.year#-#URL.month#&nbsp;&nbsp;
<cfif ((URL.year LTE startYear) AND (URL.month LT startMonth)) OR (URL.year LT startYear)>
<a href="#CGI.SCRIPT_NAME#?year=#nextYear#&month=#nextMonth#">&gt;&gt;</a>
<cfelse>
&gt;&gt;
</cfif>
</td>
</cfoutput>
</tr>
<tr bgcolor="#ffffff">
<td>
<table width="100%" border="0" cellpadding="2" cellspacing="1" id="day">
<tr style="font-size:10pt;color:#ffffff;text-align:center;" bgcolor="#8499A4">
<cfloop from="1" to="7" index="i">
<cfoutput>
<td width="48">#Right(DayOfWeekAsString(DayOfWeek(i)),1)#</td>
</cfoutput>
</cfloop>
</tr>
    <cfset thisDay=0>
    <cfloop condition="thisDay LTE thisMonthDays">
    <tr bgcolor="#f4f4f4" style="text-align:center;font-size:10pt;color:#666666;">
    <cfloop from="1" to="7" index="i">
    <cfif thisDay IS 0>
     <cfif DayOfWeek(thisDate) IS i>
     <cfset thisDay=1>
     </cfif>
    </cfif>
    <cfif (thisDay NEQ 0) AND (thisDay LTE thisMonthDays)>
     <cfoutput>
     <cfif (thisDay IS day) AND (URL.year IS startYear) AND (URL.month IS startMonth)>
     <td style="color:##000099;">#thisDay#</td>
     <cfelse>
     <td>#thisDay#</td>
     </cfif>
     </cfoutput>
     <cfset thisDay=thisDay+1>
    <cfelse>
    <td></td>
    </cfif>
    </cfloop>
    </tr>
    </cfloop>
</table>
</td>
</tr>
</table>
</body>
</html>



7yue_5d

职务:普通成员
等级:1
金币:0.0
发贴:32
注册:2003/4/1 13:24:33
#22003/11/18 16:40:55
看看我的:
import java.util.*;

/**
*

Title: J2se Register Project


*

Description: Created by Zerlot.ma


*

Copyright: Copyright www.7yue.com (c) 2003


*

Company: 7yue.com


* @author Zerlot
* @version 1.0
*/

public class TodayDate {
public static void main(String[] args){
GregorianCalendar d=new GregorianCalendar();
int today=d.get(Calendar.DAY_OF_MONTH);
int month=d.get(Calendar.MONTH);
System.out.println(month);
d.set(Calendar.DAY_OF_MONTH,1);
int weekday=d.get(Calendar.DAY_OF_WEEK);
System.out.println("Sun Mon Tue Wed Thu Fri Sat");
//indent first line of calendar
for(int i=Calendar.SUNDAY;i System.out.print(" ");
do{
//print the day
int day=d.get(Calendar.DAY_OF_MONTH);
if (day<10)
System.out.print(" ");
System.out.print(day);
//mark current day with *
if (day==today)
System.out.print("* ");
else
System.out.print(" ");
if (weekday==Calendar.SATURDAY)
System.out.println();
//advanced d to next day
d.add(Calendar.DAY_OF_MONTH,1);
weekday=d.get(Calendar.DAY_OF_WEEK);
}
while (d.get(Calendar.MONTH)==month);
if (weekday!=Calendar.SUNDAY)
System.out.println();
}
}



雅痞公子

职务:普通成员
等级:3
金币:-3.0
发贴:732
注册:2003/3/27 23:16:34
#32003/11/20 14:46:55
javascript不是在这里讨论吧



雅痞公子

职务:普通成员
等级:3
金币:-3.0
发贴:732
注册:2003/3/27 23:16:34
#42003/11/20 14:55:08
强,这是什么代吗??



7yue_5d

职务:普通成员
等级:1
金币:0.0
发贴:32
注册:2003/4/1 13:24:33
#52003/11/20 17:30:16
J2se的,瞎写着玩的,别在意。
在jdk下面编译后,就显示这个:



雅痞公子

职务:普通成员
等级:3
金币:-3.0
发贴:732
注册:2003/3/27 23:16:34
#62003/11/20 19:03:53
效果一样,
但比你的好看多了。
写个日历有必要用j2se吗??



孤独的牧羊人

职务:版主
等级:2
金币:25.0
发贴:357
注册:2003/7/11 8:31:54
#72003/11/20 23:03:25

图片如下:


虽然没有太大必要,但是还是有点用的,我把这个程序改造了一下,写了个 eclipse 插件


CalendarView.java
package com.eiffelqiu.tools;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.ui.part.ViewPart;

/**
 * Calendar plugin for eclipse
 * 
 * @author Qiu Hai Feng
 * @version 1.0, Created on 2003-10-28 15:36:57
 */
public class CalendarView extends ViewPart {
	Label label;
	public CalendarView() {
	}
	public void createPartControl(Composite parent) {
	   label = new Label(parent, SWT.WRAP);
	   label.setText(CalendarImp.show());
	}
	public void setFocus() {

	}

}




CalendarImp.java
package com.eiffelqiu.tools;

import java.util.*;

/**
 * Calendar implementation 
 * 
 * @author Qiu Hai Feng
 * @version 1.0, Created on 2003-10-28 15:36:57
 */
public class CalendarImp {
	/**
	 * concate calendar output string
	 * 
	 * @param void
	 * @return String
	 */	
	public static String show() {

		StringBuffer calString = new StringBuffer();
		GregorianCalendar nowDate = new GregorianCalendar();

		int today = nowDate.get(Calendar.DAY_OF_MONTH);
		int month = nowDate.get(Calendar.MONTH);

		nowDate.set(Calendar.DAY_OF_MONTH, 1);
		int weekday = nowDate.get(Calendar.DAY_OF_WEEK);
		calString.append("Sun  Mon  Tue  Wed  Thu  Fri  Sat\n" );
		//	  indent first line of calendar
		for (int i = Calendar.SUNDAY; i < weekday; i++)
			calString.append("        " );
		do {
			//	  print the day
			int day = nowDate.get(Calendar.DAY_OF_MONTH);
			if (day < 10)
				calString.append("  " );
			calString.append( "  " + day);
			//	  mark current day with *
			if (day == today)
				calString.append("* " );
			else
				calString.append("  " );
			if (weekday == Calendar.SATURDAY)
				calString.append("\n" );
			//	  advanced d to next day
			nowDate.add(Calendar.DAY_OF_MONTH, 1);
			weekday = nowDate.get(Calendar.DAY_OF_WEEK);
		} while (nowDate.get(Calendar.MONTH) == month);
		
		if (weekday != Calendar.SUNDAY)
			calString.append("\n" );
			
		return calString.toString();
	}

}





plugin.xml




  
     
  
  
     
  
  
     
     
  

   
      
   



编辑历史:[此帖被eiffelqiu编辑过(编辑时间2003-11-21 09:01:14)]


孤独的牧羊人

职务:版主
等级:2
金币:25.0
发贴:357
注册:2003/7/11 8:31:54
#82003/11/21 9:18:29
把测试用例也贴上来


package com.eiffelqiu.tools;

import junit.framework.TestCase;

/**
 * Calendar implement TestCase
 * 
 * @author Qiu Hai Feng
 * @version 1.0, Created on 2003-10-28 15:36:57
 */
public class CalendarImpTest extends TestCase {

	/**
	 * Constructor for CalendarImpTest.
	 * @param name
	 */
	public CalendarImpTest(String name) {
		super(name);
	}

	public static void main(String[] args) {
		junit.swingui.TestRunner.run(CalendarImpTest.class);
	}

	/*
	 * @see TestCase#setUp()
	 */
	protected void setUp() throws Exception {
		super.setUp();
	}

	/*
	 * @see TestCase#tearDown()
	 */
	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testShow() {
		assertTrue(!CalendarImp.show().equals(null));
		assertEquals(CalendarImp.show(),CalendarImp.show());
	}

}



编辑历史:[此帖被eiffelqiu编辑过(编辑时间2003-11-21 09:36:46)]
[此帖被eiffelqiu编辑过(编辑时间2003-11-21 09:37:10)]


雅痞公子

职务:普通成员
等级:3
金币:-3.0
发贴:732
注册:2003/3/27 23:16:34
#92003/11/21 19:25:46
长见识,
这就是JSP,
好像有点难。



孤独的牧羊人

职务:版主
等级:2
金币:25.0
发贴:357
注册:2003/7/11 8:31:54
#102003/11/21 20:11:55
岚人在上个帖子中说
引用:
长见识,
这就是JSP,
好像有点难。


不是,不是,这不是 JSP, 是 j2se 的内容。
JSP 属于 J2ee 的内容。

Java 不是太难,只是要学的东西太多, 要不停的学。
不过学习java 还是很有趣的,你总能接触一些思想。

设计模式,重构,极限编程都在 JAVA 上有很多的应用。



雅痞公子

职务:普通成员
等级:3
金币:-3.0
发贴:732
注册:2003/3/27 23:16:34
#112003/11/23 1:37:21
谢谢,我很想学Java,
但现在先学会一点点CFML.



雅痞公子

职务:普通成员
等级:3
金币:-3.0
发贴:732
注册:2003/3/27 23:16:34
#122003/11/29 1:07:42
效果图:

图片如下:



foxfire

职务:普通成员
等级:1
金币:0.0
发贴:1
注册:2003/11/24 15:42:10
#132003/12/4 11:06:46
的确,不难度



cxshower

职务:普通成员
等级:1
金币:0.0
发贴:39
注册:2003/7/1 16:56:25
#142004/6/13 3:41:23
不错。



dnaliang

职务:普通成员
等级:1
金币:1.0
发贴:193
注册:2002/10/15 19:41:05
#152004/6/15 13:51:14
晕死了。不知道能否用asp做出这样的东东来。cfm一窍不通。