diff --git a/src/lib/convertDate.js b/src/lib/convertDate.js new file mode 100644 index 0000000..88ecb68 --- /dev/null +++ b/src/lib/convertDate.js @@ -0,0 +1,23 @@ +import { getMonthName } from '$lib/monthName'; +/** + * @param {string} date - Fecha del evento + * @returns {string} - Fecha en dia (nĂºmero) mes (letras) + */ +export const convertDate = (date) => { + if (date == undefined) { + return ''; + } + /** @type {string} */ const monthNumber = date.split('-')[1]; + /** @type {string} */ let day = date.split('-')[2].split('T')[0]; + /** @type {number} */ const dayNumber = Number(day); + /** @type {string} */ const month = getMonthName(monthNumber); + + /** Removes 0 on single digit days */ + if (dayNumber < 10) { + day = day.charAt(1); + } + + /** @type {string} */ const res = `${day} ${month}`; + return res; +}; + diff --git a/src/lib/preview/Preview.svelte b/src/lib/preview/Preview.svelte index 9e5c1de..5721334 100644 --- a/src/lib/preview/Preview.svelte +++ b/src/lib/preview/Preview.svelte @@ -12,6 +12,7 @@ import Date from '$lib/templates/Date.svelte'; import Weekday from '$lib/templates/Weekday.svelte'; import Address from '$lib/templates/Address.svelte'; + import Text from '$lib/templates/Text.svelte';
@@ -74,6 +75,9 @@
{/if} +
+ +