| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
| 3 | <html> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 | <title>Test TextBox for Time</title> |
| 7 | |
| 8 | <style type="text/css"> |
| 9 | @import "../../themes/claro/document.css"; |
| 10 | @import "../../themes/claro/claro.css"; |
| 11 | @import "../css/dijitTests.css"; |
| 12 | |
| 13 | .title { |
| 14 | background-color:#ddd; |
| 15 | } |
| 16 | |
| 17 | .hint { |
| 18 | background-color:#eee; |
| 19 | } |
| 20 | |
| 21 | .testExample { |
| 22 | background-color:#fbfbfb; |
| 23 | padding:1em; |
| 24 | margin-bottom:1em; |
| 25 | border:1px solid #bfbfbf; |
| 26 | } |
| 27 | |
| 28 | .dojoTitlePaneLabel label { |
| 29 | font-weight:bold; |
| 30 | } |
| 31 | |
| 32 | td {white-space:nowrap} |
| 33 | </style> |
| 34 | |
| 35 | <script type="text/javascript" src="../../../dojo/dojo.js" |
| 36 | data-dojo-config="isDebug: true, extraLocale: ['zh-cn','fr-fr','ja-jp','ar-eg','ru-ru','hi-in','en-us']"></script> |
| 37 | <script type="text/javascript" src="test_i18n.js"></script> |
| 38 | <script type="text/javascript"> |
| 39 | dojo.require("dijit.form.ValidationTextBox"); |
| 40 | dojo.require("dojo.date.locale"); |
| 41 | dojo.require("dojo.date.stamp"); |
| 42 | dojo.require("dojo.date"); |
| 43 | dojo.require("dojo.string"); |
| 44 | dojo.require("dojo.number"); |
| 45 | dojo.require("dojo.parser"); // scan page for widgets and instantiate them |
| 46 | dojo.require("doh.runner"); |
| 47 | |
| 48 | dojo.ready(function(){ |
| 49 | var tz_s = dojo.date.getTimezoneName(new Date()); |
| 50 | if(!tz_s){ |
| 51 | var offset = new Date().getTimezoneOffset(); |
| 52 | var tz = [ |
| 53 | (offset <= 0 ? "+" : "-"), |
| 54 | dojo.string.pad(Math.floor(Math.abs(offset) / 60), 2), |
| 55 | dojo.string.pad(Math.abs(offset) % 60, 2) |
| 56 | ]; |
| 57 | tz.splice(0, 0, "GMT"); |
| 58 | tz.splice(3, 0, ":"); |
| 59 | tz_s = tz.join(""); |
| 60 | } |
| 61 | |
| 62 | function gen4DateFormat(testCases, language, locale, date, shortFmt, shortCmt, mediumFmt, mediumCmt, longFmt, longCmt, full, fullCmt){ |
| 63 | var tz_l = language.indexOf("hi") == 0 && dojo.number.normalizeDigitChars ? |
| 64 | dojo.number.normalizeDigitChars(tz_s, language) : tz_s; |
| 65 | |
| 66 | shortFmt = shortFmt.replace(/UTC/, tz_l); |
| 67 | mediumFmt = mediumFmt.replace(/UTC/, tz_l); |
| 68 | longFmt = longFmt.replace(/UTC/g, tz_l); |
| 69 | full = full.replace(/UTC/, tz_l); |
| 70 | |
| 71 | var shortDate = null; |
| 72 | testCases.push({ |
| 73 | attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'short', selector:'time', localeDigit:true}" : "{formatLength:'short', selector:'time'}", |
| 74 | lang: language}, |
| 75 | desc: "Locale: <b>" + locale + "</b> Format: <b>short</b>", |
| 76 | value: typeof(date) == "string" ? date : shortDate = new Date(date.getYear(), date.getMonth(), date.getDay() - 5, date.getHours(), date.getMinutes()), |
| 77 | expValue: shortFmt, |
| 78 | comment: shortCmt |
| 79 | }); |
| 80 | testCases.push({ |
| 81 | attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'medium', selector:'time', localeDigit:true}" : "{formatLength:'medium', selector:'time'}", |
| 82 | lang: language}, |
| 83 | desc: "Locale: <b>" + locale + "</b> Format: <b>medium</b>", |
| 84 | value: date, |
| 85 | expValue: mediumFmt, |
| 86 | comment: mediumCmt |
| 87 | }); |
| 88 | testCases.push({ |
| 89 | attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'long', selector:'time', localeDigit:true}" : "{formatLength:'long', selector:'time'}", |
| 90 | lang: language}, |
| 91 | desc: "Locale: <b>" + locale + "</b> Format: <b>long</b>", |
| 92 | value: date, |
| 93 | expValue: longFmt, |
| 94 | comment: longCmt |
| 95 | }); |
| 96 | testCases.push({ |
| 97 | attrs: {constraints: language.indexOf("hi") == 0 ? "{formatLength:'full', selector:'time', localeDigit:true}" : "{formatLength:'full', selector:'time'}", |
| 98 | lang: language}, |
| 99 | desc: "Locale: <b>" + locale + "</b> Format: <b>Full</b>", |
| 100 | //value: typeof(date) == "string" || language.indexOf("fr") ? date : shortDate, |
| 101 | value: date, |
| 102 | expValue: full, |
| 103 | comment: fullCmt |
| 104 | }); |
| 105 | |
| 106 | date.processValue = function(value){ |
| 107 | return value ? new Date(1970, 0, 1, value.getHours(), value.getMinutes(), value.getSeconds()) : value; |
| 108 | }; |
| 109 | if(shortDate){ |
| 110 | shortDate.processValue = date.processValue; |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | var testCases = []; |
| 115 | gen4DateFormat(testCases, "ru-ru", "ru_RU", "1970-01-01T15:25:35", |
| 116 | "15:25", "", "15:25:35", "", "15:25:35 UTC", "", "15:25:35 UTC", ""); |
| 117 | gen4DateFormat(testCases, "zh-cn", "zh_CN", "1970-01-01T15:25:35", |
| 118 | "下午3:25", "", "下午03:25:35", "", "下午03时25分35秒", "", "下午03时25分35秒 UTC", ""); |
| 119 | gen4DateFormat(testCases, "en-us", "en_US", "1970-01-01T15:25:35", |
| 120 | "3:25 PM", "", "3:25:35 PM", "", "3:25:35 PM UTC", "", "3:25:35 PM UTC", ""); |
| 121 | gen4DateFormat(testCases, "fr-fr", "fr_FR", "1970-01-01T15:25:35", |
| 122 | "15:25", "", "15:25:35", "", "15:25:35 UTC", "", "15:25:35 UTC", ""); |
| 123 | gen4DateFormat(testCases, "ja-jp", "ja_JP", "1970-01-01T15:25:35", |
| 124 | "15:25", "", "15:25:35", "", "15:25:35:UTC", "", "15時25分35秒UTC", ""); |
| 125 | gen4DateFormat(testCases, "ar-eg", "ar_EG", "1970-01-01T15:25:35", |
| 126 | "3:25 \u0645", "", "3:25:35 \u0645", "", "UTC 3:25:35 \u0645", "", "UTC 3:25:35 \u0645", ""); |
| 127 | gen4DateFormat(testCases, "hi-in", "hi_IN", "1970-01-01T15:25:35", |
| 128 | "१५:२५", "", "१५:२५:३५", "", "१५:२५:३५ UTC", " ", "१५:२५:३५ UTC", " "); |
| 129 | |
| 130 | genFormatTestCases("Time Format", "dijit.form.TimeTextBox", testCases); |
| 131 | |
| 132 | testCases = []; |
| 133 | gen4DateFormat(testCases, "ru-ru", "ru_RU", new Date(1970, 0, 1, 15, 25, 35), |
| 134 | "15:25", "", "15:25:35", "", "15:25:35 UTC", "", "15:25:35 UTC", ""); |
| 135 | gen4DateFormat(testCases, "zh-cn", "zh_CN", new Date(1970, 0, 1, 15, 25, 35), |
| 136 | "下午3:25", "", "下午03:25:35", "", "下午03时25分35秒", "", "下午03时25分35秒 UTC", ""); |
| 137 | gen4DateFormat(testCases, "en-us", "en_US", new Date(1970, 0, 1, 15, 25, 35), |
| 138 | "3:25 PM", "", "3:25:35 PM", "", "3:25:35 PM UTC", "", "3:25:35 PM UTC", ""); |
| 139 | gen4DateFormat(testCases, "fr-fr", "fr_FR", new Date(1970, 0, 1, 15, 25, 35), |
| 140 | "15:25", "", "15:25:35", "", "15:25:35 UTC", "", "15:25:35 UTC", ""); |
| 141 | gen4DateFormat(testCases, "ja-jp", "ja_JP", new Date(1970, 0, 1, 15, 25, 35), |
| 142 | "15:25", "", "15:25:35", "", "15:25:35:UTC", "", "15時25分35秒UTC", ""); |
| 143 | gen4DateFormat(testCases, "ar-eg", "ar_EG", new Date(1970, 0, 1, 15, 25, 35), |
| 144 | "3:25 \u0645", "", "3:25:35 \u0645", "", "UTC 3:25:35 \u0645", "", "UTC 3:25:35 \u0645", ""); |
| 145 | gen4DateFormat(testCases, "hi-in", "hi_IN", new Date(1970, 0, 1, 15, 25, 35), |
| 146 | "१५:२५", "", "१५:२५:३५", "", "१५:२५:३५ UTC", " ", "१५:२५:३५ UTC", " "); |
| 147 | genValidateTestCases("Time Validate", "dijit.form.TimeTextBox", testCases); |
| 148 | |
| 149 | doh.register("parse", function(){ |
| 150 | dojo.parser.parse(); |
| 151 | }); |
| 152 | |
| 153 | doh.register("t", getAllTestCases()); |
| 154 | |
| 155 | doh.run(); |
| 156 | }); |
| 157 | </script> |
| 158 | </head> |
| 159 | |
| 160 | <body class="claro"> |
| 161 | <h1 class="testTitle">Dijit TextBox Globalization Test for Time</h1> |
| 162 | |
| 163 | <p> |
| 164 | Before start this test, make sure the <b>dojo/cldr/nls</b> contains the data for "zh-cn", "fr-fr", "ja-jp", "ru-ru", "hi-in", "en-us" and "ar-eg". If not, convert these CLDR data and put them there. |
| 165 | </p> |
| 166 | </body> |
| 167 | </html> |
| 168 |