Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format.toValue and format.toDisplay undefined #71

Closed
debbieAtenea opened this issue Mar 30, 2022 · 0 comments
Closed

format.toValue and format.toDisplay undefined #71

debbieAtenea opened this issue Mar 30, 2022 · 0 comments

Comments

@debbieAtenea
Copy link

debbieAtenea commented Mar 30, 2022

I have an issue with parsing dates format.

Everything is correct but the line 306 is not doing anything.

// v1.0.0 - Parse format (date)
 EvoCalendar.prototype.parseFormat = function(format) {
     var _ = this;
     if (typeof format.toValue === 'function' && typeof format.toDisplay === 'function')
         return format;
     // IE treats \0 as a string end in inputs (truncating the value),
     // so it's a bad format delimiter, anyway
     var separators = format.replace(_.initials.validParts, '\0').split('\0'),
         parts = format.match(_.initials.validParts);
     if (!separators || !separators.length || !parts || parts.length === 0){
         console.log("%c Invalid date format ", "color:white;font-weight:bold;background-color:#e21d1d;");
     }
     return {separators: separators, parts: parts};
 };
// v1.0.0 - Format date
 EvoCalendar.prototype.formatDate = function(date, format, language) {
     var _ = this;
     if (!date)
         return '';
     language = language ? language : _.defaults.language
     if (typeof format === 'string')
         format = _.parseFormat(format);
     if (format.toDisplay)                          #This is the line 306 in the code.
         return format.toDisplay(date, format, language);

     var ndate = new Date(date);
     // if (!_.isValidDate(ndate)) { // test
     //     ndate = new Date(date.replace(/-/g, '/'))
     // }
     
     var val = {
         d: ndate.getDate(),
         D: _.initials.dates[language].daysShort[ndate.getDay()],
         DD: _.initials.dates[language].days[ndate.getDay()],
         m: ndate.getMonth() + 1,
         M: _.initials.dates[language].monthsShort[ndate.getMonth()],
         MM: _.initials.dates[language].months[ndate.getMonth()],
         yy: ndate.getFullYear().toString().substring(2),
         yyyy: ndate.getFullYear()
     };
     
     val.dd = (val.d < 10 ? '0' : '') + val.d;
     val.mm = (val.m < 10 ? '0' : '') + val.m;
     date = [];
     var seps = $.extend([], format.separators);
     for (var i=0, cnt = format.parts.length; i <= cnt; i++){
         if (seps.length)
             date.push(seps.shift());
         date.push(val[format.parts[i]]);
     }
     return date.join('');
 };

When I go to the DOM and see the eventList is showing ,as a title, NaN, NaN

How do I solve this issue as I think is giving a non show error to display the event tag with the data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant