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

Moment.js: Deprecation Warning #56

Closed
ivavictoria opened this issue Jun 3, 2015 · 1 comment
Closed

Moment.js: Deprecation Warning #56

ivavictoria opened this issue Jun 3, 2015 · 1 comment

Comments

@ivavictoria
Copy link
Contributor

Moment.js is printing a warning to the console:

"Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to moment/moment#1407 for more info."

This is being caused by line 218 of jquery.rss.js:

date: moment(entry.publishedDate).format(this.options.dateFormat),

This usage of the moment() constructor is going to be deprecated soon. It is suggested that instead of dumping any date string into the constructor, one should instead use String + Format. For example:

date: moment(entry.publishedDate, "MM-DD-YYYY").format(this.options.dateFormat),

Or, as is mentioned in moment/moment#1407, if one really needs to dump in random dates without specifying the format, another alternative is to let Date handle it:

date: moment(new Date(entry.publishedDate)).format(this.options.dateFormat),

For our use case -- an RSS feed reader -- I don't know if we can successfully use String + Format. RSS feeds are supposed to have a standardized date format, as shown in the RSS 2.0 specification:

All date-times in RSS conform to the Date and Time Specification of RFC 822, with the exception that the year may be expressed with two characters or four characters (four preferred).
Example: Sat, 07 Sep 2002 0:00:01 GMT

..but, my impression is that feeds in the wild don't predictably follow this standard, so anticipating what format the dates will use in any given feed is probably out of the question.

Should we go with letting Date parse the initial publishedDate string and hope for the best?
My guess is that we should, because Date is what Moment currently falls back to when the pubDate isn't ISO-8601 compliant. Using Date like this is a risky practice and doesn't always work, so they're removing this feature to wipe their hands clean of it. But, that doesn't stop us from using it.

ivavictoria added a commit to ivavictoria/jquery-rss that referenced this issue Jun 3, 2015
@jhfrench
Copy link
Contributor

jhfrench commented Jun 5, 2015

Related: #54

@sdepold sdepold closed this as completed in ca4fc92 Jun 6, 2015
ivavictoria added a commit to ivavictoria/jquery-rss that referenced this issue Jun 12, 2015
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

2 participants