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