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

📄 locale.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 2 页
字号:
if(!dojo._hasResource["tests.date.locale"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.dojo._hasResource["tests.date.locale"] = true;dojo.provide("tests.date.locale");dojo.require("dojo.date.locale");tests.register("tests.date.locale", 	[		{			// Test formatting and parsing of dates in various locales pre-built in dojo.cldr			// NOTE: we can't set djConfig.extraLocale before bootstrapping unit tests, so directly			// load resources here for specific locales:			name: "date.locale",			setUp: function(){				var partLocaleList = ["en-us", "fr-fr", "es", "de-at", "ja-jp", "zh-cn"];				dojo.forEach(partLocaleList, function(locale){					dojo.requireLocalization("dojo.cldr", "gregorian", locale, "zh-cn,zh,en-ca,ko-kr,pt,pt-br,it-it,ROOT,en-gb,de,ja,en,en-au,fr,es,ko,zh-tw,it,es-es");				});			},			runTest: function(t){			},			tearDown: function(){				//Clean up bundles that should not exist if				//the test is re-run.				delete dojo.cldr.nls.gregorian;			}		},		{			name: "isWeekend",			runTest: function(t){				var thursday = new Date(2006, 8, 21);				var friday = new Date(2006, 8, 22);				var saturday = new Date(2006, 8, 23);				var sunday = new Date(2006, 8, 24);				var monday = new Date(2006, 8, 25);				t.f(dojo.date.locale.isWeekend(thursday, 'en-us'));				t.t(dojo.date.locale.isWeekend(saturday, 'en-us'));				t.t(dojo.date.locale.isWeekend(sunday, 'en-us'));				t.f(dojo.date.locale.isWeekend(monday, 'en-us'));//	t.f(dojo.date.locale.isWeekend(saturday, 'en-in'));//	t.t(dojo.date.locale.isWeekend(sunday, 'en-in'));//	t.f(dojo.date.locale.isWeekend(monday, 'en-in'));//	t.t(dojo.date.locale.isWeekend(friday, 'he-il'));//	t.f(dojo.date.locale.isWeekend(sunday, 'he-il'));			}		},		{			name: "format",			runTest: function(t){	var date = new Date(2006, 7, 11, 0, 55, 12, 345);	t.is("Friday, August 11, 2006", dojo.date.locale.format(date, {formatLength:'full',selector:'date', locale:'en-us'}));	t.is("vendredi 11 ao\xFBt 2006", dojo.date.locale.format(date, {formatLength:'full',selector:'date', locale:'fr-fr'}));	t.is("Freitag, 11. August 2006", dojo.date.locale.format(date, {formatLength:'full',selector:'date', locale:'de-at'}));	t.is("2006\u5E748\u670811\u65E5\u91D1\u66DC\u65E5", dojo.date.locale.format(date, {formatLength:'full',selector:'date', locale:'ja-jp'}));	t.is("8/11/06", dojo.date.locale.format(date, {formatLength:'short',selector:'date', locale:'en-us'}));	t.is("11/08/06", dojo.date.locale.format(date, {formatLength:'short',selector:'date', locale:'fr-fr'}));	t.is("11.08.06", dojo.date.locale.format(date, {formatLength:'short',selector:'date', locale:'de-at'}));	t.is("06/08/11", dojo.date.locale.format(date, {formatLength:'short',selector:'date', locale:'ja-jp'}));	t.is("12:55 AM", dojo.date.locale.format(date, {formatLength:'short',selector:'time', locale:'en-us'}));	t.is("12:55:12", dojo.date.locale.format(date, {timePattern:'h:m:s',selector:'time'}));	t.is("12:55:12.35", dojo.date.locale.format(date, {timePattern:'h:m:s.SS',selector:'time'}));	t.is("24:55:12.35", dojo.date.locale.format(date, {timePattern:'k:m:s.SS',selector:'time'}));	t.is("0:55:12.35", dojo.date.locale.format(date, {timePattern:'H:m:s.SS',selector:'time'}));	t.is("0:55:12.35", dojo.date.locale.format(date, {timePattern:'K:m:s.SS',selector:'time'}));	t.is("11082006", dojo.date.locale.format(date, {datePattern:"ddMMyyyy", selector:"date"}));	// compare without timezone	t.is("\u4e0a\u534812\u65f655\u520612\u79d2", dojo.date.locale.format(date, {formatLength:'full',selector:'time', locale:'zh-cn'}).split(' ')[0]);			}		},		{			name: "parse_dates",			runTest: function(t){	var aug_11_2006 = new Date(2006, 7, 11, 0);	//en: 'short' fmt: M/d/yy	// Tolerate either 8 or 08 for month part.	t.is( aug_11_2006, dojo.date.locale.parse("08/11/06", {formatLength:'short', selector:'date', locale:'en'}));	t.is( aug_11_2006, dojo.date.locale.parse("8/11/06", {formatLength:'short', selector:'date', locale:'en'}));		// Tolerate yyyy input in yy part...	t.is( aug_11_2006, dojo.date.locale.parse("8/11/2006", {formatLength:'short', selector:'date', locale:'en'}));	// ...but not in strict mode	t.f( Boolean(dojo.date.locale.parse("8/11/2006", {formatLength:'short', selector:'date', locale:'en', strict:true})));	//en: 'medium' fmt: MMM d, yyyy	// Tolerate either 8 or 08 for month part.	t.is( aug_11_2006, dojo.date.locale.parse("Aug 11, 2006", {formatLength:'medium', selector:'date', locale:'en'}));	t.is( aug_11_2006, dojo.date.locale.parse("Aug 11, 2006", {formatLength:'medium', selector:'date', locale:'en'}));		// Tolerate abbreviating period in month part...	t.is( aug_11_2006, dojo.date.locale.parse("Aug. 11, 2006", {formatLength:'medium', selector:'date', locale:'en'}));	// ...but not in strict mode	t.f( Boolean(dojo.date.locale.parse("Aug. 11, 2006", {formatLength:'medium', selector:'date', locale:'en', strict:true})));	// Note: 06 for year part will be translated literally as the year 6 C.E.	var aug_11_06CE = new Date(2006, 7, 11, 0);	aug_11_06CE.setFullYear(6); //literally the year 6 C.E.	t.is( aug_11_06CE, dojo.date.locale.parse("Aug 11, 06", {selector:'date', datePattern:'MMM dd, yyyy', strict:true}));	//en: 'long' fmt: MMMM d, yyyy	t.is( aug_11_2006, dojo.date.locale.parse("August 11, 2006", {formatLength:'long', selector:'date', locale:'en'}));	//en: 'full' fmt: EEEE, MMMM d, yyyy	t.is( aug_11_2006, dojo.date.locale.parse("Friday, August 11, 2006", {formatLength:'full', selector:'date', locale:'en'}));	//TODO: wrong day-of-week should fail	//t.f( Boolean(dojo.date.locale.parse("Thursday, August 11, 2006", {formatLength:'full', selector:'date', locale:'en'})));	//TODO: Whitespace tolerance	//	t.is( aug_11_2006, dojo.date.locale.parse(" August 11, 2006", {formatLength:'long', selector:'date', locale:'en'}));	//	t.is( aug_11_2006, dojo.date.locale.parse("August  11, 2006", {formatLength:'long', selector:'date', locale:'en'}));	//	t.is( aug_11_2006, dojo.date.locale.parse("August 11 , 2006", {formatLength:'long', selector:'date', locale:'en'}));	//	t.is( aug_11_2006, dojo.date.locale.parse("August 11,  2006", {formatLength:'long', selector:'date', locale:'en'}));	//	t.is( aug_11_2006, dojo.date.locale.parse("August 11, 2006 ", {formatLength:'long', selector:'date', locale:'en'}));	//Simple Validation Tests	//catch "month" > 12 (note: month/day reversals are common when user expectation isn't met wrt european versus US formats)	t.f( Boolean(dojo.date.locale.parse("15/1/2005", {formatLength:'short', selector:'date', locale:'en'})));	//day of month typo rolls over to the next month	t.f( Boolean(dojo.date.locale.parse("Aug 32, 2006", {formatLength:'medium', selector:'date', locale:'en'})));	//German (de)	t.is( aug_11_2006, dojo.date.locale.parse("11.08.06", {formatLength:'short', selector:'date', locale:'de'}));	t.f( Boolean(dojo.date.locale.parse("11.8/06", {formatLength:'short', selector:'date', locale:'de'})));	t.f( Boolean(dojo.date.locale.parse("11.8x06", {formatLength:'short', selector:'date', locale:'de'})));	t.f( Boolean(dojo.date.locale.parse("11.13.06", {formatLength:'short', selector:'date', locale:'de'})));	t.f( Boolean(dojo.date.locale.parse("11.0.06", {formatLength:'short', selector:'date', locale:'de'})));	t.f( Boolean(dojo.date.locale.parse("32.08.06", {formatLength:'short', selector:'date', locale:'de'})));	//Spanish (es)	//es: 'short' fmt: d/MM/yy	t.is( aug_11_2006, dojo.date.locale.parse("11/08/06", {formatLength:'short', selector:'date', locale:'es'}));	t.is( aug_11_2006, dojo.date.locale.parse("11/8/06", {formatLength:'short', selector:'date', locale:'es'}));		// Tolerate yyyy input in yy part...	t.is( aug_11_2006, dojo.date.locale.parse("11/8/2006", {formatLength:'short', selector:'date', locale:'es'}));	// ...but not in strict mode	t.f( Boolean(dojo.date.locale.parse("11/8/2006", {formatLength:'short', selector:'date', locale:'es', strict:true})));	//es: 'medium' fmt: dd-MMM-yy (not anymore as of CLDR 1.5.1)//	t.is( aug_11_2006, dojo.date.locale.parse("11-ago-06", {formatLength:'medium', selector:'date', locale:'es'}));//	t.is( aug_11_2006, dojo.date.locale.parse("11-ago-2006", {formatLength:'medium', selector:'date', locale:'es'}));		// Tolerate abbreviating period in month part...//	t.is( aug_11_2006, dojo.date.locale.parse("11-ago.-2006", {formatLength:'medium', selector:'date', locale:'es'}));	// ...but not in strict mode//	t.f( Boolean(dojo.date.locale.parse("11-ago.-2006", {formatLength:'medium', selector:'date', locale:'es', strict:true})));	//es: 'long' fmt: d' de 'MMMM' de 'yyyy	t.is( aug_11_2006, dojo.date.locale.parse("11 de agosto de 2006", {formatLength:'long', selector:'date', locale:'es'}));	//case-insensitive month...	t.is( aug_11_2006, dojo.date.locale.parse("11 de Agosto de 2006", {formatLength:'long', selector:'date', locale:'es'}));	//...but not in strict mode	t.f( Boolean(dojo.date.locale.parse("11 de Agosto de 2006", {formatLength:'long', selector:'date', locale:'es', strict:true})));	//es 'full' fmt: EEEE d' de 'MMMM' de 'yyyy	t.is( aug_11_2006, dojo.date.locale.parse("viernes 11 de agosto de 2006", {formatLength:'full', selector:'date', locale:'es'}));	//case-insensitive day-of-week...	t.is( aug_11_2006, dojo.date.locale.parse("Viernes 11 de agosto de 2006", {formatLength:'full', selector:'date', locale:'es'}));	//...but not in strict mode	t.f( Boolean(dojo.date.locale.parse("Viernes 11 de agosto de 2006", {formatLength:'full', selector:'date', locale:'es', strict:true})));	//Japanese (ja)	//note: to avoid garbling from non-utf8-aware editors that may touch this file, using the \uNNNN format 	//for expressing double-byte chars.	//toshi (year): \u5e74	//getsu (month): \u6708	//nichi (day): \u65e5	//kinyoubi (Friday): \u91d1\u66dc\u65e5	//zenkaku space: \u3000		//ja: 'short' fmt: yy/MM/dd (note: the "short" fmt isn't actually defined in the CLDR data...)	t.is( aug_11_2006, dojo.date.locale.parse("06/08/11", {formatLength:'short', selector:'date', locale:'ja'}));	t.is( aug_11_2006, dojo.date.locale.parse("06/8/11", {formatLength:'short', selector:'date', locale:'ja'}));	 	// Tolerate yyyy input in yy part...	t.is( aug_11_2006, dojo.date.locale.parse("2006/8/11", {formatLength:'short', selector:'date', locale:'ja'}));	// ...but not in strict mode	t.f( Boolean(dojo.date.locale.parse("2006/8/11", {formatLength:'short', selector:'date', locale:'ja', strict:true})));	//ja: 'medium' fmt: yyyy/MM/dd	t.is( aug_11_2006, dojo.date.locale.parse("2006/08/11", {formatLength:'medium', selector:'date', locale:'ja'}));	t.is( aug_11_2006, dojo.date.locale.parse("2006/8/11", {formatLength:'medium', selector:'date', locale:'ja'}));			//ja: 'long' fmt: yyyy'\u5e74'\u6708'd'\u65e5'	t.is( aug_11_2006, dojo.date.locale.parse("2006\u5e748\u670811\u65e5", {formatLength:'long', selector:'date', locale:'ja'}));	//ja 'full' fmt: yyyy'\u5e74'M'\u6708'd'\u65e5'EEEE	t.is( aug_11_2006, dojo.date.locale.parse("2006\u5e748\u670811\u65e5\u91d1\u66dc\u65e5", {formatLength:'full', selector:'date', locale:'ja'}));	//TODO: Whitespace tolerance	//tolerate ascii space	//	t.is( aug_11_2006, dojo.date.locale.parse(" 2006\u5e748\u670811\u65e5\u91d1\u66dc\u65e5 ", {formatLength:'full', selector:'date', locale:'ja'}));	//	t.is( aug_11_2006, dojo.date.locale.parse("2006\u5e74 8\u670811\u65e5 \u91d1\u66dc\u65e5", {formatLength:'full', selector:'date', locale:'ja'}));	//tolerate zenkaku space	//	t.is( aug_11_2006, dojo.date.locale.parse("\u30002006\u5e748\u670811\u65e5\u91d1\u66dc\u65e5\u3000", {formatLength:'full', selector:'date', locale:'ja'}));	//	t.is( aug_11_2006, dojo.date.locale.parse("2006\u5e74\u30008\u670811\u65e5\u3000\u91d1\u66dc\u65e5", {formatLength:'full', selector:'date', locale:'ja'}));	var apr_11_2006 = new Date(2006, 3, 11, 0);	//Roundtrip	var options={formatLength:'medium',selector:'date', locale:'fr-fr'};	t.is(0, dojo.date.compare(apr_11_2006, dojo.date.locale.parse(dojo.date.locale.format(apr_11_2006, options), options)));	//Tolerance for abbreviations

⌨️ 快捷键说明

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