⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 date.js

📁 dojo与json创建无限级树的时候,当在父结点下添加了一个新结点,我怎么让父亲结点重新调用json加载一下子结点内容.
💻 JS
📖 第 1 页 / 共 2 页
字号:
/*	Copyright (c) 2004-2006, The Dojo Foundation	All Rights Reserved.	Licensed under the Academic Free License version 2.1 or above OR the	modified BSD license. For more information on Dojo licensing, see:		http://dojotoolkit.org/community/licensing.shtml*/dojo.provide("dojo.date");/* Supplementary Date Functions *******************************/dojo.date.setDayOfYear = function (dateObject, dayofyear) {	dateObject.setMonth(0);	dateObject.setDate(dayofyear);	return dateObject;}dojo.date.getDayOfYear = function (dateObject) {	var firstDayOfYear = new Date(dateObject.getFullYear(), 0, 1);	return Math.floor((dateObject.getTime() -		firstDayOfYear.getTime()) / 86400000);}dojo.date.setWeekOfYear = function (dateObject, week, firstDay) {	if (arguments.length == 1) { firstDay = 0; } // Sunday	dojo.unimplemented("dojo.date.setWeekOfYear");}dojo.date.getWeekOfYear = function (dateObject, firstDay) {	if (arguments.length == 1) { firstDay = 0; } // Sunday	// work out the first day of the year corresponding to the week	var firstDayOfYear = new Date(dateObject.getFullYear(), 0, 1);	var day = firstDayOfYear.getDay();	firstDayOfYear.setDate(firstDayOfYear.getDate() -			day + firstDay - (day > firstDay ? 7 : 0));	return Math.floor((dateObject.getTime() -		firstDayOfYear.getTime()) / 604800000);}dojo.date.setIsoWeekOfYear = function (dateObject, week, firstDay) {	if (arguments.length == 1) { firstDay = 1; } // Monday	dojo.unimplemented("dojo.date.setIsoWeekOfYear");}dojo.date.getIsoWeekOfYear = function (dateObject, firstDay) {	if (arguments.length == 1) { firstDay = 1; } // Monday	dojo.unimplemented("dojo.date.getIsoWeekOfYear");}/* ISO 8601 Functions *********************/dojo.date.setIso8601 = function (dateObject, string){	var comps = (string.indexOf("T") == -1) ? string.split(" ") : string.split("T");	dojo.date.setIso8601Date(dateObject, comps[0]);	if (comps.length == 2) { dojo.date.setIso8601Time(dateObject, comps[1]); }	return dateObject;}dojo.date.fromIso8601 = function (string) {	return dojo.date.setIso8601(new Date(0, 0), string);}dojo.date.setIso8601Date = function (dateObject, string) {	var regexp = "^([0-9]{4})((-?([0-9]{2})(-?([0-9]{2}))?)|" +			"(-?([0-9]{3}))|(-?W([0-9]{2})(-?([1-7]))?))?$";	var d = string.match(new RegExp(regexp));	if(!d) {		dojo.debug("invalid date string: " + string);		return false;	}	var year = d[1];	var month = d[4];	var date = d[6];	var dayofyear = d[8];	var week = d[10];	var dayofweek = (d[12]) ? d[12] : 1;	dateObject.setYear(year);		if (dayofyear) { dojo.date.setDayOfYear(dateObject, Number(dayofyear)); }	else if (week) {		dateObject.setMonth(0);		dateObject.setDate(1);		var gd = dateObject.getDay();		var day =  (gd) ? gd : 7;		var offset = Number(dayofweek) + (7 * Number(week));				if (day <= 4) { dateObject.setDate(offset + 1 - day); }		else { dateObject.setDate(offset + 8 - day); }	} else {		if (month) { 			dateObject.setDate(1);			dateObject.setMonth(month - 1); 		}		if (date) { dateObject.setDate(date); }	}		return dateObject;}dojo.date.fromIso8601Date = function (string) {	return dojo.date.setIso8601Date(new Date(0, 0), string);}dojo.date.setIso8601Time = function (dateObject, string) {	// first strip timezone info from the end	var timezone = "Z|(([-+])([0-9]{2})(:?([0-9]{2}))?)$";	var d = string.match(new RegExp(timezone));	var offset = 0; // local time if no tz info	if (d) {		if (d[0] != 'Z') {			offset = (Number(d[3]) * 60) + Number(d[5]);			offset *= ((d[2] == '-') ? 1 : -1);		}		offset -= dateObject.getTimezoneOffset();		string = string.substr(0, string.length - d[0].length);	}	// then work out the time	var regexp = "^([0-9]{2})(:?([0-9]{2})(:?([0-9]{2})(\.([0-9]+))?)?)?$";	var d = string.match(new RegExp(regexp));	if(!d) {		dojo.debug("invalid time string: " + string);		return false;	}	var hours = d[1];	var mins = Number((d[3]) ? d[3] : 0);	var secs = (d[5]) ? d[5] : 0;	var ms = d[7] ? (Number("0." + d[7]) * 1000) : 0;	dateObject.setHours(hours);	dateObject.setMinutes(mins);	dateObject.setSeconds(secs);	dateObject.setMilliseconds(ms);		return dateObject;}dojo.date.fromIso8601Time = function (string) {	return dojo.date.setIso8601Time(new Date(0, 0), string);}/* Informational Functions **************************/dojo.date.shortTimezones = ["IDLW", "BET", "HST", "MART", "AKST", "PST", "MST",	"CST", "EST", "AST", "NFT", "BST", "FST", "AT", "GMT", "CET", "EET", "MSK",	"IRT", "GST", "AFT", "AGTT", "IST", "NPT", "ALMT", "MMT", "JT", "AWST",	"JST", "ACST", "AEST", "LHST", "VUT", "NFT", "NZT", "CHAST", "PHOT",	"LINT"];dojo.date.timezoneOffsets = [-720, -660, -600, -570, -540, -480, -420, -360,	-300, -240, -210, -180, -120, -60, 0, 60, 120, 180, 210, 240, 270, 300,	330, 345, 360, 390, 420, 480, 540, 570, 600, 630, 660, 690, 720, 765, 780,	840];/*dojo.date.timezones = ["International Date Line West", "Bering Standard Time",	"Hawaiian Standard Time", "Marquesas Time", "Alaska Standard Time",	"Pacific Standard Time (USA)", "Mountain Standard Time",	"Central Standard Time (USA)", "Eastern Standard Time (USA)",	"Atlantic Standard Time", "Newfoundland Time", "Brazil Standard Time",	"Fernando de Noronha Standard Time (Brazil)", "Azores Time",	"Greenwich Mean Time", "Central Europe Time", "Eastern Europe Time",	"Moscow Time", "Iran Standard Time", "Gulf Standard Time",	"Afghanistan Time", "Aqtobe Time", "Indian Standard Time", "Nepal Time",	"Almaty Time", "Myanmar Time", "Java Time",	"Australian Western Standard Time", "Japan Standard Time",	"Australian Central Standard Time", "Lord Hove Standard Time (Australia)",	"Vanuata Time", "Norfolk Time (Australia)", "New Zealand Standard Time",	"Chatham Standard Time (New Zealand)", "Phoenix Islands Time (Kribati)",	"Line Islands Time (Kribati)"];*/dojo.date.months = ["January", "February", "March", "April", "May", "June",	"July", "August", "September", "October", "November", "December"];dojo.date.shortMonths = ["Jan", "Feb", "Mar", "Apr", "May", "June",	"July", "Aug", "Sep", "Oct", "Nov", "Dec"];dojo.date.days = ["Sunday", "Monday", "Tuesday", "Wednesday",	"Thursday", "Friday", "Saturday"];dojo.date.shortDays = ["Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat"];dojo.date.getDaysInMonth = function (dateObject) {	var month = dateObject.getMonth();	var days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];	if (month == 1 && dojo.date.isLeapYear(dateObject)) { return 29; }	else { return days[month]; }}dojo.date.isLeapYear = function (dateObject) {	/*	 * Leap years are years with an additional day YYYY-02-29, where the year	 * number is a multiple of four with the following exception: If a year	 * is a multiple of 100, then it is only a leap year if it is also a	 * multiple of 400. For example, 1900 was not a leap year, but 2000 is one.	 */	var year = dateObject.getFullYear();	return (year%400 == 0) ? true : (year%100 == 0) ? false : (year%4 == 0) ? true : false;}dojo.date.getDayName = function (dateObject) {	return dojo.date.days[dateObject.getDay()];}dojo.date.getDayShortName = function (dateObject) {	return dojo.date.shortDays[dateObject.getDay()];}dojo.date.getMonthName = function (dateObject) {	return dojo.date.months[dateObject.getMonth()];}dojo.date.getMonthShortName = function (dateObject) {	return dojo.date.shortMonths[dateObject.getMonth()];}dojo.date.getTimezoneName = function (dateObject) {	// need to negate timezones to get it right 	// i.e UTC+1 is CET winter, but getTimezoneOffset returns -60	var timezoneOffset = -(dateObject.getTimezoneOffset());		for (var i = 0; i < dojo.date.timezoneOffsets.length; i++) {		if (dojo.date.timezoneOffsets[i] == timezoneOffset) {			return dojo.date.shortTimezones[i];		}	}		// we don't know so return it formatted as "+HH:MM"	function $ (s) { s = String(s); while (s.length < 2) { s = "0" + s; } return s; }	return (timezoneOffset < 0 ? "-" : "+") + $(Math.floor(Math.abs(		timezoneOffset)/60)) + ":" + $(Math.abs(timezoneOffset)%60);}dojo.date.getOrdinal = function (dateObject) {	var date = dateObject.getDate();	if (date%100 != 11 && date%10 == 1) { return "st"; }	else if (date%100 != 12 && date%10 == 2) { return "nd"; }	else if (date%100 != 13 && date%10 == 3) { return "rd"; }	else { return "th"; }}/* Date Formatter Functions ***************************/// POSIX strftime// see <http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html>dojo.date.format = dojo.date.strftime = function (dateObject, format) {	// zero pad	var padChar = null;	function _ (s, n) {		s = String(s);		n = (n || 2) - s.length;		while (n-- > 0) { s = (padChar == null ? "0" : padChar) + s; }		return s;	}		function $ (property) {		switch (property) {			case "a": // abbreviated weekday name according to the current locale				return dojo.date.getDayShortName(dateObject); break;			case "A": // full weekday name according to the current locale				return dojo.date.getDayName(dateObject); break;			case "b":			case "h": // abbreviated month name according to the current locale				return dojo.date.getMonthShortName(dateObject); break;							case "B": // full month name according to the current locale				return dojo.date.getMonthName(dateObject); break;							case "c": // preferred date and time representation for the current				      // locale				return dateObject.toLocaleString(); break;			case "C": // century number (the year divided by 100 and truncated				      // to an integer, range 00 to 99)				return _(Math.floor(dateObject.getFullYear()/100)); break;							case "d": // day of the month as a decimal number (range 01 to 31)				return _(dateObject.getDate()); break;							case "D": // same as %m/%d/%y				return $("m") + "/" + $("d") + "/" + $("y"); break;								case "e": // day of the month as a decimal number, a single digit is				      // preceded by a space (range ' 1' to '31')				if (padChar == null) { padChar = " "; }				return _(dateObject.getDate(), 2); break;						case "g": // like %G, but without the century.				break;						case "G": // The 4-digit year corresponding to the ISO week number				      // (see %V).  This has the same format and value as %Y,				      // except that if the ISO week number belongs to the				      // previous or next year, that year is used instead.				break;						case "F": // same as %Y-%m-%d				return $("Y") + "-" + $("m") + "-" + $("d"); break;							case "H": // hour as a decimal number using a 24-hour clock (range				      // 00 to 23)				return _(dateObject.getHours()); break;							case "I": // hour as a decimal number using a 12-hour clock (range				      // 01 to 12)				return _(dateObject.getHours() % 12 || 12); break;							case "j": // day of the year as a decimal number (range 001 to 366)				return _(dojo.date.getDayOfYear(dateObject), 3); break;							case "m": // month as a decimal number (range 01 to 12)				return _(dateObject.getMonth() + 1); break;							case "M": // minute as a decimal numbe				return _(dateObject.getMinutes()); break;						case "n":				return "\n"; break;			case "p": // either `am' or `pm' according to the given time value,				      // or the corresponding strings for the current locale				return dateObject.getHours() < 12 ? "am" : "pm"; break;							case "r": // time in a.m. and p.m. notation				return $("I") + ":" + $("M") + ":" + $("S") + " " + $("p"); break;							case "R": // time in 24 hour notation				return $("H") + ":" + $("M"); break;							case "S": // second as a decimal number				return _(dateObject.getSeconds()); break;			case "t":				return "\t"; break;			case "T": // current time, equal to %H:%M:%S				return $("H") + ":" + $("M") + ":" + $("S"); break;							case "u": // weekday as a decimal number [1,7], with 1 representing

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -