blob: fc9a2f91911480d040bcfd7ffbe07432ab2d8788 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Set of functions to handle articles
function getArticleYear(article) {
if (article.metaData.pubDate.getFullYear) {
return article.metaData.pubDate.getFullYear();
}
if (article.metaData.pubDate.getUTCFullYear) {
return article.metaData.pubDate.getUTCFullYear();
}
return 0;
}
function getArticleDate(article) {
if (article.metaData.pubDate.getDate) {
return (
article.metaData.pubDate.getFullYear() * 100 +
article.metaData.pubDate.getDate()
);
}
if (article.metaData.pubDate.getUTCDate) {
return (
article.metaData.pubDate.getUTCFullYear() * 100 +
article.metaData.pubDate.getDate()
);
}
return 0;
}
function cmpArticles(a, b) {
return getArticleDate(b) - getArticleDate(a);
}
export { getArticleDate, getArticleYear, cmpArticles };
|