PageRenderTime 27ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/src/main/resources/org/apache/struts2/static/dputils.js

http://struts2yuiplugin.googlecode.com/
JavaScript | 58 lines | 53 code | 5 blank | 0 comment | 10 complexity | e59fb63215fdb32af27126950645a4d7 MD5 | raw file
  1. var s2yui = YAHOO.namespace("s2yui");
  2. YAHOO.namespace("s2yui.i18n");
  3. YAHOO.s2yui.toRFC3339 = function(dateObject) {
  4. if(!dateObject){
  5. dateObject = new Date();
  6. }
  7. var formattedDate = [];
  8. var date = [this.padString(dateObject.getFullYear(),4), this.padString(dateObject.getMonth()+1,2), this.padString(dateObject.getDate(),2)].join('-');
  9. formattedDate.push(date);
  10. var time = [this.padString(dateObject.getHours(),2), this.padString(dateObject.getMinutes(),2), this.padString(dateObject.getSeconds(),2)].join(':');
  11. var timezoneOffset = dateObject.getTimezoneOffset();
  12. time += (timezoneOffset > 0 ? "-" : "+") +
  13. this.padString(Math.floor(Math.abs(timezoneOffset)/60),2) + ":" +
  14. this.padString(Math.abs(timezoneOffset)%60,2);
  15. formattedDate.push(time);
  16. return formattedDate.join('T'); // String
  17. };
  18. YAHOO.s2yui.padString = function (str, len, c, dir) {
  19. var out = String(str);
  20. if(!c) {
  21. c = '0';
  22. }
  23. if(!dir) {
  24. dir = 1;
  25. }
  26. while(out.length < len) {
  27. if(dir > 0) {
  28. out = c + out;
  29. } else {
  30. out += c;
  31. }
  32. }
  33. return out; // string
  34. };
  35. YAHOO.s2yui.showDateValue = function(target, value) {
  36. if(target.nodeName.toLowerCase() == "input") {
  37. target.value = value;
  38. } else {
  39. target.innerHTML = value;
  40. }
  41. };
  42. YAHOO.s2yui.loadLanguageStrings = function(dp, langName) {
  43. var lang = YAHOO.s2yui.i18n[langName];
  44. if(!lang) {
  45. YAHOO.log("Language " + langName + " is not available");
  46. return;
  47. } else {
  48. dp.cfg.setProperty("MONTHS_SHORT", lang.months_short);
  49. dp.cfg.setProperty("MONTHS_LONG", lang.months_long);
  50. dp.cfg.setProperty("WEEKDAYS_SHORT", lang.weekdays_short);
  51. dp.cfg.setProperty("WEEKDAYS_LONG", lang.weekdays_long );
  52. }
  53. };