Loading ...
Sorry, an error occurred while loading the content.
 

Re: Date format, not responding

Expand Messages
  • alexshusta
    Hi Robert, If you need your dates in a different order than that which the calendar expects by default you can set that using the MDY_DAY_POSITION,
    Message 1 of 2 , May 31, 2007
      Hi Robert,

      If you need your dates in a different order than that which the calendar expects by default you can set that using the MDY_DAY_POSITION, MDY_MONTH_POSITION, and MDY_YEAR_POSITION values for your calendar object. There's a good example available at http://developer.yahoo.com/yui/calendar/#internationalization But remember, that's only for setting the order of stuff passed into the calendar.

      When you get a selected date back from the calendar you'll want to use built in JavaScript methods to work with it:
          // slightly modified code based on the linked example
          var cal1;
          function init() {
             cal1 = new YAHOO.widget.Calendar("cal1","cal1Container");
             cal1.render();
             cal1.selectEvent.subscribe(getDate);
          }
          function getDate() {
              // Later in your application, when you need the selected dates
              var arrDates = cal1.getSelectedDates();
              for (var i = 0; i < arrDates.length; ++i) {
                      var date = arrDates[i];
             
                      // Work with selected date...
                      var displayMonth = date.getMonth() + 1;
                      var displayYear = date.getFullYear();
                      var displayDate = date.getDate();
                      var fullDate = displayYear + "-" + displayMonth + "-" + displayDate;
                      alert(fullDate);
              }   
          }


      Hope that answered your questions, if not please reply to the list with a clarification of what you're still wondering about.
      ~Alexander

      --- In ydn-javascript@yahoogroups.com, "roblj689" <robert.ljungwald@...> wrote:
      >
      > Hi,
      > the format of my selected date has to me YYYY-MM-DD
      >
      > Tried to change it by commenting //var date= this._toDate(selected[0]);
      >
      > Also, there were an option of
      > YAHOO.example.calendar.cal1.cfg.setProperty("DATE_FIELD_DELIMITER",
      > "-"); But it doesn't respond to that change. Does anyone have an idea
      > where to place that line or what to do instead?
      >
      >
      >
      > /* ---------------- Calendar function ---------------- */
      > YAHOO.namespace("example.calendar");
      >
      > function init() {
      > YAHOO.example.calendar.cal1 = new
      > YAHOO.widget.Calendar("cal1","cal1Container");
      >
      >
      > var mySelectHandler = function(type,args,obj) {
      > var selected = args[0];
      > var date= selected[0];
      > //var date= this._toDate(selected[0]);
      > var state = getState();
      > ajaxSetDate(date, state);
      > };
      >
      > var myDeselectHandler = function(type,args,obj) {
      > var deselected = args[0];
      > alert("Deselected: " + this._toDate(deselected[0]));
      > };
      >
      >
      > YAHOO.example.calendar.cal1.selectEvent.subscribe(mySelectHandler,
      > YAHOO.example.calendar.cal1, true);
      >
      >
      > YAHOO.example.calendar.cal1.deselectEvent.subscribe(myDeselectHandler,
      > YAHOO.example.calendar.cal1, true);
      >
      > YAHOO.example.calendar.cal1.render();
      > }
      > YAHOO.util.Event.addListener(window, "load", init);
      >
      > /* ---------------- Calendar function ---------------- */
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.