sondakika 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/index.js +31 -2
- package/package.json +1 -1
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -42,21 +42,45 @@ async function fetchNews(source, count) {
|
|
|
42
42
|
const feed = await parser.parseURL(url);
|
|
43
43
|
const items = feed.items.slice(0, count);
|
|
44
44
|
|
|
45
|
+
const firstItem = feed.items[0];
|
|
46
|
+
let latestUpdate = '';
|
|
47
|
+
if (firstItem && (firstItem.pubDate || firstItem.isodate)) {
|
|
48
|
+
const date = new Date(firstItem.pubDate || firstItem.isodate);
|
|
49
|
+
if (!isNaN(date.getTime())) {
|
|
50
|
+
const options = { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit' };
|
|
51
|
+
latestUpdate = date.toLocaleDateString('tr-TR', options);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
45
55
|
console.log('\n📰 ' + '═'.repeat(50));
|
|
46
56
|
console.log(` Latest ${items.length} News from ${source.toUpperCase()}`);
|
|
57
|
+
if (latestUpdate) {
|
|
58
|
+
console.log(` Son guncelleme: ${latestUpdate}`);
|
|
59
|
+
}
|
|
47
60
|
console.log(' ' + '═'.repeat(50) + '\n');
|
|
48
61
|
|
|
49
62
|
items.forEach((item, index) => {
|
|
50
63
|
const title = item.title;
|
|
51
64
|
const summary = item.summary || item.contentSnippet || '';
|
|
52
65
|
const link = item.link;
|
|
66
|
+
const pubDate = item.pubDate || item.isodate;
|
|
53
67
|
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
let dateStr = '';
|
|
69
|
+
if (pubDate) {
|
|
70
|
+
const date = new Date(pubDate);
|
|
71
|
+
if (!isNaN(date.getTime())) {
|
|
72
|
+
const options = { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit' };
|
|
73
|
+
dateStr = date.toLocaleDateString('tr-TR', options);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const titleLines = wrapText(title, 60);
|
|
78
|
+
const summaryLines = wrapText(summary, 60);
|
|
56
79
|
|
|
57
80
|
const maxWidth = Math.max(
|
|
58
81
|
...titleLines.map(l => l.length),
|
|
59
82
|
...summaryLines.map(l => l.length),
|
|
83
|
+
dateStr.length,
|
|
60
84
|
3
|
|
61
85
|
);
|
|
62
86
|
|
|
@@ -69,6 +93,11 @@ async function fetchNews(source, count) {
|
|
|
69
93
|
});
|
|
70
94
|
console.log(` │`);
|
|
71
95
|
|
|
96
|
+
if (dateStr) {
|
|
97
|
+
console.log(` │ 📅 ${dateStr}`);
|
|
98
|
+
console.log(` │`);
|
|
99
|
+
}
|
|
100
|
+
|
|
72
101
|
summaryLines.forEach(line => {
|
|
73
102
|
console.log(` │ ${line}`);
|
|
74
103
|
});
|