PageRenderTime 54ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/public/javascripts/ui/yui/tests/datasource/tests/date.php

https://bitbucket.org/lolski/weevil-source
PHP | 306 lines | 274 code | 24 blank | 8 comment | 2 complexity | 936217b0fb0abcaf6d0f4f0eac509275 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1, Apache-2.0
  1. <html>
  2. <head>
  3. <script type="text/javascript" src="../../../build/yahoo/yahoo-min.js" ></script>
  4. <script type="text/javascript" src="../../../build/event/event-min.js" ></script>
  5. <script type="text/javascript" src="../../../build/datasource/datasource.js" ></script>
  6. <script type="text/javascript">
  7. YAHOO.util.DateLocale['fr'] = YAHOO.lang.merge(YAHOO.util.DateLocale, {
  8. a: ['dim', 'lun', 'mar', 'mer', 'jeu', 'ven', 'sam'],
  9. A: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'],
  10. b: ['jan', 'fév', 'mar', 'avr', 'mai', 'jun', 'jui', 'aoû', 'sep', 'oct', 'nov', 'déc'],
  11. B: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
  12. p: ['', ''],
  13. P: ['', ''],
  14. x: '%d.%m.%Y'
  15. });
  16. YAHOO.util.DateLocale['fr-CA'] = YAHOO.lang.merge(YAHOO.util.DateLocale['fr'], { x: '%Y-%m-%d' });
  17. YAHOO.util.DateLocale['fr-CH'] = YAHOO.lang.merge(YAHOO.util.DateLocale['fr'], { x: '%d. %m. %y' });
  18. YAHOO.util.DateLocale['de'] = YAHOO.lang.merge(YAHOO.util.DateLocale['fr'], {
  19. a: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
  20. A: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
  21. b: ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
  22. B: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember']
  23. });
  24. YAHOO.util.DateLocale['de-CH'] = YAHOO.lang.merge(YAHOO.util.DateLocale['de'], {
  25. a: ['Son', 'Mon', 'Die', 'Mit', 'Don', 'Fre', 'Sam'],
  26. x: '%Y-%m-%d'
  27. });
  28. YAHOO.util.DateLocale['hi'] = YAHOO.lang.merge(YAHOO.util.DateLocale, {
  29. "a": ["\u0930\u0935\u093f ","\u0938\u094b\u092e ","\u092e\u0902\u0917\u0932 ","\u092c\u0941\u0927 ","\u0917\u0941\u0930\u0941 ","\u0936\u0941\u0915\u094d\u0930 ","\u0936\u0928\u093f "],
  30. "A": ["\u0930\u0935\u093f\u0935\u093e\u0930 ","\u0938\u094b\u092e\u0935\u093e\u0930 ","\u092e\u0902\u0917\u0932\u0935\u093e\u0930 ","\u092c\u0941\u0927\u0935\u093e\u0930 ","\u0917\u0941\u0930\u0941\u0935\u093e\u0930 ","\u0936\u0941\u0915\u094d\u0930\u0935\u093e\u0930 ","\u0936\u0928\u093f\u0935\u093e\u0930 "],
  31. "b": ["\u091c\u0928\u0935\u0930\u0940","\u092b\u093c\u0930\u0935\u0930\u0940","\u092e\u093e\u0930\u094d\u091a","\u0905\u092a\u094d\u0930\u0947\u0932","\u092e\u0908","\u091c\u0942\u0928","\u091c\u0941\u0932\u093e\u0908","\u0905\u0917\u0938\u094d\u0924","\u0938\u093f\u0924\u092e\u094d\u092c\u0930","\u0905\u0915\u094d\u091f\u0942\u092c\u0930","\u0928\u0935\u092e\u094d\u092c\u0930","\u0926\u093f\u0938\u092e\u094d\u092c\u0930"],
  32. "B":["\u091c\u0928\u0935\u0930\u0940","\u092b\u093c\u0930\u0935\u0930\u0940","\u092e\u093e\u0930\u094d\u091a","\u0905\u092a\u094d\u0930\u0947\u0932","\u092e\u0908","\u091c\u0942\u0928","\u091c\u0941\u0932\u093e\u0908","\u0905\u0917\u0938\u094d\u0924","\u0938\u093f\u0924\u092e\u094d\u092c\u0930","\u0905\u0915\u094d\u091f\u0942\u092c\u0930","\u0928\u0935\u092e\u094d\u092c\u0930","\u0926\u093f\u0938\u092e\u094d\u092c\u0930"],
  33. "c": "%A %d %B %Y %r",
  34. "p": ["\u092a\u0942\u0930\u094d\u0935\u093e\u0939\u094d\u0928","\u0905\u092a\u0930\u093e\u0939\u094d\u0928"],
  35. "P": ["\u092a\u0942\u0930\u094d\u0935\u093e\u0939\u094d\u0928","\u0905\u092a\u0930\u093e\u0939\u094d\u0928"],
  36. "r":"%I:%M:%S %p %Z",
  37. "x":"%A %d %B %Y",
  38. "X":"%I:%M:%S %Z"
  39. });
  40. YAHOO.util.DateLocale['ko-KR'] = YAHOO.lang.merge(YAHOO.util.DateLocale, {
  41. "a": ["\uc77c","\uc6d4","\ud654","\uc218","\ubaa9","\uae08","\ud1a0"],
  42. "A": ["\uc77c\uc694\uc77c","\uc6d4\uc694\uc77c","\ud654\uc694\uc77c","\uc218\uc694\uc77c","\ubaa9\uc694\uc77c","\uae08\uc694\uc77c","\ud1a0\uc694\uc77c"],
  43. "b": [" 1\uc6d4"," 2\uc6d4"," 3\uc6d4"," 4\uc6d4"," 5\uc6d4"," 6\uc6d4"," 7\uc6d4"," 8\uc6d4"," 9\uc6d4","10\uc6d4","11\uc6d4","12\uc6d4"],
  44. "B": ["1\uc6d4","2\uc6d4","3\uc6d4","4\uc6d4","5\uc6d4","6\uc6d4","7\uc6d4","8\uc6d4","9\uc6d4","10\uc6d4","11\uc6d4","12\uc6d4"],
  45. "c": "%x (%a) %r",
  46. "p": ["\uc624\uc804","\uc624\ud6c4"],
  47. "P": ["\uc624\uc804","\uc624\ud6c4"],
  48. "r": "%p %I\uc2dc %M\ubd84 %S\ucd08",
  49. "x": "%Y\ub144 %m\uc6d4 %d\uc77c",
  50. "X": "%H\uc2dc %M\ubd84 %S\ucd08"
  51. });
  52. </script>
  53. <style type="text/css">
  54. TH, TD { font-size: 0.8em; }
  55. .nomatch { background-color: #f88; #color: #fff; }
  56. .match { background-color: #8f8; #color: #000; }
  57. TH { text-align: left; }
  58. </style>
  59. </head>
  60. <body>
  61. <?php
  62. $testdates = array(time(), strtotime('1900/01/01'), strtotime('2008/01/01'), strtotime('2008/01/01 08:00:00'), strtotime('2007/12/31 23:59:59'), strtotime('2008/02/29'), strtotime('2000/12/31'));
  63. /*$testdates = array();
  64. for($i=1; $i<366; $i++)
  65. {
  66. $testdates[] = strtotime("2008/01/$i");
  67. $testdates[] = strtotime("2008/01/$i 11:59:59");
  68. $testdates[] = strtotime("2008/01/$i 12:00:00");
  69. }*/
  70. $formats = array('a','A','b','B','c','C','d','D','e','F','g','G','h','H','I','j','k','l','m','M','n','p','P','r','R','s','S','t','T','u','U','V','w','W','x','X','y','Y','z','Z','%');
  71. //$formats = array('j');
  72. foreach($testdates as $date)
  73. {
  74. ?>
  75. <script type="text/javascript">
  76. var date = new Date('<?php echo strftime('%Y/%m/%d %H:%M:%S', $date); ?>');
  77. </script>
  78. <h2>Testing: <?php echo strftime('%Y/%m/%d %H:%M:%S', $date) ?> (
  79. <script type="text/javascript">
  80. document.write(YAHOO.util.Date.format(date, {format: '%Y/%m/%d %H:%M:%S'}));
  81. </script>
  82. )</h2>
  83. <table cellspacing=0 cellpadding=4 border=1>
  84. <tr> <th rowspan="2">format</th> <th colspan="2">US English</th> <th colspan="2">UK English</th> <th colspan="2">French</th> <th colspan="2">Canadian French</th> <th colspan="2">Swiss French</th> <th colspan="2">German</th> <th colspan="2">Swiss German</th> <th colspan="2">Hindi</th> <th colspan="2">Hangul</th> </tr>
  85. <tr> <th>PHP</th> <th>Javascript</th> <th>PHP</th> <th>Javascript</th> <th>PHP</th> <th>Javascript</th> <th>PHP</th> <th>Javascript</th> <th>PHP</th> <th>Javascript</th> <th>PHP</th> <th>Javascript</th> <th>PHP</th> <th>Javascript</th> <th>PHP</th> <th>Javascript</th> <th>PHP</th> <th>Javascript</th> </tr>
  86. <?php
  87. foreach($formats as $format)
  88. {
  89. $format = "%$format";
  90. setlocale(LC_TIME, 'en_US.UTF-8', 'en_US');
  91. $sDate = strftime($format, $date);
  92. $jsDate = preg_replace('/\n/', '\n', $sDate);
  93. ?>
  94. <tr>
  95. <td>
  96. <?php echo $format; ?>
  97. </td>
  98. <!-- en-US -->
  99. <td>
  100. <?php echo $sDate ?>
  101. </td>
  102. <script type="text/javascript">
  103. var sDate=YAHOO.util.Date.format(date, {format: "<?php echo $format ?>"}, "en-US");
  104. document.write("<td class='" + (sDate == "<?php echo $jsDate ?>"?"match":"nomatch") + "'>");
  105. document.write(sDate);
  106. document.write("</td>\n");
  107. </script>
  108. <!-- en-GB -->
  109. <?php
  110. setlocale(LC_TIME, 'en_GB.UTF-8', 'en_GB');
  111. $sDate = strftime($format, $date);
  112. $jsDate = preg_replace('/\n/', '\n', $sDate);
  113. ?>
  114. <td>
  115. <?php echo $sDate ?>
  116. </td>
  117. <script type="text/javascript">
  118. var sDate=YAHOO.util.Date.format(date, {format: "<?php echo $format ?>"}, "en-GB");
  119. document.write("<td class='" + (sDate == "<?php echo $jsDate ?>"?"match":"nomatch") + "'>");
  120. document.write(sDate);
  121. document.write("</td>\n");
  122. </script>
  123. <!-- fr -->
  124. <?php
  125. setlocale(LC_TIME, 'fr_FR.UTF-8', 'fr_FR', 'fr');
  126. $sDate = strftime($format, $date);
  127. $jsDate = preg_replace('/\n/', '\n', $sDate);
  128. ?>
  129. <td>
  130. <?php echo $sDate ?>
  131. </td>
  132. </td>
  133. <script type="text/javascript">
  134. var sDate=YAHOO.util.Date.format(date, {format: "<?php echo $format ?>"}, "fr");
  135. document.write("<td class='" + (sDate == "<?php echo $jsDate ?>"?"match":"nomatch") + "'>");
  136. document.write(sDate);
  137. document.write("</td>\n");
  138. </script>
  139. <!-- fr-CA -->
  140. <?php
  141. setlocale(LC_TIME, 'fr_CA.UTF-8', 'fr_CA');
  142. $sDate = strftime($format, $date);
  143. $jsDate = preg_replace('/\n/', '\n', $sDate);
  144. ?>
  145. <td>
  146. <?php echo $sDate ?>
  147. </td>
  148. </td>
  149. <script type="text/javascript">
  150. var sDate=YAHOO.util.Date.format(date, {format: "<?php echo $format ?>"}, "fr-CA");
  151. document.write("<td class='" + (sDate == "<?php echo $jsDate ?>"?"match":"nomatch") + "'>");
  152. document.write(sDate);
  153. document.write("</td>\n");
  154. </script>
  155. <!-- fr-CH -->
  156. <?php
  157. setlocale(LC_TIME, 'fr_CH.UTF-8', 'fr_CH');
  158. $sDate = strftime($format, $date);
  159. $jsDate = preg_replace('/\n/', '\n', $sDate);
  160. ?>
  161. <td>
  162. <?php echo $sDate ?>
  163. </td>
  164. </td>
  165. <script type="text/javascript">
  166. var sDate=YAHOO.util.Date.format(date, {format: "<?php echo $format ?>"}, "fr-CH");
  167. document.write("<td class='" + (sDate == "<?php echo $jsDate ?>"?"match":"nomatch") + "'>");
  168. document.write(sDate);
  169. document.write("</td>\n");
  170. </script>
  171. <!-- de -->
  172. <?php
  173. setlocale(LC_TIME, 'de_DE.UTF-8', 'de_DE', 'de');
  174. $sDate = strftime($format, $date);
  175. $jsDate = preg_replace('/\n/', '\n', $sDate);
  176. ?>
  177. <td>
  178. <?php echo $sDate ?>
  179. </td>
  180. </td>
  181. <script type="text/javascript">
  182. var sDate=YAHOO.util.Date.format(date, {format: "<?php echo $format ?>"}, "de-DE");
  183. document.write("<td class='" + (sDate == "<?php echo $jsDate ?>"?"match":"nomatch") + "'>");
  184. document.write(sDate);
  185. document.write("</td>\n");
  186. </script>
  187. <!-- de-CH -->
  188. <?php
  189. setlocale(LC_TIME, 'de_CH.UTF-8', 'de_CH');
  190. $sDate = strftime($format, $date);
  191. $jsDate = preg_replace('/\n/', '\n', $sDate);
  192. ?>
  193. <td>
  194. <?php echo $sDate ?>
  195. </td>
  196. </td>
  197. <script type="text/javascript">
  198. var sDate=YAHOO.util.Date.format(date, {format: "<?php echo $format ?>"}, "de-CH");
  199. document.write("<td class='" + (sDate == "<?php echo $jsDate ?>"?"match":"nomatch") + "'>");
  200. document.write(sDate);
  201. document.write("</td>\n");
  202. </script>
  203. <!-- hi -->
  204. <?php
  205. setlocale(LC_TIME, 'hi_IN.UTF-8', 'hi_IN');
  206. $sDate = strftime($format, $date);
  207. $jsDate = preg_replace('/\n/', '\n', $sDate);
  208. ?>
  209. <td>
  210. <?php echo $sDate ?>
  211. </td>
  212. </td>
  213. <script type="text/javascript">
  214. var sDate=YAHOO.util.Date.format(date, {format: "<?php echo $format ?>"}, "hi-IN");
  215. document.write("<td class='" + (sDate == "<?php echo $jsDate ?>"?"match":"nomatch") + "'>");
  216. document.write(sDate);
  217. document.write("</td>\n");
  218. </script>
  219. <!-- ko_KR -->
  220. <?php
  221. setlocale(LC_TIME, 'ko_KR.UTF-8', 'ko_KR');
  222. $sDate = strftime($format, $date);
  223. $jsDate = preg_replace('/\n/', '\n', $sDate);
  224. ?>
  225. <td>
  226. <?php echo $sDate ?>
  227. </td>
  228. </td>
  229. <script type="text/javascript">
  230. var sDate=YAHOO.util.Date.format(date, {format: "<?php echo $format ?>"}, "ko-KR");
  231. document.write("<td class='" + (sDate == "<?php echo $jsDate ?>"?"match":"nomatch") + "'>");
  232. document.write(sDate);
  233. document.write("</td>\n");
  234. </script>
  235. </tr>
  236. <?php
  237. }
  238. ?>
  239. </table>
  240. <?php
  241. }
  242. ?>
  243. </body>
  244. </html>
  245. <?php
  246. setlocale(LC_TIME, 'ko_KR.UTF-8', 'ko_KR');
  247. $lc = array (
  248. "a" => array(),
  249. "A" => array(),
  250. "b" => array(),
  251. "B" => array(),
  252. "c" => "%Y %m %d (%a) %r",
  253. "p" => array(),
  254. "P" => array(),
  255. "r" => "%p %I %M %S %p %Z",
  256. "x" => "%Y %m %d",
  257. "X" => "%H %M %S"
  258. );
  259. $lc['c'] = strftime("%c");
  260. $lc['r'] = strftime("%r");
  261. $lc['x'] = strftime("%X");
  262. $lc['X'] = strftime("%X");
  263. for($i=6; $i<13; $i++)
  264. {
  265. $d = strtotime("2008/01/$i");
  266. $lc['a'][] = strftime("%a", $d);
  267. $lc['A'][] = strftime("%A", $d);
  268. }
  269. for($i=1; $i<13; $i++)
  270. {
  271. $d = strtotime("2008/$i/1");
  272. $lc['b'][] = strftime("%b", $d);
  273. $lc['B'][] = strftime("%B", $d);
  274. }
  275. $d = strtotime("2008/01/01 10:00:00");
  276. $lc['p'][] = strftime("%p", $d);
  277. $lc['P'][] = strftime("%p", $d);
  278. $d = strtotime("2008/01/01 22:00:00");
  279. $lc['p'][] = strftime("%p", $d);
  280. $lc['P'][] = strftime("%p", $d);
  281. echo "<!-- " . json_encode($lc) . " -->";
  282. ?>