el-text-editor 0.0.62 → 0.0.63
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.
@@ -1492,6 +1492,21 @@ class ElTextEditorComponent {
|
|
1492
1492
|
}
|
1493
1493
|
}
|
1494
1494
|
}
|
1495
|
+
// formatTextWithDates(text: string): string {
|
1496
|
+
// // Regular expression to detect YYYY-MM-DD formatted dates
|
1497
|
+
// const dateRegex = /\b\d{4}-\d{2}-\d{2}\b/g;
|
1498
|
+
// // Replace found dates with a formatted version
|
1499
|
+
// return text.replace(dateRegex, (dateStr) => {
|
1500
|
+
// // Convert the detected date string into a Date object
|
1501
|
+
// const dateObj = new Date(dateStr);
|
1502
|
+
// // Format the date to 'Month Day, Year' (e.g., October 10, 2024)
|
1503
|
+
// return dateObj.toLocaleDateString('en-US', {
|
1504
|
+
// year: 'numeric',
|
1505
|
+
// month: 'long',
|
1506
|
+
// day: 'numeric',
|
1507
|
+
// });
|
1508
|
+
// });
|
1509
|
+
// }
|
1495
1510
|
formatTextWithDates(text) {
|
1496
1511
|
// Regular expression to detect YYYY-MM-DD formatted dates
|
1497
1512
|
const dateRegex = /\b\d{4}-\d{2}-\d{2}\b/g;
|
@@ -1499,12 +1514,12 @@ class ElTextEditorComponent {
|
|
1499
1514
|
return text.replace(dateRegex, (dateStr) => {
|
1500
1515
|
// Convert the detected date string into a Date object
|
1501
1516
|
const dateObj = new Date(dateStr);
|
1502
|
-
//
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
}
|
1517
|
+
// Extract day, month, and year
|
1518
|
+
const day = dateObj.getDate().toString().padStart(2, '0'); // Ensure day is two digits
|
1519
|
+
const month = dateObj.toLocaleString('en-US', { month: 'short' }); // Get abbreviated month name
|
1520
|
+
const year = dateObj.getFullYear(); // Get full year
|
1521
|
+
// Format the date as 'dd/mmm/yyyy'
|
1522
|
+
return `${day}/${month}/${year}`;
|
1508
1523
|
});
|
1509
1524
|
}
|
1510
1525
|
}
|