' +
'
{{date}} at {{time}} CET' +
'
' +
'{{title}}'+
'
' +
'
{{trimmed}}
'+
'
'+
'
'+
'
'+
''+
'{{/data}}' +
'{{^data}}' +
'
No items found.
'+
'{{/data}}'
;
$.ajax({
type: 'GET',
url: 'https://newsroom-api.pr.co/v1/pressrooms/jet/press_releases?country=WW&language=en&includes=featured_images%2Ctags&limit=6',
dataType: 'json',
success: function (data) {
console.log('external data', data);
data.data.forEach(function(item){
// var date = item.release_date
const isoString = item.release_date;
// const isoString = "2024-11-13T06:00:05.000Z";
// Split the string by the 'T' character
const [datePart, timePart] = isoString.split('T');
console.log('date part', datePart);
console.log('time part', timePart);
// Split the date part by the '-' character
const [year, month, day] = datePart.split('-');
var _entryDate = new Date(year, month-1, day);
console.log('entry',_entryDate)
const day2 = _entryDate.getDate();
const month2 = _entryDate.toLocaleString('default', { month: 'long' });
const year2 = _entryDate.getFullYear();
// Format the date string
const formattedDate = `${day2} ${month2}, ${year2}`;
item.date = formattedDate;
// console.log('formated date', formattedDate); // Output: 13 November, 2024
var image = item.featured_images[0].sizes.large.url;
console.log ('image url', image);
item.thumb = image;
function trimStringWithEllipsis(text, maxLength) {
if (text.length <= maxLength) {
return text;
}
return text.substring(0, maxLength) + "...";
}
const longString = item.summary;
// const longString = 'Just Eat Takeaway.com N.V. (LSE: JET, AMS: TKWY), hereinafter the “Company”, or together with its group companies “Just Eat Takeaway.com”, is pleased to announce that it has entered into a definitive agreement to sell Grubhub Inc. (“Grubhub”) to Wonder Group, Inc. (“Wonder”) for an enterprise value of USD650 million (the “Transaction”). ';
const trimmedString = trimStringWithEllipsis(longString, 199);
// console.log(trimmedString);
item.trimmed = trimmedString;
// const longString = item.summary;
// item.trimmed = longString.substring(0, 199) + '...';
// function convertUTCToEST(utcTime) {
// // Create a Date object from the UTC time string
// const utcDate = new Date(utcTime);
// // Convert the UTC time to EST time
// const estDate = new Date(utcDate.getTime() - 5 * 3600000); // 5 hours difference between UTC and EST
// // Extract hours and minutes from the EST time
// const hours = estDate.getHours();
// const minutes = estDate.getMinutes();
// const ampm = hours >= 12 ? 'PM' : 'AM';
// // Format the hours and minutes with AM/PM
// const formattedTime = `${hours % 12 || 12}:${minutes.toString().padStart(2, '0')} ${ampm}`;
// return formattedTime;
// }
// const utcTime = '04:59:59.000Z';
// const estTime = convertUTCToEST(isoString);
// item.time = estTime;
function convertUTCToCET(utcTime) {
// Create a Date object from the UTC time string
const utcDate = new Date(utcTime);
// Convert the UTC time to EST time
const cteDate = new Date(utcDate.getTime()); // 1 hours difference between UTC and CET
// Extract hours and minutes from the EST time
const hours = cteDate.getHours();
const minutes = cteDate.getMinutes();
const ampm = hours >= 12 ? 'PM' : 'AM';
// Format the hours and minutes with AM/PM
const formattedTime = `${hours % 12 || 12}:${minutes.toString().padStart(2, '0')} ${ampm}`;
return formattedTime;
}
const utcTime = '04:59:59.000Z';
const cteTime = convertUTCToCET(isoString);
item.time = cteTime;
})
var html = Mustache.render(newsTemplate, data);
$('#newsContainer').html(html);
}
});